From ceac38e41c5c0a7131d7581244713d33b5fff521 Mon Sep 17 00:00:00 2001 From: Ron Dreslinski Date: Wed, 22 Feb 2006 17:43:08 -0500 Subject: [PATCH] Remove unneeded functions, moving code around abit. mem/physical.cc: Remove unneeded functions. Need to add a .toString option for commands to making printing prettier. mem/physical.hh: Remove unneeded functions. --HG-- extra : convert_revision : 3707d317f542d56c0a0758a2c5ba493b92fb0c87 --- mem/physical.cc | 33 ++++++++------------------------- mem/physical.hh | 8 +++----- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/mem/physical.cc b/mem/physical.cc index e6d99358b..beebb65c8 100644 --- a/mem/physical.cc +++ b/mem/physical.cc @@ -130,36 +130,18 @@ PhysicalMemory::new_page() // little helper for better prot_* error messages // void -PhysicalMemory::prot_access_error(Addr addr, int size, const string &func) +PhysicalMemory::prot_access_error(Addr addr, int size, Command func) { panic("invalid physical memory access!\n" - "%s: %s(addr=%#x, size=%d) out of range (max=%#x)\n", + "%s: %i(addr=%#x, size=%d) out of range (max=%#x)\n", name(), func, addr, size, pmem_size - 1); } -void -PhysicalMemory::prot_read(Addr addr, uint8_t *p, int size) -{ - if (addr + size >= pmem_size) - prot_access_error(addr, size, "prot_read"); - - memcpy(p, pmem_addr + addr - base_addr, size); -} - -void -PhysicalMemory::prot_write(Addr addr, const uint8_t *p, int size) -{ - if (addr + size >= pmem_size) - prot_access_error(addr, size, "prot_write"); - - memcpy(pmem_addr + addr - base_addr, p, size); -} - void PhysicalMemory::prot_memset(Addr addr, uint8_t val, int size) { if (addr + size >= pmem_size) - prot_access_error(addr, size, "prot_memset"); + prot_access_error(addr, size, Write); memset(pmem_addr + addr - base_addr, val, size); } @@ -189,13 +171,14 @@ PhysicalMemory::doAtomicAccess(Packet &pkt) void PhysicalMemory::doFunctionalAccess(Packet &pkt) { + if (pkt.addr + pkt.size >= pmem_size) + prot_access_error(pkt.addr, pkt.size, pkt.cmd); + switch (pkt.cmd) { case Read: - prot_read(pkt.addr, (uint8_t *)pkt.data, pkt.size); - + memcpy(pkt.data, pmem_addr + pkt.addr - base_addr, pkt.size); case Write: - prot_write(pkt.addr, (uint8_t *)pkt.data, pkt.size); - + memcpy(pmem_addr + pkt.addr - base_addr, pkt.data, pkt.size); default: panic("unimplemented"); } diff --git a/mem/physical.hh b/mem/physical.hh index 06e6f1f0e..bac7e3d46 100644 --- a/mem/physical.hh +++ b/mem/physical.hh @@ -34,6 +34,7 @@ #include "base/range.hh" #include "mem/memory.hh" +#include "mem/packet.hh" // // Functional model for a contiguous block of physical memory. (i.e. RAM) @@ -94,18 +95,15 @@ class PhysicalMemory : public Memory protected: // error handling for prot_* functions - void prot_access_error(Addr addr, int size, const std::string &func); + void prot_access_error(Addr addr, int size, Command func); public: virtual int deviceBlockSize(); - // Read/Write arbitrary amounts of data to simulated memory space - void prot_read(Addr addr, uint8_t *p, int size); - void prot_write(Addr addr, const uint8_t *p, int size); void prot_memset(Addr addr, uint8_t val, int size); // fast back-door memory access for vtophys(), remote gdb, etc. - uint64_t phys_read_qword(Addr addr) const; + // uint64_t phys_read_qword(Addr addr) const; private: bool doTimingAccess(Packet &pkt); Tick doAtomicAccess(Packet &pkt); -- 2.30.2