physical.cc (10700:417ba77dedb4) | physical.cc (10905:a6ca6831e775) |
---|---|
1/* 2 * Copyright (c) 2012, 2014 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 --- 275 unchanged lines hidden (view full) --- 284 // isMemAddr before calling functionalAccess 285 const auto& m = addrMap.find(addr); 286 assert(m != addrMap.end()); 287 m->second->functionalAccess(pkt); 288 } 289} 290 291void | 1/* 2 * Copyright (c) 2012, 2014 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 --- 275 unchanged lines hidden (view full) --- 284 // isMemAddr before calling functionalAccess 285 const auto& m = addrMap.find(addr); 286 assert(m != addrMap.end()); 287 m->second->functionalAccess(pkt); 288 } 289} 290 291void |
292PhysicalMemory::serialize(ostream& os) | 292PhysicalMemory::serialize(CheckpointOut &cp) const |
293{ 294 // serialize all the locked addresses and their context ids 295 vector<Addr> lal_addr; 296 vector<int> lal_cid; 297 298 for (auto& m : memories) { 299 const list<LockedAddr>& locked_addrs = m->getLockedAddrList(); 300 for (const auto& l : locked_addrs) { 301 lal_addr.push_back(l.addr); 302 lal_cid.push_back(l.contextId); 303 } 304 } 305 | 293{ 294 // serialize all the locked addresses and their context ids 295 vector<Addr> lal_addr; 296 vector<int> lal_cid; 297 298 for (auto& m : memories) { 299 const list<LockedAddr>& locked_addrs = m->getLockedAddrList(); 300 for (const auto& l : locked_addrs) { 301 lal_addr.push_back(l.addr); 302 lal_cid.push_back(l.contextId); 303 } 304 } 305 |
306 arrayParamOut(os, "lal_addr", lal_addr); 307 arrayParamOut(os, "lal_cid", lal_cid); | 306 SERIALIZE_CONTAINER(lal_addr); 307 SERIALIZE_CONTAINER(lal_cid); |
308 309 // serialize the backing stores 310 unsigned int nbr_of_stores = backingStore.size(); 311 SERIALIZE_SCALAR(nbr_of_stores); 312 313 unsigned int store_id = 0; 314 // store each backing store memory segment in a file 315 for (auto& s : backingStore) { | 308 309 // serialize the backing stores 310 unsigned int nbr_of_stores = backingStore.size(); 311 SERIALIZE_SCALAR(nbr_of_stores); 312 313 unsigned int store_id = 0; 314 // store each backing store memory segment in a file 315 for (auto& s : backingStore) { |
316 nameOut(os, csprintf("%s.store%d", name(), store_id)); 317 serializeStore(os, store_id++, s.first, s.second); | 316 ScopedCheckpointSection sec(cp, csprintf("store%d", store_id)); 317 serializeStore(cp, store_id++, s.first, s.second); |
318 } 319} 320 321void | 318 } 319} 320 321void |
322PhysicalMemory::serializeStore(ostream& os, unsigned int store_id, 323 AddrRange range, uint8_t* pmem) | 322PhysicalMemory::serializeStore(CheckpointOut &cp, unsigned int store_id, 323 AddrRange range, uint8_t* pmem) const |
324{ 325 // we cannot use the address range for the name as the 326 // memories that are not part of the address map can overlap 327 string filename = name() + ".store" + to_string(store_id) + ".pmem"; 328 long range_size = range.size(); 329 330 DPRINTF(Checkpoint, "Serializing physical memory %s with size %d\n", 331 filename, range_size); 332 333 SERIALIZE_SCALAR(store_id); 334 SERIALIZE_SCALAR(filename); 335 SERIALIZE_SCALAR(range_size); 336 337 // write memory file | 324{ 325 // we cannot use the address range for the name as the 326 // memories that are not part of the address map can overlap 327 string filename = name() + ".store" + to_string(store_id) + ".pmem"; 328 long range_size = range.size(); 329 330 DPRINTF(Checkpoint, "Serializing physical memory %s with size %d\n", 331 filename, range_size); 332 333 SERIALIZE_SCALAR(store_id); 334 SERIALIZE_SCALAR(filename); 335 SERIALIZE_SCALAR(range_size); 336 337 // write memory file |
338 string filepath = Checkpoint::dir() + "/" + filename.c_str(); | 338 string filepath = CheckpointIn::dir() + "/" + filename.c_str(); |
339 gzFile compressed_mem = gzopen(filepath.c_str(), "wb"); 340 if (compressed_mem == NULL) 341 fatal("Can't open physical memory checkpoint file '%s'\n", 342 filename); 343 344 uint64_t pass_size = 0; 345 346 // gzwrite fails if (int)len < 0 (gzwrite returns int) --- 13 unchanged lines hidden (view full) --- 360 // is zero 361 if (gzclose(compressed_mem)) 362 fatal("Close failed on physical memory checkpoint file '%s'\n", 363 filename); 364 365} 366 367void | 339 gzFile compressed_mem = gzopen(filepath.c_str(), "wb"); 340 if (compressed_mem == NULL) 341 fatal("Can't open physical memory checkpoint file '%s'\n", 342 filename); 343 344 uint64_t pass_size = 0; 345 346 // gzwrite fails if (int)len < 0 (gzwrite returns int) --- 13 unchanged lines hidden (view full) --- 360 // is zero 361 if (gzclose(compressed_mem)) 362 fatal("Close failed on physical memory checkpoint file '%s'\n", 363 filename); 364 365} 366 367void |
368PhysicalMemory::unserialize(Checkpoint* cp, const string& section) | 368PhysicalMemory::unserialize(CheckpointIn &cp) |
369{ 370 // unserialize the locked addresses and map them to the 371 // appropriate memory controller 372 vector<Addr> lal_addr; 373 vector<int> lal_cid; | 369{ 370 // unserialize the locked addresses and map them to the 371 // appropriate memory controller 372 vector<Addr> lal_addr; 373 vector<int> lal_cid; |
374 arrayParamIn(cp, section, "lal_addr", lal_addr); 375 arrayParamIn(cp, section, "lal_cid", lal_cid); | 374 UNSERIALIZE_CONTAINER(lal_addr); 375 UNSERIALIZE_CONTAINER(lal_cid); |
376 for(size_t i = 0; i < lal_addr.size(); ++i) { 377 const auto& m = addrMap.find(lal_addr[i]); 378 m->second->addLockedAddr(LockedAddr(lal_addr[i], lal_cid[i])); 379 } 380 381 // unserialize the backing stores 382 unsigned int nbr_of_stores; 383 UNSERIALIZE_SCALAR(nbr_of_stores); 384 385 for (unsigned int i = 0; i < nbr_of_stores; ++i) { | 376 for(size_t i = 0; i < lal_addr.size(); ++i) { 377 const auto& m = addrMap.find(lal_addr[i]); 378 m->second->addLockedAddr(LockedAddr(lal_addr[i], lal_cid[i])); 379 } 380 381 // unserialize the backing stores 382 unsigned int nbr_of_stores; 383 UNSERIALIZE_SCALAR(nbr_of_stores); 384 385 for (unsigned int i = 0; i < nbr_of_stores; ++i) { |
386 unserializeStore(cp, csprintf("%s.store%d", section, i)); | 386 ScopedCheckpointSection sec(cp, csprintf("store%d", i)); 387 unserializeStore(cp); |
387 } 388 389} 390 391void | 388 } 389 390} 391 392void |
392PhysicalMemory::unserializeStore(Checkpoint* cp, const string& section) | 393PhysicalMemory::unserializeStore(CheckpointIn &cp) |
393{ 394 const uint32_t chunk_size = 16384; 395 396 unsigned int store_id; 397 UNSERIALIZE_SCALAR(store_id); 398 399 string filename; 400 UNSERIALIZE_SCALAR(filename); | 394{ 395 const uint32_t chunk_size = 16384; 396 397 unsigned int store_id; 398 UNSERIALIZE_SCALAR(store_id); 399 400 string filename; 401 UNSERIALIZE_SCALAR(filename); |
401 string filepath = cp->cptDir + "/" + filename; | 402 string filepath = cp.cptDir + "/" + filename; |
402 403 // mmap memoryfile 404 gzFile compressed_mem = gzopen(filepath.c_str(), "rb"); 405 if (compressed_mem == NULL) 406 fatal("Can't open physical memory checkpoint file '%s'", filename); 407 408 // we've already got the actual backing store mapped 409 uint8_t* pmem = backingStore[store_id].second; --- 40 unchanged lines hidden --- | 403 404 // mmap memoryfile 405 gzFile compressed_mem = gzopen(filepath.c_str(), "rb"); 406 if (compressed_mem == NULL) 407 fatal("Can't open physical memory checkpoint file '%s'", filename); 408 409 // we've already got the actual backing store mapped 410 uint8_t* pmem = backingStore[store_id].second; --- 40 unchanged lines hidden --- |