This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]