Allocate aligned memory
Hans Petter Selasky
hselasky at c2i.net
Fri Dec 15 01:19:44 PST 2006
On Friday 15 December 2006 09:50, Suleiman Souhlal wrote:
> Marc Lörner wrote:
> > Hello all,
> >
> > I want to allocate 120KB of memory thats aligned to 32KB.
> > I already saw/found the function contigmalloc, now my question is, why
> > following functioncall never does return with an resulting address,
> > instead null is returned?
> >
> > unsigned long *p = (unsigned long*)
> > contigmalloc(120*1024, M_DEVBUF, M_WAITOK, 0, (1<<22), 32*1024,
> > 1024*1024);
>
> Have you considered the fact that there might be no 32K-aligned 120KB chunk
> of memory in the range you specified?
>
> My suggestion is to make the your high limit (currently 1 << 22) MUCH
> higher, if possible. Also, getting rid of the 1MB boundary might help.
>
PS: contigmalloc is on the way out. Please use "man bus_dma" instead. For an
example see:
http://www.turbocat.net/~hselasky/isdn4bsd/sources/src/sys/dev/usb/usb_subr.c
And the function "usbd_mem_alloc_sub()".
--HPS
More information about the freebsd-hackers
mailing list