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",
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
loader::ObjectFile * kernelObj
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
virtual const PCStateBase & pcState() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
Addr write(PortProxy &phys_proxy, Allocator &alloc) const
void writeOutACPITables(Addr begin, Addr &size)
void writeOutSMBiosTable(Addr header, Addr &headerSize, Addr &tableSize, Addr table=0)
smbios::SMBiosTable * smbiosTable
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
FsWorkload(const Params &p)
intelmp::FloatingPointer * mpFloatingPointer
intelmp::ConfigTable * mpConfigTable
void writeOutMPTable(Addr fp, Addr &fpSize, Addr &tableSize, Addr table=0)
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Addr writeOut(PortProxy &proxy, Addr addr)
Addr writeOut(PortProxy &proxy, Addr addr)
void setTableAddr(Addr addr)
void writeOut(PortProxy &proxy, Addr addr, Addr &headerSize, Addr &structSize)
void setTableAddr(Addr addr)
static constexpr T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
static RegIndex segAttr(int index)
static RegIndex segBase(int index)
static RegIndex segLimit(int index)
static RegIndex segEffBase(int index)
void installSegDesc(ThreadContext *tc, int seg, SegDescriptor desc, bool longmode)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Addr alloc(std::size_t size, unsigned align) override