[okl4-developer] V2 device_create functions
Ryan Heffernan
ryan.heffernan at nicta.com.au
Thu Apr 10 10:01:09 EST 2008
Hello,
I've been writing an Iguana driver using the v2 framework and trying to
keep my code as close as possible to that of the other iguana drivers
(vserial, vtimer, etc), but yesterday I noticed something that seemed
odd with the existing drivers and wondered if someone could clear this
up.
The device_create functions in the driver servers (ie.
vserial/src/serial_server.c) all return a cap_t with references to the
created device. I assume this is so that if needed, shared memory can be
set up between a client and the driver server (ie. for a shared buffer),
since a client can call devicecore to get this object reference and
recreate the device's cap_t on the client side to initiate the shared
memory.
However, what is actually stored in the cap_t returned by device_create
is a pointer to the base address of the device structure (from a malloc
call), not a memory section reference like memsection_create() would
return. From what i gather, it's this memory reference
(memsection_ref_t) that needs to be stored in a cap for proper shared
memory to be set up, and indeed I wasn't able to set up shared memory
between a client and my driver server with the device_create function in
its current incarnation. When I changed the device_create function in my
driver to use memsection create I was then able to create some shared
memory using the objref_t returned by devicecore_get_vdevice.
My first question is if it appears that I did something wrong in trying
to set up shared memory with the original device_create that used
malloc. I did something like this:
cap_t cap;
...stuff to setup devicecore...
objref_t obj = device_core_get_vdevice(..)
cap.ref.obj = obj;
cap.passwd = 0; //My driver server's cap also had password 0
clist_insert(clist_default, cap);
//Any attempts now to dereference obj cause a pagefault
My second question is why malloc is used in device_create instead of
memsection_create, and why it doesn't return a cap that contains a
memsection_ref_t?
Thanks for the help! If I I'm not clear enough in my attempts to explain
my issue please let me know and I'll try to make it more clear.
Ryan
More information about the Developer
mailing list