47 #include "params/X86FsWorkload.hh" 54 smbiosTable(p->smbios_table),
55 mpFloatingPointer(p->intel_mp_pointer),
56 mpConfigTable(p->intel_mp_table),
57 rsdp(p->acpi_description_table_pointer)
62 SegDescriptor desc,
bool longmode)
73 attr.defaultSize = desc.d;
74 attr.longMode = desc.l;
76 attr.granularity = desc.g;
77 attr.present = desc.p;
79 attr.type = desc.type;
81 if (desc.type.codeOrData) {
84 attr.readable = desc.type.r;
88 attr.expandDown = desc.type.e;
90 attr.writable = desc.type.w;
112 if (tc->contextId() == 0) {
125 "Loading a 32 bit x86 kernel is not supported.");
138 const int NumPDTs = 4;
140 const Addr PageMapLevel4 = 0x70000;
141 const Addr PageDirPtrTable = 0x71000;
142 const Addr PageDirTable[NumPDTs] =
143 {0x72000, 0x73000, 0x74000, 0x75000};
144 const Addr GDTBase = 0x76000;
146 const int PML4Bits = 9;
147 const int PDPTBits = 9;
148 const int PDTBits = 9;
153 uint8_t numGDTEntries = 0;
155 uint64_t nullDescriptor = 0;
156 phys_proxy.
writeBlob(GDTBase + numGDTEntries * 8, &nullDescriptor, 8);
159 SegDescriptor initDesc = 0;
160 initDesc.type.codeOrData = 0;
169 initDesc.limit = 0xFFFFFFFF;
173 SegDescriptor csDesc = initDesc;
174 csDesc.type.codeOrData = 1;
180 uint64_t csDescVal = csDesc;
181 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&csDescVal), 8);
186 cs.si = numGDTEntries - 1;
191 SegDescriptor dsDesc = initDesc;
192 uint64_t dsDescVal = dsDesc;
193 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&dsDescVal), 8);
198 ds.si = numGDTEntries - 1;
210 SegDescriptor tssDesc = initDesc;
211 uint64_t tssDescVal = tssDesc;
212 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&tssDescVal), 8);
217 tss.si = numGDTEntries - 1;
239 uint64_t pml4e = htole<uint64_t>(0x6);
241 phys_proxy.writeBlob(PageMapLevel4 + offset, (&pml4e), 8);
243 pml4e = htole<uint64_t>(0x7 | PageDirPtrTable);
244 phys_proxy.writeBlob(PageMapLevel4, (&pml4e), 8);
249 uint64_t pdpe = htole<uint64_t>(0x6);
250 for (
int offset = 0; offset < (1 << PDPTBits) * 8; offset += 8)
251 phys_proxy.writeBlob(PageDirPtrTable + offset, &pdpe, 8);
253 for (
int table = 0; table < NumPDTs; table++) {
254 pdpe = htole<uint64_t>(0x7 | PageDirTable[table]);
255 phys_proxy.writeBlob(PageDirPtrTable + table * 8, &pdpe, 8);
261 const Addr pageSize = 2 << 20;
262 for (
int table = 0; table < NumPDTs; table++) {
263 for (
int offset = 0; offset < (1 << PDTBits) * 8; offset += 8) {
265 uint64_t pdte =
htole(0x87 | base);
266 phys_proxy.writeBlob(PageDirTable[table] + offset, &pdte, 8);
311 Addr ebdaPos = 0xF0000;
316 ebdaPos += (fixed + table);
317 ebdaPos =
roundUp(ebdaPos, 16);
321 ebdaPos += (fixed + table);
331 table = header + 0x1F;
338 assert(header > table || header + headerSize <= table);
339 assert(table > header || table + structSize <= header);
362 assert(fp > table || fp + fpSize <= table);
363 assert(table > fp || table + tableSize <= fp);
364 assert(fpSize == 0x10);
370 X86FsWorkloadParams::create()
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
IntelMP::FloatingPointer * mpFloatingPointer
void installSegDesc(ThreadContext *tc, SegmentRegIndex seg, SegDescriptor desc, bool longmode)
void writeOut(PortProxy &proxy, Addr addr, Addr &headerSize, Addr &structSize)
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Addr writeOut(PortProxy &proxy, Addr addr)
void writeOutMPTable(Addr fp, Addr &fpSize, Addr &tableSize, Addr table=0)
void writeOutSMBiosTable(Addr header, Addr &headerSize, Addr &tableSize, Addr table=0)
T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Loader::ObjectFile * kernelObj
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
X86FsWorkloadParams Params
void setTableAddr(Addr addr)
static MiscRegIndex MISCREG_SEG_ATTR(int index)
static MiscRegIndex MISCREG_SEG_LIMIT(int index)
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
IntelMP::ConfigTable * mpConfigTable
Addr writeOut(PortProxy &proxy, Addr addr)
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
std::vector< ThreadContext * > threadContexts
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
SMBios::SMBiosTable * smbiosTable
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void setTableAddr(Addr addr)
static MiscRegIndex MISCREG_SEG_BASE(int index)
This is exposed globally, independent of the ISA.
static MiscRegIndex MISCREG_SEG_EFF_BASE(int index)