Re: Packed structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux