From owner-freebsd-hackers Wed Jul 7 12:40:20 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from sumatra.americantv.com (sumatra.americantv.com [208.139.222.227]) by hub.freebsd.org (Postfix) with ESMTP id 0EF3A14F08 for ; Wed, 7 Jul 1999 12:40:17 -0700 (PDT) (envelope-from jlemon@americantv.com) Received: from right.PCS (right.PCS [148.105.10.31]) by sumatra.americantv.com (8.8.5/8.8.5) with ESMTP id OAA11951; Wed, 7 Jul 1999 14:40:16 -0500 (CDT) Received: from free.pcs (free.PCS [148.105.10.51]) by right.PCS (8.6.13/8.6.4) with ESMTP id OAA04230; Wed, 7 Jul 1999 14:40:14 -0500 Received: (from jlemon@localhost) by free.pcs (8.8.6/8.8.5) id OAA28900; Wed, 7 Jul 1999 14:40:13 -0500 (CDT) Date: Wed, 7 Jul 1999 14:40:13 -0500 (CDT) From: Jonathan Lemon Message-Id: <199907071940.OAA28900@free.pcs> To: hm@kts.org, hackers@freebsd.org Subject: Re: howto allocate 32k phys. mem-space in driver ? X-Newsgroups: local.mail.freebsd-hackers In-Reply-To: Organization: Architecture and Operating System Fanatics Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article you write: >Hi, > >perhaps i don't see the wood for trees. > >I'd like to write a driver for a PCI ISDN chipset which uses a 32k byte >memory window as a sort of "dual ported ram" in the memory address space. > >What has to be done in the driver attach routine is > > - allocate a 32k contingous memory window > - get the physical address of it > - program the ISDN PCI chipset with the start address of the window > >Now can i just malloc 32k and then use vtophys() to get the physical >start address to program the PCI chip with ? With the "new-bus" architecture, I believe this is done the following way: 1. Create a DMA tag describing the amount of memory needed, and what the alignment constraints are. error = bus_dma_tag_create( .... ); 2. Allocate the memory described by the tag. error = bus_dmamem_alloc( .... ); 3. Map the memory into the address space. A callback routine is used to record the physical -> virtual mapping. bus_dmamap_load( .... ); For pre-newbus, I think you just call contigmalloc(), and vtophys(). -- Jonathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message