packet.cc (4622:f681e10844f3) | packet.cc (4626:ed8aacb19c03) |
---|---|
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; --- 45 unchanged lines hidden (view full) --- 54{ 55 /* InvalidCmd */ 56 { 0, InvalidCmd, "InvalidCmd" }, 57 /* ReadReq */ 58 { SET3(IsRead, IsRequest, NeedsResponse), ReadResp, "ReadReq" }, 59 /* ReadResp */ 60 { SET3(IsRead, IsResponse, HasData), InvalidCmd, "ReadResp" }, 61 /* WriteReq */ | 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; --- 45 unchanged lines hidden (view full) --- 54{ 55 /* InvalidCmd */ 56 { 0, InvalidCmd, "InvalidCmd" }, 57 /* ReadReq */ 58 { SET3(IsRead, IsRequest, NeedsResponse), ReadResp, "ReadReq" }, 59 /* ReadResp */ 60 { SET3(IsRead, IsResponse, HasData), InvalidCmd, "ReadResp" }, 61 /* WriteReq */ |
62 { SET4(IsWrite, IsRequest, NeedsResponse, HasData), | 62 { SET5(IsWrite, NeedsExclusive, IsRequest, NeedsResponse, HasData), |
63 WriteResp, "WriteReq" }, 64 /* WriteResp */ | 63 WriteResp, "WriteReq" }, 64 /* WriteResp */ |
65 { SET2(IsWrite, IsResponse), InvalidCmd, "WriteResp" }, | 65 { SET3(IsWrite, NeedsExclusive, IsResponse), InvalidCmd, "WriteResp" }, |
66 /* Writeback */ | 66 /* Writeback */ |
67 { SET4(IsWrite, IsRequest, HasData, NeedsResponse), | 67 { SET5(IsWrite, NeedsExclusive, IsRequest, HasData, NeedsResponse), |
68 WritebackAck, "Writeback" }, 69 /* WritebackAck */ | 68 WritebackAck, "Writeback" }, 69 /* WritebackAck */ |
70 { SET2(IsWrite, IsResponse), InvalidCmd, "WritebackAck" }, | 70 { SET3(IsWrite, NeedsExclusive, IsResponse), InvalidCmd, "WritebackAck" }, |
71 /* SoftPFReq */ 72 { SET4(IsRead, IsRequest, IsSWPrefetch, NeedsResponse), 73 SoftPFResp, "SoftPFReq" }, 74 /* HardPFReq */ 75 { SET4(IsRead, IsRequest, IsHWPrefetch, NeedsResponse), 76 HardPFResp, "HardPFReq" }, 77 /* SoftPFResp */ 78 { SET4(IsRead, IsResponse, IsSWPrefetch, HasData), 79 InvalidCmd, "SoftPFResp" }, 80 /* HardPFResp */ 81 { SET4(IsRead, IsResponse, IsHWPrefetch, HasData), 82 InvalidCmd, "HardPFResp" }, | 71 /* SoftPFReq */ 72 { SET4(IsRead, IsRequest, IsSWPrefetch, NeedsResponse), 73 SoftPFResp, "SoftPFReq" }, 74 /* HardPFReq */ 75 { SET4(IsRead, IsRequest, IsHWPrefetch, NeedsResponse), 76 HardPFResp, "HardPFReq" }, 77 /* SoftPFResp */ 78 { SET4(IsRead, IsResponse, IsSWPrefetch, HasData), 79 InvalidCmd, "SoftPFResp" }, 80 /* HardPFResp */ 81 { SET4(IsRead, IsResponse, IsHWPrefetch, HasData), 82 InvalidCmd, "HardPFResp" }, |
83 /* InvalidateReq */ 84 { SET2(IsInvalidate, IsRequest), InvalidCmd, "InvalidateReq" }, | |
85 /* WriteInvalidateReq */ | 83 /* WriteInvalidateReq */ |
86 { SET5(IsWrite, IsInvalidate, IsRequest, HasData, NeedsResponse), | 84 { SET6(IsWrite, NeedsExclusive, IsInvalidate, 85 IsRequest, HasData, NeedsResponse), |
87 WriteInvalidateResp, "WriteInvalidateReq" }, 88 /* WriteInvalidateResp */ | 86 WriteInvalidateResp, "WriteInvalidateReq" }, 87 /* WriteInvalidateResp */ |
89 { SET3(IsWrite, IsInvalidate, IsResponse), | 88 { SET4(IsWrite, NeedsExclusive, IsInvalidate, IsResponse), |
90 InvalidCmd, "WriteInvalidateResp" }, 91 /* UpgradeReq */ 92 { SET3(IsInvalidate, IsRequest, IsUpgrade), InvalidCmd, "UpgradeReq" }, 93 /* ReadExReq */ | 89 InvalidCmd, "WriteInvalidateResp" }, 90 /* UpgradeReq */ 91 { SET3(IsInvalidate, IsRequest, IsUpgrade), InvalidCmd, "UpgradeReq" }, 92 /* ReadExReq */ |
94 { SET4(IsRead, IsInvalidate, IsRequest, NeedsResponse), | 93 { SET5(IsRead, NeedsExclusive, IsInvalidate, IsRequest, NeedsResponse), |
95 ReadExResp, "ReadExReq" }, 96 /* ReadExResp */ | 94 ReadExResp, "ReadExReq" }, 95 /* ReadExResp */ |
97 { SET4(IsRead, IsInvalidate, IsResponse, HasData), | 96 { SET5(IsRead, NeedsExclusive, IsInvalidate, IsResponse, HasData), |
98 InvalidCmd, "ReadExResp" }, | 97 InvalidCmd, "ReadExResp" }, |
98 /* LoadLockedReq */ 99 { SET4(IsRead, IsLocked, IsRequest, NeedsResponse), 100 ReadResp, "LoadLockedReq" }, 101 /* LoadLockedResp */ 102 { SET4(IsRead, IsLocked, IsResponse, HasData), 103 InvalidCmd, "LoadLockedResp" }, 104 /* StoreCondReq */ 105 { SET6(IsWrite, NeedsExclusive, IsLocked, 106 IsRequest, NeedsResponse, HasData), 107 StoreCondResp, "StoreCondReq" }, 108 /* StoreCondResp */ 109 { SET4(IsWrite, NeedsExclusive, IsLocked, IsResponse), 110 InvalidCmd, "StoreCondResp" }, |
|
99 /* SwapReq -- for Swap ldstub type operations */ | 111 /* SwapReq -- for Swap ldstub type operations */ |
100 { SET4(IsReadWrite, IsRequest, HasData, NeedsResponse), | 112 { SET6(IsRead, IsWrite, NeedsExclusive, IsRequest, HasData, NeedsResponse), |
101 SwapResp, "SwapReq" }, 102 /* SwapResp -- for Swap ldstub type operations */ | 113 SwapResp, "SwapReq" }, 114 /* SwapResp -- for Swap ldstub type operations */ |
103 { SET3(IsReadWrite, IsResponse, HasData), | 115 { SET5(IsRead, IsWrite, NeedsExclusive, IsResponse, HasData), |
104 InvalidCmd, "SwapResp" } 105}; 106 107 108/** delete the data pointed to in the data pointer. Ok to call to matter how 109 * data was allocted. */ 110void 111Packet::deleteData() --- 54 unchanged lines hidden (view full) --- 166 //Don't toggle if it isn't a read/write response 167 result = fixPacket(func, timing); 168 } 169 170 return result; 171} 172 173bool | 116 InvalidCmd, "SwapResp" } 117}; 118 119 120/** delete the data pointed to in the data pointer. Ok to call to matter how 121 * data was allocted. */ 122void 123Packet::deleteData() --- 54 unchanged lines hidden (view full) --- 178 //Don't toggle if it isn't a read/write response 179 result = fixPacket(func, timing); 180 } 181 182 return result; 183} 184 185bool |
174fixPacket(PacketPtr func, PacketPtr timing) | 186Packet::checkFunctional(Addr addr, int size, uint8_t *data) |
175{ | 187{ |
176 Addr funcStart = func->getAddr(); 177 Addr funcEnd = func->getAddr() + func->getSize() - 1; 178 Addr timingStart = timing->getAddr(); 179 Addr timingEnd = timing->getAddr() + timing->getSize() - 1; | 188 Addr func_start = getAddr(); 189 Addr func_end = getAddr() + getSize() - 1; 190 Addr val_start = addr; 191 Addr val_end = val_start + size - 1; |
180 | 192 |
181 assert(!(funcStart > timingEnd || timingStart > funcEnd)); | 193 if (func_start > val_end || val_start > func_end) { 194 // no intersection 195 return false; 196 } |
182 | 197 |
183 // this packet can't solve our problem, continue on 184 if (!timing->hasData()) 185 return true; | 198 // offset of functional request into supplied value (could be 199 // negative if partial overlap) 200 int offset = func_start - val_start; |
186 | 201 |
187 if (func->isRead()) { 188 if (funcStart >= timingStart && funcEnd <= timingEnd) { 189 func->allocate(); 190 std::memcpy(func->getPtr<uint8_t>(), timing->getPtr<uint8_t>() + 191 funcStart - timingStart, func->getSize()); 192 func->result = Packet::Success; 193 func->flags |= SATISFIED; 194 return false; | 202 if (isRead()) { 203 if (func_start >= val_start && func_end <= val_end) { 204 allocate(); 205 std::memcpy(getPtr<uint8_t>(), data + offset, getSize()); 206 result = Packet::Success; 207 return true; |
195 } else { 196 // In this case the timing packet only partially satisfies 197 // the request, so we would need more information to make 198 // this work. Like bytes valid in the packet or 199 // something, so the request could continue and get this 200 // bit of possibly newer data along with the older data 201 // not written to yet. | 208 } else { 209 // In this case the timing packet only partially satisfies 210 // the request, so we would need more information to make 211 // this work. Like bytes valid in the packet or 212 // something, so the request could continue and get this 213 // bit of possibly newer data along with the older data 214 // not written to yet. |
202 panic("Timing packet only partially satisfies the functional" 203 "request. Now what?"); | 215 panic("Memory value only partially satisfies the functional " 216 "request. Now what?"); |
204 } | 217 } |
205 } else if (func->isWrite()) { 206 if (funcStart >= timingStart) { 207 std::memcpy(timing->getPtr<uint8_t>() + (funcStart - timingStart), 208 func->getPtr<uint8_t>(), 209 (std::min(funcEnd, timingEnd) - funcStart) + 1); 210 } else { // timingStart > funcStart 211 std::memcpy(timing->getPtr<uint8_t>(), 212 func->getPtr<uint8_t>() + (timingStart - funcStart), 213 (std::min(funcEnd, timingEnd) - timingStart) + 1); | 218 } else if (isWrite()) { 219 if (offset >= 0) { 220 std::memcpy(data + offset, getPtr<uint8_t>(), 221 (std::min(func_end, val_end) - func_start) + 1); 222 } else { // val_start > func_start 223 std::memcpy(data, getPtr<uint8_t>() - offset, 224 (std::min(func_end, val_end) - val_start) + 1); |
214 } 215 // we always want to keep going with a write | 225 } 226 // we always want to keep going with a write |
216 return true; | 227 return false; |
217 } else | 228 } else |
218 panic("Don't know how to handle command type %#x\n", 219 func->cmdToIndex()); 220 | 229 panic("Don't know how to handle command %s\n", cmdString()); |
221} 222 223 224std::ostream & 225operator<<(std::ostream &o, const Packet &p) 226{ 227 228 o << "[0x"; --- 13 unchanged lines hidden (view full) --- 242 o << "Nacked "; 243 if (p.result == Packet::Unknown) 244 o << "Inflight "; 245 246 if (p.isRead()) 247 o << "Read "; 248 if (p.isWrite()) 249 o << "Write "; | 230} 231 232 233std::ostream & 234operator<<(std::ostream &o, const Packet &p) 235{ 236 237 o << "[0x"; --- 13 unchanged lines hidden (view full) --- 251 o << "Nacked "; 252 if (p.result == Packet::Unknown) 253 o << "Inflight "; 254 255 if (p.isRead()) 256 o << "Read "; 257 if (p.isWrite()) 258 o << "Write "; |
250 if (p.isReadWrite()) 251 o << "Read/Write "; | |
252 if (p.isInvalidate()) 253 o << "Invalidate "; 254 if (p.isRequest()) 255 o << "Request "; 256 if (p.isResponse()) 257 o << "Response "; 258 if (p.hasData()) 259 o << "w/Data "; 260 261 o << std::endl; 262 return o; 263} 264 | 259 if (p.isInvalidate()) 260 o << "Invalidate "; 261 if (p.isRequest()) 262 o << "Request "; 263 if (p.isResponse()) 264 o << "Response "; 265 if (p.hasData()) 266 o << "w/Data "; 267 268 o << std::endl; 269 return o; 270} 271 |