Merge with the main repository again.
[gem5.git] / src / mem / physical.cc
index a134165bcb40753c5647d813228e18c9624d0b89..d5c4e892fb2467d78d573654bfd05486dcc28618 100644 (file)
  *          Ali Saidi
  */
 
-#include <sys/types.h>
 #include <sys/mman.h>
+#include <sys/types.h>
 #include <sys/user.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
 
+#include <cerrno>
 #include <cstdio>
 #include <iostream>
 #include <string>
@@ -59,8 +59,9 @@
 #include "base/misc.hh"
 #include "base/random.hh"
 #include "base/types.hh"
-#include "config/full_system.hh"
 #include "config/the_isa.hh"
+#include "debug/LLSC.hh"
+#include "debug/MemoryAccess.hh"
 #include "mem/packet_access.hh"
 #include "mem/physical.hh"
 #include "sim/eventq.hh"
@@ -88,7 +89,7 @@ PhysicalMemory::PhysicalMemory(const Params *p)
         int fd = open(params()->file.c_str(), O_RDONLY);
         _size = lseek(fd, 0, SEEK_END);
         lseek(fd, 0, SEEK_SET);
-        pmemAddr = (uint8_t *)mmap(NULL, roundUp(size(), PAGE_SIZE),
+        pmemAddr = (uint8_t *)mmap(NULL, roundUp(size(), sysconf(_SC_PAGESIZE)),
                                    PROT_READ | PROT_WRITE, map_flags, fd, 0);
     }
 
@@ -548,14 +549,15 @@ PhysicalMemory::unserialize(Checkpoint *cp, const string &section)
         fatal("Insufficient memory to allocate compression state for %s\n",
                 filename);
 
-    // unmap file that was mmaped in the constructor
+    // unmap file that was mmapped in the constructor
     // This is done here to make sure that gzip and open don't muck with our
     // nice large space of memory before we reallocate it
     munmap((char*)pmemAddr, size());
 
     UNSERIALIZE_SCALAR(_size);
     if (size() > params()->range.size())
-        fatal("Memory size has changed!\n");
+        fatal("Memory size has changed! size %lld, param size %lld\n",
+              size(), params()->range.size());
 
     pmemAddr = (uint8_t *)mmap(NULL, size(),
         PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);