32bit pointer in 64bit kernel code

Armin Schindler mac at melware.de
Sat Aug 3 02:46:53 EST 2002

Hi Todd,

thanx for your hint, but I know dma_addr_t. I think I didn't explain
my problem very good. The PCI card runs with its own CPU and software
on board. The PCI memory space is some kind of dual-ported memory.
The card now stores the data my driver wants to read in a defined structure,
which need to be aligned like my structure definition. One member of
this structure is an internal 32bit pointer which I like to define
as 32bit pointer and not u32.
I think I will change it to u32, it seems better...


On 2 Aug 2002, Todd Inglett wrote:

> On Fri, 2002-08-02 at 04:28, Armin Schindler wrote:
> > I want to port a PCI card driver to be 64bit compatible and my current
> > problem is how to tell the cross gcc to produce 32bit pointers.
> Well, by "pointer" I assume you really mean a PCI bus address (or "DMA
> address").  Remember that system memory addresses (what I would call a
> "pointer") and PCI bus addresses are two different address spaces.  What
> confuses the issue is that 32-bit machines (mainly PCs) have a
> one-to-one mapping between these spaces, so you may be working with a
> driver that has made this mistake.
> In Linux you should use the "dma_addr_t"  as your data type for these
> addresses (it is a 32-bit value by PCI definition).  You will need to
> use the pci mapping functions to map between system memory addresses
> (i.e. "pointers") and dma_addr_t.  These are declared in <linux/pci.h>.
> The simplest such function is pci_alloc_consistent(dev, size, &bus_addr)
> which will allocate "size" bytes of system memory and return its address
> and it will also create the mapping for the given PCI device and return
> the bus_addr (dma_addr_t).
> If you are doing this on the fly with memory you have already allocated
> you can use other pci mapping functions.  See
> Documentation/DMA-mapping.txt for all the details.
> Finally, note that bus_to_virt() and virt_to_bus() are not implemented
> on ppc64 (nor on sparc64).  These functions are gone in the 2.5 kernel
> anyway.  If you need to translate system addresses vs. bus addresses for
> mappings you have made, you need to keep track of the address pairs.
> This is rare in existing drivers but, if I recall, the SCSI middle layer
> does it.
> -todd

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/

More information about the Linuxppc64-dev mailing list