abstract_mem.cc (9235:5aa4896ed55a) abstract_mem.cc (9236:c38988024f1f)
1/*
2 * Copyright (c) 2010-2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 62 unchanged lines hidden (view full) ---

71 _system(NULL)
72{
73 if (size() % TheISA::PageBytes != 0)
74 panic("Memory Size not divisible by page size\n");
75
76 if (params()->null)
77 return;
78
1/*
2 * Copyright (c) 2010-2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 62 unchanged lines hidden (view full) ---

71 _system(NULL)
72{
73 if (size() % TheISA::PageBytes != 0)
74 panic("Memory Size not divisible by page size\n");
75
76 if (params()->null)
77 return;
78
79 if (params()->file == "") {
80 int map_flags = MAP_ANON | MAP_PRIVATE;
81 pmemAddr = (uint8_t *)mmap(NULL, size(),
82 PROT_READ | PROT_WRITE, map_flags, -1, 0);
83 } else {
84 int map_flags = MAP_PRIVATE;
85 int fd = open(params()->file.c_str(), O_RDONLY);
86 long _size = lseek(fd, 0, SEEK_END);
87 if (_size != range.size()) {
88 fatal("Specified size %d does not match file %s %d\n",
89 range.size(), params()->file, _size);
90 }
91 lseek(fd, 0, SEEK_SET);
92 pmemAddr = (uint8_t *)mmap(NULL, roundUp(_size, sysconf(_SC_PAGESIZE)),
93 PROT_READ | PROT_WRITE, map_flags, fd, 0);
94 }
79 int map_flags = MAP_ANON | MAP_PRIVATE;
80 pmemAddr = (uint8_t *)mmap(NULL, size(),
81 PROT_READ | PROT_WRITE, map_flags, -1, 0);
95
96 if (pmemAddr == (void *)MAP_FAILED) {
97 perror("mmap");
82
83 if (pmemAddr == (void *)MAP_FAILED) {
84 perror("mmap");
98 if (params()->file == "")
99 fatal("Could not mmap!\n");
100 else
101 fatal("Could not find file: %s\n", params()->file);
85 fatal("Could not mmap!\n");
102 }
103
104 //If requested, initialize all the memory to 0
105 if (p->zero)
106 memset(pmemAddr, 0, size());
107}
108
109

--- 495 unchanged lines hidden ---
86 }
87
88 //If requested, initialize all the memory to 0
89 if (p->zero)
90 memset(pmemAddr, 0, size());
91}
92
93

--- 495 unchanged lines hidden ---