CODE
struct PCIRegisterType {
UInt32 Reg1;
UInt32 Reg2;
...
}
int main ()
{
IOMemoryMap *PCIMemoryMap;
PCIRegisterType *PCIRegisters;
...
PCIMemoryMap = Device->getDeviceMapWithRegister(kIOPCIConfigBaseAddress0);
PCIRegisters = (PCIRegisterType *)PCIMemoryMap->getVirtualAddress();
printf("Result 1: 0x%02x", Device->ioRead8(0x00, PCIMemoryMap)); /* Result 1: 0xfe */
printf("Result 2: 0x%02x", PCIRegisters->Reg1); /* Result 2: 0x00 */
...
}
UInt32 Reg1;
UInt32 Reg2;
...
}
int main ()
{
IOMemoryMap *PCIMemoryMap;
PCIRegisterType *PCIRegisters;
...
PCIMemoryMap = Device->getDeviceMapWithRegister(kIOPCIConfigBaseAddress0);
PCIRegisters = (PCIRegisterType *)PCIMemoryMap->getVirtualAddress();
printf("Result 1: 0x%02x", Device->ioRead8(0x00, PCIMemoryMap)); /* Result 1: 0xfe */
printf("Result 2: 0x%02x", PCIRegisters->Reg1); /* Result 2: 0x00 */
...
}
This compiles and runs fine. Everything except the printf lines were taken from Apple's documentation on the IOMemoryMap class. When I use the memory map to ioRead32(0x00, PCIMemoryMap) I get the correct value from the register. But when I try to read the register using PCIRegisters->Reg1 (or Reg2, etc...) all I get is a value of 0x00. The output of both printf lines should be the same because, according to what I would LIKE to happen, both statements should be reading the same address in memory. This, though, does not seem to be true. The memory mapping seems fine, but I can't use a struct pointer to access the mapped memory? Apple's documentation seems to let on that this is possible, but maybe I am just not getting it.
Any help would greatly be appreciated, as I've been working on this for days...
