Subject: Portable code (was: Any way to get virtual addr ...)
To: Chris G. Demetriou <cgd@pa.dec.com>
From: Zdenek Salvet <salvet@horn.ics.muni.cz>
List: tech-kern
Date: 08/13/1997 07:56:13
> > I'm using pci_mapreg_map() to map the chip's RAM, passing it
> > PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT for the "expected"
> > argument. This gets me a tag and handle that I can use with the
> > bus_space_* macros/functions to access the memory. However, the driver
> > wants to be able to access the memory as a struct, and do stuff like
> > "scriptstruct->member = somevalue".
>
> "so, fix it." That is not portable code. Device memory may not be
> mapped linearly, and indeed on many systems _is not_ mapped inearly.
Is it OK to access network protocol headers through structures in C ?
I am worried about compilers and systems with weird alignment requirements
- e.g. aligning u_int16_t to 4 bytes or not having u_int16_t at all
(fortunately, I haven't any yet).
--
Zdenek Salvet salvet@ics.muni.cz
----------------------------------------------------------------------------
If God had meant for us to be in the Army,
we would have been born with green, baggy skin.