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> |
58 59#include "base/cprintf.hh" 60#include "base/logging.hh" 61#include "base/trace.hh" 62#include "mem/packet_access.hh" 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()) { |
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()) { |
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 |
360Packet::print(std::ostream &o, const int verbosity, 361 const std::string &prefix) 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 { |
375 std::ostringstream str; |
376 print(str); 377 return str.str(); 378} 379 |
380Packet::PrintReqState::PrintReqState(std::ostream &_os, int _verbosity) 381 : curPrefixPtr(new std::string("")), os(_os), verbosity(_verbosity) |
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:: |
394LabelStackEntry::LabelStackEntry(const std::string &_label, 395 std::string *_prefix) |
396 : label(_label), prefix(_prefix), labelPrinted(false) 397{ 398} 399 400void |
401Packet::PrintReqState::pushLabel(const std::string &lbl, 402 const std::string &prefix) |
403{ 404 labelStack.push_back(LabelStackEntry(lbl, curPrefixPtr)); |
405 curPrefixPtr = new std::string(*curPrefixPtr); |
406 *curPrefixPtr += prefix; 407} 408 409void 410Packet::PrintReqState::popLabel() 411{ 412 delete curPrefixPtr; 413 curPrefixPtr = labelStack.back().prefix; --- 27 unchanged lines hidden --- |