system.cc (12483:fd8c7ada2fb9) | system.cc (12484:be3fa5e27fb5) |
---|---|
1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * Copyright (c) 2018 TU Dresden 4 * All rights reserved. 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 150 unchanged lines hidden (view full) --- 159 initDesc.d = 0; // operand size 160 initDesc.g = 1; // granularity 161 initDesc.s = 1; // system segment 162 initDesc.limitHigh = 0xF; 163 initDesc.limitLow = 0xFFFF; 164 initDesc.baseHigh = 0x0; 165 initDesc.baseLow = 0x0; 166 | 1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * Copyright (c) 2018 TU Dresden 4 * All rights reserved. 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 150 unchanged lines hidden (view full) --- 159 initDesc.d = 0; // operand size 160 initDesc.g = 1; // granularity 161 initDesc.s = 1; // system segment 162 initDesc.limitHigh = 0xF; 163 initDesc.limitLow = 0xFFFF; 164 initDesc.baseHigh = 0x0; 165 initDesc.baseLow = 0x0; 166 |
167 //64 bit code segment | 167 // 64 bit code segment |
168 SegDescriptor csDesc = initDesc; 169 csDesc.type.codeOrData = 1; 170 csDesc.dpl = 0; | 168 SegDescriptor csDesc = initDesc; 169 csDesc.type.codeOrData = 1; 170 csDesc.dpl = 0; |
171 //Because we're dealing with a pointer and I don't think it's 172 //guaranteed that there isn't anything in a nonvirtual class between 173 //it's beginning in memory and it's actual data, we'll use an 174 //intermediary. | 171 // Because we're dealing with a pointer and I don't think it's 172 // guaranteed that there isn't anything in a nonvirtual class between 173 // it's beginning in memory and it's actual data, we'll use an 174 // intermediary. |
175 uint64_t csDescVal = csDesc; 176 physProxy.writeBlob(GDTBase + numGDTEntries * 8, 177 (uint8_t *)(&csDescVal), 8); 178 179 numGDTEntries++; 180 181 SegSelector cs = 0; 182 cs.si = numGDTEntries - 1; 183 184 tc->setMiscReg(MISCREG_CS, (MiscReg)cs); 185 | 175 uint64_t csDescVal = csDesc; 176 physProxy.writeBlob(GDTBase + numGDTEntries * 8, 177 (uint8_t *)(&csDescVal), 8); 178 179 numGDTEntries++; 180 181 SegSelector cs = 0; 182 cs.si = numGDTEntries - 1; 183 184 tc->setMiscReg(MISCREG_CS, (MiscReg)cs); 185 |
186 //32 bit data segment | 186 // 32 bit data segment |
187 SegDescriptor dsDesc = initDesc; 188 uint64_t dsDescVal = dsDesc; 189 physProxy.writeBlob(GDTBase + numGDTEntries * 8, 190 (uint8_t *)(&dsDescVal), 8); 191 192 numGDTEntries++; 193 194 SegSelector ds = 0; --- 75 unchanged lines hidden (view full) --- 270 base += pageSize; 271 } 272 } 273 274 /* 275 * Transition from real mode all the way up to Long mode 276 */ 277 CR0 cr0 = tc->readMiscRegNoEffect(MISCREG_CR0); | 187 SegDescriptor dsDesc = initDesc; 188 uint64_t dsDescVal = dsDesc; 189 physProxy.writeBlob(GDTBase + numGDTEntries * 8, 190 (uint8_t *)(&dsDescVal), 8); 191 192 numGDTEntries++; 193 194 SegSelector ds = 0; --- 75 unchanged lines hidden (view full) --- 270 base += pageSize; 271 } 272 } 273 274 /* 275 * Transition from real mode all the way up to Long mode 276 */ 277 CR0 cr0 = tc->readMiscRegNoEffect(MISCREG_CR0); |
278 //Turn off paging. | 278 // Turn off paging. |
279 cr0.pg = 0; 280 tc->setMiscReg(MISCREG_CR0, cr0); | 279 cr0.pg = 0; 280 tc->setMiscReg(MISCREG_CR0, cr0); |
281 //Turn on protected mode. | 281 // Turn on protected mode. |
282 cr0.pe = 1; 283 tc->setMiscReg(MISCREG_CR0, cr0); 284 285 CR4 cr4 = tc->readMiscRegNoEffect(MISCREG_CR4); | 282 cr0.pe = 1; 283 tc->setMiscReg(MISCREG_CR0, cr0); 284 285 CR4 cr4 = tc->readMiscRegNoEffect(MISCREG_CR4); |
286 //Turn on pae. | 286 // Turn on pae. |
287 cr4.pae = 1; 288 tc->setMiscReg(MISCREG_CR4, cr4); 289 | 287 cr4.pae = 1; 288 tc->setMiscReg(MISCREG_CR4, cr4); 289 |
290 //Point to the page tables. | 290 // Point to the page tables. |
291 tc->setMiscReg(MISCREG_CR3, PageMapLevel4); 292 293 Efer efer = tc->readMiscRegNoEffect(MISCREG_EFER); | 291 tc->setMiscReg(MISCREG_CR3, PageMapLevel4); 292 293 Efer efer = tc->readMiscRegNoEffect(MISCREG_EFER); |
294 //Enable long mode. | 294 // Enable long mode. |
295 efer.lme = 1; 296 tc->setMiscReg(MISCREG_EFER, efer); 297 | 295 efer.lme = 1; 296 tc->setMiscReg(MISCREG_EFER, efer); 297 |
298 //Start using longmode segments. | 298 // Start using longmode segments. |
299 installSegDesc(tc, SEGMENT_REG_CS, csDesc, true); 300 installSegDesc(tc, SEGMENT_REG_DS, dsDesc, true); 301 installSegDesc(tc, SEGMENT_REG_ES, dsDesc, true); 302 installSegDesc(tc, SEGMENT_REG_FS, dsDesc, true); 303 installSegDesc(tc, SEGMENT_REG_GS, dsDesc, true); 304 installSegDesc(tc, SEGMENT_REG_SS, dsDesc, true); 305 | 299 installSegDesc(tc, SEGMENT_REG_CS, csDesc, true); 300 installSegDesc(tc, SEGMENT_REG_DS, dsDesc, true); 301 installSegDesc(tc, SEGMENT_REG_ES, dsDesc, true); 302 installSegDesc(tc, SEGMENT_REG_FS, dsDesc, true); 303 installSegDesc(tc, SEGMENT_REG_GS, dsDesc, true); 304 installSegDesc(tc, SEGMENT_REG_SS, dsDesc, true); 305 |
306 //Activate long mode. | 306 // Activate long mode. |
307 cr0.pg = 1; 308 tc->setMiscReg(MISCREG_CR0, cr0); 309 310 tc->pcState(tc->getSystemPtr()->kernelEntry); 311 312 // We should now be in long mode. Yay! 313 314 Addr ebdaPos = 0xF0000; 315 Addr fixed, table; 316 | 307 cr0.pg = 1; 308 tc->setMiscReg(MISCREG_CR0, cr0); 309 310 tc->pcState(tc->getSystemPtr()->kernelEntry); 311 312 // We should now be in long mode. Yay! 313 314 Addr ebdaPos = 0xF0000; 315 Addr fixed, table; 316 |
317 //Write out the SMBios/DMI table | 317 // Write out the SMBios/DMI table. |
318 writeOutSMBiosTable(ebdaPos, fixed, table); 319 ebdaPos += (fixed + table); 320 ebdaPos = roundUp(ebdaPos, 16); 321 | 318 writeOutSMBiosTable(ebdaPos, fixed, table); 319 ebdaPos += (fixed + table); 320 ebdaPos = roundUp(ebdaPos, 16); 321 |
322 //Write out the Intel MP Specification configuration table | 322 // Write out the Intel MP Specification configuration table. |
323 writeOutMPTable(ebdaPos, fixed, table); 324 ebdaPos += (fixed + table); 325} 326 327void 328X86System::writeOutSMBiosTable(Addr header, 329 Addr &headerSize, Addr &structSize, Addr table) 330{ 331 // If the table location isn't specified, just put it after the header. | 323 writeOutMPTable(ebdaPos, fixed, table); 324 ebdaPos += (fixed + table); 325} 326 327void 328X86System::writeOutSMBiosTable(Addr header, 329 Addr &headerSize, Addr &structSize, Addr table) 330{ 331 // If the table location isn't specified, just put it after the header. |
332 // The header size as of the 2.5 SMBios specification is 0x1F bytes | 332 // The header size as of the 2.5 SMBios specification is 0x1F bytes. |
333 if (!table) 334 table = header + 0x1F; 335 smbiosTable->setTableAddr(table); 336 337 smbiosTable->writeOut(physProxy, header, headerSize, structSize); 338 339 // Do some bounds checking to make sure we at least didn't step on 340 // ourselves. --- 41 unchanged lines hidden --- | 333 if (!table) 334 table = header + 0x1F; 335 smbiosTable->setTableAddr(table); 336 337 smbiosTable->writeOut(physProxy, header, headerSize, structSize); 338 339 // Do some bounds checking to make sure we at least didn't step on 340 // ourselves. --- 41 unchanged lines hidden --- |