Subject: Re: how to allocate physically contiguous memory?
To: Andrew Gallatin <>
From: Jason Thorpe <>
List: port-alpha
Date: 05/07/1997 16:59:50
On Wed, 7 May 1997 19:59:27 -0400 (EDT) 
 Andrew Gallatin <> wrote:

 > I'm porting a device driver to NetBSD (and starting with NetBSD/alpha)
 > I would like to be able to allocate a large chunk (512k or so) of
 > physically contiguous memory in the driver. 
 > Other systems (OSF/1, BSDI) have something like contig_malloc() or
 > vm_page_alloc_contig() for this purpose.  Is there a way to do this in
 > NetBSD/alpha?

I have a sneaking suspicion I know what you want this for :-)

I'm working on the bus dma subsystem, and need this as part of it.  I
will send you, out of band, the diffs I have that implment more-or-less
what you want (the memory that is allocated is not mapped, and that's
a feature :-)  (I'm not ready to distribute them publicly yet.)

Eventually, you will call bus_dmamem_alloc() with the appropriate
constraints, and then bus_dmamem_map() to map it into kva space
(or allow the driver's mmap entry point to call bus_dmamem_mmap() to
map it into user space :-)

...but for now, you'll be calling vm_page_alloc_memory() and then
a loop around pmap_enter() (note, I don't call it contig anything,
since the API allows the caller to specifiy a maximum segment

Jason R. Thorpe                             
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939