packet.cc (4021:bdae6aac5c43) | packet.cc (4022:c422464ca16e) |
---|---|
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; --- 27 unchanged lines hidden (view full) --- 36 */ 37 38#include <iostream> 39#include <cstring> 40#include "base/misc.hh" 41#include "base/trace.hh" 42#include "mem/packet.hh" 43 | 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; --- 27 unchanged lines hidden (view full) --- 36 */ 37 38#include <iostream> 39#include <cstring> 40#include "base/misc.hh" 41#include "base/trace.hh" 42#include "mem/packet.hh" 43 |
44static const std::string ReadReqString("ReadReq"); 45static const std::string WriteReqString("WriteReq"); 46static const std::string WriteReqNoAckString("WriteReqNoAck|Writeback"); 47static const std::string ReadRespString("ReadResp"); 48static const std::string WriteRespString("WriteResp"); 49static const std::string SoftPFReqString("SoftPFReq"); 50static const std::string SoftPFRespString("SoftPFResp"); 51static const std::string HardPFReqString("HardPFReq"); 52static const std::string HardPFRespString("HardPFResp"); 53static const std::string InvalidateReqString("InvalidateReq"); 54static const std::string WriteInvalidateReqString("WriteInvalidateReq"); 55static const std::string WriteInvalidateRespString("WriteInvalidateResp"); 56static const std::string UpgradeReqString("UpgradeReq"); 57static const std::string ReadExReqString("ReadExReq"); 58static const std::string ReadExRespString("ReadExResp"); 59static const std::string OtherCmdString("<other>"); | 44// The one downside to bitsets is that static initializers can get ugly. 45#define SET1(a1) (1 << (a1)) 46#define SET2(a1, a2) (SET1(a1) | SET1(a2)) 47#define SET3(a1, a2, a3) (SET2(a1, a2) | SET1(a3)) 48#define SET4(a1, a2, a3, a4) (SET3(a1, a2, a3) | SET1(a4)) 49#define SET5(a1, a2, a3, a4, a5) (SET4(a1, a2, a3, a4) | SET1(a5)) 50#define SET6(a1, a2, a3, a4, a5, a6) (SET5(a1, a2, a3, a4, a5) | SET1(a6)) |
60 | 51 |
61const std::string & 62Packet::cmdString() const | 52const MemCmd::CommandInfo 53MemCmd::commandInfo[] = |
63{ | 54{ |
64 switch (cmd) { 65 case ReadReq: return ReadReqString; 66 case WriteReq: return WriteReqString; 67 case WriteReqNoAck: return WriteReqNoAckString; 68 case ReadResp: return ReadRespString; 69 case WriteResp: return WriteRespString; 70 case SoftPFReq: return SoftPFReqString; 71 case SoftPFResp: return SoftPFRespString; 72 case HardPFReq: return HardPFReqString; 73 case HardPFResp: return HardPFRespString; 74 case InvalidateReq: return InvalidateReqString; 75 case WriteInvalidateReq:return WriteInvalidateReqString; 76 case WriteInvalidateResp:return WriteInvalidateRespString; 77 case UpgradeReq: return UpgradeReqString; 78 case ReadExReq: return ReadExReqString; 79 case ReadExResp: return ReadExRespString; 80 default: return OtherCmdString; 81 } 82} | 55 /* InvalidCmd */ 56 { 0, InvalidCmd, "InvalidCmd" }, 57 /* ReadReq */ 58 { SET3(IsRead, IsRequest, NeedsResponse), ReadResp, "ReadReq" }, 59 /* WriteReq */ 60 { SET4(IsWrite, IsRequest, NeedsResponse, HasData), 61 WriteResp, "WriteReq" }, 62 /* WriteReqNoAck */ 63 { SET3(IsWrite, IsRequest, HasData), InvalidCmd, "WriteReqNoAck" }, 64 /* ReadResp */ 65 { SET3(IsRead, IsResponse, HasData), InvalidCmd, "ReadResp" }, 66 /* WriteResp */ 67 { SET2(IsWrite, IsResponse), InvalidCmd, "WriteResp" }, 68 /* Writeback */ 69 { SET3(IsWrite, IsRequest, HasData), InvalidCmd, "Writeback" }, 70 /* SoftPFReq */ 71 { SET4(IsRead, IsRequest, IsSWPrefetch, NeedsResponse), 72 SoftPFResp, "SoftPFReq" }, 73 /* HardPFReq */ 74 { SET4(IsRead, IsRequest, IsHWPrefetch, NeedsResponse), 75 HardPFResp, "HardPFReq" }, 76 /* SoftPFResp */ 77 { SET4(IsRead, IsResponse, IsSWPrefetch, HasData), 78 InvalidCmd, "SoftPFResp" }, 79 /* HardPFResp */ 80 { SET4(IsRead, IsResponse, IsHWPrefetch, HasData), 81 InvalidCmd, "HardPFResp" }, 82 /* InvalidateReq */ 83 { SET2(IsInvalidate, IsRequest), InvalidCmd, "InvalidateReq" }, 84 /* WriteInvalidateReq */ 85 { SET5(IsWrite, IsInvalidate, IsRequest, HasData, NeedsResponse), 86 WriteInvalidateResp, "WriteInvalidateReq" }, 87 /* WriteInvalidateResp */ 88 { SET5(IsWrite, IsInvalidate, IsRequest, NeedsResponse, IsResponse), 89 InvalidCmd, "WriteInvalidateResp" }, 90 /* UpgradeReq */ 91 { SET3(IsInvalidate, IsRequest, IsUpgrade), InvalidCmd, "UpgradeReq" }, 92 /* ReadExReq */ 93 { SET4(IsRead, IsInvalidate, IsRequest, NeedsResponse), 94 ReadExResp, "ReadExReq" }, 95 /* ReadExResp */ 96 { SET4(IsRead, IsInvalidate, IsResponse, HasData), 97 InvalidCmd, "ReadExResp" } 98}; |
83 | 99 |
84const std::string & 85Packet::cmdIdxToString(Packet::Command idx) 86{ 87 switch (idx) { 88 case ReadReq: return ReadReqString; 89 case WriteReq: return WriteReqString; 90 case WriteReqNoAck: return WriteReqNoAckString; 91 case ReadResp: return ReadRespString; 92 case WriteResp: return WriteRespString; 93 case SoftPFReq: return SoftPFReqString; 94 case SoftPFResp: return SoftPFRespString; 95 case HardPFReq: return HardPFReqString; 96 case HardPFResp: return HardPFRespString; 97 case InvalidateReq: return InvalidateReqString; 98 case WriteInvalidateReq:return WriteInvalidateReqString; 99 case WriteInvalidateResp:return WriteInvalidateRespString; 100 case UpgradeReq: return UpgradeReqString; 101 case ReadExReq: return ReadExReqString; 102 case ReadExResp: return ReadExRespString; 103 default: return OtherCmdString; 104 } 105} | |
106 107/** delete the data pointed to in the data pointer. Ok to call to matter how 108 * data was allocted. */ 109void 110Packet::deleteData() 111{ 112 assert(staticData || dynamicData); 113 if (staticData) --- 30 unchanged lines hidden (view full) --- 144} 145 146bool 147fixDelayedResponsePacket(PacketPtr func, PacketPtr timing) 148{ 149 bool result; 150 151 if (timing->isRead() || timing->isWrite()) { | 100 101/** delete the data pointed to in the data pointer. Ok to call to matter how 102 * data was allocted. */ 103void 104Packet::deleteData() 105{ 106 assert(staticData || dynamicData); 107 if (staticData) --- 30 unchanged lines hidden (view full) --- 138} 139 140bool 141fixDelayedResponsePacket(PacketPtr func, PacketPtr timing) 142{ 143 bool result; 144 145 if (timing->isRead() || timing->isWrite()) { |
152 timing->toggleData(); | 146 // Ugly hack to deal with the fact that we queue the requests 147 // and don't convert them to responses until we issue them on 148 // the bus. I tried to avoid this by converting packets to 149 // responses right away, but this breaks during snoops where a 150 // responder may do the conversion before other caches have 151 // done the snoop. Would work if we copied the packet instead 152 // of just hanging on to a pointer. 153 MemCmd oldCmd = timing->cmd; 154 timing->cmd = timing->cmd.responseCommand(); |
153 result = fixPacket(func, timing); | 155 result = fixPacket(func, timing); |
154 timing->toggleData(); | 156 timing->cmd = oldCmd; |
155 } 156 else { 157 //Don't toggle if it isn't a read/write response 158 result = fixPacket(func, timing); 159 } 160 161 return result; 162} --- 90 unchanged lines hidden --- | 157 } 158 else { 159 //Don't toggle if it isn't a read/write response 160 result = fixPacket(func, timing); 161 } 162 163 return result; 164} --- 90 unchanged lines hidden --- |