physical.cc (9404:c194718a592c) physical.cc (9405:c0a0593510db)
1/*
2 * Copyright (c) 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

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

115 }
116}
117
118void
119PhysicalMemory::createBackingStore(AddrRange range,
120 const vector<AbstractMemory*>& _memories)
121{
122 // perform the actual mmap
1/*
2 * Copyright (c) 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

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

115 }
116}
117
118void
119PhysicalMemory::createBackingStore(AddrRange range,
120 const vector<AbstractMemory*>& _memories)
121{
122 // perform the actual mmap
123 DPRINTF(BusAddrRanges, "Creating backing store for range %x:%x\n",
124 range.start, range.end);
123 DPRINTF(BusAddrRanges, "Creating backing store for range %s\n",
124 range.to_string());
125 int map_flags = MAP_ANON | MAP_PRIVATE;
126 uint8_t* pmem = (uint8_t*) mmap(NULL, range.size(),
127 PROT_READ | PROT_WRITE,
128 map_flags, -1, 0);
129
130 if (pmem == (uint8_t*) MAP_FAILED) {
131 perror("mmap");
125 int map_flags = MAP_ANON | MAP_PRIVATE;
126 uint8_t* pmem = (uint8_t*) mmap(NULL, range.size(),
127 PROT_READ | PROT_WRITE,
128 map_flags, -1, 0);
129
130 if (pmem == (uint8_t*) MAP_FAILED) {
131 perror("mmap");
132 fatal("Could not mmap %d bytes for range %x:%x!\n", range.size(),
133 range.start, range.end);
132 fatal("Could not mmap %d bytes for range %s!\n", range.size(),
133 range.to_string());
134 }
135
136 // remember this backing store so we can checkpoint it and unmap
137 // it appropriately
138 backingStore.push_back(make_pair(range, pmem));
139
140 // count how many of the memories are to be zero initialized so we
141 // can see if some but not all have this parameter set

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

152 // if it should be zero, then go and make it so
153 if ((*m)->initToZero()) {
154 ++init_to_zero;
155 }
156 }
157
158 if (init_to_zero != 0) {
159 if (init_to_zero != _memories.size())
134 }
135
136 // remember this backing store so we can checkpoint it and unmap
137 // it appropriately
138 backingStore.push_back(make_pair(range, pmem));
139
140 // count how many of the memories are to be zero initialized so we
141 // can see if some but not all have this parameter set

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

152 // if it should be zero, then go and make it so
153 if ((*m)->initToZero()) {
154 ++init_to_zero;
155 }
156 }
157
158 if (init_to_zero != 0) {
159 if (init_to_zero != _memories.size())
160 fatal("Some, but not all memories in range %x:%x are set zero\n",
161 range.start, range.end);
160 fatal("Some, but not all memories in range %s are set zero\n",
161 range.to_string());
162
163 memset(pmem, 0, range.size());
164 }
165}
166
167PhysicalMemory::~PhysicalMemory()
168{
169 // unmap the backing store
170 for (vector<pair<AddrRange, uint8_t*> >::iterator s = backingStore.begin();
171 s != backingStore.end(); ++s)
172 munmap((char*)s->second, s->first.size());
173}
174
175bool
176PhysicalMemory::isMemAddr(Addr addr) const
177{
178 // see if the address is within the last matched range
162
163 memset(pmem, 0, range.size());
164 }
165}
166
167PhysicalMemory::~PhysicalMemory()
168{
169 // unmap the backing store
170 for (vector<pair<AddrRange, uint8_t*> >::iterator s = backingStore.begin();
171 s != backingStore.end(); ++s)
172 munmap((char*)s->second, s->first.size());
173}
174
175bool
176PhysicalMemory::isMemAddr(Addr addr) const
177{
178 // see if the address is within the last matched range
179 if (addr != rangeCache) {
179 if (!rangeCache.contains(addr)) {
180 // lookup in the interval tree
181 AddrRangeMap<AbstractMemory*>::const_iterator r = addrMap.find(addr);
182 if (r == addrMap.end()) {
183 // not in the cache, and not in the tree
184 return false;
185 }
186 // the range is in the tree, update the cache
187 rangeCache = r->first;

--- 232 unchanged lines hidden ---
180 // lookup in the interval tree
181 AddrRangeMap<AbstractMemory*>::const_iterator r = addrMap.find(addr);
182 if (r == addrMap.end()) {
183 // not in the cache, and not in the tree
184 return false;
185 }
186 // the range is in the tree, update the cache
187 rangeCache = r->first;

--- 232 unchanged lines hidden ---