packet.cc (3262:5f96609a30ef) | packet.cc (3286:21d9d32ab8ab) |
---|---|
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; --- 20 unchanged lines hidden (view full) --- 29 * Steve Reinhardt 30 */ 31 32/** 33 * @file 34 * Definition of the Packet Class, a packet is a transaction occuring 35 * between a single level of the memory heirarchy (ie L1->L2). 36 */ | 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; --- 20 unchanged lines hidden (view full) --- 29 * Steve Reinhardt 30 */ 31 32/** 33 * @file 34 * Definition of the Packet Class, a packet is a transaction occuring 35 * between a single level of the memory heirarchy (ie L1->L2). 36 */ |
37 38#include <iostream> |
|
37#include "base/misc.hh" 38#include "mem/packet.hh" | 39#include "base/misc.hh" 40#include "mem/packet.hh" |
41#include "base/trace.hh" |
|
39 40static const std::string ReadReqString("ReadReq"); 41static const std::string WriteReqString("WriteReq"); 42static const std::string WriteReqNoAckString("WriteReqNoAck|Writeback"); 43static const std::string ReadRespString("ReadResp"); 44static const std::string WriteRespString("WriteResp"); 45static const std::string SoftPFReqString("SoftPFReq"); 46static const std::string SoftPFRespString("SoftPFResp"); --- 87 unchanged lines hidden (view full) --- 134 Addr e2 = p->getAddr() + p->getSize() - 1; 135 136 return !(s1 > e2 || e1 < s2); 137} 138 139bool 140fixPacket(Packet *func, Packet *timing) 141{ | 42 43static const std::string ReadReqString("ReadReq"); 44static const std::string WriteReqString("WriteReq"); 45static const std::string WriteReqNoAckString("WriteReqNoAck|Writeback"); 46static const std::string ReadRespString("ReadResp"); 47static const std::string WriteRespString("WriteResp"); 48static const std::string SoftPFReqString("SoftPFReq"); 49static const std::string SoftPFRespString("SoftPFResp"); --- 87 unchanged lines hidden (view full) --- 137 Addr e2 = p->getAddr() + p->getSize() - 1; 138 139 return !(s1 > e2 || e1 < s2); 140} 141 142bool 143fixPacket(Packet *func, Packet *timing) 144{ |
142 panic("Need to implement!"); | 145 Addr funcStart = func->getAddr(); 146 Addr funcEnd = func->getAddr() + func->getSize() - 1; 147 Addr timingStart = timing->getAddr(); 148 Addr timingEnd = timing->getAddr() + timing->getSize() - 1; 149 150 assert(!(funcStart > timingEnd || timingStart < funcEnd)); 151 152 if (DTRACE(FunctionalAccess)) { 153 DebugOut() << func; 154 DebugOut() << timing; 155 } 156 157 // this packet can't solve our problem, continue on 158 if (!timing->hasData()) 159 return true; 160 161 if (func->isRead()) { 162 if (funcStart >= timingStart && funcEnd <= timingEnd) { 163 func->allocate(); 164 memcpy(func->getPtr<uint8_t>(), timing->getPtr<uint8_t>() + 165 funcStart - timingStart, func->getSize()); 166 func->result = Packet::Success; 167 return false; 168 } else { 169 // In this case the timing packet only partially satisfies the 170 // requset, so we would need more information to make this work. 171 // Like bytes valid in the packet or something, so the request could 172 // continue and get this bit of possibly newer data along with the 173 // older data not written to yet. 174 panic("Timing packet only partially satisfies the functional" 175 "request. Now what?"); 176 } 177 } else if (func->isWrite()) { 178 if (funcStart >= timingStart) { 179 memcpy(timing->getPtr<uint8_t>() + (funcStart - timingStart), 180 func->getPtr<uint8_t>(), 181 funcStart - std::min(funcEnd, timingEnd)); 182 } else { // timingStart > funcStart 183 memcpy(timing->getPtr<uint8_t>(), 184 func->getPtr<uint8_t>() + (timingStart - funcStart), 185 timingStart - std::min(funcEnd, timingEnd)); 186 } 187 // we always want to keep going with a write 188 return true; 189 } else 190 panic("Don't know how to handle command type %#x\n", 191 func->cmdToIndex()); 192 |
143} | 193} |
194 195 196std::ostream & 197operator<<(std::ostream &o, const Packet &p) 198{ 199 200 o << "[0x"; 201 o.setf(std::ios_base::hex, std::ios_base::showbase); 202 o << p.getAddr(); 203 o.unsetf(std::ios_base::hex| std::ios_base::showbase); 204 o << ":"; 205 o.setf(std::ios_base::hex, std::ios_base::showbase); 206 o << p.getAddr() + p.getSize() - 1 << "] "; 207 o.unsetf(std::ios_base::hex| std::ios_base::showbase); 208 209 if (p.result == Packet::Success) 210 o << "Successful "; 211 if (p.result == Packet::BadAddress) 212 o << "BadAddress "; 213 if (p.result == Packet::Nacked) 214 o << "Nacked "; 215 if (p.result == Packet::Unknown) 216 o << "Inflight "; 217 218 if (p.isRead()) 219 o << "Read "; 220 if (p.isWrite()) 221 o << "Read "; 222 if (p.isInvalidate()) 223 o << "Read "; 224 if (p.isRequest()) 225 o << "Request "; 226 if (p.isResponse()) 227 o << "Response "; 228 if (p.hasData()) 229 o << "w/Data "; 230 231 o << std::endl; 232 return o; 233} 234 |
|