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 --- 27 unchanged lines hidden (view full) --- 36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 * 41 * Authors: Ron Dreslinski 42 * Steve Reinhardt 43 * Ali Saidi |
44 * Andreas Hansson |
45 */ 46 47/** 48 * @file 49 * Declaration of the Packet class. 50 */ 51 52#ifndef __MEM_PACKET_HH__ --- 174 unchanged lines hidden (view full) --- 227 * ultimate destination and back, possibly being conveyed by several 228 * different Packets along the way.) 229 */ 230class Packet : public FastAlloc, public Printable 231{ 232 public: 233 typedef uint32_t FlagsType; 234 typedef ::Flags<FlagsType> Flags; |
235 236 private: 237 static const FlagsType PUBLIC_FLAGS = 0x00000000; 238 static const FlagsType PRIVATE_FLAGS = 0x00007F0F; 239 static const FlagsType COPY_FLAGS = 0x0000000F; 240 241 static const FlagsType SHARED = 0x00000001; 242 // Special control flags 243 /// Special timing-mode atomic snoop for multi-level coherence. 244 static const FlagsType EXPRESS_SNOOP = 0x00000002; 245 /// Does supplier have exclusive copy? 246 /// Useful for multi-level coherence. 247 static const FlagsType SUPPLY_EXCLUSIVE = 0x00000004; 248 // Snoop response flags 249 static const FlagsType MEM_INHIBIT = 0x00000008; 250 /// Are the 'addr' and 'size' fields valid? 251 static const FlagsType VALID_ADDR = 0x00000100; 252 static const FlagsType VALID_SIZE = 0x00000200; |
253 /// Is the data pointer set to a value that shouldn't be freed 254 /// when the packet is destroyed? 255 static const FlagsType STATIC_DATA = 0x00001000; 256 /// The data pointer points to a value that should be freed when 257 /// the packet is destroyed. 258 static const FlagsType DYNAMIC_DATA = 0x00002000; 259 /// the data pointer points to an array (thus delete []) needs to 260 /// be called on it rather than simply delete. --- 37 unchanged lines hidden (view full) --- 298 * the timing responses need this information to be routed back to 299 * the appropriate port at a later point in time. The field can be 300 * updated (over-written) as the request packet passes through 301 * additional multiplexing components, and it is their 302 * responsibility to remember the original source port identifier, 303 * for example by using an appropriate sender state. The latter is 304 * done in the cache and bridge. 305 */ |
306 PortID src; |
307 308 /** 309 * Destination port identifier that is present on all response 310 * packets that passed through a multiplexing component as a 311 * request packet. The source port identifier is turned into a 312 * destination port identifier when the packet is turned into a 313 * response, and the destination is used, e.g. by the bus, to 314 * select the appropriate path through the interconnect. 315 */ |
316 PortID dest; |
317 318 /** 319 * The original value of the command field. Only valid when the 320 * current command field is an error condition; in that case, the 321 * previous contents of the command field are copied here. This 322 * field is *not* set on non-error responses. 323 */ 324 MemCmd origCmd; --- 154 unchanged lines hidden (view full) --- 479 assert(isResponse()); 480 cmd = MemCmd::BadAddressError; 481 } 482 483 bool wasNacked() const { return cmd == MemCmd::NetworkNackError; } 484 bool hadBadAddress() const { return cmd == MemCmd::BadAddressError; } 485 void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; } 486 |
487 bool isSrcValid() const { return src != InvalidPortID; } |
488 /// Accessor function to get the source index of the packet. |
489 PortID getSrc() const { assert(isSrcValid()); return src; } |
490 /// Accessor function to set the source index of the packet. |
491 void setSrc(PortID _src) { src = _src; } |
492 /// Reset source field, e.g. to retransmit packet on different bus. |
493 void clearSrc() { src = InvalidPortID; } |
494 |
495 bool isDestValid() const { return dest != InvalidPortID; } |
496 /// Accessor function for the destination index of the packet. |
497 PortID getDest() const { assert(isDestValid()); return dest; } |
498 /// Accessor function to set the destination index of the packet. |
499 void setDest(PortID _dest) { dest = _dest; } |
500 /// Reset destination field, e.g. to turn a response into a request again. |
501 void clearDest() { dest = InvalidPortID; } |
502 503 Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; } 504 unsigned getSize() const { assert(flags.isSet(VALID_SIZE)); return size; } 505 Addr getOffset(int blkSize) const { return getAddr() & (Addr)(blkSize - 1); } 506 507 /** 508 * It has been determined that the SC packet should successfully update 509 * memory. Therefore, convert this SC packet to a normal write. --- 20 unchanged lines hidden (view full) --- 530 531 /** 532 * Constructor. Note that a Request object must be constructed 533 * first, but the Requests's physical address and size fields need 534 * not be valid. The command must be supplied. 535 */ 536 Packet(Request *_req, MemCmd _cmd) 537 : cmd(_cmd), req(_req), data(NULL), |
538 src(InvalidPortID), dest(InvalidPortID), |
539 bytesValidStart(0), bytesValidEnd(0), 540 time(curTick()), senderState(NULL) 541 { 542 if (req->hasPaddr()) { 543 addr = req->getPaddr(); 544 flags.set(VALID_ADDR); 545 } 546 if (req->hasSize()) { --- 4 unchanged lines hidden (view full) --- 551 552 /** 553 * Alternate constructor if you are trying to create a packet with 554 * a request that is for a whole block, not the address from the 555 * req. this allows for overriding the size/addr of the req. 556 */ 557 Packet(Request *_req, MemCmd _cmd, int _blkSize) 558 : cmd(_cmd), req(_req), data(NULL), |
559 src(InvalidPortID), dest(InvalidPortID), |
560 bytesValidStart(0), bytesValidEnd(0), 561 time(curTick()), senderState(NULL) 562 { 563 if (req->hasPaddr()) { 564 addr = req->getPaddr() & ~(_blkSize - 1); 565 flags.set(VALID_ADDR); 566 } 567 size = _blkSize; --- 12 unchanged lines hidden (view full) --- 580 data(pkt->flags.isSet(STATIC_DATA) ? pkt->data : NULL), 581 addr(pkt->addr), size(pkt->size), src(pkt->src), dest(pkt->dest), 582 bytesValidStart(pkt->bytesValidStart), bytesValidEnd(pkt->bytesValidEnd), 583 time(curTick()), senderState(pkt->senderState) 584 { 585 if (!clearFlags) 586 flags.set(pkt->flags & COPY_FLAGS); 587 |
588 flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE)); |
589 flags.set(pkt->flags & STATIC_DATA); 590 591 } 592 593 /** 594 * clean up packet variables 595 */ 596 ~Packet() --- 41 unchanged lines hidden (view full) --- 638 origCmd = cmd; 639 cmd = cmd.responseCommand(); 640 641 // responses are never express, even if the snoop that 642 // triggered them was 643 flags.clear(EXPRESS_SNOOP); 644 645 dest = src; |
646 clearSrc(); |
647 } 648 649 void 650 makeAtomicResponse() 651 { 652 makeResponse(); 653 } 654 --- 219 unchanged lines hidden --- |