summaryrefslogtreecommitdiff
path: root/src/arch/x86/system.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-02-24 11:45:30 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2012-02-24 11:45:30 -0500
commit9e3c8de30bafe33f35e4b9e82fb49418941f8cb7 (patch)
tree016c65f8060c49b31d3fd3c064b97ae09279d689 /src/arch/x86/system.cc
parent1031b824b975cec999c37cabc8c05c485a4ae5ca (diff)
downloadgem5-9e3c8de30bafe33f35e4b9e82fb49418941f8cb7.tar.xz
MEM: Make port proxies use references rather than pointers
This patch is adding a clearer design intent to all objects that would not be complete without a port proxy by making the proxies members rathen than dynamically allocated. In essence, if NULL would not be a valid value for the proxy, then we avoid using a pointer to make this clear. The same approach is used for the methods using these proxies, such as loadSections, that now use references rather than pointers to better reflect the fact that NULL would not be an acceptable value (in fact the code would break and that is how this patch started out). Overall the concept of "using a reference to express unconditional composition where a NULL pointer is never valid" could be done on a much broader scale throughout the code base, but for now it is only done in the locations affected by the proxies.
Diffstat (limited to 'src/arch/x86/system.cc')
-rw-r--r--src/arch/x86/system.cc41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/arch/x86/system.cc b/src/arch/x86/system.cc
index ca13fd5ce..effe1e994 100644
--- a/src/arch/x86/system.cc
+++ b/src/arch/x86/system.cc
@@ -138,17 +138,14 @@ X86System::initState()
const int PDPTBits = 9;
const int PDTBits = 9;
- // Get a port proxy to write the page tables and descriptor tables.
- PortProxy* physProxy = tc->getPhysProxy();
-
/*
* Set up the gdt.
*/
uint8_t numGDTEntries = 0;
// Place holder at selector 0
uint64_t nullDescriptor = 0;
- physProxy->writeBlob(GDTBase + numGDTEntries * 8,
- (uint8_t *)(&nullDescriptor), 8);
+ physProxy.writeBlob(GDTBase + numGDTEntries * 8,
+ (uint8_t *)(&nullDescriptor), 8);
numGDTEntries++;
//64 bit code segment
@@ -169,8 +166,8 @@ X86System::initState()
//it's beginning in memory and it's actual data, we'll use an
//intermediary.
uint64_t csDescVal = csDesc;
- physProxy->writeBlob(GDTBase + numGDTEntries * 8,
- (uint8_t *)(&csDescVal), 8);
+ physProxy.writeBlob(GDTBase + numGDTEntries * 8,
+ (uint8_t *)(&csDescVal), 8);
numGDTEntries++;
@@ -192,8 +189,8 @@ X86System::initState()
dsDesc.limitHigh = 0xF;
dsDesc.limitLow = 0xFF;
uint64_t dsDescVal = dsDesc;
- physProxy->writeBlob(GDTBase + numGDTEntries * 8,
- (uint8_t *)(&dsDescVal), 8);
+ physProxy.writeBlob(GDTBase + numGDTEntries * 8,
+ (uint8_t *)(&dsDescVal), 8);
numGDTEntries++;
@@ -220,8 +217,8 @@ X86System::initState()
tssDesc.limitHigh = 0xF;
tssDesc.limitLow = 0xFF;
uint64_t tssDescVal = tssDesc;
- physProxy->writeBlob(GDTBase + numGDTEntries * 8,
- (uint8_t *)(&tssDescVal), 8);
+ physProxy.writeBlob(GDTBase + numGDTEntries * 8,
+ (uint8_t *)(&tssDescVal), 8);
numGDTEntries++;
@@ -250,25 +247,25 @@ X86System::initState()
// read/write, user, not present
uint64_t pml4e = X86ISA::htog(0x6);
for (int offset = 0; offset < (1 << PML4Bits) * 8; offset += 8) {
- physProxy->writeBlob(PageMapLevel4 + offset, (uint8_t *)(&pml4e), 8);
+ physProxy.writeBlob(PageMapLevel4 + offset, (uint8_t *)(&pml4e), 8);
}
// Point to the only PDPT
pml4e = X86ISA::htog(0x7 | PageDirPtrTable);
- physProxy->writeBlob(PageMapLevel4, (uint8_t *)(&pml4e), 8);
+ physProxy.writeBlob(PageMapLevel4, (uint8_t *)(&pml4e), 8);
// Page Directory Pointer Table
// read/write, user, not present
uint64_t pdpe = X86ISA::htog(0x6);
for (int offset = 0; offset < (1 << PDPTBits) * 8; offset += 8) {
- physProxy->writeBlob(PageDirPtrTable + offset,
- (uint8_t *)(&pdpe), 8);
+ physProxy.writeBlob(PageDirPtrTable + offset,
+ (uint8_t *)(&pdpe), 8);
}
// Point to the PDTs
for (int table = 0; table < NumPDTs; table++) {
pdpe = X86ISA::htog(0x7 | PageDirTable[table]);
- physProxy->writeBlob(PageDirPtrTable + table * 8,
- (uint8_t *)(&pdpe), 8);
+ physProxy.writeBlob(PageDirPtrTable + table * 8,
+ (uint8_t *)(&pdpe), 8);
}
// Page Directory Tables
@@ -279,8 +276,8 @@ X86System::initState()
for (int offset = 0; offset < (1 << PDTBits) * 8; offset += 8) {
// read/write, user, present, 4MB
uint64_t pdte = X86ISA::htog(0x87 | base);
- physProxy->writeBlob(PageDirTable[table] + offset,
- (uint8_t *)(&pdte), 8);
+ physProxy.writeBlob(PageDirTable[table] + offset,
+ (uint8_t *)(&pdte), 8);
base += pageSize;
}
}
@@ -342,9 +339,6 @@ void
X86System::writeOutSMBiosTable(Addr header,
Addr &headerSize, Addr &structSize, Addr table)
{
- // Get a port proxy to write the table and header to memory.
- PortProxy* physProxy = threadContexts[0]->getPhysProxy();
-
// If the table location isn't specified, just put it after the header.
// The header size as of the 2.5 SMBios specification is 0x1F bytes
if (!table)
@@ -363,9 +357,6 @@ void
X86System::writeOutMPTable(Addr fp,
Addr &fpSize, Addr &tableSize, Addr table)
{
- // Get a port proxy to write the table and header to memory.
- PortProxy* physProxy = threadContexts[0]->getPhysProxy();
-
// If the table location isn't specified and it exists, just put
// it after the floating pointer. The fp size as of the 1.4 Intel MP
// specification is 0x10 bytes.