summaryrefslogtreecommitdiff
path: root/src/dev
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
committerNathan Binkert <nate@binkert.org>2009-06-04 23:21:12 -0700
commit6faf377b5305f9dcc3c7b013c4d67f5accb92617 (patch)
tree0e437fb49a32dd3d2d2bec95a8dc3bdb4ddf05b0 /src/dev
parent4e3426624557b555c354035ee3961eab7554d81d (diff)
downloadgem5-6faf377b5305f9dcc3c7b013c4d67f5accb92617.tar.xz
types: clean up types, especially signed vs unsigned
Diffstat (limited to 'src/dev')
-rw-r--r--src/dev/disk_image.cc4
-rw-r--r--src/dev/disk_image.hh4
-rw-r--r--src/dev/etherdump.hh2
-rw-r--r--src/dev/etherpkt.hh4
-rw-r--r--src/dev/ethertap.hh4
-rw-r--r--src/dev/i8254xGBe.cc40
-rw-r--r--src/dev/i8254xGBe.hh33
-rw-r--r--src/dev/i8254xGBe_defs.hh6
-rw-r--r--src/dev/io_device.hh4
-rw-r--r--src/dev/pktfifo.cc4
-rw-r--r--src/dev/pktfifo.hh25
-rw-r--r--src/dev/sinic.cc4
-rw-r--r--src/dev/sinic.hh8
13 files changed, 70 insertions, 72 deletions
diff --git a/src/dev/disk_image.cc b/src/dev/disk_image.cc
index 792a31204..aa8c98732 100644
--- a/src/dev/disk_image.cc
+++ b/src/dev/disk_image.cc
@@ -151,8 +151,8 @@ RawDiskImageParams::create()
//
// Copy on Write Disk image
//
-const int CowDiskImage::VersionMajor = 1;
-const int CowDiskImage::VersionMinor = 0;
+const uint32_t CowDiskImage::VersionMajor = 1;
+const uint32_t CowDiskImage::VersionMinor = 0;
class CowDiskCallback : public Callback
{
diff --git a/src/dev/disk_image.hh b/src/dev/disk_image.hh
index 3918209fc..a5c70ec82 100644
--- a/src/dev/disk_image.hh
+++ b/src/dev/disk_image.hh
@@ -102,8 +102,8 @@ class RawDiskImage : public DiskImage
class CowDiskImage : public DiskImage
{
public:
- static const int VersionMajor;
- static const int VersionMinor;
+ static const uint32_t VersionMajor;
+ static const uint32_t VersionMinor;
protected:
struct Sector {
diff --git a/src/dev/etherdump.hh b/src/dev/etherdump.hh
index 18a5d2c44..cf4213b27 100644
--- a/src/dev/etherdump.hh
+++ b/src/dev/etherdump.hh
@@ -47,7 +47,7 @@ class EtherDump : public SimObject
{
private:
std::ostream *stream;
- const int maxlen;
+ const unsigned maxlen;
void dumpPacket(EthPacketPtr &packet);
void init();
diff --git a/src/dev/etherpkt.hh b/src/dev/etherpkt.hh
index b7d33887b..c71d9cc30 100644
--- a/src/dev/etherpkt.hh
+++ b/src/dev/etherpkt.hh
@@ -58,14 +58,14 @@ class EthPacketData : public RefCounted
/*
* Length of the current packet
*/
- int length;
+ unsigned length;
public:
EthPacketData()
: data(NULL), length(0)
{ }
- explicit EthPacketData(size_t size)
+ explicit EthPacketData(unsigned size)
: data(new uint8_t[size]), length(0)
{ }
diff --git a/src/dev/ethertap.hh b/src/dev/ethertap.hh
index ac287cecb..94957b2ce 100644
--- a/src/dev/ethertap.hh
+++ b/src/dev/ethertap.hh
@@ -65,8 +65,8 @@ class EtherTap : public EtherObject
int socket;
char *buffer;
int buflen;
- int32_t buffer_offset;
- int32_t data_len;
+ uint32_t buffer_offset;
+ uint32_t data_len;
EtherDump *dump;
diff --git a/src/dev/i8254xGBe.cc b/src/dev/i8254xGBe.cc
index 37e253051..743de8a83 100644
--- a/src/dev/i8254xGBe.cc
+++ b/src/dev/i8254xGBe.cc
@@ -1095,9 +1095,9 @@ void
IGbE::DescCache<T>::reset()
{
DPRINTF(EthernetDesc, "Reseting descriptor cache\n");
- for (int x = 0; x < usedCache.size(); x++)
+ for (CacheType::size_type x = 0; x < usedCache.size(); x++)
delete usedCache[x];
- for (int x = 0; x < unusedCache.size(); x++)
+ for (CacheType::size_type x = 0; x < unusedCache.size(); x++)
delete unusedCache[x];
usedCache.clear();
@@ -1117,16 +1117,16 @@ IGbE::DescCache<T>::serialize(std::ostream &os)
SERIALIZE_SCALAR(moreToWb);
SERIALIZE_SCALAR(wbAlignment);
- int usedCacheSize = usedCache.size();
+ CacheType::size_type usedCacheSize = usedCache.size();
SERIALIZE_SCALAR(usedCacheSize);
- for(int x = 0; x < usedCacheSize; x++) {
+ for (CacheType::size_type x = 0; x < usedCacheSize; x++) {
arrayParamOut(os, csprintf("usedCache_%d", x),
(uint8_t*)usedCache[x],sizeof(T));
}
- int unusedCacheSize = unusedCache.size();
+ CacheType::size_type unusedCacheSize = unusedCache.size();
SERIALIZE_SCALAR(unusedCacheSize);
- for(int x = 0; x < unusedCacheSize; x++) {
+ for(CacheType::size_type x = 0; x < unusedCacheSize; x++) {
arrayParamOut(os, csprintf("unusedCache_%d", x),
(uint8_t*)unusedCache[x],sizeof(T));
}
@@ -1152,19 +1152,19 @@ IGbE::DescCache<T>::unserialize(Checkpoint *cp, const std::string &section)
UNSERIALIZE_SCALAR(moreToWb);
UNSERIALIZE_SCALAR(wbAlignment);
- int usedCacheSize;
+ CacheType::size_type usedCacheSize;
UNSERIALIZE_SCALAR(usedCacheSize);
T *temp;
- for(int x = 0; x < usedCacheSize; x++) {
+ for(CacheType::size_type x = 0; x < usedCacheSize; x++) {
temp = new T;
arrayParamIn(cp, section, csprintf("usedCache_%d", x),
(uint8_t*)temp,sizeof(T));
usedCache.push_back(temp);
}
- int unusedCacheSize;
+ CacheType::size_type unusedCacheSize;
UNSERIALIZE_SCALAR(unusedCacheSize);
- for(int x = 0; x < unusedCacheSize; x++) {
+ for(CacheType::size_type x = 0; x < unusedCacheSize; x++) {
temp = new T;
arrayParamIn(cp, section, csprintf("unusedCache_%d", x),
(uint8_t*)temp,sizeof(T));
@@ -1221,7 +1221,7 @@ IGbE::RxDescCache::writePacket(EthPacketPtr packet, int pkt_offset)
pktPtr = packet;
pktDone = false;
- int buf_len, hdr_len;
+ unsigned buf_len, hdr_len;
RxDesc *desc = unusedCache.front();
switch (igbe->regs.srrctl.desctype()) {
@@ -1648,20 +1648,16 @@ IGbE::TxDescCache::headerComplete()
igbe->checkDrain();
}
-int
+unsigned
IGbE::TxDescCache::getPacketSize(EthPacketPtr p)
{
- TxDesc *desc;
-
-
if (!unusedCache.size())
- return -1;
+ return 0;
DPRINTF(EthernetDesc, "Starting processing of descriptor\n");
assert(!useTso || tsoLoadedHeader);
- desc = unusedCache.front();
-
+ TxDesc *desc = unusedCache.front();
if (useTso) {
DPRINTF(EthernetDesc, "getPacket(): TxDescriptor data "
@@ -1680,7 +1676,8 @@ IGbE::TxDescCache::getPacketSize(EthPacketPtr p)
else
tsoCopyBytes = std::min(tsoMss,
TxdOp::getLen(desc) - tsoDescBytesUsed);
- Addr pkt_size = tsoCopyBytes + (tsoPktHasHeader ? 0 : tsoHeaderLen);
+ unsigned pkt_size =
+ tsoCopyBytes + (tsoPktHasHeader ? 0 : tsoHeaderLen);
DPRINTF(EthernetDesc, "TSO: Next packet is %d bytes\n", pkt_size);
return pkt_size;
}
@@ -2175,8 +2172,7 @@ IGbE::txStateMachine()
return;
}
- int size;
- size = txDescCache.getPacketSize(txPacket);
+ unsigned size = txDescCache.getPacketSize(txPacket);
if (size > 0 && txFifo.avail() > size) {
anRq("TXS", "TX FIFO Q");
anBegin("TXS", "DMA Packet");
@@ -2184,7 +2180,7 @@ IGbE::txStateMachine()
"beginning DMA of next packet\n", size);
txFifo.reserve(size);
txDescCache.getPacketData(txPacket);
- } else if (size <= 0) {
+ } else if (size == 0) {
DPRINTF(EthernetSM, "TXS: getPacketSize returned: %d\n", size);
DPRINTF(EthernetSM,
"TXS: No packets to get, writing back used descriptors\n");
diff --git a/src/dev/i8254xGBe.hh b/src/dev/i8254xGBe.hh
index 5ae90eebc..f7f7d9a2a 100644
--- a/src/dev/i8254xGBe.hh
+++ b/src/dev/i8254xGBe.hh
@@ -86,7 +86,7 @@ class IGbE : public EtherDevice
bool rxDmaPacket;
// Number of bytes copied from current RX packet
- int pktOffset;
+ unsigned pktOffset;
// Delays in managaging descriptors
Tick fetchDelay, wbDelay;
@@ -224,8 +224,9 @@ class IGbE : public EtherDevice
virtual void actionAfterWb() {}
virtual void fetchAfterWb() = 0;
- std::deque<T*> usedCache;
- std::deque<T*> unusedCache;
+ typedef std::deque<T *> CacheType;
+ CacheType usedCache;
+ CacheType unusedCache;
T *fetchBuf;
T *wbBuf;
@@ -301,9 +302,10 @@ class IGbE : public EtherDevice
/* Return the number of descriptors left in the ring, so the device has
* a way to figure out if it needs to interrupt.
*/
- int descLeft() const
+ unsigned
+ descLeft() const
{
- int left = unusedCache.size();
+ unsigned left = unusedCache.size();
if (cachePnt > descTail())
left += (descLen() - cachePnt + descTail());
else
@@ -314,10 +316,10 @@ class IGbE : public EtherDevice
/* Return the number of descriptors used and not written back.
*/
- int descUsed() const { return usedCache.size(); }
+ unsigned descUsed() const { return usedCache.size(); }
/* Return the number of cache unused descriptors we have. */
- int descUnused() const {return unusedCache.size(); }
+ unsigned descUnused() const { return unusedCache.size(); }
/* Get into a state where the descriptor address/head/etc colud be
* changed */
@@ -354,7 +356,7 @@ class IGbE : public EtherDevice
/** Bytes of packet that have been copied, so we know when to
set EOP */
- int bytesCopied;
+ unsigned bytesCopied;
public:
RxDescCache(IGbE *i, std::string n, int s);
@@ -442,15 +444,19 @@ class IGbE : public EtherDevice
* return the size the of the packet to reserve space in tx fifo.
* @return size of the packet
*/
- int getPacketSize(EthPacketPtr p);
+ unsigned getPacketSize(EthPacketPtr p);
void getPacketData(EthPacketPtr p);
void processContextDesc();
/** Return the number of dsecriptors in a cache block for threshold
* operations.
*/
- int descInBlock(int num_desc) { return num_desc /
- igbe->cacheBlockSize() / sizeof(iGbReg::TxDesc); }
+ unsigned
+ descInBlock(unsigned num_desc)
+ {
+ return num_desc / igbe->cacheBlockSize() / sizeof(iGbReg::TxDesc);
+ }
+
/** Ask if the packet has been transfered so the state machine can give
* it to the fifo.
* @return packet available in descriptor cache
@@ -548,9 +554,4 @@ class IGbEInt : public EtherInt
virtual void sendDone() { dev->ethTxDone(); }
};
-
-
-
-
#endif //__DEV_I8254XGBE_HH__
-
diff --git a/src/dev/i8254xGBe_defs.hh b/src/dev/i8254xGBe_defs.hh
index 4634dd9a3..4de347b99 100644
--- a/src/dev/i8254xGBe_defs.hh
+++ b/src/dev/i8254xGBe_defs.hh
@@ -481,7 +481,7 @@ struct Regs {
ADD_FIELD32(pmcf,23,1); // pass mac control frames
ADD_FIELD32(bsex,25,1); // buffer size extension
ADD_FIELD32(secrc,26,1); // strip ethernet crc from incoming packet
- int descSize()
+ unsigned descSize()
{
switch(bsize()) {
case 0: return bsex() == 0 ? 2048 : -1;
@@ -559,8 +559,8 @@ struct Regs {
ADD_FIELD32(hdrlen, 8, 8); // guess based on header, not documented
ADD_FIELD32(desctype, 25,3); // type of descriptor 000 legacy, 001 adv,
//101 hdr split
- int bufLen() { return pktlen() << 10; }
- int hdrLen() { return hdrlen() << 6; }
+ unsigned bufLen() { return pktlen() << 10; }
+ unsigned hdrLen() { return hdrlen() << 6; }
};
SRRCTL srrctl;
diff --git a/src/dev/io_device.hh b/src/dev/io_device.hh
index 70af6093d..54128e48f 100644
--- a/src/dev/io_device.hh
+++ b/src/dev/io_device.hh
@@ -152,7 +152,7 @@ class DmaPort : public Port
bool dmaPending() { return pendingCount > 0; }
- int cacheBlockSize() { return peerBlockSize(); }
+ unsigned cacheBlockSize() const { return peerBlockSize(); }
unsigned int drain(Event *de);
};
@@ -284,7 +284,7 @@ class DmaDevice : public PioDevice
virtual unsigned int drain(Event *de);
- int cacheBlockSize() { return dmaPort->cacheBlockSize(); }
+ unsigned cacheBlockSize() const { return dmaPort->cacheBlockSize(); }
virtual Port *getPort(const std::string &if_name, int idx = -1)
{
diff --git a/src/dev/pktfifo.cc b/src/dev/pktfifo.cc
index 97d6c04af..e5d67d5ec 100644
--- a/src/dev/pktfifo.cc
+++ b/src/dev/pktfifo.cc
@@ -34,7 +34,7 @@
using namespace std;
bool
-PacketFifo::copyout(void *dest, int offset, int len)
+PacketFifo::copyout(void *dest, unsigned offset, unsigned len)
{
char *data = (char *)dest;
if (offset + len >= size())
@@ -52,7 +52,7 @@ PacketFifo::copyout(void *dest, int offset, int len)
if (i == end)
panic("invalid fifo");
- int size = min(pkt->length - offset, len);
+ unsigned size = min(pkt->length - offset, len);
memcpy(data, pkt->data, size);
offset = 0;
len -= size;
diff --git a/src/dev/pktfifo.hh b/src/dev/pktfifo.hh
index 6ded248be..b548627e0 100644
--- a/src/dev/pktfifo.hh
+++ b/src/dev/pktfifo.hh
@@ -44,7 +44,7 @@ struct PacketFifoEntry
{
EthPacketPtr packet;
uint64_t number;
- int slack;
+ unsigned slack;
int priv;
PacketFifoEntry()
@@ -85,24 +85,25 @@ class PacketFifo
protected:
std::list<PacketFifoEntry> fifo;
uint64_t _counter;
- int _maxsize;
- int _size;
- int _reserved;
+ unsigned _maxsize;
+ unsigned _size;
+ unsigned _reserved;
public:
explicit PacketFifo(int max)
: _counter(0), _maxsize(max), _size(0), _reserved(0) {}
virtual ~PacketFifo() {}
- int packets() const { return fifo.size(); }
- int maxsize() const { return _maxsize; }
- int size() const { return _size; }
- int reserved() const { return _reserved; }
- int avail() const { return _maxsize - _size - _reserved; }
+ unsigned packets() const { return fifo.size(); }
+ unsigned maxsize() const { return _maxsize; }
+ unsigned size() const { return _size; }
+ unsigned reserved() const { return _reserved; }
+ unsigned avail() const { return _maxsize - _size - _reserved; }
bool empty() const { return size() <= 0; }
bool full() const { return avail() <= 0; }
- int reserve(int len = 0)
+ unsigned
+ reserve(unsigned len = 0)
{
_reserved += len;
assert(avail() >= 0);
@@ -169,7 +170,7 @@ class PacketFifo
fifo.erase(i);
}
- bool copyout(void *dest, int offset, int len);
+ bool copyout(void *dest, unsigned offset, unsigned len);
int countPacketsBefore(iterator i)
{
@@ -188,7 +189,7 @@ class PacketFifo
void check()
{
- int total = 0;
+ unsigned total = 0;
for (iterator i = begin(); i != end(); ++i)
total += i->packet->length + i->slack;
diff --git a/src/dev/sinic.cc b/src/dev/sinic.cc
index ae01e2930..133f70b0b 100644
--- a/src/dev/sinic.cc
+++ b/src/dev/sinic.cc
@@ -1032,8 +1032,8 @@ Device::rxKick()
rxDmaAddr = params()->platform->pciToDma(
Regs::get_RxData_Addr(vnic->RxData));
- rxDmaLen = min<int>(Regs::get_RxData_Len(vnic->RxData),
- vnic->rxPacketBytes);
+ rxDmaLen = min<unsigned>(Regs::get_RxData_Len(vnic->RxData),
+ vnic->rxPacketBytes);
/*
* if we're doing zero/delay copy and we're below the fifo
diff --git a/src/dev/sinic.hh b/src/dev/sinic.hh
index cd8412ef4..d2124d8ce 100644
--- a/src/dev/sinic.hh
+++ b/src/dev/sinic.hh
@@ -142,8 +142,8 @@ class Device : public Base
uint64_t TxDone;
PacketFifo::iterator rxIndex;
- int rxPacketOffset;
- int rxPacketBytes;
+ unsigned rxPacketOffset;
+ unsigned rxPacketBytes;
uint64_t rxDoneData;
Counter rxUnique;
@@ -155,7 +155,7 @@ class Device : public Base
{ }
};
typedef std::vector<VirtualReg> VirtualRegs;
- typedef std::list<int> VirtualList;
+ typedef std::list<unsigned> VirtualList;
Counter rxUnique;
Counter txUnique;
VirtualRegs virtualRegs;
@@ -180,7 +180,7 @@ class Device : public Base
bool rxLow;
Addr rxDmaAddr;
uint8_t *rxDmaData;
- int rxDmaLen;
+ unsigned rxDmaLen;
TxState txState;
PacketFifo txFifo;