Merge gblack@m5.eecs.umich.edu:/bk/multiarch
[gem5.git] / dev / disk_image.cc
index d990d70783259d75b3917a028f5889dd1f0cac0f..447c54697db928f7faeb9586f0d5d54d3b8c2169 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2004 The Regents of The University of Michigan
+ * Copyright (c) 2001-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* @file
+/** @file
  * Disk Image Definitions
  */
 
@@ -46,7 +46,7 @@
 #include "dev/disk_image.hh"
 #include "sim/builder.hh"
 #include "sim/sim_exit.hh"
-#include "targetarch/byte_swap.hh"
+#include "sim/byteswap.hh"
 
 using namespace std;
 
@@ -237,7 +237,7 @@ void
 SafeReadSwap(ifstream &stream, T &data)
 {
     SafeRead(stream, &data, sizeof(data));
-    data = htoa(data);
+    data = letoh(data); //is this the proper byte order conversion?
 }
 
 bool
@@ -319,7 +319,7 @@ template<class T>
 void
 SafeWriteSwap(ofstream &stream, const T &data)
 {
-    T swappeddata = htoa(data);
+    T swappeddata = letoh(data); //is this the proper byte order conversion?
     SafeWrite(stream, &swappeddata, sizeof(data));
 }
 void
@@ -425,9 +425,9 @@ CowDiskImage::write(const uint8_t *data, off_t offset)
 void
 CowDiskImage::serialize(ostream &os)
 {
-    string cowFilename = Checkpoint::dir() + name() + ".cow";
+    string cowFilename = name() + ".cow";
     SERIALIZE_SCALAR(cowFilename);
-    save(cowFilename);
+    save(Checkpoint::dir() + "/" + cowFilename);
 }
 
 void
@@ -435,6 +435,7 @@ CowDiskImage::unserialize(Checkpoint *cp, const string &section)
 {
     string cowFilename;
     UNSERIALIZE_SCALAR(cowFilename);
+    cowFilename = cp->cptDir + "/" + cowFilename;
     open(cowFilename);
 }