summaryrefslogtreecommitdiff
path: root/mem
diff options
context:
space:
mode:
Diffstat (limited to 'mem')
-rw-r--r--mem/bus.cc17
-rw-r--r--mem/bus.hh13
-rw-r--r--mem/packet.hh6
-rw-r--r--mem/page_table.cc11
-rw-r--r--mem/page_table.hh2
-rw-r--r--mem/physical.cc10
-rw-r--r--mem/physical.hh2
-rw-r--r--mem/port.cc8
-rw-r--r--mem/request.hh113
-rw-r--r--mem/vport.hh33
10 files changed, 151 insertions, 64 deletions
diff --git a/mem/bus.cc b/mem/bus.cc
index 0cadc2045..5e84beb83 100644
--- a/mem/bus.cc
+++ b/mem/bus.cc
@@ -31,7 +31,8 @@
*/
-#include "bus.hh"
+#include "base/trace.hh"
+#include "mem/bus.hh"
#include "sim/builder.hh"
/** Function called by the port when the bus is recieving a Timing
@@ -56,9 +57,13 @@ Bus::findPort(Addr addr, int id)
if (portList[i].range == addr) {
dest_id = portList[i].portId;
found = true;
+ DPRINTF(Bus, "Found Addr: %llx on device %d\n", addr, dest_id);
}
+ i++;
}
- assert(dest_id != -1 && "Unable to find destination");
+ if (dest_id == -1)
+ panic("Unable to find destination for addr: %llx", addr);
+
// we shouldn't be sending this back to where it came from
assert(dest_id != id);
@@ -85,8 +90,10 @@ Bus::recvFunctional(Packet &pkt, int id)
void
Bus::recvStatusChange(Port::Status status, int id)
{
- assert(status == Port:: RangeChange &&
+ assert(status == Port::RangeChange &&
"The other statuses need to be implemented.");
+
+ assert(id < interfaces.size() && id >= 0);
Port *port = interfaces[id];
AddrRangeList ranges;
AddrRangeList snoops;
@@ -97,11 +104,15 @@ Bus::recvStatusChange(Port::Status status, int id)
assert(snoops.size() == 0);
// or multiple ranges
assert(ranges.size() == 1);
+
DevMap dm;
dm.portId = id;
dm.range = ranges.front();
+ DPRINTF(MMU, "Adding range %llx - %llx for id %d\n", dm.range.start,
+ dm.range.end, id);
portList.push_back(dm);
+ DPRINTF(MMU, "port list has %d entries\n", portList.size());
}
void
diff --git a/mem/bus.hh b/mem/bus.hh
index eff42c55a..fad44aba5 100644
--- a/mem/bus.hh
+++ b/mem/bus.hh
@@ -127,12 +127,9 @@ class Bus : public MemObject
};
- /** A count of the number of interfaces connected to this bus. */
- int num_interfaces;
-
/** An array of pointers to the peer port interfaces
connected to this bus.*/
- Port *interfaces[];
+ std::vector<Port*> interfaces;
public:
@@ -140,12 +137,12 @@ class Bus : public MemObject
virtual Port *getPort(const std::string &if_name)
{
// if_name ignored? forced to be empty?
- int id = num_interfaces++;
- interfaces[id] = new BusPort(this, id);
- return interfaces[id];
+ int id = interfaces.size();
+ interfaces.push_back(new BusPort(this, id));
+ return interfaces.back();
}
Bus(const std::string &n)
- : MemObject(n), num_interfaces(0) {}
+ : MemObject(n) {}
};
diff --git a/mem/packet.hh b/mem/packet.hh
index 91e56385d..843d34ac0 100644
--- a/mem/packet.hh
+++ b/mem/packet.hh
@@ -128,6 +128,12 @@ struct Packet
/** Accessor function that returns the destination index of
the packet. */
short getDest() const { return dest; }
+
+ Packet()
+ : result(Unknown)
+ {}
+
+ void reset() { result = Unknown; }
};
#endif //__MEM_PACKET_HH
diff --git a/mem/page_table.cc b/mem/page_table.cc
index 714ddde35..c4e1ea193 100644
--- a/mem/page_table.cc
+++ b/mem/page_table.cc
@@ -121,11 +121,14 @@ PageTable::translate(Addr vaddr, Addr &paddr)
Fault
-PageTable::translate(CpuRequestPtr &req)
+PageTable::translate(RequestPtr &req)
{
- assert(pageAlign(req->vaddr + req->size - 1) == pageAlign(req->vaddr));
- if (!translate(req->vaddr, req->paddr)) {
+ Addr paddr;
+ assert(pageAlign(req->getVaddr() + req->getSize() - 1)
+ == pageAlign(req->getVaddr()));
+ if (!translate(req->getVaddr(), paddr)) {
return genMachineCheckFault();
}
- return page_check(req->paddr, req->size);
+ req->setPaddr(paddr);
+ return page_check(req->getPaddr(), req->getSize());
}
diff --git a/mem/page_table.hh b/mem/page_table.hh
index 8f0842f58..26248261a 100644
--- a/mem/page_table.hh
+++ b/mem/page_table.hh
@@ -83,7 +83,7 @@ class PageTable
* field of mem_req.
* @param req The memory request.
*/
- Fault translate(CpuRequestPtr &req);
+ Fault translate(RequestPtr &req);
};
diff --git a/mem/physical.cc b/mem/physical.cc
index 4087f3e32..b00935990 100644
--- a/mem/physical.cc
+++ b/mem/physical.cc
@@ -70,7 +70,7 @@ PhysicalMemory::MemResponseEvent::description()
}
PhysicalMemory::PhysicalMemory(const string &n)
- : MemObject(n), base_addr(0), pmem_addr(NULL)
+ : MemObject(n), base_addr(0), pmem_addr(NULL), port(NULL)
{
// Hardcoded to 128 MB for now.
pmem_size = 1 << 27;
@@ -90,6 +90,14 @@ PhysicalMemory::PhysicalMemory(const string &n)
page_ptr = 0;
}
+void
+PhysicalMemory::init()
+{
+ if (!port)
+ panic("PhysicalMemory not connected to anything!");
+ port->sendStatusChange(Port::RangeChange);
+}
+
PhysicalMemory::~PhysicalMemory()
{
if (pmem_addr)
diff --git a/mem/physical.hh b/mem/physical.hh
index 53e86f85f..ce0a2099c 100644
--- a/mem/physical.hh
+++ b/mem/physical.hh
@@ -107,7 +107,7 @@ class PhysicalMemory : public MemObject
int deviceBlockSize();
void getAddressRanges(AddrRangeList &resp, AddrRangeList &snoop);
virtual Port *getPort(const std::string &if_name);
- void virtual init() { port->sendStatusChange(Port::RangeChange); }
+ void virtual init();
// fast back-door memory access for vtophys(), remote gdb, etc.
// uint64_t phys_read_qword(Addr addr) const;
diff --git a/mem/port.cc b/mem/port.cc
index fb4f3b4e0..d312f3e3c 100644
--- a/mem/port.cc
+++ b/mem/port.cc
@@ -36,15 +36,15 @@
void
Port::blobHelper(Addr addr, uint8_t *p, int size, Command cmd)
{
- Request req;
+ Request req(false);
Packet pkt;
pkt.req = &req;
pkt.cmd = cmd;
for (ChunkGenerator gen(addr, size, peerBlockSize());
!gen.done(); gen.next()) {
- pkt.addr = req.paddr = gen.addr();
- pkt.size = req.size = gen.size();
+ req.setPaddr(pkt.addr = gen.addr());
+ req.setSize(pkt.size = gen.size());
pkt.data = p;
sendFunctional(pkt);
p += gen.size();
@@ -72,5 +72,5 @@ Port::memsetBlob(Addr addr, uint8_t val, int size)
memset(buf, val, size);
blobHelper(addr, buf, size, Write);
- delete buf;
+ delete [] buf;
}
diff --git a/mem/request.hh b/mem/request.hh
index 5e2275741..903e7503c 100644
--- a/mem/request.hh
+++ b/mem/request.hh
@@ -37,10 +37,8 @@
#include "arch/isa_traits.hh"
class Request;
-class CpuRequest;
typedef Request* RequestPtr;
-typedef CpuRequest* CpuRequestPtr;
/** The request is a Load locked/store conditional. */
const unsigned LOCKED = 0x001;
@@ -58,50 +56,147 @@ const unsigned NO_FAULT = 0x020;
const unsigned PF_EXCLUSIVE = 0x100;
/** The request should be marked as LRU. */
const unsigned EVICT_NEXT = 0x200;
+/** The request should ignore unaligned access faults */
+const unsigned NO_ALIGN_FAULT = 0x400;
class Request
{
//@todo Make Accesor functions, make these private.
public:
+ /** Constructor, needs a bool to signify if it is/isn't Cpu Request. */
+ Request(bool isCpu);
+
+ /** reset the request to it's initial state so it can be reused.*/
+ void resetAll(bool isCpu);
+
+ /** reset the request's addrs times, etc, so but not everything to same
+ * time. */
+ void resetMin();
+
+//First non-cpu request fields
+ private:
/** The physical address of the request. */
Addr paddr;
-
- /** whether this req came from the CPU or not **DO we need this??***/
- bool nicReq;
+ /** Wether or not paddr is valid (has been written yet). */
+ bool validPaddr;
/** The size of the request. */
int size;
+ /** Wether or not size is valid (has been written yet). */
+ bool validSize;
/** The time this request was started. Used to calculate latencies. */
Tick time;
+ /** Wether or not time is valid (has been written yet). */
+ bool validTime;
/** Destination address if this is a block copy. */
Addr copyDest;
+ /** Wether or not copyDest is valid (has been written yet). */
+ bool validCopyDest;
+ /** Flag structure for the request. */
uint32_t flags;
-};
+ /** Wether or not flags is valid (has been written yet). */
+ bool validFlags;
-class CpuRequest : public Request
-{
- //@todo Make Accesor functions, make these private.
+//Accsesors for non-cpu request fields
public:
+ /** Accesor for paddr. */
+ Addr getPaddr();
+ /** Accesor for paddr. */
+ void setPaddr(Addr _paddr);
+
+ /** Accesor for size. */
+ int getSize();
+ /** Accesor for size. */
+ void setSize(int _size);
+
+ /** Accesor for time. */
+ Tick getTime();
+ /** Accesor for time. */
+ void setTime(Tick _time);
+
+ /** Accesor for copy dest. */
+ Addr getCopyDest();
+ /** Accesor for copy dest. */
+ void setCopyDest(Addr _copyDest);
+
+ /** Accesor for flags. */
+ uint32_t getFlags();
+ /** Accesor for paddr. */
+ void setFlags(uint32_t _flags);
+
+//Now cpu-request fields
+ private:
+ /** Bool to signify if this is a cpuRequest. */
+ bool cpuReq;
+
/** The virtual address of the request. */
Addr vaddr;
+ /** Wether or not the vaddr is valid. */
+ bool validVaddr;
/** The address space ID. */
int asid;
+ /** Wether or not the asid is valid. */
+ bool validAsid;
/** The return value of store conditional. */
uint64_t scResult;
+ /** Wether or not the sc result is valid. */
+ bool validScResult;
/** The cpu number for statistics. */
int cpuNum;
+ /** Wether or not the cpu number is valid. */
+ bool validCpuNum;
/** The requesting thread id. */
int threadNum;
+ /** Wether or not the thread id is valid. */
+ bool validThreadNum;
/** program counter of initiating access; for tracing/debugging */
Addr pc;
+ /** Wether or not the pc is valid. */
+ bool validPC;
+
+//Accessor Functions for cpu request fields
+ public:
+ /** Accesor function to determine if this is a cpu request or not.*/
+ bool isCpuRequest();
+
+ /** Accesor function for vaddr.*/
+ Addr getVaddr();
+ /** Accesor function for vaddr.*/
+ void setVaddr(Addr _vaddr);
+
+ /** Accesor function for asid.*/
+ int getAsid();
+ /** Accesor function for asid.*/
+ void setAsid(int _asid);
+
+ /** Accesor function for store conditional return value.*/
+ uint64_t getScResult();
+ /** Accesor function for store conditional return value.*/
+ void setScResult(uint64_t _scResult);
+
+ /** Accesor function for cpu number.*/
+ int getCpuNum();
+ /** Accesor function for cpu number.*/
+ void setCpuNum(int _cpuNum);
+
+ /** Accesor function for thread number.*/
+ int getThreadNum();
+ /** Accesor function for thread number.*/
+ void setThreadNum(int _threadNum);
+
+ /** Accesor function for pc.*/
+ Addr getPC();
+ /** Accesor function for pc.*/
+ void setPC(Addr _pc);
+
};
#endif // __MEM_REQUEST_HH__
diff --git a/mem/vport.hh b/mem/vport.hh
index da036b981..fbc230ba3 100644
--- a/mem/vport.hh
+++ b/mem/vport.hh
@@ -63,39 +63,6 @@ class VirtualPort : public FunctionalPort
*/
bool nullExecContext() { return xc != NULL; }
- /** Write a piece of data into a virtual address.
- * @param vaddr virtual address to write to
- * @param data data to write
- */
- template <typename T>
- inline void write(Addr vaddr, T data)
- {
- Addr paddr;
- if (xc)
- paddr = TheISA::vtophys(xc,vaddr);
- else
- paddr = TheISA::vtophys(vaddr);
-
- FunctionalPort::write(paddr, data);
- }
-
- /** Read data from a virtual address and return it.
- * @param vaddr address to read
- * @return data read
- */
-
- template <typename T>
- inline T read(Addr vaddr)
- {
- Addr paddr;
- if (xc)
- paddr = TheISA::vtophys(xc,vaddr);
- else
- paddr = TheISA::vtophys(vaddr);
-
- return FunctionalPort::read<T>(paddr);
- }
-
/** Version of readblob that translates virt->phys and deals
* with page boundries. */
virtual void readBlob(Addr addr, uint8_t *p, int size);