From abc76f20cb98c90e8dab416dd16dfd4a954013ba Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 23 Jul 2007 21:51:38 -0700 Subject: Major changes to how SimObjects are created and initialized. Almost all creation and initialization now happens in python. Parameter objects are generated and initialized by python. The .ini file is now solely for debugging purposes and is not used in construction of the objects in any way. --HG-- extra : convert_revision : 7e722873e417cb3d696f2e34c35ff488b7bff4ed --- src/dev/sparc/dtod.cc | 42 ++++++------------------------------------ src/dev/sparc/dtod.hh | 17 ++++++++--------- src/dev/sparc/iob.cc | 32 ++++---------------------------- src/dev/sparc/iob.hh | 21 ++++++++++----------- src/dev/sparc/mm_disk.cc | 40 ++++------------------------------------ src/dev/sparc/mm_disk.hh | 16 ++++++++-------- src/dev/sparc/t1000.cc | 23 ++++------------------- 7 files changed, 44 insertions(+), 147 deletions(-) (limited to 'src/dev/sparc') diff --git a/src/dev/sparc/dtod.cc b/src/dev/sparc/dtod.cc index 42275c60a..7e948085e 100644 --- a/src/dev/sparc/dtod.cc +++ b/src/dev/sparc/dtod.cc @@ -37,26 +37,25 @@ #include #include +#include "base/time.hh" #include "base/trace.hh" #include "dev/sparc/dtod.hh" #include "dev/platform.hh" #include "mem/packet_access.hh" #include "mem/port.hh" -#include "sim/builder.hh" #include "sim/system.hh" using namespace std; using namespace TheISA; -DumbTOD::DumbTOD(Params *p) +DumbTOD::DumbTOD(const Params *p) : BasicPioDevice(p) { - struct tm tm; + struct tm tm = p->time; char *tz; pioSize = 0x08; - parseTime(p->init_time, &tm); tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); @@ -104,37 +103,8 @@ DumbTOD::unserialize(Checkpoint *cp, const std::string §ion) UNSERIALIZE_SCALAR(todTime); } - -BEGIN_DECLARE_SIM_OBJECT_PARAMS(DumbTOD) - - Param pio_addr; - Param pio_latency; - SimObjectParam platform; - SimObjectParam system; - VectorParam time; - -END_DECLARE_SIM_OBJECT_PARAMS(DumbTOD) - -BEGIN_INIT_SIM_OBJECT_PARAMS(DumbTOD) - - INIT_PARAM(pio_addr, "Device Address"), - INIT_PARAM(pio_latency, "Programmed IO latency"), - INIT_PARAM(platform, "platform"), - INIT_PARAM(system, "system object"), - INIT_PARAM(time, "") - -END_INIT_SIM_OBJECT_PARAMS(DumbTOD) - -CREATE_SIM_OBJECT(DumbTOD) +DumbTOD * +DumbTODParams::create() { - DumbTOD::Params *p = new DumbTOD::Params; - p->name =getInstanceName(); - p->pio_addr = pio_addr; - p->pio_delay = pio_latency; - p->platform = platform; - p->system = system; - p->init_time = time; - return new DumbTOD(p); + return new DumbTOD(this); } - -REGISTER_SIM_OBJECT("DumbTOD", DumbTOD) diff --git a/src/dev/sparc/dtod.hh b/src/dev/sparc/dtod.hh index ddf9fcc96..35dda42dd 100644 --- a/src/dev/sparc/dtod.hh +++ b/src/dev/sparc/dtod.hh @@ -40,7 +40,7 @@ #include "base/range.hh" #include "dev/io_device.hh" - +#include "params/DumbTOD.hh" /** * DumbTOD simply returns some idea of time when read. Until we finish with @@ -52,15 +52,14 @@ class DumbTOD : public BasicPioDevice uint64_t todTime; public: - struct Params : public BasicPioDevice::Params - { - std::vector init_time; - }; - protected: - const Params *params() const { return (const Params *)_params; } + typedef DumbTODParams Params; + DumbTOD(const Params *p); - public: - DumbTOD(Params *p); + const Params * + params() const + { + return dynamic_cast(_params); + } virtual Tick read(PacketPtr pkt); virtual Tick write(PacketPtr pkt); diff --git a/src/dev/sparc/iob.cc b/src/dev/sparc/iob.cc index e686e51f7..6a4e91730 100644 --- a/src/dev/sparc/iob.cc +++ b/src/dev/sparc/iob.cc @@ -45,11 +45,10 @@ #include "dev/platform.hh" #include "mem/port.hh" #include "mem/packet_access.hh" -#include "sim/builder.hh" #include "sim/faults.hh" #include "sim/system.hh" -Iob::Iob(Params *p) +Iob::Iob(const Params *p) : PioDevice(p), ic(p->platform->intrctrl) { iobManAddr = ULL(0x9800000000); @@ -372,31 +371,8 @@ Iob::unserialize(Checkpoint *cp, const std::string §ion) }; } - - - -BEGIN_DECLARE_SIM_OBJECT_PARAMS(Iob) - Param pio_latency; - SimObjectParam platform; - SimObjectParam system; -END_DECLARE_SIM_OBJECT_PARAMS(Iob) - -BEGIN_INIT_SIM_OBJECT_PARAMS(Iob) - - INIT_PARAM(pio_latency, "Programmed IO latency"), - INIT_PARAM(platform, "platform"), - INIT_PARAM(system, "system object") - -END_INIT_SIM_OBJECT_PARAMS(Iob) - -CREATE_SIM_OBJECT(Iob) +Iob * +IobParams::create() { - Iob::Params *p = new Iob::Params; - p->name = getInstanceName(); - p->pio_delay = pio_latency; - p->platform = platform; - p->system = system; - return new Iob(p); + return new Iob(this); } - -REGISTER_SIM_OBJECT("Iob", Iob) diff --git a/src/dev/sparc/iob.hh b/src/dev/sparc/iob.hh index c05c4f2ef..b2fd6cbf6 100644 --- a/src/dev/sparc/iob.hh +++ b/src/dev/sparc/iob.hh @@ -39,6 +39,7 @@ #include "base/range.hh" #include "dev/io_device.hh" #include "dev/disk_image.hh" +#include "params/Iob.hh" class IntrControl; @@ -123,24 +124,22 @@ class Iob : public PioDevice void readIob(PacketPtr pkt); void readJBus(PacketPtr pkt); - public: - struct Params : public PioDevice::Params - { - Tick pio_delay; - }; - protected: - const Params *params() const { return (const Params*)_params; } + typedef IobParams Params; + Iob(const Params *p); - public: - Iob(Params *p); + const Params * + params() const + { + return dynamic_cast(_params); + } virtual Tick read(PacketPtr pkt); virtual Tick write(PacketPtr pkt); void generateIpi(Type type, int cpu_id, int vector); void receiveDeviceInterrupt(DeviceId devid); - bool receiveJBusInterrupt(int cpu_id, int source, uint64_t d0, uint64_t d1); - + bool receiveJBusInterrupt(int cpu_id, int source, uint64_t d0, + uint64_t d1); void addressRanges(AddrRangeList &range_list); diff --git a/src/dev/sparc/mm_disk.cc b/src/dev/sparc/mm_disk.cc index 81c5c589a..4a2550dd2 100644 --- a/src/dev/sparc/mm_disk.cc +++ b/src/dev/sparc/mm_disk.cc @@ -40,11 +40,10 @@ #include "dev/platform.hh" #include "mem/port.hh" #include "mem/packet_access.hh" -#include "sim/builder.hh" #include "sim/byteswap.hh" #include "sim/system.hh" -MmDisk::MmDisk(Params *p) +MmDisk::MmDisk(const Params *p) : BasicPioDevice(p), image(p->image), curSector((off_t)-1), dirty(false) { std::memset(&diskData, 0, SectorSize); @@ -173,39 +172,8 @@ MmDisk::serialize(std::ostream &os) } } - - - -BEGIN_DECLARE_SIM_OBJECT_PARAMS(MmDisk) - Param pio_addr; - Param pio_latency; - Param pio_size; - SimObjectParam platform; - SimObjectParam system; - SimObjectParam image; -END_DECLARE_SIM_OBJECT_PARAMS(MmDisk) - -BEGIN_INIT_SIM_OBJECT_PARAMS(MmDisk) - - INIT_PARAM(pio_addr, "Device Address"), - INIT_PARAM(pio_latency, "Programmed IO latency"), - INIT_PARAM(pio_size, "Size of address range"), - INIT_PARAM(platform, "platform"), - INIT_PARAM(system, "system object"), - INIT_PARAM(image, "disk image") - -END_INIT_SIM_OBJECT_PARAMS(MmDisk) - -CREATE_SIM_OBJECT(MmDisk) +MmDisk * +MmDiskParams::create() { - MmDisk::Params *p = new MmDisk::Params; - p->name = getInstanceName(); - p->pio_addr = pio_addr; - p->pio_delay = pio_latency; - p->platform = platform; - p->system = system; - p->image = image; - return new MmDisk(p); + return new MmDisk(this); } - -REGISTER_SIM_OBJECT("MmDisk", MmDisk) diff --git a/src/dev/sparc/mm_disk.hh b/src/dev/sparc/mm_disk.hh index 30028d2b6..41ec0cc59 100644 --- a/src/dev/sparc/mm_disk.hh +++ b/src/dev/sparc/mm_disk.hh @@ -39,6 +39,7 @@ #include "base/range.hh" #include "dev/io_device.hh" #include "dev/disk_image.hh" +#include "params/MmDisk.hh" class MmDisk : public BasicPioDevice { @@ -49,15 +50,14 @@ class MmDisk : public BasicPioDevice uint8_t diskData[SectorSize]; public: - struct Params : public BasicPioDevice::Params - { - DiskImage *image; - }; - protected: - const Params *params() const { return (const Params*)_params; } + typedef MmDiskParams Params; + MmDisk(const Params *p); - public: - MmDisk(Params *p); + const Params * + params() const + { + return dynamic_cast(_params); + } virtual Tick read(PacketPtr pkt); virtual Tick write(PacketPtr pkt); diff --git a/src/dev/sparc/t1000.cc b/src/dev/sparc/t1000.cc index 3a2f881f1..692e0cfe1 100644 --- a/src/dev/sparc/t1000.cc +++ b/src/dev/sparc/t1000.cc @@ -39,7 +39,7 @@ #include "cpu/intr_control.hh" #include "dev/simconsole.hh" #include "dev/sparc/t1000.hh" -#include "sim/builder.hh" +#include "params/T1000.hh" #include "sim/system.hh" using namespace std; @@ -101,23 +101,8 @@ T1000::calcConfigAddr(int bus, int dev, int func) M5_DUMMY_RETURN } -BEGIN_DECLARE_SIM_OBJECT_PARAMS(T1000) - - SimObjectParam system; - SimObjectParam intrctrl; - -END_DECLARE_SIM_OBJECT_PARAMS(T1000) - -BEGIN_INIT_SIM_OBJECT_PARAMS(T1000) - - INIT_PARAM(system, "system"), - INIT_PARAM(intrctrl, "interrupt controller") - -END_INIT_SIM_OBJECT_PARAMS(T1000) - -CREATE_SIM_OBJECT(T1000) +T1000 * +T1000Params::create() { - return new T1000(getInstanceName(), system, intrctrl); + return new T1000(name, system, intrctrl); } - -REGISTER_SIM_OBJECT("T1000", T1000) -- cgit v1.2.3