dev: fixed bugs to extend interrupt capability beyond 15 cores
[gem5.git] / src / dev / disk_image.cc
index f70d2ccdb468693856d88a95776408fc7cd3ea04..aa8c98732fa221abbaf0d31d833b54d1b4a93986 100644 (file)
@@ -45,7 +45,6 @@
 #include "base/misc.hh"
 #include "base/trace.hh"
 #include "dev/disk_image.hh"
-#include "sim/builder.hh"
 #include "sim/sim_exit.hh"
 #include "sim/byteswap.hh"
 
@@ -55,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(); }
@@ -143,40 +141,18 @@ RawDiskImage::write(const uint8_t *data, off_t offset)
     return stream.tellp() - pos;
 }
 
-DEFINE_SIM_OBJECT_CLASS_NAME("DiskImage", DiskImage)
-
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(RawDiskImage)
-
-    Param<string> image_file;
-    Param<bool> read_only;
-
-END_DECLARE_SIM_OBJECT_PARAMS(RawDiskImage)
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(RawDiskImage)
-
-    INIT_PARAM(image_file, "disk image file"),
-    INIT_PARAM_DFLT(read_only, "read only image", false)
-
-END_INIT_SIM_OBJECT_PARAMS(RawDiskImage)
-
-
-CREATE_SIM_OBJECT(RawDiskImage)
+RawDiskImage *
+RawDiskImageParams::create()
 {
-    return new RawDiskImage(getInstanceName(), image_file, read_only);
+    return new RawDiskImage(this);
 }
 
-REGISTER_SIM_OBJECT("RawDiskImage", RawDiskImage)
-
 ////////////////////////////////////////////////////////////////////////
 //
 // Copy on Write Disk image
 //
-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); }
+const uint32_t CowDiskImage::VersionMajor = 1;
+const uint32_t CowDiskImage::VersionMinor = 0;
 
 class CowDiskCallback : public Callback
 {
@@ -188,17 +164,21 @@ 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)) {
+            if (p->read_only)
+                fatal("could not open read-only file");
+            init(p->table_size);
+        }
+
+        if (!p->read_only)
+            registerExitCallback(new CowDiskCallback(this));
     }
-
-    if (!read_only)
-        registerExitCallback(new CowDiskCallback(this));
 }
 
 CowDiskImage::~CowDiskImage()
@@ -440,33 +420,8 @@ CowDiskImage::unserialize(Checkpoint *cp, const string &section)
     open(cowFilename);
 }
 
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(CowDiskImage)
-
-    SimObjectParam<DiskImage *> child;
-    Param<string> image_file;
-    Param<int> table_size;
-    Param<bool> read_only;
-
-END_DECLARE_SIM_OBJECT_PARAMS(CowDiskImage)
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(CowDiskImage)
-
-    INIT_PARAM(child, "child image"),
-    INIT_PARAM_DFLT(image_file, "disk image file", ""),
-    INIT_PARAM_DFLT(table_size, "initial table size", 65536),
-    INIT_PARAM_DFLT(read_only, "don't write back to the copy-on-write file",
-                    true)
-
-END_INIT_SIM_OBJECT_PARAMS(CowDiskImage)
-
-
-CREATE_SIM_OBJECT(CowDiskImage)
+CowDiskImage *
+CowDiskImageParams::create()
 {
-    if (((string)image_file).empty())
-        return new CowDiskImage(getInstanceName(), child, table_size);
-    else
-        return new CowDiskImage(getInstanceName(), child, table_size,
-                                image_file, read_only);
+    return new CowDiskImage(this);
 }
-
-REGISTER_SIM_OBJECT("CowDiskImage", CowDiskImage)