I'm writing a simple device driver to drive a panel with LEDs on it
that is attatched to a parallel port on our MV5110 board (attached via
transition module). I've written the create and ioctl functions (that's
all I want), and they work fine when I call them 'manually'. My problem
occurs when I try to use iosDrvInstall and then iosDevAdd so I can use
the panel as a vxWorks device.
iosDrvInstall works OK - the create and ioctl functions are registered
for a new driver in the driver list (viewed with iosDrvShow). When I
try to use iosDrvInstall, however, I run into problems which are
related to the doubly-linked device list structure. If I just do
something like the following:
...
DEV_HDR* hdr;
iosDevAdd (hdr, "/dev/panel", drvNum);
...
the device simply won't appear in the list. If I try to manipulate the
DL_NODE struct contained inside the new DEV_HDR to point to, say, the
last item currently in the device list, I obviously break the list
because a call to "devs" will then return several device entries with
spurious driver numbers/names, and then the call dies with a data
access exception. The same thing happens whether or not I explicitly
set the "drvNum" and "name" entries of the DEV_HDR struct.
The literature that I've seen all seems to indicate that you "don't
need to initialise" DEV_HDR... iosDevAdd should take care of it.
However, this doesn't seem to be the case... but I can't figure out a
way around it.
Any pointers much appreciated.
Thanks kindly,
Ben
You have to allocate space for the "DEV_HDR". As a matter of fact,
you can keep data for your device by including this in another
structure.
struct led_dev
{
DEV_HDR hdr;
int flash_rate; /* etc. */
};
struct led_dev led;
iosDevAdd(&led.hdr, "/dev/panel", drvNum);
hth,
Bill Pringlemeir.
--
Two wrongs don't make a right, but three lefts do.
vxWorks FAQ, "http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html"
Thanks very much for your help (I didn't see it until today due to the
weekend).
Unfortunately, this doesn't work for me either (I had tried it before).
This is the exact code that I used to test your suggested approach:
---------------------------------
struct MY_DEV
{
DEV_HDR hdr;
int test;
};
STATUS panelDrvInit ()
{
int drvNum;
struct MY_DEV panel;
drvNum = iosDrvInstall ((FUNCPTR) panelDevCreate, NULL, NULL, NULL,
NULL, NULL, (FUNCPTR) panelIoctl);
iosDevAdd (&panel.hdr, "/dev/panel", drvNum);
}
---------------------------------
And this is the result:
---------------------------------
>From the host shell:
-> panelDrvInit
value = 0 = 0x0
-> devs
WTX Error 0x100d1 (AGENT_GOPHER_FAULT)
value = -1 = 0xffffffff
And then from the target shell:
-> devs
drv name
0 /null
1 /tyCo/0
1 /tyCo/1
1 /tyCo/2
1 /tyCo/3
1 /tyCo/4
1 /tyCo/5
5 XP024031:
6 /vio
3 /dev/pccard
8191 (null)
16384 (null)
0 (null)
0 (null)
-4370
data access
Exception current instruction address: 0x001e9cfc
Machine Status Register: 0x0200b030
Data Access Register: 0xeeeeeeee
Condition Register: 0x2375b080002084
Data storage interrupt Register: 0x40000000
vxTaskEntry +68 : shell ()
20755c shell +190: 207588 ()
207788 shell +3bc: execute ()
20790c execute +d8 : yyparse ()
219400 yyparse +71c: 217798 ()
21791c yystart +96c: devs ()
20a974 devs +10 : iosDevShow ()
2136fc iosDevShow +5c : printf ()
1ee8e8 fioFormatV +b74: strlen ()
shell restarted.
---------------------------------
All the devices shown there up to /dev/pccard were properly installed
and working prior to the iosDevAdd call. It seems that somehow I'm
breaking the doubly-linked list structure which vxWorks uses to
identify the devices that are installed. I've tried manually creating
and setting DL_NODE structures to insert a new device at the end of the
list, but that didn't seem to work either. I can't find any other
references to this problem, so perhaps I'm just doing something very
stupid and trivial... but I can't for the life of me figure out what it
is!
Thanks,
Ben
Cheers,
Ben