Date: Sun, 11 Oct 1998 00:45:34 -0400 From: Christopher Masto <chris@netmonger.net> To: hackers@FreeBSD.ORG Subject: Re: Contiguous memory allocation Message-ID: <19981011004534.A1416@netmonger.net> In-Reply-To: <199810100955.RAA15119@spinner.netplex.com.au>; from Peter Wemm on Sat, Oct 10, 1998 at 05:55:35PM %2B0800 References: <361F1F49.6E4F@cs.strath.ac.uk> <199810100955.RAA15119@spinner.netplex.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Oct 10, 1998 at 05:55:35PM +0800, Peter Wemm wrote: > Have a look at some code that uses contigmalloc(). It's not particularly > intuitive, but it does work. Some things that use it are busdma_machdep.c > and isa.c (the isa dma code). > > You can request things like: > > Give me 16K of physically contiguous data that is aligned on a 16 byte > boundary, and is entirely within the same 64K window. > > Of course, there are no guarantees that you will be able to get a large > chunk that is physically contiguous, but you can only try. The VM system > will try quite hard to make the space for your request, even if it has to I use said function in a driver (LKM) I wrote for a satellite data receiver, and it is fairly certain to lock the machine up tight if I don't start it rather soon after boot time. IANAKH. YMMV. #define BUFFER_SIZE 32768 /* Allocate memory for a buffer */ dma_buflen = BUFFER_SIZE; dma_buf = (char *)contigmalloc(dma_buflen, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful, 1ul, 0x10000ul); if (!dma_buf) { uprintf("satlink: Failed to allocate a DMA buffer\n"); return ENOMEM; } -- Christopher Masto Director of Operations S NetMonger Communications chris@netmonger.net info@netmonger.net SSS http://www.netmonger.net \_/ Microsoft's biggest and most dangerous contribution to the software industry may be the degree to which it has lowered user expectations. - ESTHER SCHINDLER, OS/2 Magazine To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981011004534.A1416>