packet.cc (12821:3663a543ed2a) | packet.cc (12822:fe6f6d605214) |
---|---|
1/* 2 * Copyright (c) 2011-2018 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 --- 39 unchanged lines hidden (view full) --- 48 * between a single level of the memory heirarchy (ie L1->L2). 49 */ 50 51#include "mem/packet.hh" 52 53#include <algorithm> 54#include <cstring> 55#include <iostream> | 1/* 2 * Copyright (c) 2011-2018 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 --- 39 unchanged lines hidden (view full) --- 48 * between a single level of the memory heirarchy (ie L1->L2). 49 */ 50 51#include "mem/packet.hh" 52 53#include <algorithm> 54#include <cstring> 55#include <iostream> |
56#include <sstream> 57#include <string> |
|
56 57#include "base/cprintf.hh" 58#include "base/logging.hh" 59#include "base/trace.hh" 60#include "mem/packet_access.hh" 61 | 58 59#include "base/cprintf.hh" 60#include "base/logging.hh" 61#include "base/trace.hh" 62#include "mem/packet_access.hh" 63 |
62using namespace std; 63 | |
64// The one downside to bitsets is that static initializers can get ugly. 65#define SET1(a1) (1 << (a1)) 66#define SET2(a1, a2) (SET1(a1) | SET1(a2)) 67#define SET3(a1, a2, a3) (SET2(a1, a2) | SET1(a3)) 68#define SET4(a1, a2, a3, a4) (SET3(a1, a2, a3) | SET1(a4)) 69#define SET5(a1, a2, a3, a4, a5) (SET4(a1, a2, a3, a4) | SET1(a5)) 70#define SET6(a1, a2, a3, a4, a5, a6) (SET5(a1, a2, a3, a4, a5) | SET1(a6)) 71#define SET7(a1, a2, a3, a4, a5, a6, a7) (SET6(a1, a2, a3, a4, a5, a6) | \ --- 183 unchanged lines hidden (view full) --- 255 const Addr val_offset = func_start > val_start ? 256 func_start - val_start : 0; 257 const Addr func_offset = func_start < val_start ? 258 val_start - func_start : 0; 259 const Addr overlap_size = std::min(val_end, func_end)+1 - 260 std::max(val_start, func_start); 261 262 if (isRead()) { | 64// The one downside to bitsets is that static initializers can get ugly. 65#define SET1(a1) (1 << (a1)) 66#define SET2(a1, a2) (SET1(a1) | SET1(a2)) 67#define SET3(a1, a2, a3) (SET2(a1, a2) | SET1(a3)) 68#define SET4(a1, a2, a3, a4) (SET3(a1, a2, a3) | SET1(a4)) 69#define SET5(a1, a2, a3, a4, a5) (SET4(a1, a2, a3, a4) | SET1(a5)) 70#define SET6(a1, a2, a3, a4, a5, a6) (SET5(a1, a2, a3, a4, a5) | SET1(a6)) 71#define SET7(a1, a2, a3, a4, a5, a6, a7) (SET6(a1, a2, a3, a4, a5, a6) | \ --- 183 unchanged lines hidden (view full) --- 255 const Addr val_offset = func_start > val_start ? 256 func_start - val_start : 0; 257 const Addr func_offset = func_start < val_start ? 258 val_start - func_start : 0; 259 const Addr overlap_size = std::min(val_end, func_end)+1 - 260 std::max(val_start, func_start); 261 262 if (isRead()) { |
263 memcpy(getPtr | 263 std::memcpy(getPtr<uint8_t>() + func_offset, |
264 _data + val_offset, 265 overlap_size); 266 267 // initialise the tracking of valid bytes if we have not 268 // used it already 269 if (bytesValid.empty()) 270 bytesValid.resize(getSize(), false); 271 --- 11 unchanged lines hidden (view full) --- 283 bytesValid[i] = true; 284 285 // check the bit after the update we just made 286 for (; all_bytes_valid && i < getSize(); ++i) 287 all_bytes_valid &= bytesValid[i]; 288 289 return all_bytes_valid; 290 } else if (isWrite()) { | 264 _data + val_offset, 265 overlap_size); 266 267 // initialise the tracking of valid bytes if we have not 268 // used it already 269 if (bytesValid.empty()) 270 bytesValid.resize(getSize(), false); 271 --- 11 unchanged lines hidden (view full) --- 283 bytesValid[i] = true; 284 285 // check the bit after the update we just made 286 for (; all_bytes_valid && i < getSize(); ++i) 287 all_bytes_valid &= bytesValid[i]; 288 289 return all_bytes_valid; 290 } else if (isWrite()) { |
291 memcpy(_data + val_offset, | 291 std::memcpy(_data + val_offset, |
292 getConstPtr<uint8_t>() + func_offset, 293 overlap_size); 294 } else { 295 panic("Don't know how to handle command %s\n", cmdString()); 296 } 297 298 // keep going with request by default 299 return false; --- 52 unchanged lines hidden (view full) --- 352 break; 353 default: 354 panic("%i isn't a supported word size.\n", getSize()); 355 } 356 357} 358 359void | 292 getConstPtr<uint8_t>() + func_offset, 293 overlap_size); 294 } else { 295 panic("Don't know how to handle command %s\n", cmdString()); 296 } 297 298 // keep going with request by default 299 return false; --- 52 unchanged lines hidden (view full) --- 352 break; 353 default: 354 panic("%i isn't a supported word size.\n", getSize()); 355 } 356 357} 358 359void |
360Packet::print(ostream &o, const int verbosity, const string &prefix) const | 360Packet::print(std::ostream &o, const int verbosity, 361 const std::string &prefix) const |
361{ 362 ccprintf(o, "%s%s [%x:%x]%s%s%s%s%s%s", prefix, cmdString(), 363 getAddr(), getAddr() + getSize() - 1, 364 req->isSecure() ? " (s)" : "", 365 req->isInstFetch() ? " IF" : "", 366 req->isUncacheable() ? " UC" : "", 367 isExpressSnoop() ? " ES" : "", 368 req->isToPOC() ? " PoC" : "", 369 req->isToPOU() ? " PoU" : ""); 370} 371 372std::string 373Packet::print() const { | 362{ 363 ccprintf(o, "%s%s [%x:%x]%s%s%s%s%s%s", prefix, cmdString(), 364 getAddr(), getAddr() + getSize() - 1, 365 req->isSecure() ? " (s)" : "", 366 req->isInstFetch() ? " IF" : "", 367 req->isUncacheable() ? " UC" : "", 368 isExpressSnoop() ? " ES" : "", 369 req->isToPOC() ? " PoC" : "", 370 req->isToPOU() ? " PoU" : ""); 371} 372 373std::string 374Packet::print() const { |
374 ostringstream str; | 375 std::ostringstream str; |
375 print(str); 376 return str.str(); 377} 378 | 376 print(str); 377 return str.str(); 378} 379 |
379Packet::PrintReqState::PrintReqState(ostream &_os, int _verbosity) 380 : curPrefixPtr(new string("")), os(_os), verbosity(_verbosity) | 380Packet::PrintReqState::PrintReqState(std::ostream &_os, int _verbosity) 381 : curPrefixPtr(new std::string("")), os(_os), verbosity(_verbosity) |
381{ 382 labelStack.push_back(LabelStackEntry("", curPrefixPtr)); 383} 384 385Packet::PrintReqState::~PrintReqState() 386{ 387 labelStack.pop_back(); 388 assert(labelStack.empty()); 389 delete curPrefixPtr; 390} 391 392Packet::PrintReqState:: | 382{ 383 labelStack.push_back(LabelStackEntry("", curPrefixPtr)); 384} 385 386Packet::PrintReqState::~PrintReqState() 387{ 388 labelStack.pop_back(); 389 assert(labelStack.empty()); 390 delete curPrefixPtr; 391} 392 393Packet::PrintReqState:: |
393LabelStackEntry::LabelStackEntry(const string &_label, string *_prefix) | 394LabelStackEntry::LabelStackEntry(const std::string &_label, 395 std::string *_prefix) |
394 : label(_label), prefix(_prefix), labelPrinted(false) 395{ 396} 397 398void | 396 : label(_label), prefix(_prefix), labelPrinted(false) 397{ 398} 399 400void |
399Packet::PrintReqState::pushLabel(const string &lbl, const string &prefix) | 401Packet::PrintReqState::pushLabel(const std::string &lbl, 402 const std::string &prefix) |
400{ 401 labelStack.push_back(LabelStackEntry(lbl, curPrefixPtr)); | 403{ 404 labelStack.push_back(LabelStackEntry(lbl, curPrefixPtr)); |
402 curPrefixPtr = new string(*curPrefixPtr); | 405 curPrefixPtr = new std::string(*curPrefixPtr); |
403 *curPrefixPtr += prefix; 404} 405 406void 407Packet::PrintReqState::popLabel() 408{ 409 delete curPrefixPtr; 410 curPrefixPtr = labelStack.back().prefix; --- 27 unchanged lines hidden --- | 406 *curPrefixPtr += prefix; 407} 408 409void 410Packet::PrintReqState::popLabel() 411{ 412 delete curPrefixPtr; 413 curPrefixPtr = labelStack.back().prefix; --- 27 unchanged lines hidden --- |