memPort = &dcachePort;
+ //Create Memory Ports (conect them up)
+ p->mem->addPort("DCACHE");
+ dcachePort.setPeer(p->mem->getPort("DCACHE"));
+ (p->mem->getPort("DCACHE"))->setPeer(&dcachePort);
+
+ p->mem->addPort("ICACHE");
+ icachePort.setPeer(p->mem->getPort("ICACHE"));
+ (p->mem->getPort("ICACHE"))->setPeer(&icachePort);
+
+
+
req = new CpuRequest;
req->asid = 0;
#if FULL_SYSTEM
SimObjectParam<AlphaITB *> itb;
SimObjectParam<AlphaDTB *> dtb;
- SimObjectParam<FunctionalMemory *> mem;
SimObjectParam<System *> system;
Param<int> cpu_id;
Param<Tick> profile;
#else
+ SimObjectParam<Memory *> mem;
SimObjectParam<Process *> workload;
#endif // FULL_SYSTEM
#if FULL_SYSTEM
INIT_PARAM(itb, "Instruction TLB"),
INIT_PARAM(dtb, "Data TLB"),
- INIT_PARAM(mem, "memory"),
INIT_PARAM(system, "system object"),
INIT_PARAM(cpu_id, "processor ID"),
INIT_PARAM(profile, ""),
#else
+ INIT_PARAM(mem, "memory"),
INIT_PARAM(workload, "processes to run"),
#endif // FULL_SYSTEM
#if FULL_SYSTEM
params->itb = itb;
params->dtb = dtb;
- params->mem = mem;
params->system = system;
params->cpu_id = cpu_id;
params->profile = profile;
#else
+ params->mem = mem;
params->process = workload;
#endif
class Processor;
class AlphaITB;
class AlphaDTB;
-class PhysicalMemory;
+class Memory;
class RemoteGDB;
class GDBListener;
#if FULL_SYSTEM
AlphaITB *itb;
AlphaDTB *dtb;
- FunctionalMemory *mem;
#else
+ Memory *mem;
Process *process;
#endif
};
#include "base/misc.hh"
#include "config/full_system.hh"
-#if FULL_SYSTEM
-#include "mem/functional/memory_control.hh"
-#endif
#include "mem/physical.hh"
#include "sim/host.hh"
#include "sim/builder.hh"
return "Physical Memory Timing Access respnse event";
}
-#if FULL_SYSTEM
-PhysicalMemory::PhysicalMemory(const string &n, Range<Addr> range,
- MemoryController *mmu, const std::string &fname)
- : Memory(n), base_addr(range.start), pmem_size(range.size()),
- pmem_addr(NULL)
-{
- if (pmem_size % TheISA::PageBytes != 0)
- panic("Memory Size not divisible by page size\n");
-
- mmu->add_child(this, range);
-
- int fd = -1;
-
- if (!fname.empty()) {
- fd = open(fname.c_str(), O_RDWR | O_CREAT, 0644);
- if (fd == -1) {
- perror("open");
- fatal("Could not open physical memory file: %s\n", fname);
- }
- ftruncate(fd, pmem_size);
- }
-
- int map_flags = (fd == -1) ? (MAP_ANON | MAP_PRIVATE) : MAP_SHARED;
- pmem_addr = (uint8_t *)mmap(NULL, pmem_size, PROT_READ | PROT_WRITE,
- map_flags, fd, 0);
-
- if (fd != -1)
- close(fd);
-
- if (pmem_addr == (void *)MAP_FAILED) {
- perror("mmap");
- fatal("Could not mmap!\n");
- }
-
- page_ptr = 0;
-}
-#endif
-
PhysicalMemory::PhysicalMemory(const string &n)
- : Memory(n), memoryPort(this), base_addr(0), pmem_addr(NULL)
+ : Memory(n), base_addr(0), pmem_addr(NULL)
{
// Hardcoded to 128 MB for now.
pmem_size = 1 << 27;
{
if (pmem_addr)
munmap(pmem_addr, pmem_size);
+ //Remove memPorts?
}
Addr
return return_addr;
}
+Port *
+PhysicalMemory::addPort(std::string portName)
+{
+ memoryPortList[portName] = new MemoryPort(this);
+ return memoryPortList[portName];
+}
+
//
// little helper for better prot_* error messages
//
}
bool
-PhysicalMemory::doTimingAccess (Packet &pkt)
+PhysicalMemory::doTimingAccess (Packet &pkt, MemoryPort* memoryPort)
{
doFunctionalAccess(pkt);
- MemResponseEvent* response = new MemResponseEvent(pkt, &memoryPort);
+ MemResponseEvent* response = new MemResponseEvent(pkt, memoryPort);
response->schedule(curTick + lat);
return true;
Port *
PhysicalMemory::getPort(const char *if_name)
{
- return &memoryPort;
+ if (memoryPortList.find(if_name) != memoryPortList.end())
+ return memoryPortList[if_name];
+ else
+ panic("Looking for a port that didn't exist\n");
}
void
bool
PhysicalMemory::MemoryPort::recvTiming(Packet &pkt)
{
- return memory->doTimingAccess(pkt);
+ return memory->doTimingAccess(pkt, this);
}
Tick
#include "mem/packet.hh"
#include "mem/port.hh"
#include "sim/eventq.hh"
-
+#include <map>
+#include <string>
//
// Functional model for a contiguous block of physical memory. (i.e. RAM)
//
virtual int deviceBlockSize();
};
- MemoryPort memoryPort;
+ std::map<std::string, MemoryPort*> memoryPortList;
Port * PhysicalMemory::getPort(const char *if_name);
+ Port * addPort(std::string portName);
+
+ int numPorts;
+
int lat;
struct MemResponseEvent : public Event
// fast back-door memory access for vtophys(), remote gdb, etc.
// uint64_t phys_read_qword(Addr addr) const;
private:
- bool doTimingAccess(Packet &pkt);
+ bool doTimingAccess(Packet &pkt, MemoryPort *memoryPort);
Tick doAtomicAccess(Packet &pkt);
void doFunctionalAccess(Packet &pkt);
if build_env['FULL_SYSTEM']:
dtb = Param.AlphaDTB("Data TLB")
itb = Param.AlphaITB("Instruction TLB")
- mem = Param.FunctionalMemory("memory")
system = Param.System(Parent.any, "system object")
cpu_id = Param.Int(-1, "CPU identifier")
else:
+ mem = Param.Memory("memory")
workload = VectorParam.Process("processes to run")
max_insts_all_threads = Param.Counter(0,
if (execContexts.empty())
fatal("Process %s is not associated with any CPUs!\n", name());
- initVirtMem = new TranslatingPort((system->physmem->getPort("any"))->getPeer(), pTable);
+ initVirtMem = new TranslatingPort((system->physmem->getPort("DCACHE"))->getPeer(), pTable);
// first exec context for this process... initialize & enable
ExecContext *xc = execContexts[0];