move code from packet.hh to packet.cc and packet_impl.hh
fix very annoying not-compiler bug arch/sparc/regfile.hh: You have not included an out-of-class definition of your static members. See [9.4.2]/4 and about a billion gcc bug reports. If statements get around the problem through some magic, and than seems nicer that putting a definition of them in a c file somewhere. cpu/simple/cpu.cc: get() and set() do the conversion now dev/io_device.hh: need get() and set() defentions in all the devices mem/packet.cc: mem/packet.hh: move code from packet.hh to packet.cc mem/physical.cc: packet_impl needed for templated packet functions --HG-- extra : convert_revision : 6c11842aa928d9af7b4cabe826306fe1fe09e693
This commit is contained in:
parent
a8fbc4ec76
commit
8a9d270f6c
6 changed files with 83 additions and 76 deletions
|
@ -140,7 +140,16 @@ namespace SparcISA
|
||||||
DPRINTF(Sparc, "Now using %s globals",
|
DPRINTF(Sparc, "Now using %s globals",
|
||||||
useAlt ? "alternate" : "regular");
|
useAlt ? "alternate" : "regular");
|
||||||
regView[Globals] = useAlt ? altGlobals : regGlobals;
|
regView[Globals] = useAlt ? altGlobals : regGlobals;
|
||||||
offset[Globals] = useAlt ? AltGlobalOffset : RegGlobalOffset;
|
|
||||||
|
// You have not included an out-of-class definition of your static
|
||||||
|
// members. See [9.4.2]/4 and about a billion gcc bug reports. If
|
||||||
|
// statements get around the problem through some magic, and than
|
||||||
|
// seems nicer that putting a definition of them in a c file
|
||||||
|
// somewhere.
|
||||||
|
if (useAlt)
|
||||||
|
offset[Globals] = AltGlobalOffset;
|
||||||
|
else
|
||||||
|
offset[Globals] = RegGlobalOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialize(std::ostream &os);
|
void serialize(std::ostream &os);
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#include "cpu/smt.hh"
|
#include "cpu/smt.hh"
|
||||||
#include "cpu/static_inst.hh"
|
#include "cpu/static_inst.hh"
|
||||||
#include "kern/kernel_stats.hh"
|
#include "kern/kernel_stats.hh"
|
||||||
|
#include "mem/packet_impl.hh"
|
||||||
#include "sim/byteswap.hh"
|
#include "sim/byteswap.hh"
|
||||||
#include "sim/builder.hh"
|
#include "sim/builder.hh"
|
||||||
#include "sim/debug.hh"
|
#include "sim/debug.hh"
|
||||||
|
@ -480,7 +481,7 @@ SimpleCPU::read(Addr addr, T &data, unsigned flags)
|
||||||
// Fault fault = xc->read(memReq,data);
|
// Fault fault = xc->read(memReq,data);
|
||||||
// Not sure what to check for no fault...
|
// Not sure what to check for no fault...
|
||||||
if (data_read_pkt->result == Success) {
|
if (data_read_pkt->result == Success) {
|
||||||
data = gtoh(data_read_pkt->get<T>());
|
data = data_read_pkt->get<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (traceData) {
|
if (traceData) {
|
||||||
|
@ -523,7 +524,7 @@ SimpleCPU::read(Addr addr, T &data, unsigned flags)
|
||||||
// Need to find a way to not duplicate code above.
|
// Need to find a way to not duplicate code above.
|
||||||
|
|
||||||
if (data_read_pkt->result == Success) {
|
if (data_read_pkt->result == Success) {
|
||||||
data = gtoh(data_read_pkt->get<T>());
|
data = data_read_pkt->get<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (traceData) {
|
if (traceData) {
|
||||||
|
@ -627,9 +628,8 @@ SimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
|
||||||
data_write_pkt = new Packet;
|
data_write_pkt = new Packet;
|
||||||
data_write_pkt->cmd = Write;
|
data_write_pkt->cmd = Write;
|
||||||
data_write_pkt->req = data_write_req;
|
data_write_pkt->req = data_write_req;
|
||||||
T hostData = htog(data);
|
|
||||||
data_write_pkt->allocate();
|
data_write_pkt->allocate();
|
||||||
data_write_pkt->set(hostData);
|
data_write_pkt->set(data);
|
||||||
#else
|
#else
|
||||||
data_write_pkt->reset();
|
data_write_pkt->reset();
|
||||||
data = htog(data);
|
data = htog(data);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "base/chunk_generator.hh"
|
#include "base/chunk_generator.hh"
|
||||||
#include "mem/mem_object.hh"
|
#include "mem/mem_object.hh"
|
||||||
|
#include "mem/packet_impl.hh"
|
||||||
#include "sim/eventq.hh"
|
#include "sim/eventq.hh"
|
||||||
#include "sim/sim_object.hh"
|
#include "sim/sim_object.hh"
|
||||||
|
|
||||||
|
|
|
@ -34,5 +34,61 @@
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
#include "mem/packet.hh"
|
#include "mem/packet.hh"
|
||||||
|
|
||||||
|
|
||||||
|
/** delete the data pointed to in the data pointer. Ok to call to matter how
|
||||||
|
* data was allocted. */
|
||||||
|
void
|
||||||
|
Packet::deleteData() {
|
||||||
|
assert(staticData || dynamicData);
|
||||||
|
if (staticData)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (arrayData)
|
||||||
|
delete [] data;
|
||||||
|
else
|
||||||
|
delete data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** If there isn't data in the packet, allocate some. */
|
||||||
|
void
|
||||||
|
Packet::allocate() {
|
||||||
|
if (data)
|
||||||
|
return;
|
||||||
|
assert(!staticData);
|
||||||
|
dynamicData = true;
|
||||||
|
arrayData = true;
|
||||||
|
data = new uint8_t[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Do the packet modify the same addresses. */
|
||||||
|
bool
|
||||||
|
Packet::intersect(Packet *p) {
|
||||||
|
Addr s1 = addr;
|
||||||
|
Addr e1 = addr + size;
|
||||||
|
Addr s2 = p->addr;
|
||||||
|
Addr e2 = p->addr + p->size;
|
||||||
|
|
||||||
|
if (s1 >= s2 && s1 < e2)
|
||||||
|
return true;
|
||||||
|
if (e1 >= s2 && e1 < e2)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Minimally reset a packet so something like simple cpu can reuse it. */
|
||||||
|
void
|
||||||
|
Packet::reset() {
|
||||||
|
result = Unknown;
|
||||||
|
if (dynamicData) {
|
||||||
|
deleteData();
|
||||||
|
dynamicData = false;
|
||||||
|
arrayData = false;
|
||||||
|
time = curTick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool fixPacket(Packet &func, Packet &timing)
|
bool fixPacket(Packet &func, Packet &timing)
|
||||||
{ panic("Need to implement!"); }
|
{ panic("Need to implement!"); }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003 The Regents of The University of Michigan
|
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -150,102 +150,42 @@ struct Packet
|
||||||
|
|
||||||
|
|
||||||
/** Minimally reset a packet so something like simple cpu can reuse it. */
|
/** Minimally reset a packet so something like simple cpu can reuse it. */
|
||||||
void reset() {
|
void reset();
|
||||||
result = Unknown;
|
|
||||||
if (dynamicData) {
|
|
||||||
deleteData();
|
|
||||||
dynamicData = false;
|
|
||||||
arrayData = false;
|
|
||||||
time = curTick;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the data pointer to the following value that should not be freed. */
|
/** Set the data pointer to the following value that should not be freed. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void dataStatic(T *p) {
|
void dataStatic(T *p);
|
||||||
assert(!dynamicData);
|
|
||||||
data = (PacketDataPtr)p;
|
|
||||||
staticData = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the data pointer to a value that should have delete [] called on it.
|
/** Set the data pointer to a value that should have delete [] called on it.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void dataDynamicArray(T *p) {
|
void dataDynamicArray(T *p);
|
||||||
assert(!staticData && !dynamicData);
|
|
||||||
data = (PacketDataPtr)p;
|
|
||||||
dynamicData = true;
|
|
||||||
arrayData = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** set the data pointer to a value that should have delete called on it. */
|
/** set the data pointer to a value that should have delete called on it. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void dataDynamic(T *p) {
|
void dataDynamic(T *p);
|
||||||
assert(!staticData && !dynamicData);
|
|
||||||
data = (PacketDataPtr)p;
|
|
||||||
dynamicData = true;
|
|
||||||
arrayData = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** return the value of what is pointed to in the packet. */
|
/** return the value of what is pointed to in the packet. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T get() {
|
T get();
|
||||||
assert(staticData || dynamicData);
|
|
||||||
assert(sizeof(T) <= size);
|
|
||||||
return *(T*)data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** get a pointer to the data ptr. */
|
/** get a pointer to the data ptr. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* getPtr() {
|
T* getPtr();
|
||||||
assert(staticData || dynamicData);
|
|
||||||
return (T*)data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** set the value in the data pointer to v. */
|
/** set the value in the data pointer to v. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void set(T v) {
|
void set(T v);
|
||||||
assert(sizeof(T) <= size);
|
|
||||||
*(T*)data = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** delete the data pointed to in the data pointer. Ok to call to matter how
|
/** delete the data pointed to in the data pointer. Ok to call to matter how
|
||||||
* data was allocted. */
|
* data was allocted. */
|
||||||
void deleteData() {
|
void deleteData();
|
||||||
assert(staticData || dynamicData);
|
|
||||||
if (staticData)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arrayData)
|
|
||||||
delete [] data;
|
|
||||||
else
|
|
||||||
delete data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** If there isn't data in the packet, allocate some. */
|
/** If there isn't data in the packet, allocate some. */
|
||||||
void allocate() {
|
void allocate();
|
||||||
if (data)
|
|
||||||
return;
|
|
||||||
assert(!staticData);
|
|
||||||
dynamicData = true;
|
|
||||||
arrayData = true;
|
|
||||||
data = new uint8_t[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Do the packet modify the same addresses. */
|
/** Do the packet modify the same addresses. */
|
||||||
bool intersect(Packet *p) {
|
bool intersect(Packet *p);
|
||||||
Addr s1 = addr;
|
|
||||||
Addr e1 = addr + size;
|
|
||||||
Addr s2 = p->addr;
|
|
||||||
Addr e2 = p->addr + p->size;
|
|
||||||
|
|
||||||
if (s1 >= s2 && s1 < e2)
|
|
||||||
return true;
|
|
||||||
if (e1 >= s2 && e1 < e2)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool fixPacket(Packet &func, Packet &timing);
|
bool fixPacket(Packet &func, Packet &timing);
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
#include "config/full_system.hh"
|
#include "config/full_system.hh"
|
||||||
|
#include "mem/packet_impl.hh"
|
||||||
#include "mem/physical.hh"
|
#include "mem/physical.hh"
|
||||||
#include "sim/host.hh"
|
#include "sim/host.hh"
|
||||||
#include "sim/builder.hh"
|
#include "sim/builder.hh"
|
||||||
|
|
Loading…
Reference in a new issue