diff -r 5afd0f5c1ed4 -r e3d480532111 configs/common/FSConfig.py --- a/configs/common/FSConfig.py Sat Oct 02 21:13:47 2010 -0500 +++ b/configs/common/FSConfig.py Sat Oct 02 21:13:54 2010 -0500 @@ -200,9 +200,12 @@ self.membus.badaddr_responder.warn_access = "warn" self.bridge = Bridge(delay='50ns', nack_delay='4ns') self.physmem = PhysicalMemory(range = AddrRange(mdesc.mem()), zero = True) + self.diskmem = PhysicalMemory(range = AddrRange(Addr('128MB'), size = '128MB'), + file = disk('ael-arm.ext2')) self.bridge.side_a = self.iobus.port self.bridge.side_b = self.membus.port self.physmem.port = self.membus.port + self.diskmem.port = self.membus.port self.mem_mode = mem_mode @@ -224,7 +227,10 @@ self.intrctrl = IntrControl() self.terminal = Terminal() - self.boot_osflags = 'earlyprintk mem=128MB console=ttyAMA0 lpj=19988480 norandmaps' + self.kernel = binary('vmlinux.arm') + self.boot_osflags = 'earlyprintk mem=128MB console=ttyAMA0 lpj=19988480' + \ + ' norandmaps slram=slram0,0x8000000,+0x8000000' + \ + ' mtdparts=slram0:- rw loglevel=8 root=/dev/mtdblock0' return self diff -r 5afd0f5c1ed4 -r e3d480532111 src/mem/physical.cc --- a/src/mem/physical.cc Sat Oct 02 21:13:47 2010 -0500 +++ b/src/mem/physical.cc Sat Oct 02 21:13:54 2010 -0500 @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include "arch/registers.hh" +#include "base/intmath.hh" #include "base/misc.hh" #include "base/random.hh" #include "base/types.hh" @@ -58,15 +60,25 @@ lat(p->latency), lat_var(p->latency_var), cachedSize(params()->range.size()), cachedStart(params()->range.start) { - if (params()->range.size() % TheISA::PageBytes != 0) + if (cachedSize % TheISA::PageBytes != 0) panic("Memory Size not divisible by page size\n"); if (params()->null) return; - int map_flags = MAP_ANON | MAP_PRIVATE; - pmemAddr = (uint8_t *)mmap(NULL, params()->range.size(), - PROT_READ | PROT_WRITE, map_flags, -1, 0); + + if (params()->file == "") { + int map_flags = MAP_ANON | MAP_PRIVATE; + pmemAddr = (uint8_t *)mmap(NULL,cachedSize, + PROT_READ | PROT_WRITE, map_flags, -1, 0); + } else { + int map_flags = MAP_PRIVATE; + int fd = open(params()->file.c_str(), O_RDONLY); + cachedSize = lseek(fd, 0, SEEK_END); + lseek(fd, 0, SEEK_SET); + pmemAddr = (uint8_t *)mmap(NULL, roundUp(cachedSize, PAGE_SIZE), + PROT_READ | PROT_WRITE, map_flags, fd, 0); + } if (pmemAddr == (void *)MAP_FAILED) { perror("mmap"); @@ -75,7 +87,7 @@ //If requested, initialize all the memory to 0 if (p->zero) - memset(pmemAddr, 0, p->range.size()); + memset(pmemAddr, 0, cachedSize); } void @@ -94,8 +106,7 @@ PhysicalMemory::~PhysicalMemory() { if (pmemAddr) - munmap((char*)pmemAddr, params()->range.size()); - //Remove memPorts? + munmap((char*)pmemAddr, cachedSize); } Addr @@ -408,7 +419,7 @@ { snoop = false; resp.clear(); - resp.push_back(RangeSize(start(), params()->range.size())); + resp.push_back(RangeSize(start(), cachedSize)); } unsigned @@ -463,6 +474,7 @@ string filename = name() + ".physmem"; SERIALIZE_SCALAR(filename); + SERIALIZE_SCALAR(cachedSize); // write memory file string thefile = Checkpoint::dir() + "/" + filename.c_str(); @@ -477,8 +489,7 @@ fatal("Insufficient memory to allocate compression state for %s\n", filename); - if (gzwrite(compressedMem, pmemAddr, params()->range.size()) != - (int)params()->range.size()) { + if (gzwrite(compressedMem, pmemAddr, cachedSize) != (int)cachedSize) { fatal("Write failed on physical memory checkpoint file '%s'\n", filename); } @@ -522,9 +533,13 @@ // unmap file that was mmaped 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, params()->range.size()); + munmap((char*)pmemAddr, cachedSize); - pmemAddr = (uint8_t *)mmap(NULL, params()->range.size(), + UNSERIALIZE_SCALAR(cachedSize); + if (cachedSize > params()->range.size()) + fatal("Memory size has changed!\n"); + + pmemAddr = (uint8_t *)mmap(NULL, cachedSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (pmemAddr == (void *)MAP_FAILED) { @@ -538,7 +553,7 @@ fatal("Unable to malloc memory to read file %s\n", filename); /* Only copy bytes that are non-zero, so we don't give the VM system hell */ - while (curSize < params()->range.size()) { + while (curSize < cachedSize) { bytesRead = gzread(compressedMem, tempPage, chunkSize); if (bytesRead == 0) break;