diff options
author | Miles Kaufmann <milesck@eecs.umich.edu> | 2007-08-30 15:16:59 -0400 |
---|---|---|
committer | Miles Kaufmann <milesck@eecs.umich.edu> | 2007-08-30 15:16:59 -0400 |
commit | 54cc0053f0a6822e47a49771976af6daaabc24bb (patch) | |
tree | 72e6c7879de698347832e1e1475afbb9c1be2b70 /src/dev | |
parent | 9cb49ab9e0ff8917d20fd7dc81be3ce5ecc81bd8 (diff) | |
download | gem5-54cc0053f0a6822e47a49771976af6daaabc24bb.tar.xz |
params: Deprecate old-style constructors; update most SimObject constructors.
SimObjects not yet updated:
- Process and subclasses
- BaseCPU and subclasses
The SimObject(const std::string &name) constructor was removed. Subclasses
that still rely on that behavior must call the parent initializer as
: SimObject(makeParams(name))
--HG--
extra : convert_revision : d6faddde76e7c3361ebdbd0a7b372a40941c12ed
Diffstat (limited to 'src/dev')
-rw-r--r-- | src/dev/alpha/tsunami.cc | 7 | ||||
-rw-r--r-- | src/dev/alpha/tsunami.hh | 10 | ||||
-rw-r--r-- | src/dev/disk_image.cc | 42 | ||||
-rw-r--r-- | src/dev/disk_image.hh | 15 | ||||
-rw-r--r-- | src/dev/etherbus.hh | 1 | ||||
-rw-r--r-- | src/dev/etherdump.cc | 8 | ||||
-rw-r--r-- | src/dev/etherdump.hh | 4 | ||||
-rw-r--r-- | src/dev/etherlink.cc | 8 | ||||
-rw-r--r-- | src/dev/etherlink.hh | 1 | ||||
-rw-r--r-- | src/dev/ide_disk.cc | 10 | ||||
-rw-r--r-- | src/dev/ide_disk.hh | 12 | ||||
-rw-r--r-- | src/dev/isa_fake.hh | 2 | ||||
-rw-r--r-- | src/dev/pciconfigall.cc | 13 | ||||
-rw-r--r-- | src/dev/pciconfigall.hh | 10 | ||||
-rw-r--r-- | src/dev/platform.cc | 4 | ||||
-rw-r--r-- | src/dev/platform.hh | 4 | ||||
-rw-r--r-- | src/dev/simconsole.cc | 30 | ||||
-rw-r--r-- | src/dev/simconsole.hh | 4 | ||||
-rw-r--r-- | src/dev/simple_disk.cc | 7 | ||||
-rw-r--r-- | src/dev/simple_disk.hh | 4 | ||||
-rw-r--r-- | src/dev/sparc/t1000.cc | 7 | ||||
-rw-r--r-- | src/dev/sparc/t1000.hh | 4 |
22 files changed, 93 insertions, 114 deletions
diff --git a/src/dev/alpha/tsunami.cc b/src/dev/alpha/tsunami.cc index bac2a8682..5bc0de5da 100644 --- a/src/dev/alpha/tsunami.cc +++ b/src/dev/alpha/tsunami.cc @@ -42,15 +42,14 @@ #include "dev/alpha/tsunami_pchip.hh" #include "dev/alpha/tsunami_io.hh" #include "dev/alpha/tsunami.hh" -#include "params/Tsunami.hh" #include "sim/system.hh" using namespace std; //Should this be AlphaISA? using namespace TheISA; -Tsunami::Tsunami(const string &name, System *s, IntrControl *ic) - : Platform(name, ic), system(s) +Tsunami::Tsunami(const Params *p) + : Platform(p), system(p->system) { // set the back pointer from the system to myself system->platform = this; @@ -117,5 +116,5 @@ Tsunami::unserialize(Checkpoint *cp, const std::string §ion) Tsunami * TsunamiParams::create() { - return new Tsunami(name, system, intrctrl); + return new Tsunami(this); } diff --git a/src/dev/alpha/tsunami.hh b/src/dev/alpha/tsunami.hh index 6fbfac851..44c5d41a4 100644 --- a/src/dev/alpha/tsunami.hh +++ b/src/dev/alpha/tsunami.hh @@ -38,6 +38,7 @@ #define __DEV_TSUNAMI_HH__ #include "dev/platform.hh" +#include "params/Tsunami.hh" class IdeController; class TsunamiCChip; @@ -80,13 +81,8 @@ class Tsunami : public Platform int ipi_pending[Tsunami::Max_CPUs]; public: - /** - * Constructor for the Tsunami Class. - * @param name name of the object - * @param s system the object belongs to - * @param intctrl pointer to the interrupt controller - */ - Tsunami(const std::string &name, System *s, IntrControl *intctrl); + typedef TsunamiParams Params; + Tsunami(const Params *p); /** * Return the interrupting frequency to AlphaAccess diff --git a/src/dev/disk_image.cc b/src/dev/disk_image.cc index 1cccf3a0f..b8386bc3d 100644 --- a/src/dev/disk_image.cc +++ b/src/dev/disk_image.cc @@ -45,8 +45,6 @@ #include "base/misc.hh" #include "base/trace.hh" #include "dev/disk_image.hh" -#include "params/CowDiskImage.hh" -#include "params/RawDiskImage.hh" #include "sim/sim_exit.hh" #include "sim/byteswap.hh" @@ -56,10 +54,9 @@ using namespace std; // // Raw Disk image // -RawDiskImage::RawDiskImage(const string &name, const string &filename, - bool rd_only) - : DiskImage(name), disk_size(0) -{ open(filename, rd_only); } +RawDiskImage::RawDiskImage(const Params* p) + : DiskImage(p), disk_size(0) +{ open(p->image_file, p->read_only); } RawDiskImage::~RawDiskImage() { close(); } @@ -147,7 +144,7 @@ RawDiskImage::write(const uint8_t *data, off_t offset) RawDiskImage * RawDiskImageParams::create() { - return new RawDiskImage(name, image_file, read_only); + return new RawDiskImage(this); } //////////////////////////////////////////////////////////////////////// @@ -157,10 +154,6 @@ RawDiskImageParams::create() const int CowDiskImage::VersionMajor = 1; const int CowDiskImage::VersionMinor = 0; -CowDiskImage::CowDiskImage(const string &name, DiskImage *kid, int hash_size) - : DiskImage(name), child(kid), table(NULL) -{ init(hash_size); } - class CowDiskCallback : public Callback { private: @@ -171,17 +164,20 @@ class CowDiskCallback : public Callback void process() { image->save(); delete this; } }; -CowDiskImage::CowDiskImage(const string &name, DiskImage *kid, int hash_size, - const string &file, bool read_only) - : DiskImage(name), filename(file), child(kid), table(NULL) +CowDiskImage::CowDiskImage(const Params *p) + : DiskImage(p), filename(p->image_file), child(p->child), table(NULL) { - if (!open(filename)) { - assert(!read_only && "why have a non-existent read only file?"); - init(hash_size); - } + if (filename.empty()) { + init(p->table_size); + } else { + if (!open(filename)) { + assert(!p->read_only && "why have a non-existent read only file?"); + init(p->table_size); + } - if (!read_only) - registerExitCallback(new CowDiskCallback(this)); + if (!p->read_only) + registerExitCallback(new CowDiskCallback(this)); + } } CowDiskImage::~CowDiskImage() @@ -426,9 +422,5 @@ CowDiskImage::unserialize(Checkpoint *cp, const string §ion) CowDiskImage * CowDiskImageParams::create() { - if (((string)image_file).empty()) - return new CowDiskImage(name, child, table_size); - else - return new CowDiskImage(name, child, table_size, - image_file, read_only); + return new CowDiskImage(this); } diff --git a/src/dev/disk_image.hh b/src/dev/disk_image.hh index 45d5af649..3918209fc 100644 --- a/src/dev/disk_image.hh +++ b/src/dev/disk_image.hh @@ -39,6 +39,9 @@ #include "base/hashmap.hh" #include "sim/sim_object.hh" +#include "params/DiskImage.hh" +#include "params/CowDiskImage.hh" +#include "params/RawDiskImage.hh" #define SectorSize (512) @@ -51,7 +54,8 @@ class DiskImage : public SimObject bool initialized; public: - DiskImage(const std::string &name) : SimObject(name), initialized(false) {} + typedef DiskImageParams Params; + DiskImage(const Params *p) : SimObject(p), initialized(false) {} virtual ~DiskImage() {} virtual off_t size() const = 0; @@ -72,8 +76,8 @@ class RawDiskImage : public DiskImage mutable off_t disk_size; public: - RawDiskImage(const std::string &name, const std::string &filename, - bool rd_only); + typedef RawDiskImageParams Params; + RawDiskImage(const Params *p); ~RawDiskImage(); void close(); @@ -113,9 +117,8 @@ class CowDiskImage : public DiskImage SectorTable *table; public: - CowDiskImage(const std::string &name, DiskImage *kid, int hash_size); - CowDiskImage(const std::string &name, DiskImage *kid, int hash_size, - const std::string &filename, bool read_only); + typedef CowDiskImageParams Params; + CowDiskImage(const Params *p); ~CowDiskImage(); void init(int hash_size); diff --git a/src/dev/etherbus.hh b/src/dev/etherbus.hh index a3a7f0606..4deb7fccc 100644 --- a/src/dev/etherbus.hh +++ b/src/dev/etherbus.hh @@ -40,6 +40,7 @@ #include "dev/etherobject.hh" #include "params/EtherBus.hh" #include "sim/sim_object.hh" +#include "params/EtherBus.hh" class EtherDump; class EtherInt; diff --git a/src/dev/etherdump.cc b/src/dev/etherdump.cc index 7dcf1ca97..471093521 100644 --- a/src/dev/etherdump.cc +++ b/src/dev/etherdump.cc @@ -40,13 +40,13 @@ #include "base/misc.hh" #include "base/output.hh" #include "dev/etherdump.hh" -#include "params/EtherDump.hh" #include "sim/core.hh" using std::string; -EtherDump::EtherDump(const string &name, const string &file, int max) - : SimObject(name), stream(file.c_str()), maxlen(max) +EtherDump::EtherDump(const Params *p) + : SimObject(p), stream(simout.resolve(p->file).c_str()), + maxlen(p->maxlen) { } @@ -119,5 +119,5 @@ EtherDump::dumpPacket(EthPacketPtr &packet) EtherDump * EtherDumpParams::create() { - return new EtherDump(name, simout.resolve(file), maxlen); + return new EtherDump(this); } diff --git a/src/dev/etherdump.hh b/src/dev/etherdump.hh index f3080f341..1027ce4d0 100644 --- a/src/dev/etherdump.hh +++ b/src/dev/etherdump.hh @@ -38,6 +38,7 @@ #include <fstream> #include "dev/etherpkt.hh" #include "sim/sim_object.hh" +#include "params/EtherDump.hh" /* * Simple object for creating a simple pcap style packet trace @@ -53,7 +54,8 @@ class EtherDump : public SimObject Tick curtime; public: - EtherDump(const std::string &name, const std::string &file, int max); + typedef EtherDumpParams Params; + EtherDump(const Params *p); inline void dump(EthPacketPtr &pkt) { dumpPacket(pkt); } }; diff --git a/src/dev/etherlink.cc b/src/dev/etherlink.cc index baa4fb741..4130a7b3f 100644 --- a/src/dev/etherlink.cc +++ b/src/dev/etherlink.cc @@ -54,10 +54,10 @@ using namespace std; EtherLink::EtherLink(const Params *p) : EtherObject(p) { - link[0] = new Link(name() + ".link0", this, 0, params()->speed, - params()->delay, params()->delay_var, params()->dump); - link[1] = new Link(name() + ".link1", this, 1, params()->speed, - params()->delay, params()->delay_var, params()->dump); + link[0] = new Link(name() + ".link0", this, 0, p->speed, + p->delay, p->delay_var, p->dump); + link[1] = new Link(name() + ".link1", this, 1, p->speed, + p->delay, p->delay_var, p->dump); interface[0] = new Interface(name() + ".int0", link[0], link[1]); interface[1] = new Interface(name() + ".int1", link[1], link[0]); diff --git a/src/dev/etherlink.hh b/src/dev/etherlink.hh index 52092dbf4..8f38fcab8 100644 --- a/src/dev/etherlink.hh +++ b/src/dev/etherlink.hh @@ -42,6 +42,7 @@ #include "sim/eventq.hh" #include "sim/host.hh" #include "sim/sim_object.hh" +#include "params/EtherLink.hh" class EtherDump; class Checkpoint; diff --git a/src/dev/ide_disk.cc b/src/dev/ide_disk.cc index cfd743a13..8f9999beb 100644 --- a/src/dev/ide_disk.cc +++ b/src/dev/ide_disk.cc @@ -45,22 +45,20 @@ #include "dev/disk_image.hh" #include "dev/ide_ctrl.hh" #include "dev/ide_disk.hh" -#include "params/IdeDisk.hh" #include "sim/core.hh" #include "sim/sim_object.hh" using namespace std; using namespace TheISA; -IdeDisk::IdeDisk(const string &name, DiskImage *img, - int id, Tick delay) - : SimObject(name), ctrl(NULL), image(img), diskDelay(delay), +IdeDisk::IdeDisk(const Params *p) + : SimObject(p), ctrl(NULL), image(p->image), diskDelay(p->delay), dmaTransferEvent(this), dmaReadCG(NULL), dmaReadWaitEvent(this), dmaWriteCG(NULL), dmaWriteWaitEvent(this), dmaPrdReadEvent(this), dmaReadEvent(this), dmaWriteEvent(this) { // Reset the device state - reset(id); + reset(p->driveID); // fill out the drive ID structure memset(&driveID, 0, sizeof(struct ataparams)); @@ -1117,5 +1115,5 @@ IdeDisk::unserialize(Checkpoint *cp, const string §ion) IdeDisk * IdeDiskParams::create() { - return new IdeDisk(name, image, driveID, delay); + return new IdeDisk(this); } diff --git a/src/dev/ide_disk.hh b/src/dev/ide_disk.hh index 2ed860013..62c89add4 100644 --- a/src/dev/ide_disk.hh +++ b/src/dev/ide_disk.hh @@ -42,6 +42,8 @@ #include "dev/ide_wdcreg.h" #include "dev/io_device.hh" #include "sim/eventq.hh" +#include "params/IdeDisk.hh" + class ChunkGenerator; @@ -248,14 +250,8 @@ class IdeDisk : public SimObject Stats::Formula totBytes; public: - /** - * Create and initialize this Disk. - * @param name The name of this disk. - * @param img The disk image of this disk. - * @param id The disk ID (master=0/slave=1) - * @param disk_delay The disk delay in milliseconds - */ - IdeDisk(const std::string &name, DiskImage *img, int id, Tick disk_delay); + typedef IdeDiskParams Params; + IdeDisk(const Params *p); /** * Delete the data buffer. diff --git a/src/dev/isa_fake.hh b/src/dev/isa_fake.hh index 5f54b1af3..4233d9d4c 100644 --- a/src/dev/isa_fake.hh +++ b/src/dev/isa_fake.hh @@ -39,7 +39,7 @@ #include "base/range.hh" #include "dev/io_device.hh" -#include "dev/alpha/tsunami.hh" +// #include "dev/alpha/tsunami.hh" #include "params/IsaFake.hh" #include "mem/packet.hh" diff --git a/src/dev/pciconfigall.cc b/src/dev/pciconfigall.cc index 884fab7ac..faf033705 100644 --- a/src/dev/pciconfigall.cc +++ b/src/dev/pciconfigall.cc @@ -44,7 +44,7 @@ using namespace std; -PciConfigAll::PciConfigAll(Params *p) +PciConfigAll::PciConfigAll(const Params *p) : PioDevice(p) { pioAddr = p->platform->calcConfigAddr(params()->bus,0,0); @@ -74,7 +74,7 @@ PciConfigAll::read(PacketPtr pkt) panic("invalid access size(?) for PCI configspace!\n"); } pkt->makeAtomicResponse(); - return params()->pio_delay; + return params()->pio_latency; } Tick @@ -98,14 +98,7 @@ PciConfigAll::addressRanges(AddrRangeList &range_list) PciConfigAll * PciConfigAllParams::create() { - PciConfigAll::Params *p = new PciConfigAll::Params; - p->pio_delay = pio_latency; - p->platform = platform; - p->system = system; - p->bus = bus; - p->size = size; - - return new PciConfigAll(p); + return new PciConfigAll(this); } #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/dev/pciconfigall.hh b/src/dev/pciconfigall.hh index 720a2f005..fbd022340 100644 --- a/src/dev/pciconfigall.hh +++ b/src/dev/pciconfigall.hh @@ -40,6 +40,7 @@ #include "dev/pcireg.h" #include "base/range.hh" #include "dev/io_device.hh" +#include "params/PciConfigAll.hh" /** @@ -52,19 +53,14 @@ class PciConfigAll : public PioDevice { public: - struct Params : public PioDevice::Params - { - Tick pio_delay; - Addr size; - int bus; - }; + typedef PciConfigAllParams Params; const Params *params() const { return (const Params *)_params; } /** * Constructor for PCIConfigAll * @param p parameters structure */ - PciConfigAll(Params *p); + PciConfigAll(const Params *p); /** * Read something in PCI config space. If the device does not exist diff --git a/src/dev/platform.cc b/src/dev/platform.cc index c8922432b..2b51a6245 100644 --- a/src/dev/platform.cc +++ b/src/dev/platform.cc @@ -36,8 +36,8 @@ using namespace std; using namespace TheISA; -Platform::Platform(const string &name, IntrControl *intctrl) - : SimObject(name), intrctrl(intctrl) +Platform::Platform(const Params *p) + : SimObject(p), intrctrl(p->intrctrl) { } diff --git a/src/dev/platform.hh b/src/dev/platform.hh index aceec0970..699b168ce 100644 --- a/src/dev/platform.hh +++ b/src/dev/platform.hh @@ -42,6 +42,7 @@ #include "sim/sim_object.hh" #include "arch/isa_traits.hh" +#include "params/Platform.hh" class PciConfigAll; class IntrControl; @@ -59,7 +60,8 @@ class Platform : public SimObject System *system; public: - Platform(const std::string &name, IntrControl *intctrl); + typedef PlatformParams Params; + Platform(const Params *p); virtual ~Platform(); virtual void postConsoleInt() = 0; virtual void clearConsoleInt() = 0; diff --git a/src/dev/simconsole.cc b/src/dev/simconsole.cc index 7ce462bd0..e8dc1b210 100644 --- a/src/dev/simconsole.cc +++ b/src/dev/simconsole.cc @@ -52,7 +52,6 @@ #include "dev/platform.hh" #include "dev/simconsole.hh" #include "dev/uart.hh" -#include "params/SimConsole.hh" using namespace std; @@ -91,18 +90,24 @@ SimConsole::DataEvent::process(int revent) /* * SimConsole code */ -SimConsole::SimConsole(const string &name, ostream *os, int num, int port) - : SimObject(name), listenEvent(NULL), dataEvent(NULL), number(num), - data_fd(-1), txbuf(16384), rxbuf(16384), outfile(os) +SimConsole::SimConsole(const Params *p) + : SimObject(p), listenEvent(NULL), dataEvent(NULL), number(p->number), + data_fd(-1), txbuf(16384), rxbuf(16384), outfile(NULL) #if TRACING_ON == 1 , linebuf(16384) #endif { - if (outfile) + if (!p->output.empty()) { + if (p->append_name) + outfile = simout.find(p->output + "." + p->name); + else + outfile = simout.find(p->output); + outfile->setf(ios::unitbuf); + } - if (port) - listen(port); + if (p->port) + listen(p->port); } SimConsole::~SimConsole() @@ -328,14 +333,5 @@ SimConsole::out(char c) SimConsole * SimConsoleParams::create() { - string filename = output; - ostream *stream = NULL; - - if (!filename.empty()) { - if (append_name) - filename += "." + name; - stream = simout.find(filename); - } - - return new SimConsole(name, stream, number, port); + return new SimConsole(this); } diff --git a/src/dev/simconsole.hh b/src/dev/simconsole.hh index 18a193493..c8d453960 100644 --- a/src/dev/simconsole.hh +++ b/src/dev/simconsole.hh @@ -43,6 +43,7 @@ #include "base/pollevent.hh" #include "base/socket.hh" #include "sim/sim_object.hh" +#include "params/SimConsole.hh" class ConsoleListener; class Uart; @@ -84,7 +85,8 @@ class SimConsole : public SimObject int data_fd; public: - SimConsole(const std::string &name, std::ostream *os, int num, int port); + typedef SimConsoleParams Params; + SimConsole(const Params *p); ~SimConsole(); protected: diff --git a/src/dev/simple_disk.cc b/src/dev/simple_disk.cc index 4b6d37286..b8096d213 100644 --- a/src/dev/simple_disk.cc +++ b/src/dev/simple_disk.cc @@ -45,13 +45,12 @@ #include "dev/disk_image.hh" #include "dev/simple_disk.hh" #include "mem/port.hh" -#include "params/SimpleDisk.hh" #include "sim/system.hh" using namespace std; -SimpleDisk::SimpleDisk(const string &name, System *sys, DiskImage *img) - : SimObject(name), system(sys), image(img) +SimpleDisk::SimpleDisk(const Params *p) + : SimObject(p), system(p->system), image(p->disk) {} SimpleDisk::~SimpleDisk() @@ -94,5 +93,5 @@ SimpleDisk::write(Addr addr, baddr_t block, int count) SimpleDisk * SimpleDiskParams::create() { - return new SimpleDisk(name, system, disk); + return new SimpleDisk(this); } diff --git a/src/dev/simple_disk.hh b/src/dev/simple_disk.hh index 9f588cb95..2f3802975 100644 --- a/src/dev/simple_disk.hh +++ b/src/dev/simple_disk.hh @@ -37,6 +37,7 @@ #include "sim/sim_object.hh" #include "arch/isa_traits.hh" +#include "params/SimpleDisk.hh" class DiskImage; class System; @@ -54,7 +55,8 @@ class SimpleDisk : public SimObject DiskImage *image; public: - SimpleDisk(const std::string &name, System *sys, DiskImage *img); + typedef SimpleDiskParams Params; + SimpleDisk(const Params *p); ~SimpleDisk(); void read(Addr addr, baddr_t block, int count) const; diff --git a/src/dev/sparc/t1000.cc b/src/dev/sparc/t1000.cc index 692e0cfe1..49e44af55 100644 --- a/src/dev/sparc/t1000.cc +++ b/src/dev/sparc/t1000.cc @@ -39,15 +39,14 @@ #include "cpu/intr_control.hh" #include "dev/simconsole.hh" #include "dev/sparc/t1000.hh" -#include "params/T1000.hh" #include "sim/system.hh" using namespace std; //Should this be AlphaISA? using namespace TheISA; -T1000::T1000(const string &name, System *s, IntrControl *ic) - : Platform(name, ic), system(s) +T1000::T1000(const Params *p) + : Platform(p), system(p->system) { // set the back pointer from the system to myself system->platform = this; @@ -104,5 +103,5 @@ T1000::calcConfigAddr(int bus, int dev, int func) T1000 * T1000Params::create() { - return new T1000(name, system, intrctrl); + return new T1000(this); } diff --git a/src/dev/sparc/t1000.hh b/src/dev/sparc/t1000.hh index 8e28d90e5..76de0a550 100644 --- a/src/dev/sparc/t1000.hh +++ b/src/dev/sparc/t1000.hh @@ -38,6 +38,7 @@ #define __DEV_T1000_HH__ #include "dev/platform.hh" +#include "params/T1000.hh" class IdeController; class System; @@ -49,13 +50,14 @@ class T1000 : public Platform System *system; public: + typedef T1000Params Params; /** * Constructor for the Tsunami Class. * @param name name of the object * @param s system the object belongs to * @param intctrl pointer to the interrupt controller */ - T1000(const std::string &name, System *s, IntrControl *intctrl); + T1000(const Params *p); /** * Return the interrupting frequency to AlphaAccess |