47 #include "debug/ACPI.hh"
48 #include "params/X86FsWorkload.hh"
58 smbiosTable(
p.smbios_table),
59 mpFloatingPointer(
p.intel_mp_pointer),
60 mpConfigTable(
p.intel_mp_table),
61 rsdp(
p.acpi_description_table_pointer)
74 attr.defaultSize = desc.d;
75 attr.longMode = desc.l;
77 attr.granularity = desc.g;
78 attr.present = desc.p;
80 attr.type = desc.type;
82 if (desc.type.codeOrData) {
85 attr.readable = desc.type.r;
89 attr.expandDown = desc.type.e;
91 attr.writable = desc.type.w;
113 if (tc->contextId() == 0) {
126 "Loading a 32 bit x86 kernel is not supported.");
139 const int NumPDTs = 4;
141 const Addr PageMapLevel4 = 0x70000;
142 const Addr PageDirPtrTable = 0x71000;
143 const Addr PageDirTable[NumPDTs] =
144 {0x72000, 0x73000, 0x74000, 0x75000};
145 const Addr GDTBase = 0x76000;
147 const int PML4Bits = 9;
148 const int PDPTBits = 9;
149 const int PDTBits = 9;
154 uint8_t numGDTEntries = 0;
156 uint64_t nullDescriptor = 0;
157 phys_proxy.
writeBlob(GDTBase + numGDTEntries * 8, &nullDescriptor, 8);
160 SegDescriptor initDesc = 0;
161 initDesc.type.codeOrData = 0;
170 initDesc.limit = 0xFFFFFFFF;
174 SegDescriptor csDesc = initDesc;
175 csDesc.type.codeOrData = 1;
181 uint64_t csDescVal = csDesc;
182 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&csDescVal), 8);
187 cs.si = numGDTEntries - 1;
192 SegDescriptor dsDesc = initDesc;
199 uint64_t dsDescVal = dsDesc;
200 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&dsDescVal), 8);
205 ds.si = numGDTEntries - 1;
215 ldtAttr.unusable = 1;
220 SegDescriptor tssDesc = initDesc;
224 uint64_t tssDescVal = tssDesc;
225 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&tssDescVal), 8);
230 tss.si = numGDTEntries - 1;
252 uint64_t pml4e = htole<uint64_t>(0x6);
254 phys_proxy.writeBlob(PageMapLevel4 +
offset, (&pml4e), 8);
256 pml4e = htole<uint64_t>(0x7 | PageDirPtrTable);
257 phys_proxy.writeBlob(PageMapLevel4, (&pml4e), 8);
262 uint64_t pdpe = htole<uint64_t>(0x6);
264 phys_proxy.writeBlob(PageDirPtrTable +
offset, &pdpe, 8);
266 for (
int table = 0; table < NumPDTs; table++) {
267 pdpe = htole<uint64_t>(0x7 | PageDirTable[table]);
268 phys_proxy.writeBlob(PageDirPtrTable + table * 8, &pdpe, 8);
274 const Addr pageSize = 2 << 20;
275 for (
int table = 0; table < NumPDTs; table++) {
279 phys_proxy.writeBlob(PageDirTable[table] +
offset, &pdte, 8);
324 Addr ebdaPos = 0xF0000;
329 ebdaPos += (fixed + table);
330 ebdaPos =
roundUp(ebdaPos, 16);
334 ebdaPos += (fixed + table);
379 assert(
fp > table ||
fp + fpSize <= table);
380 assert(table >
fp || table + tableSize <=
fp);
381 assert(fpSize == 0x10);
391 fpSize = alloc.
alloc(0, 0) -
fp;
392 DPRINTF(ACPI,
"Wrote ACPI tables to memory at %llx with size %llx.\n",