packet.hh (5012:c0a28154d002) | packet.hh (5314:e902f12a3af1) |
---|---|
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 31 unchanged lines hidden (view full) --- 40 41#include <cassert> 42#include <list> 43#include <bitset> 44 45#include "base/compiler.hh" 46#include "base/fast_alloc.hh" 47#include "base/misc.hh" | 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 31 unchanged lines hidden (view full) --- 40 41#include <cassert> 42#include <list> 43#include <bitset> 44 45#include "base/compiler.hh" 46#include "base/fast_alloc.hh" 47#include "base/misc.hh" |
48#include "base/printable.hh" |
|
48#include "mem/request.hh" 49#include "sim/host.hh" 50#include "sim/core.hh" 51 52 53struct Packet; 54typedef Packet *PacketPtr; 55typedef uint8_t* PacketDataPtr; --- 30 unchanged lines hidden (view full) --- 86 SwapResp, 87 // Error responses 88 // @TODO these should be classified as responses rather than 89 // requests; coding them as requests initially for backwards 90 // compatibility 91 NetworkNackError, // nacked at network layer (not by protocol) 92 InvalidDestError, // packet dest field invalid 93 BadAddressError, // memory address invalid | 49#include "mem/request.hh" 50#include "sim/host.hh" 51#include "sim/core.hh" 52 53 54struct Packet; 55typedef Packet *PacketPtr; 56typedef uint8_t* PacketDataPtr; --- 30 unchanged lines hidden (view full) --- 87 SwapResp, 88 // Error responses 89 // @TODO these should be classified as responses rather than 90 // requests; coding them as requests initially for backwards 91 // compatibility 92 NetworkNackError, // nacked at network layer (not by protocol) 93 InvalidDestError, // packet dest field invalid 94 BadAddressError, // memory address invalid |
95 // Fake simulator-only commands 96 PrintReq, // Print state matching address |
|
94 NUM_MEM_CMDS 95 }; 96 97 private: 98 /** List of command attributes. */ 99 enum Attribute 100 { 101 IsRead, //!< Data flows from responder to requester --- 4 unchanged lines hidden (view full) --- 106 IsRequest, //!< Issued by requester 107 IsResponse, //!< Issue by responder 108 NeedsResponse, //!< Requester needs response from target 109 IsSWPrefetch, 110 IsHWPrefetch, 111 IsLocked, //!< Alpha/MIPS LL or SC access 112 HasData, //!< There is an associated payload 113 IsError, //!< Error response | 97 NUM_MEM_CMDS 98 }; 99 100 private: 101 /** List of command attributes. */ 102 enum Attribute 103 { 104 IsRead, //!< Data flows from responder to requester --- 4 unchanged lines hidden (view full) --- 109 IsRequest, //!< Issued by requester 110 IsResponse, //!< Issue by responder 111 NeedsResponse, //!< Requester needs response from target 112 IsSWPrefetch, 113 IsHWPrefetch, 114 IsLocked, //!< Alpha/MIPS LL or SC access 115 HasData, //!< There is an associated payload 116 IsError, //!< Error response |
117 IsPrint, //!< Print state matching address (for debugging) |
|
114 NUM_COMMAND_ATTRIBUTES 115 }; 116 117 /** Structure that defines attributes and other data associated 118 * with a Command. */ 119 struct CommandInfo { 120 /** Set of attribute flags. */ 121 const std::bitset<NUM_COMMAND_ATTRIBUTES> attributes; --- 23 unchanged lines hidden (view full) --- 145 bool isResponse() const { return testCmdAttrib(IsResponse); } 146 bool needsExclusive() const { return testCmdAttrib(NeedsExclusive); } 147 bool needsResponse() const { return testCmdAttrib(NeedsResponse); } 148 bool isInvalidate() const { return testCmdAttrib(IsInvalidate); } 149 bool hasData() const { return testCmdAttrib(HasData); } 150 bool isReadWrite() const { return isRead() && isWrite(); } 151 bool isLocked() const { return testCmdAttrib(IsLocked); } 152 bool isError() const { return testCmdAttrib(IsError); } | 118 NUM_COMMAND_ATTRIBUTES 119 }; 120 121 /** Structure that defines attributes and other data associated 122 * with a Command. */ 123 struct CommandInfo { 124 /** Set of attribute flags. */ 125 const std::bitset<NUM_COMMAND_ATTRIBUTES> attributes; --- 23 unchanged lines hidden (view full) --- 149 bool isResponse() const { return testCmdAttrib(IsResponse); } 150 bool needsExclusive() const { return testCmdAttrib(NeedsExclusive); } 151 bool needsResponse() const { return testCmdAttrib(NeedsResponse); } 152 bool isInvalidate() const { return testCmdAttrib(IsInvalidate); } 153 bool hasData() const { return testCmdAttrib(HasData); } 154 bool isReadWrite() const { return isRead() && isWrite(); } 155 bool isLocked() const { return testCmdAttrib(IsLocked); } 156 bool isError() const { return testCmdAttrib(IsError); } |
157 bool isPrint() const { return testCmdAttrib(IsPrint); } |
|
153 154 const Command responseCommand() const { 155 return commandInfo[cmd].response; 156 } 157 158 /** Return the string to a cmd given by idx. */ 159 const std::string &toString() const { 160 return commandInfo[cmd].str; --- 21 unchanged lines hidden (view full) --- 182 183/** 184 * A Packet is used to encapsulate a transfer between two objects in 185 * the memory system (e.g., the L1 and L2 cache). (In contrast, a 186 * single Request travels all the way from the requester to the 187 * ultimate destination and back, possibly being conveyed by several 188 * different Packets along the way.) 189 */ | 158 159 const Command responseCommand() const { 160 return commandInfo[cmd].response; 161 } 162 163 /** Return the string to a cmd given by idx. */ 164 const std::string &toString() const { 165 return commandInfo[cmd].str; --- 21 unchanged lines hidden (view full) --- 187 188/** 189 * A Packet is used to encapsulate a transfer between two objects in 190 * the memory system (e.g., the L1 and L2 cache). (In contrast, a 191 * single Request travels all the way from the requester to the 192 * ultimate destination and back, possibly being conveyed by several 193 * different Packets along the way.) 194 */ |
190class Packet : public FastAlloc | 195class Packet : public FastAlloc, public Printable |
191{ 192 public: 193 194 typedef MemCmd::Command Command; 195 196 /** The command field of the packet. */ 197 MemCmd cmd; 198 --- 90 unchanged lines hidden (view full) --- 289 * needed to process it. A specific subclass would be derived 290 * from this to carry state specific to a particular sending 291 * device. */ 292 class SenderState : public FastAlloc { 293 public: 294 virtual ~SenderState() {} 295 }; 296 | 196{ 197 public: 198 199 typedef MemCmd::Command Command; 200 201 /** The command field of the packet. */ 202 MemCmd cmd; 203 --- 90 unchanged lines hidden (view full) --- 294 * needed to process it. A specific subclass would be derived 295 * from this to carry state specific to a particular sending 296 * device. */ 297 class SenderState : public FastAlloc { 298 public: 299 virtual ~SenderState() {} 300 }; 301 |
302 class PrintReqState : public SenderState { 303 class LabelStackEntry { 304 public: 305 const std::string label; 306 std::string *prefix; 307 bool labelPrinted; 308 LabelStackEntry(const std::string &_label, 309 std::string *_prefix); 310 }; 311 312 typedef std::list<LabelStackEntry> LabelStack; 313 LabelStack labelStack; 314 315 std::string *curPrefixPtr; 316 317 public: 318 std::ostream &os; 319 const int verbosity; 320 321 PrintReqState(std::ostream &os, int verbosity = 0); 322 ~PrintReqState(); 323 324 const std::string &curPrefix() { return *curPrefixPtr; } 325 void pushLabel(const std::string &lbl, 326 const std::string &prefix = " "); 327 void popLabel(); 328 void printLabels(); 329 void printObj(Printable *obj); 330 }; 331 |
|
297 /** This packet's sender state. Devices should use dynamic_cast<> 298 * to cast to the state appropriate to the sender. */ 299 SenderState *senderState; 300 301 /** Return the string name of the cmd field (for debugging and 302 * tracing). */ 303 const std::string &cmdString() const { return cmd.toString(); } 304 --- 6 unchanged lines hidden (view full) --- 311 bool isResponse() const { return cmd.isResponse(); } 312 bool needsExclusive() const { return cmd.needsExclusive(); } 313 bool needsResponse() const { return cmd.needsResponse(); } 314 bool isInvalidate() const { return cmd.isInvalidate(); } 315 bool hasData() const { return cmd.hasData(); } 316 bool isReadWrite() const { return cmd.isReadWrite(); } 317 bool isLocked() const { return cmd.isLocked(); } 318 bool isError() const { return cmd.isError(); } | 332 /** This packet's sender state. Devices should use dynamic_cast<> 333 * to cast to the state appropriate to the sender. */ 334 SenderState *senderState; 335 336 /** Return the string name of the cmd field (for debugging and 337 * tracing). */ 338 const std::string &cmdString() const { return cmd.toString(); } 339 --- 6 unchanged lines hidden (view full) --- 346 bool isResponse() const { return cmd.isResponse(); } 347 bool needsExclusive() const { return cmd.needsExclusive(); } 348 bool needsResponse() const { return cmd.needsResponse(); } 349 bool isInvalidate() const { return cmd.isInvalidate(); } 350 bool hasData() const { return cmd.hasData(); } 351 bool isReadWrite() const { return cmd.isReadWrite(); } 352 bool isLocked() const { return cmd.isLocked(); } 353 bool isError() const { return cmd.isError(); } |
354 bool isPrint() const { return cmd.isPrint(); } |
|
319 320 // Snoop flags 321 void assertMemInhibit() { flags[MemInhibit] = true; } 322 bool memInhibitAsserted() { return flags[MemInhibit]; } 323 void assertShared() { flags[Shared] = true; } 324 bool sharedAsserted() { return flags[Shared]; } 325 326 // Special control flags --- 241 unchanged lines hidden (view full) --- 568 569 /** 570 * Check a functional request against a memory value represented 571 * by a base/size pair and an associated data array. If the 572 * functional request is a read, it may be satisfied by the memory 573 * value. If the functional request is a write, it may update the 574 * memory value. 575 */ | 355 356 // Snoop flags 357 void assertMemInhibit() { flags[MemInhibit] = true; } 358 bool memInhibitAsserted() { return flags[MemInhibit]; } 359 void assertShared() { flags[Shared] = true; } 360 bool sharedAsserted() { return flags[Shared]; } 361 362 // Special control flags --- 241 unchanged lines hidden (view full) --- 604 605 /** 606 * Check a functional request against a memory value represented 607 * by a base/size pair and an associated data array. If the 608 * functional request is a read, it may be satisfied by the memory 609 * value. If the functional request is a write, it may update the 610 * memory value. 611 */ |
576 bool checkFunctional(Addr base, int size, uint8_t *data); | 612 bool checkFunctional(Printable *obj, Addr base, int size, uint8_t *data); |
577 578 /** 579 * Check a functional request against a memory value stored in | 613 614 /** 615 * Check a functional request against a memory value stored in |
580 * another packet (i.e. an in-transit request or response). | 616 * another packet (i.e. an in-transit request or response). If 617 * possible, the request will be satisfied and transformed 618 * in-place into a response (at which point no further checking 619 * need be done). 620 * 621 * @return True if the memory location addressed by the request 622 * overlaps with the location addressed by otherPkt. |
581 */ 582 bool checkFunctional(PacketPtr otherPkt) { | 623 */ 624 bool checkFunctional(PacketPtr otherPkt) { |
583 return (otherPkt->hasData() && 584 checkFunctional(otherPkt->getAddr(), otherPkt->getSize(), 585 otherPkt->getPtr<uint8_t>())); | 625 return checkFunctional(otherPkt, 626 otherPkt->getAddr(), otherPkt->getSize(), 627 otherPkt->hasData() ? 628 otherPkt->getPtr<uint8_t>() : NULL); |
586 } | 629 } |
587}; | |
588 | 630 |
589std::ostream & operator<<(std::ostream &o, const Packet &p); | 631 void pushLabel(const std::string &lbl) { 632 if (isPrint()) { 633 dynamic_cast<PrintReqState*>(senderState)->pushLabel(lbl); 634 } 635 } |
590 | 636 |
637 void popLabel() { 638 if (isPrint()) { 639 dynamic_cast<PrintReqState*>(senderState)->popLabel(); 640 } 641 } 642 643 void print(std::ostream &o, int verbosity = 0, 644 const std::string &prefix = "") const; 645}; 646 |
|
591#endif //__MEM_PACKET_HH | 647#endif //__MEM_PACKET_HH |