Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Jul 1999 14:40:13 -0500 (CDT)
From:      Jonathan Lemon <jlemon@americantv.com>
To:        hm@kts.org, hackers@freebsd.org
Subject:   Re: howto allocate 32k phys. mem-space in driver ?
Message-ID:  <199907071940.OAA28900@free.pcs>
In-Reply-To: <local.mail.freebsd-hackers/m111mgq-00002VC@bert.kts.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <local.mail.freebsd-hackers/m111mgq-00002VC@bert.kts.org> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907071940.OAA28900>