Mem: Remove the file parameter from AbstractMemory
This patch removes the unused file parameter from the AbstractMemory. The patch serves to make it easier to transition to a separation of the actual contigious host memory backing store, and the gem5 memory controllers. Without the file parameter it becomes easier to hide the creation of the mmap in the PhysicalMemory, as there are no longer any reasons to expose the actual contigious ranges to the user. To the best of my knowledge there is no use of the parameter, so the change should not affect anyone.
This commit is contained in:
parent
ffb6aec603
commit
a731f8f9dd
2 changed files with 4 additions and 21 deletions
|
@ -46,7 +46,6 @@ class AbstractMemory(MemObject):
|
||||||
type = 'AbstractMemory'
|
type = 'AbstractMemory'
|
||||||
abstract = True
|
abstract = True
|
||||||
range = Param.AddrRange(AddrRange('128MB'), "Address range")
|
range = Param.AddrRange(AddrRange('128MB'), "Address range")
|
||||||
file = Param.String('', "Memory-mapped file")
|
|
||||||
null = Param.Bool(False, "Do not store data, always return zero")
|
null = Param.Bool(False, "Do not store data, always return zero")
|
||||||
zero = Param.Bool(False, "Initialize memory with zeros")
|
zero = Param.Bool(False, "Initialize memory with zeros")
|
||||||
|
|
||||||
|
|
|
@ -76,29 +76,13 @@ AbstractMemory::AbstractMemory(const Params *p) :
|
||||||
if (params()->null)
|
if (params()->null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (params()->file == "") {
|
int map_flags = MAP_ANON | MAP_PRIVATE;
|
||||||
int map_flags = MAP_ANON | MAP_PRIVATE;
|
pmemAddr = (uint8_t *)mmap(NULL, size(),
|
||||||
pmemAddr = (uint8_t *)mmap(NULL, size(),
|
PROT_READ | PROT_WRITE, map_flags, -1, 0);
|
||||||
PROT_READ | PROT_WRITE, map_flags, -1, 0);
|
|
||||||
} else {
|
|
||||||
int map_flags = MAP_PRIVATE;
|
|
||||||
int fd = open(params()->file.c_str(), O_RDONLY);
|
|
||||||
long _size = lseek(fd, 0, SEEK_END);
|
|
||||||
if (_size != range.size()) {
|
|
||||||
fatal("Specified size %d does not match file %s %d\n",
|
|
||||||
range.size(), params()->file, _size);
|
|
||||||
}
|
|
||||||
lseek(fd, 0, SEEK_SET);
|
|
||||||
pmemAddr = (uint8_t *)mmap(NULL, roundUp(_size, sysconf(_SC_PAGESIZE)),
|
|
||||||
PROT_READ | PROT_WRITE, map_flags, fd, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pmemAddr == (void *)MAP_FAILED) {
|
if (pmemAddr == (void *)MAP_FAILED) {
|
||||||
perror("mmap");
|
perror("mmap");
|
||||||
if (params()->file == "")
|
fatal("Could not mmap!\n");
|
||||||
fatal("Could not mmap!\n");
|
|
||||||
else
|
|
||||||
fatal("Could not find file: %s\n", params()->file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If requested, initialize all the memory to 0
|
//If requested, initialize all the memory to 0
|
||||||
|
|
Loading…
Reference in a new issue