Re: Newbie: allocating aligned physically-contiguous memory?
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 12 Jul 2007 21:35:51 GMT
Neil Steiner <neil.steiner@xxxxxx> wrote:
Here's what I need to do:
1. Allocate block of 0x00200000 physically contiguous bytes from memory.
2. Guarantee the block is aligned on a physical 0x00200000 boundary.
3. Make the block visible from user space, if possible.
It would be nice to just kmalloc(0x00200000,GFP_USER), but that wouldn't
give me any way to enforce the physical alignment requirement. I'm sure
someone here has done this kind of thing a million times. Any ideas?
Anything I should be reading up on?
I guess you should have a look at the __get_free_pages() function,
it returns (if available) a number of physically contiguous pages
(of course starting on a page bondary-:). It's defined as
__get_free_pages( unsigned int flags, unsigned int order )
The 'flags' argument is the same as for kmalloc() and 'order'
is the base-two logarithm of the number of pages you are re-
questing (i.e. 21 in your case if I got the maths right;-).
The function exists for both 2.4 and 2.6 kernels (include
<linux/slab.h> for the declaration).
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: Newbie: allocating aligned physically-contiguous memory?
- From: Neil Steiner
- Re: Newbie: allocating aligned physically-contiguous memory?
- References:
- Newbie: allocating aligned physically-contiguous memory?
- From: Neil Steiner
- Newbie: allocating aligned physically-contiguous memory?
- Prev by Date: Newbie: allocating aligned physically-contiguous memory?
- Next by Date: Undefined SysCall
- Previous by thread: Newbie: allocating aligned physically-contiguous memory?
- Next by thread: Re: Newbie: allocating aligned physically-contiguous memory?
- Index(es):
Relevant Pages
|