Re: Equivalent of Linux kmap on Mac OS
Re: Equivalent of Linux kmap on Mac OS
- Subject: Re: Equivalent of Linux kmap on Mac OS
- From: Terry Lambert <email@hidden>
- Date: Wed, 7 Mar 2007 03:50:42 -0800
On Mar 6, 2007, at 4:35 PM, Bhavesh Davda wrote:
What's the equivalent of Linux's kmap to map a user virtual address
into the kernel memory space so that it is accessible "magically"
(i.e. without any additional mapping/unmapping required) to all other
tasks and kernel threads?
I've already looked at vm_map and AFAICT, that ain't it.
The concept of kmap() is specifically for split kernel and user
virtual address spaces, with both a limit on the total of the two
together (a 1G/3G split is common for Linux and BSD systems), and a
limit on the visibility of physical memory over the 4G mark to a 32
bit kernel with a 4G limit on virtual address space, on a machine with
>4G of physical RAM.
In other words, it's a generic bounce buffer mechanism utilizing
memory mapping windows to relocate so-called "high memory" into the
kernel virtual address space so that the kernel can see it.
It's unlikely that you will need to worry yourself with this sort of
thing.
In general, this is taken care of either by uio or by the
IOMemoryDescriptor construct, which pretty much amount to the same
thing.
If the reason you are asking is that you are trying to find a kmap()-
like mechanism to avoid polluting the VM/buffer cache with pages that
you plan to use once and throw away clean (i.e. you are trying to
write a streaming video server or something else that wants to move a
lot of data, and since it isn't going to look at it again, it doesn't
want to keep it around taking up space), then you should look at:
man fcntl
and look at F_NOCACHE to disable caching of the data in the kernel by
the unified buffer cache subsystem.
If the reason you are asking is that you want to abuse the ability to
map user space pages into the kernel virtual address space, an
IOMemoryDescriptor will let you do this, in combination with the "map"
member function, but I would discourage that, just like the Linux guys
discourage using kmap() that way:
<http://lwn.net/Articles/111226/>
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden