111 for (
auto *tc:
system->threads) {
114 if (tc->contextId() == 0) {
127 "Loading a 32 bit x86 kernel is not supported.");
130 auto phys_proxy =
system->physProxy;
140 const int NumPDTs = 4;
142 const Addr PageMapLevel4 = 0x70000;
143 const Addr PageDirPtrTable = 0x71000;
144 const Addr PageDirTable[NumPDTs] =
145 {0x72000, 0x73000, 0x74000, 0x75000};
146 const Addr GDTBase = 0x76000;
148 const int PML4Bits = 9;
149 const int PDPTBits = 9;
150 const int PDTBits = 9;
155 uint8_t numGDTEntries = 0;
157 uint64_t nullDescriptor = 0;
158 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, &nullDescriptor, 8);
161 SegDescriptor initDesc = 0;
162 initDesc.type.codeOrData = 0;
171 initDesc.limit = 0xFFFFFFFF;
175 SegDescriptor csDesc = initDesc;
176 csDesc.type.codeOrData = 1;
182 uint64_t csDescVal = csDesc;
183 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&csDescVal), 8);
188 cs.si = numGDTEntries - 1;
193 SegDescriptor dsDesc = initDesc;
200 uint64_t dsDescVal = dsDesc;
201 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&dsDescVal), 8);
206 ds.si = numGDTEntries - 1;
216 ldtAttr.unusable = 1;
221 SegDescriptor tssDesc = initDesc;
225 uint64_t tssDescVal = tssDesc;
226 phys_proxy.writeBlob(GDTBase + numGDTEntries * 8, (&tssDescVal), 8);
231 tss.si = numGDTEntries - 1;
255 phys_proxy.writeBlob(PageMapLevel4 +
offset, (&pml4e), 8);
258 phys_proxy.writeBlob(PageMapLevel4, (&pml4e), 8);
265 phys_proxy.writeBlob(PageDirPtrTable +
offset, &pdpe, 8);
267 for (
int table = 0; table < NumPDTs; table++) {
269 phys_proxy.writeBlob(PageDirPtrTable + table * 8, &pdpe, 8);
275 const Addr pageSize = 2 << 20;
276 for (
int table = 0; table < NumPDTs; table++) {
280 phys_proxy.writeBlob(PageDirTable[table] +
offset, &pdte, 8);
331 Addr ebdaPos = 0xF0000;
336 ebdaPos += (fixed + table);
337 ebdaPos =
roundUp(ebdaPos, 16);
341 ebdaPos += (fixed + table);
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