summaryrefslogtreecommitdiff
path: root/mem
diff options
context:
space:
mode:
authorRon Dreslinski <rdreslin@umich.edu>2006-02-22 17:29:04 -0500
committerRon Dreslinski <rdreslin@umich.edu>2006-02-22 17:29:04 -0500
commitb403abfbdb466573cedddf9d358b7a4b66f1e8e8 (patch)
treeae184bbb91d2b781fd0bbcc6c0c3e627ba5374b2 /mem
parent0c2f55b585f5d7d8d10591d4f3e3af6a30cfeec3 (diff)
downloadgem5-b403abfbdb466573cedddf9d358b7a4b66f1e8e8.tar.xz
Move the port from base memory object into the physical memory object.
The Memory is now a pure virtual base class for all memory type objects (DRAM, physical). We should consider renaming MemObject to something more meaningful to represent it is for all memory heirarchy objects, perhaps MemHeirObject? mem/physical.cc: mem/physical.hh: Move the port from the base class into the actual object. --HG-- extra : convert_revision : b7754ee7b90fd8f816f9876dce374c1d43c7e34b
Diffstat (limited to 'mem')
-rw-r--r--mem/physical.cc83
-rw-r--r--mem/physical.hh45
2 files changed, 124 insertions, 4 deletions
diff --git a/mem/physical.cc b/mem/physical.cc
index 4c1743293..e6d99358b 100644
--- a/mem/physical.cc
+++ b/mem/physical.cc
@@ -90,7 +90,7 @@ PhysicalMemory::PhysicalMemory(const string &n, Range<Addr> range,
#endif
PhysicalMemory::PhysicalMemory(const string &n)
- : Memory(n), base_addr(0), pmem_addr(NULL)
+ : Memory(n), memoryPort(this), base_addr(0), pmem_addr(NULL)
{
// Hardcoded to 128 MB for now.
pmem_size = 1 << 27;
@@ -171,6 +171,86 @@ PhysicalMemory::deviceBlockSize()
return 0;
}
+bool
+PhysicalMemory::doTimingAccess (Packet &pkt)
+{
+ doFunctionalAccess(pkt);
+ //Schedule a response event at curTick + lat;
+ return true;
+}
+
+Tick
+PhysicalMemory::doAtomicAccess(Packet &pkt)
+{
+ doFunctionalAccess(pkt);
+ return curTick + lat;
+}
+
+void
+PhysicalMemory::doFunctionalAccess(Packet &pkt)
+{
+ switch (pkt.cmd) {
+ case Read:
+ prot_read(pkt.addr, (uint8_t *)pkt.data, pkt.size);
+
+ case Write:
+ prot_write(pkt.addr, (uint8_t *)pkt.data, pkt.size);
+
+ default:
+ panic("unimplemented");
+ }
+}
+
+Port *
+PhysicalMemory::getPort(const char *if_name)
+{
+ return &memoryPort;
+}
+
+void
+PhysicalMemory::recvStatusChange(Port::Status status)
+{
+ panic("??");
+}
+
+PhysicalMemory::MemoryPort::MemoryPort(PhysicalMemory *_memory)
+ : memory(_memory)
+{ }
+
+void
+PhysicalMemory::MemoryPort::recvStatusChange(Port::Status status)
+{
+ memory->recvStatusChange(status);
+}
+
+void
+PhysicalMemory::MemoryPort::getDeviceAddressRanges(AddrRangeList &range_list,
+ bool &owner)
+{
+ panic("??");
+}
+
+
+bool
+PhysicalMemory::MemoryPort::recvTiming(Packet &pkt)
+{
+ return memory->doTimingAccess(pkt);
+}
+
+Tick
+PhysicalMemory::MemoryPort::recvAtomic(Packet &pkt)
+{
+ return memory->doAtomicAccess(pkt);
+}
+
+void
+PhysicalMemory::MemoryPort::recvFunctional(Packet &pkt)
+{
+ memory->doFunctionalAccess(pkt);
+}
+
+
+
void
PhysicalMemory::serialize(ostream &os)
{
@@ -278,6 +358,7 @@ PhysicalMemory::unserialize(Checkpoint *cp, const string &section)
}
+
BEGIN_DECLARE_SIM_OBJECT_PARAMS(PhysicalMemory)
Param<string> file;
diff --git a/mem/physical.hh b/mem/physical.hh
index 156a4da1d..06e6f1f0e 100644
--- a/mem/physical.hh
+++ b/mem/physical.hh
@@ -40,6 +40,39 @@
//
class PhysicalMemory : public Memory
{
+ class MemoryPort : public Port
+ {
+ PhysicalMemory *memory;
+
+ public:
+
+ MemoryPort(PhysicalMemory *_memory);
+
+ protected:
+
+ virtual bool recvTiming(Packet &pkt);
+
+ virtual Tick recvAtomic(Packet &pkt);
+
+ virtual void recvFunctional(Packet &pkt);
+
+ virtual void recvStatusChange(Status status);
+
+ virtual void getDeviceAddressRanges(AddrRangeList &range_list,
+ bool &owner);
+
+ virtual int deviceBlockSize();
+
+ };
+
+ MemoryPort memoryPort;
+
+ Port * PhysicalMemory::getPort(const char *if_name);
+
+ int lat;
+
+ //event to send response needs to be here
+
private:
// prevent copying of a MainMemory object
PhysicalMemory(const PhysicalMemory &specmem);
@@ -67,12 +100,18 @@ class PhysicalMemory : public Memory
virtual int deviceBlockSize();
// Read/Write arbitrary amounts of data to simulated memory space
- virtual void prot_read(Addr addr, uint8_t *p, int size);
- virtual void prot_write(Addr addr, const uint8_t *p, int size);
- virtual void prot_memset(Addr addr, uint8_t val, int size);
+ 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;
+ private:
+ bool doTimingAccess(Packet &pkt);
+ Tick doAtomicAccess(Packet &pkt);
+ void doFunctionalAccess(Packet &pkt);
+
+ void recvStatusChange(Port::Status status);
public:
virtual void serialize(std::ostream &os);