1/* 2 * Copyright (c) 2012-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 --- 306 unchanged lines hidden (view full) --- 315 typedef MemCmd::Command Command; 316 317 /// The command field of the packet. 318 MemCmd cmd; 319 320 const PacketId id; 321 322 /// A pointer to the original request. |
323 RequestPtr req; |
324 325 private: 326 /** 327 * A pointer to the data being transferred. It can be different 328 * sizes at each level of the hierarchy so it belongs to the 329 * packet, not request. This may or may not be populated when a 330 * responder receives the packet. If not populated memory should 331 * be allocated. --- 408 unchanged lines hidden (view full) --- 740 cmd = MemCmd::ReadReq; 741 } 742 743 /** 744 * Constructor. Note that a Request object must be constructed 745 * first, but the Requests's physical address and size fields need 746 * not be valid. The command must be supplied. 747 */ |
748 Packet(const RequestPtr &_req, MemCmd _cmd) 749 : cmd(_cmd), id((PacketId)_req.get()), req(_req), data(nullptr), 750 addr(0), _isSecure(false), size(0), headerDelay(0), snoopDelay(0), |
751 payloadDelay(0), senderState(NULL) 752 { 753 if (req->hasPaddr()) { 754 addr = req->getPaddr(); 755 flags.set(VALID_ADDR); 756 _isSecure = req->isSecure(); 757 } 758 if (req->hasSize()) { 759 size = req->getSize(); 760 flags.set(VALID_SIZE); 761 } 762 } 763 764 /** 765 * Alternate constructor if you are trying to create a packet with 766 * a request that is for a whole block, not the address from the 767 * req. this allows for overriding the size/addr of the req. 768 */ |
769 Packet(const RequestPtr &_req, MemCmd _cmd, int _blkSize, PacketId _id = 0) 770 : cmd(_cmd), id(_id ? _id : (PacketId)_req.get()), req(_req), 771 data(nullptr), addr(0), _isSecure(false), headerDelay(0), 772 snoopDelay(0), payloadDelay(0), senderState(NULL) |
773 { 774 if (req->hasPaddr()) { 775 addr = req->getPaddr() & ~(_blkSize - 1); 776 flags.set(VALID_ADDR); 777 _isSecure = req->isSecure(); 778 } 779 size = _blkSize; 780 flags.set(VALID_SIZE); --- 37 unchanged lines hidden (view full) --- 818 } 819 } 820 } 821 822 /** 823 * Generate the appropriate read MemCmd based on the Request flags. 824 */ 825 static MemCmd |
826 makeReadCmd(const RequestPtr &req) |
827 { 828 if (req->isLLSC()) 829 return MemCmd::LoadLockedReq; 830 else if (req->isPrefetch()) 831 return MemCmd::SoftPFReq; 832 else 833 return MemCmd::ReadReq; 834 } 835 836 /** 837 * Generate the appropriate write MemCmd based on the Request flags. 838 */ 839 static MemCmd |
840 makeWriteCmd(const RequestPtr &req) |
841 { 842 if (req->isLLSC()) 843 return MemCmd::StoreCondReq; 844 else if (req->isSwap()) 845 return MemCmd::SwapReq; 846 else if (req->isCacheInvalidate()) { 847 return req->isCacheClean() ? MemCmd::CleanInvalidReq : 848 MemCmd::InvalidateReq; 849 } else if (req->isCacheClean()) { 850 return MemCmd::CleanSharedReq; 851 } else 852 return MemCmd::WriteReq; 853 } 854 855 /** 856 * Constructor-like methods that return Packets based on Request objects. 857 * Fine-tune the MemCmd type if it's not a vanilla read or write. 858 */ 859 static PacketPtr |
860 createRead(const RequestPtr &req) |
861 { 862 return new Packet(req, makeReadCmd(req)); 863 } 864 865 static PacketPtr |
866 createWrite(const RequestPtr &req) |
867 { 868 return new Packet(req, makeWriteCmd(req)); 869 } 870 871 /** 872 * clean up packet variables 873 */ 874 ~Packet() 875 { |
876 deleteData(); 877 } 878 879 /** 880 * Take a request packet and modify it in place to be suitable for 881 * returning as a response to that request. 882 */ 883 void --- 361 unchanged lines hidden --- |