I'm trying to retrieve the IOAPIC address from the ACPI table. I succeeded to get the pointer address to the XSDT. I tried to get the SDTs' addresses from the XSDT structure. Unfortunately, the addresses were incorrect : 0x7ef300000000000, 0x7ef200000000000, 0x7ef100000000000 instead of 0x7ef30000, 0x7ef20000, 0x7ef10000 and 0x7ef40000, i.e. on the example below the address of the SDTs field in my XSDT structure points to 0x4 where it should point to 0x0.
0x0
|
07ef40000 00000000 07ef3000 00000000 07ef2000 00000000 07ef1000 00000000
The SDTheader and XSDT structures :
Code: Select all
struct SDTheader {
char signature[4];
uint32_t length;
uint8_t revision;
uint8_t sum;
char OEMid[6];
char OEMtableId[8];
uint32_t OEMRevision;
uint32_t creatorID;
uint32_t creatorRevision;
} __attribute__((packed));
struct XSDT {
struct SDTheader header;
uint64_t sdts[];
} __attribute__((packed));
Furthermore, I realized my XSDT structure was 0x28 bytes wide instead of 0x24 and discovered there was some kind of "padding" between the last field and the first one. The padding was 0x4 bytes wide, which might explain the difference. This seems to be related to the problem mentioned above : if I subtract 0x4 from the address of stds[0], I get the right address.
This is strange as I put __attribute__((packed)) to avoid such a problem.
Has anyone an idea on why is there a padding ?
I'm using UEFI and a cross-compiler targeting x86_64-w64-mingw32 as shown in
UEFI Bare Bones.