change getPort parameter from char* to string
Add an extra phase between construction and init called connect
SConscript:
Add the bus and connector objects to scons
cpu/simple/cpu.cc:
cpu/simple/cpu.hh:
the connection to memory shouldn't be made until we know the memory
object exists (e.g. after construction)
dev/io_device.hh:
change to const string
mem/bus.hh:
change getPort parameter from char* to string
initialize num_interfaces
mem/mem_object.hh:
change getPort parameter from char* to string
mem/physical.cc:
mem/physical.hh:
change getPort parameter from char* to string
get rid of the bus object I created last time
python/m5/objects/PhysicalMemory.py:
get rid of the bus object I created last time
sim/main.cc:
sim/sim_object.cc:
sim/sim_object.hh:
Add an extra phase between construction and init called connect
--HG--
extra : convert_revision :
0e994f93374fa72a06d291655c440ff1b8e155a9
cpu/static_inst.cc
cpu/sampler/sampler.cc
+ mem/connector.cc
mem/mem_object.cc
mem/page_table.cc
mem/physical.cc
mem/port.cc
mem/translating_port.cc
+ mem/bus.cc
python/pyconfig.cc
python/embedded_py.cc
void
SimpleCPU::init()
{
+ //Create Memory Ports (conect them up)
+ Port *mem_dport = mem->getPort("");
+ dcachePort.setPeer(mem_dport);
+ mem_dport->setPeer(&dcachePort);
+
+ Port *mem_iport = mem->getPort("");
+ icachePort.setPeer(mem_iport);
+ mem_iport->setPeer(&icachePort);
+
BaseCPU::init();
#if FULL_SYSTEM
for (int i = 0; i < execContexts.size(); ++i) {
}
SimpleCPU::SimpleCPU(Params *p)
- : BaseCPU(p), icachePort(this),
+ : BaseCPU(p), mem(p->mem), icachePort(this),
dcachePort(this), tickEvent(this, p->width), cpuXC(NULL)
{
_status = Idle;
- //Create Memory Ports (conect them up)
- Port *mem_dport = p->mem->getPort();
- dcachePort.setPeer(mem_dport);
- mem_dport->setPeer(&dcachePort);
-
- Port *mem_iport = p->mem->getPort();
- icachePort.setPeer(mem_iport);
- mem_iport->setPeer(&icachePort);
-
#if FULL_SYSTEM
cpuXC = new CPUExecContext(this, 0, p->system, p->itb, p->dtb, p->mem);
#else
virtual Packet *recvRetry();
};
+ MemObject *mem;
CpuPort icachePort;
CpuPort dcachePort;
virtual ~PioDevice();
- virtual Port *getPort(std::string if_name)
+ virtual Port *getPort(const std::string &if_name)
{
if (if_name == "pio")
return pioPort;
DmaDevice(const std::string &name, Platform *p);
virtual ~DmaDevice();
- virtual Port *getPort(std::string if_name)
+ virtual Port *getPort(const std::string &if_name)
{
if (if_name == "pio")
return pioPort;
public:
/** A function used to return the port associated with this bus object. */
- virtual Port *getPort(const char *if_name)
+ virtual Port *getPort(const std::string &if_name)
{
// if_name ignored? forced to be empty?
int id = num_interfaces++;
return interfaces[id];
}
Bus(const std::string &n)
- : MemObject(n) {}
+ : MemObject(n), num_interfaces(0) {}
};
public:
/** Additional function to return the Port of a memory object. */
- virtual Port *getPort(const char *if_name = NULL) = 0;
+ virtual Port *getPort(const std::string &if_name) = 0;
};
#endif //__MEM_MEM_OBJECT_HH__
return "Physical Memory Timing Access respnse event";
}
-PhysicalMemory::PhysicalMemory(const string &n, MemObject *bus)
- : MemObject(n), memPort(this), base_addr(0), pmem_addr(NULL)
+PhysicalMemory::PhysicalMemory(const string &n)
+ : MemObject(n), base_addr(0), pmem_addr(NULL)
{
// Hardcoded to 128 MB for now.
pmem_size = 1 << 27;
}
page_ptr = 0;
-
- Port *peer_port;
- peer_port = bus->getPort();
- memPort.setPeer(peer_port);
- peer_port->setPeer(&memPort);
-
-
-
}
PhysicalMemory::~PhysicalMemory()
}
Port *
-PhysicalMemory::getPort(const char *if_name)
+PhysicalMemory::getPort(const std::string &if_name)
{
- if (if_name == NULL) {
- return new MemoryPort(this);
+ if (if_name == "") {
+ if (port != NULL)
+ panic("PhysicalMemory::getPort: additional port requested to memory!");
+ port = new MemoryPort(this);
+ return port;
} else {
panic("PhysicalMemory::getPort: unknown port %s requested", if_name);
}
SimObjectParam<MemoryController *> mmu;
#endif
Param<Range<Addr> > range;
- SimObjectParam<MemObject*> bus;
END_DECLARE_SIM_OBJECT_PARAMS(PhysicalMemory)
#if FULL_SYSTEM
INIT_PARAM(mmu, "Memory Controller"),
#endif
- INIT_PARAM(range, "Device Address Range"),
- INIT_PARAM(bus, "bus object memory connects to")
+ INIT_PARAM(range, "Device Address Range")
END_INIT_SIM_OBJECT_PARAMS(PhysicalMemory)
}
#endif
- return new PhysicalMemory(getInstanceName(), bus);
+ return new PhysicalMemory(getInstanceName());
}
REGISTER_SIM_OBJECT("PhysicalMemory", PhysicalMemory)
virtual int deviceBlockSize();
};
- MemoryPort memPort;
-
- virtual Port * getPort(const char *if_name);
+ virtual Port *getPort(const std::string &if_name);
int numPorts;
Addr base_addr;
Addr pmem_size;
uint8_t *pmem_addr;
+ MemoryPort *port;
int page_ptr;
public:
uint64_t size() { return pmem_size; }
public:
- PhysicalMemory(const std::string &n, MemObject *bus);
+ PhysicalMemory(const std::string &n);
virtual ~PhysicalMemory();
public:
int deviceBlockSize();
void getAddressRanges(AddrRangeList &rangeList, bool &owner);
- void virtual init() { memPort.sendStatusChange(Port::RangeChange); }
+ void virtual init() { port->sendStatusChange(Port::RangeChange); }
// fast back-door memory access for vtophys(), remote gdb, etc.
// uint64_t phys_read_qword(Addr addr) const;
type = 'PhysicalMemory'
range = Param.AddrRange("Device Address")
file = Param.String('', "memory mapped file")
- bus = Param.MemObject("Bus to attach to")
if build_env['FULL_SYSTEM']:
mmu = Param.MemoryController(Parent.any, "Memory Controller")
echoCommandLine(argc, argv, *outputStream);
ParamContext::showAllContexts(*configStream);
+ // Any objects that can't connect themselves until after construction should
+ // do so now
+ SimObject::connectAll();
+
// Do a second pass to finish initializing the sim objects
SimObject::initAll();
simObjectList.push_back(this);
}
+void
+SimObject::connect()
+{
+}
+
void
SimObject::init()
{
Stats::registerResetCallback(&StatResetCB);
}
+//
+// static function: call connect() on all SimObjects.
+//
+void
+SimObject::connectAll()
+{
+ SimObjectList::iterator i = simObjectList.begin();
+ SimObjectList::iterator end = simObjectList.end();
+
+ for (; i != end; ++i) {
+ SimObject *obj = *i;
+ obj->connect();
+ }
+}
+
//
// static function: call init() on all SimObjects.
//
// initialization pass of all objects.
// Gets invoked after construction, before unserialize.
virtual void init();
+ virtual void connect();
static void initAll();
+ static void connectAll();
// register statistics for this object
virtual void regStats();