physical.cc (9707:1305bec2733f) physical.cc (10070:83957204d43b)
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

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

90 // memories are allowed to overlap in the logic address
91 // map
92 vector<AbstractMemory*> unmapped_mems;
93 unmapped_mems.push_back(*m);
94 createBackingStore((*m)->getAddrRange(), unmapped_mems);
95 }
96 }
97
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

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

90 // memories are allowed to overlap in the logic address
91 // map
92 vector<AbstractMemory*> unmapped_mems;
93 unmapped_mems.push_back(*m);
94 createBackingStore((*m)->getAddrRange(), unmapped_mems);
95 }
96 }
97
98 // iterate over the increasing addresses and chunks of contigous
99 // space to be mapped to backing store, also remember what
100 // memories constitute the range so we can go and find out if we
101 // have to init their parts to zero
98 // iterate over the increasing addresses and chunks of contiguous
99 // space to be mapped to backing store, create it and inform the
100 // memories
102 vector<AddrRange> intlv_ranges;
103 vector<AbstractMemory*> curr_memories;
104 for (AddrRangeMap<AbstractMemory*>::const_iterator r = addrMap.begin();
105 r != addrMap.end(); ++r) {
106 // simply skip past all memories that are null and hence do
107 // not need any backing store
108 if (!r->second->isNull()) {
109 // if the range is interleaved then save it for now

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

157 fatal("Could not mmap %d bytes for range %s!\n", range.size(),
158 range.to_string());
159 }
160
161 // remember this backing store so we can checkpoint it and unmap
162 // it appropriately
163 backingStore.push_back(make_pair(range, pmem));
164
101 vector<AddrRange> intlv_ranges;
102 vector<AbstractMemory*> curr_memories;
103 for (AddrRangeMap<AbstractMemory*>::const_iterator r = addrMap.begin();
104 r != addrMap.end(); ++r) {
105 // simply skip past all memories that are null and hence do
106 // not need any backing store
107 if (!r->second->isNull()) {
108 // if the range is interleaved then save it for now

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

156 fatal("Could not mmap %d bytes for range %s!\n", range.size(),
157 range.to_string());
158 }
159
160 // remember this backing store so we can checkpoint it and unmap
161 // it appropriately
162 backingStore.push_back(make_pair(range, pmem));
163
165 // point the memories to their backing store, and if requested,
166 // initialize the memory range to 0
164 // point the memories to their backing store
167 for (vector<AbstractMemory*>::const_iterator m = _memories.begin();
168 m != _memories.end(); ++m) {
169 DPRINTF(BusAddrRanges, "Mapping memory %s to backing store\n",
170 (*m)->name());
171 (*m)->setBackingStore(pmem);
172 }
173}
174

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

388 fatal("Can't open physical memory checkpoint file '%s'", filename);
389 }
390
391 gzFile compressed_mem = gzdopen(fd, "rb");
392 if (compressed_mem == NULL)
393 fatal("Insufficient memory to allocate compression state for %s\n",
394 filename);
395
165 for (vector<AbstractMemory*>::const_iterator m = _memories.begin();
166 m != _memories.end(); ++m) {
167 DPRINTF(BusAddrRanges, "Mapping memory %s to backing store\n",
168 (*m)->name());
169 (*m)->setBackingStore(pmem);
170 }
171}
172

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

386 fatal("Can't open physical memory checkpoint file '%s'", filename);
387 }
388
389 gzFile compressed_mem = gzdopen(fd, "rb");
390 if (compressed_mem == NULL)
391 fatal("Insufficient memory to allocate compression state for %s\n",
392 filename);
393
394 // we've already got the actual backing store mapped
396 uint8_t* pmem = backingStore[store_id].second;
397 AddrRange range = backingStore[store_id].first;
398
395 uint8_t* pmem = backingStore[store_id].second;
396 AddrRange range = backingStore[store_id].first;
397
399 // unmap file that was mmapped in the constructor, this is
400 // done here to make sure that gzip and open don't muck with
401 // our nice large space of memory before we reallocate it
402 munmap((char*) pmem, range.size());
403
404 long range_size;
405 UNSERIALIZE_SCALAR(range_size);
406
407 DPRINTF(Checkpoint, "Unserializing physical memory %s with size %d\n",
408 filename, range_size);
409
410 if (range_size != range.size())
411 fatal("Memory range size has changed! Saw %lld, expected %lld\n",
412 range_size, range.size());
413
398 long range_size;
399 UNSERIALIZE_SCALAR(range_size);
400
401 DPRINTF(Checkpoint, "Unserializing physical memory %s with size %d\n",
402 filename, range_size);
403
404 if (range_size != range.size())
405 fatal("Memory range size has changed! Saw %lld, expected %lld\n",
406 range_size, range.size());
407
414 pmem = (uint8_t*) mmap(NULL, range.size(), PROT_READ | PROT_WRITE,
415 MAP_ANON | MAP_PRIVATE, -1, 0);
416
417 if (pmem == (void*) MAP_FAILED) {
418 perror("mmap");
419 fatal("Could not mmap physical memory!\n");
420 }
421
422 uint64_t curr_size = 0;
423 long* temp_page = new long[chunk_size];
424 long* pmem_current;
425 uint32_t bytes_read;
426 while (curr_size < range.size()) {
427 bytes_read = gzread(compressed_mem, temp_page, chunk_size);
428 if (bytes_read == 0)
429 break;

--- 20 unchanged lines hidden ---
408 uint64_t curr_size = 0;
409 long* temp_page = new long[chunk_size];
410 long* pmem_current;
411 uint32_t bytes_read;
412 while (curr_size < range.size()) {
413 bytes_read = gzread(compressed_mem, temp_page, chunk_size);
414 if (bytes_read == 0)
415 break;

--- 20 unchanged lines hidden ---