From owner-freebsd-hackers Mon Dec 28 07:06:54 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA08437 for freebsd-hackers-outgoing; Mon, 28 Dec 1998 07:06:54 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from spinner.netplex.com.au (spinner.netplex.com.au [202.12.86.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA08432 for ; Mon, 28 Dec 1998 07:06:51 -0800 (PST) (envelope-from peter@netplex.com.au) Received: from spinner.netplex.com.au (localhost [127.0.0.1]) by spinner.netplex.com.au (8.9.1/8.9.1/Netplex) with ESMTP id XAA65889; Mon, 28 Dec 1998 23:06:24 +0800 (WST) (envelope-from peter@spinner.netplex.com.au) Message-Id: <199812281506.XAA65889@spinner.netplex.com.au> X-Mailer: exmh version 2.0.2 2/24/98 To: bmcgover@cisco.com cc: hackers@FreeBSD.ORG Subject: Re: Aquiring contiguous wired physical memory in the kernel... In-reply-to: Your message of "Mon, 28 Dec 1998 09:45:19 EST." <199812281445.JAA04498@bmcgover-pc.cisco.com> Date: Mon, 28 Dec 1998 23:06:23 +0800 From: Peter Wemm Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Brian McGovern wrote: > I've been looking through the mailing lists for the better part of a half hou r > or so trying to find the answer to this, but it seems that the answers either > conflict for method, or the answers work for a specific case. So, I'll ask > the question directly, and hopefully get the "best" answer :) > > I'm about 1/3 of the way through writing a device driver for a high-density > tty-like device (108 modems in a PCI slot form factor). While the module has > on-board RAM that I can use for buffering, the device is also capable of usin g > the host's RAM for buffering, which I'd like to take advantage of. > > What I need to be able to do is malloc() a chunk of memory (say 512K-1MB) tha t > is physically contiguous. Then, I need to be able to get the PHYSICAL address > of this memory chunk, and pass it back off to the board so it can directly > access the memory. > > Looking through some of the drivers in the pci subdirectory, it appears that > they use a macro caled vtophys, which calls pmap_kextract, then adds 10737418 25 > ((1024 * 1024 * 1024) + 1) to the result. Others seem to use kv_top() to get > the physical address. > > Anyone care to comment? > -Brian Well, I'd certainly love to comment on the subject at hand... 108 modem-like devices on a pci card? Wow!! :-) Where do I sign up? :-) Anyway, what you are looking for is contigmalloc(). It is best to use this as early as possible in the system boot before memory gets too fragmented. You can specify an optional upper memory limit (eg: all within bottom 16MB for ISA dma), and alignment (ie: start on a 64K boundary), and a sort-of region limit (ie: the start and end must be in (say) the same 4MB) chunk. Cheers, -Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message