diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:45:30 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:45:30 -0500 |
commit | 9e3c8de30bafe33f35e4b9e82fb49418941f8cb7 (patch) | |
tree | 016c65f8060c49b31d3fd3c064b97ae09279d689 /src/arch/sparc | |
parent | 1031b824b975cec999c37cabc8c05c485a4ae5ca (diff) | |
download | gem5-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/sparc')
-rw-r--r-- | src/arch/sparc/process.cc | 26 | ||||
-rw-r--r-- | src/arch/sparc/utility.cc | 4 | ||||
-rw-r--r-- | src/arch/sparc/vtophys.cc | 6 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc index 769f15497..9377fe7d0 100644 --- a/src/arch/sparc/process.cc +++ b/src/arch/sparc/process.cc @@ -359,31 +359,31 @@ SparcLiveProcess::argsInit(int pageSize) // Write out the sentry void * uint64_t sentry_NULL = 0; - initVirtMem->writeBlob(sentry_base, + initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size); // Write the file name - initVirtMem->writeString(file_name_base, filename.c_str()); + initVirtMem.writeString(file_name_base, filename.c_str()); // Copy the aux stuff for (int x = 0; x < auxv.size(); x++) { - initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize, + initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize, (uint8_t*)&(auxv[x].a_type), intSize); - initVirtMem->writeBlob(auxv_array_base + (x * 2 + 1) * intSize, + initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize, (uint8_t*)&(auxv[x].a_val), intSize); } // Write out the terminating zeroed auxilliary vector const IntType zero = 0; - initVirtMem->writeBlob(auxv_array_base + intSize * 2 * auxv.size(), + initVirtMem.writeBlob(auxv_array_base + intSize * 2 * auxv.size(), (uint8_t*)&zero, intSize); - initVirtMem->writeBlob(auxv_array_base + intSize * (2 * auxv.size() + 1), + initVirtMem.writeBlob(auxv_array_base + intSize * (2 * auxv.size() + 1), (uint8_t*)&zero, intSize); copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); - initVirtMem->writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); + initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); // Set up space for the trap handlers into the processes address space. // Since the stack grows down and there is reserved address space abov @@ -416,9 +416,9 @@ Sparc64LiveProcess::argsInit(int intSize, int pageSize) SparcLiveProcess::argsInit<uint64_t>(pageSize); // Stuff the trap handlers into the process address space - initVirtMem->writeBlob(fillStart, + initVirtMem.writeBlob(fillStart, (uint8_t*)fillHandler64, sizeof(MachInst) * numFillInsts); - initVirtMem->writeBlob(spillStart, + initVirtMem.writeBlob(spillStart, (uint8_t*)spillHandler64, sizeof(MachInst) * numSpillInsts); } @@ -428,9 +428,9 @@ Sparc32LiveProcess::argsInit(int intSize, int pageSize) SparcLiveProcess::argsInit<uint32_t>(pageSize); // Stuff the trap handlers into the process address space - initVirtMem->writeBlob(fillStart, + initVirtMem.writeBlob(fillStart, (uint8_t*)fillHandler32, sizeof(MachInst) * numFillInsts); - initVirtMem->writeBlob(spillStart, + initVirtMem.writeBlob(spillStart, (uint8_t*)spillHandler32, sizeof(MachInst) * numSpillInsts); } @@ -452,7 +452,7 @@ void Sparc32LiveProcess::flushWindows(ThreadContext *tc) for (int index = 16; index < 32; index++) { uint32_t regVal = tc->readIntReg(index); regVal = htog(regVal); - if (!tc->getMemProxy()->tryWriteBlob( + if (!tc->getMemProxy().tryWriteBlob( sp + (index - 16) * 4, (uint8_t *)®Val, 4)) { warn("Failed to save register to the stack when " "flushing windows.\n"); @@ -487,7 +487,7 @@ Sparc64LiveProcess::flushWindows(ThreadContext *tc) for (int index = 16; index < 32; index++) { IntReg regVal = tc->readIntReg(index); regVal = htog(regVal); - if (!tc->getMemProxy()->tryWriteBlob( + if (!tc->getMemProxy().tryWriteBlob( sp + 2047 + (index - 16) * 8, (uint8_t *)®Val, 8)) { warn("Failed to save register to the stack when " "flushing windows.\n"); diff --git a/src/arch/sparc/utility.cc b/src/arch/sparc/utility.cc index 272df690c..b9a07b57b 100644 --- a/src/arch/sparc/utility.cc +++ b/src/arch/sparc/utility.cc @@ -56,8 +56,8 @@ getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp) return tc->readIntReg(8 + number); } else { Addr sp = tc->readIntReg(StackPointerReg); - FSTranslatingPortProxy* vp = tc->getVirtProxy(); - uint64_t arg = vp->read<uint64_t>(sp + 92 + + FSTranslatingPortProxy &vp = tc->getVirtProxy(); + uint64_t arg = vp.read<uint64_t>(sp + 92 + (number-NumArgumentRegs) * sizeof(uint64_t)); return arg; } diff --git a/src/arch/sparc/vtophys.cc b/src/arch/sparc/vtophys.cc index 7e3c5fe01..e3d4f5066 100644 --- a/src/arch/sparc/vtophys.cc +++ b/src/arch/sparc/vtophys.cc @@ -81,7 +81,7 @@ vtophys(ThreadContext *tc, Addr addr) int pri_context = bits(tlbdata,47,32); // int sec_context = bits(tlbdata,63,48); - PortProxy* mem = tc->getPhysProxy(); + PortProxy &mem = tc->getPhysProxy(); TLB* itb = tc->getITBPtr(); TLB* dtb = tc->getDTBPtr(); TlbEntry* tbe; @@ -110,9 +110,9 @@ vtophys(ThreadContext *tc, Addr addr) dtb->GetTsbPtr(tc, addr, ctx_zero ? 0 : pri_context, tsbs); va_tag = bits(addr, 63, 22); for (int x = 0; x < 4; x++) { - ttetag = betoh(mem->read<uint64_t>(tsbs[x])); + ttetag = betoh(mem.read<uint64_t>(tsbs[x])); if (ttetag.valid() && ttetag.va() == va_tag) { - uint64_t entry = mem->read<uint64_t>(tsbs[x]) + sizeof(uint64_t); + uint64_t entry = mem.read<uint64_t>(tsbs[x]) + sizeof(uint64_t); // I think it's sun4v at least! pte.populate(betoh(entry), PageTableEntry::sun4v); DPRINTF(VtoPhys, "Virtual(%#x)->Physical(%#x) found in TTE\n", |