Re: IOUserClient and IOExternalMethodArguments
Re: IOUserClient and IOExternalMethodArguments
- Subject: Re: IOUserClient and IOExternalMethodArguments
- From: Duane Murphy <email@hidden>
- Date: Wed, 17 Jun 2009 05:08:49 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On Jun 17, 2009, at 2:36 AM, Terry Lambert wrote:
> On Jun 16, 2009, at 3:33 PM, Duane Murphy wrote:
>> I would like to take advantage of the structureInputDescriptor and
>> structureOutputDescriptor fields of IOExternalMethodArguments to
>> memory map the data passed from user space to the kernel.
>>
>> I have done this by hand myself and it works just fine. However, I
>> can't seem to get this to work with these fields. It makes the code
>> much simpler if I can take advantage of these fields.
>>
>> I make sure that the source memory in user space uses an anonymous
>> mmap() to make sure the memory is aligned and available for mapping.
>>
>> When I detect that one of the descriptor fields is being used in my
>> kext, I prepare(), then map() the memory. Then I call
>> getVirtualAddress() using the resulting IOMemoryMap. No errors are
>> returned by any of the calls. But the resulting address can not be
>> accessed by the kernel. I get a kernel panic if I let my code run or
>> in gdb I simply get a "cannot access memory at address 0x34346000"
>> error.
>>
>> Is it possible to use these descriptors for memory mapping? My
>> examination of the code seems to indicate that it should work.
>>
>> What is it that I am doing wrong? What am I missing?
>
>
> You are probably porting code from an older 32 bit system?
>
> The virtual address is the virtual address from the user space
> process, and the user space process is not mapped into the kernel
> address space. Some older UNIX systems used to split user and
> kernel virtual address space, and mapped the process making a call
> into the kernel address space, so you would have been able to
> reference it directly on these older systems, but most more recent
> 32 bit systems want to use more than a 1G/3G or 2G/2G split address
> space, now that systems tend to have enough physical memory to fill
> up a 4G address space with actual pages.
>
> In general, you should probably not be expecting to share a huge
> amount of memory between kernel and user space. You should probably
> be using an IOMemoryDescriptor instead (see <http://developer.apple.com
> >).
This is brand new code, so there's no real porting going on. The
amount of memory is also relatively small, 16K up to 1M.
The reason for wanting to use the structureInputDescriptor and
structureIOutputDescriptor fields is that they are already
IOMemoryDescriptors that are used to handle IOUserClient interfaces
when the memory requirements use more than the 4K mach maximum.
As I indicated, if I do the IOMemoryDescriptor myself, it works just
fine. It just seems redundant for me to go to the hassle of using it
when the IOUserCleint already does it for me. I just can't seem to
work out why I map() is not returning a useable memory address and is
not failing.
...Duane
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.10.0 (Build 500)
Charset: US-ASCII
wsBVAwUBSjjc2Erg9acQ4r2CAQjtYgf9GC/k7eedNjxIVKJASFwGRBu+HwRYe7PS
BV5fUWSmVrFDSWTFGalIQtFBX+SJcx87iSXm+vgRKENesnze5dGrhGRplrVFQcs7
zYubE1+MXYun4XDDuQrMxC/4cfyEMya9pKWYjgiip48VdRkWyAyNb1K5995nnl/a
LNyByCtD8SsFwwG9X0/ubMZNDcwOoeIAnN82HBnJdHgPlv5LbC3s+OhMp+K6102Q
d32xUac3ntI56mh1ykkvNTF0C1h/nlgPAgosO+VdK5VqmDa5i271mOz0n6NGrmsz
HZKSRzaPv4OUFrTrjNa3tNZaqbdYPM+3G2DW8zYbTIM7KRxI/IKofA==
=Mmi9
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden