Deleted Added
sdiff udiff text old ( 5012:c0a28154d002 ) new ( 5314:e902f12a3af1 )
full compact
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;

--- 23 unchanged lines hidden (view full) ---

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>
39#include <cstring>
40#include "base/misc.hh"
41#include "base/trace.hh"
42#include "mem/packet.hh"
43
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))

--- 68 unchanged lines hidden (view full) ---

116 /* SwapResp -- for Swap ldstub type operations */
117 { SET5(IsRead, IsWrite, NeedsExclusive, IsResponse, HasData),
118 InvalidCmd, "SwapResp" },
119 /* NetworkNackError -- nacked at network layer (not by protocol) */
120 { SET2(IsResponse, IsError), InvalidCmd, "NetworkNackError" },
121 /* InvalidDestError -- packet dest field invalid */
122 { SET2(IsResponse, IsError), InvalidCmd, "InvalidDestError" },
123 /* BadAddressError -- memory address invalid */
124 { SET2(IsResponse, IsError), InvalidCmd, "BadAddressError" }
125};
126
127
128/** delete the data pointed to in the data pointer. Ok to call to matter how
129 * data was allocted. */
130void
131Packet::deleteData()
132{

--- 16 unchanged lines hidden (view full) ---

149 assert(!staticData);
150 dynamicData = true;
151 arrayData = true;
152 data = new uint8_t[getSize()];
153}
154
155
156bool
157Packet::checkFunctional(Addr addr, int size, uint8_t *data)
158{
159 Addr func_start = getAddr();
160 Addr func_end = getAddr() + getSize() - 1;
161 Addr val_start = addr;
162 Addr val_end = val_start + size - 1;
163
164 if (func_start > val_end || val_start > func_end) {
165 // no intersection
166 return false;
167 }
168
169 // offset of functional request into supplied value (could be
170 // negative if partial overlap)
171 int offset = func_start - val_start;
172
173 if (isRead()) {
174 if (func_start >= val_start && func_end <= val_end) {
175 allocate();
176 std::memcpy(getPtr<uint8_t>(), data + offset, getSize());

--- 12 unchanged lines hidden (view full) ---

189 } else if (isWrite()) {
190 if (offset >= 0) {
191 std::memcpy(data + offset, getPtr<uint8_t>(),
192 (std::min(func_end, val_end) - func_start) + 1);
193 } else { // val_start > func_start
194 std::memcpy(data, getPtr<uint8_t>() - offset,
195 (std::min(func_end, val_end) - val_start) + 1);
196 }
197 // we always want to keep going with a write
198 return false;
199 } else
200 panic("Don't know how to handle command %s\n", cmdString());
201}
202
203
204std::ostream &
205operator<<(std::ostream &o, const Packet &p)
206{
207
208 o << "[0x";
209 o.setf(std::ios_base::hex, std::ios_base::showbase);
210 o << p.getAddr();
211 o.unsetf(std::ios_base::hex| std::ios_base::showbase);
212 o << ":";
213 o.setf(std::ios_base::hex, std::ios_base::showbase);
214 o << p.getAddr() + p.getSize() - 1 << "] ";
215 o.unsetf(std::ios_base::hex| std::ios_base::showbase);
216
217 if (p.isRead())
218 o << "Read ";
219 if (p.isWrite())
220 o << "Write ";
221 if (p.isInvalidate())
222 o << "Invalidate ";
223 if (p.isRequest())
224 o << "Request ";
225 if (p.isResponse())
226 o << "Response ";
227 if (p.hasData())
228 o << "w/Data ";
229
230 o << std::endl;
231 return o;
232}
233