From owner-freebsd-hackers Sat Oct 10 21:45:58 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA14822 for freebsd-hackers-outgoing; Sat, 10 Oct 1998 21:45:58 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from cheddar.netmonger.net (cheddar.netmonger.net [209.54.21.140]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA14805 for ; Sat, 10 Oct 1998 21:45:51 -0700 (PDT) (envelope-from chris@cheddar.netmonger.net) Received: (from chris@localhost) by cheddar.netmonger.net (8.8.8/8.8.8) id AAA01971; Sun, 11 Oct 1998 00:45:34 -0400 (EDT) Message-ID: <19981011004534.A1416@netmonger.net> Date: Sun, 11 Oct 1998 00:45:34 -0400 From: Christopher Masto To: hackers@FreeBSD.ORG Subject: Re: Contiguous memory allocation References: <361F1F49.6E4F@cs.strath.ac.uk> <199810100955.RAA15119@spinner.netplex.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.91.1i In-Reply-To: <199810100955.RAA15119@spinner.netplex.com.au>; from Peter Wemm on Sat, Oct 10, 1998 at 05:55:35PM +0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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