47 #include "params/X86System.hh"
49 using namespace LittleEndianGuest;
50 using namespace X86ISA;
53 System(p), smbiosTable(p->smbios_table),
54 mpFloatingPointer(p->intel_mp_pointer),
55 mpConfigTable(p->intel_mp_table),
56 rsdp(p->acpi_description_table_pointer)
62 SegDescriptor desc,
bool longmode)
64 uint64_t
base = desc.baseLow + (desc.baseHigh << 24);
69 uint64_t limit = desc.limitLow | (desc.limitHigh << 16);
75 attr.defaultSize = desc.d;
76 attr.longMode = desc.l;
78 attr.granularity = desc.g;
79 attr.present = desc.p;
81 attr.type = desc.type;
83 if (desc.type.codeOrData) {
86 attr.readable = desc.type.r;
90 attr.expandDown = desc.type.e;
92 attr.writable = desc.type.w;
112 fatal(
"No kernel to load.\n");
115 fatal(
"Loading a 32 bit x86 kernel is not supported.\n");
126 const int NumPDTs = 4;
128 const Addr PageMapLevel4 = 0x70000;
129 const Addr PageDirPtrTable = 0x71000;
130 const Addr PageDirTable[NumPDTs] =
131 {0x72000, 0x73000, 0x74000, 0x75000};
132 const Addr GDTBase = 0x76000;
134 const int PML4Bits = 9;
135 const int PDPTBits = 9;
136 const int PDTBits = 9;
141 uint8_t numGDTEntries = 0;
143 uint64_t nullDescriptor = 0;
145 (uint8_t *)(&nullDescriptor), 8);
148 SegDescriptor initDesc = 0;
149 initDesc.type.codeOrData = 0;
158 initDesc.limitHigh = 0xFFFF;
159 initDesc.limitLow = 0xF;
160 initDesc.baseHigh = 0x0;
161 initDesc.baseLow = 0x0;
164 SegDescriptor csDesc = initDesc;
165 csDesc.type.codeOrData = 1;
171 uint64_t csDescVal = csDesc;
173 (uint8_t *)(&csDescVal), 8);
178 cs.si = numGDTEntries - 1;
183 SegDescriptor dsDesc = initDesc;
184 uint64_t dsDescVal = dsDesc;
186 (uint8_t *)(&dsDescVal), 8);
191 ds.si = numGDTEntries - 1;
203 SegDescriptor tssDesc = initDesc;
204 uint64_t tssDescVal = tssDesc;
206 (uint8_t *)(&tssDescVal), 8);
211 tss.si = numGDTEntries - 1;
245 for (
int offset = 0; offset < (1 << PDPTBits) * 8; offset += 8) {
247 (uint8_t *)(&pdpe), 8);
250 for (
int table = 0; table < NumPDTs; table++) {
253 (uint8_t *)(&pdpe), 8);
259 const Addr pageSize = 2 << 20;
260 for (
int table = 0; table < NumPDTs; table++) {
261 for (
int offset = 0; offset < (1 << PDTBits) * 8; offset += 8) {
265 (uint8_t *)(&pdte), 8);
310 Addr ebdaPos = 0xF0000;
315 ebdaPos += (fixed + table);
316 ebdaPos =
roundUp(ebdaPos, 16);
320 ebdaPos += (fixed + table);
330 table = header + 0x1F;
337 assert(header > table || header + headerSize <= table);
338 assert(table > header || table + structSize <= header);
362 assert(fp > table || fp + fpSize <= table);
363 assert(table > fp || table + tableSize <= fp);
364 assert(fpSize == 0x10);
374 X86SystemParams::create()
virtual System * getSystemPtr()=0
void installSegDesc(ThreadContext *tc, SegmentRegIndex seg, SegDescriptor desc, bool longmode)
void writeOut(PortProxy &proxy, Addr addr, Addr &headerSize, Addr &structSize)
Addr writeOut(PortProxy &proxy, Addr addr)
X86ISA::IntelMP::ConfigTable * mpConfigTable
virtual MiscReg readMiscRegNoEffect(int misc_reg) const =0
virtual void setMiscReg(int misc_reg, const MiscReg &val)=0
virtual TheISA::PCState pcState()=0
T roundUp(const T &val, const U &align)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void writeOutSMBiosTable(Addr header, Addr &headerSize, Addr &tableSize, Addr table=0)
void setTableAddr(Addr addr)
static MiscRegIndex MISCREG_SEG_ATTR(int index)
void initState()
Serialization stuff.
static MiscRegIndex MISCREG_SEG_LIMIT(int index)
Addr writeOut(PortProxy &proxy, Addr addr)
std::vector< ThreadContext * > threadContexts
Addr kernelEntry
Entry point in the kernel to start at.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
X86ISA::SMBios::SMBiosTable * smbiosTable
ObjectFile * kernel
Object pointer for the kernel code.
void setTableAddr(Addr addr)
static MiscRegIndex MISCREG_SEG_BASE(int index)
virtual void writeBlob(Addr addr, const uint8_t *p, int size) const
Write size bytes from p to address.
static MiscRegIndex MISCREG_SEG_EFF_BASE(int index)
X86ISA::IntelMP::FloatingPointer * mpFloatingPointer
void writeOutMPTable(Addr fp, Addr &fpSize, Addr &tableSize, Addr table=0)