This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Packed structures
- From: John Love-Jensen <eljay at adobe dot com>
- To: Phil Prentice <philp dot cheer at btinternet dot com>, <gcc-help at gnu dot org>, <gcc at gnu dot org>
- Date: Wed, 02 Jul 2003 06:44:15 -0500
- Subject: Re: Packed structures
Hi Phil,
I've used this technique...
typedef char byte;
struct IORegisters {
volatile byte setindata[1]; // write only!
byte nop0[6]; // Do not use!!!
const volatile byte getinready[1]; // read only!
const volatile byte getoutdma[4]; // read only!
volatile byte setoutdma[4]; // write only!
byte nop1[1]; // Do not use!!!
volatile byte setindma[4]; // write only!
const volatile byte getoutdata[1]; // read only!
byte nop2[1]; // Do not use!!!
const volatile byte getoutready[1]; // read only!
};
IORegisters* theRegisters = (IORegisters*)0xC00000;
If you are using C++, you can add helpers...
typedef unsigned long int nat32; // Natural 32-bit number.
void* getOutDma() {
while(getoutready[0] != 0x00)
continue;
return (void*)
( (nat32(getoutdma[0] & 0xFF) << 24)
| (nat32(getoutdma[1] & 0xFF) << 16)
| (nat32(getoutdma[2] & 0xFF) << 8)
| nat32(getoutdma[3] & 0xFF)
);
}
... et cetera ...
--Eljay