summaryrefslogtreecommitdiff
path: root/src/mem/request.hh
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-11-10 11:51:17 -0800
committerNathan Binkert <nate@binkert.org>2008-11-10 11:51:17 -0800
commit3535d746ab2adaef4c13fbf869ccc3a2e98279cd (patch)
tree8161e5a8be9572a602171a0dbb3bcda98667e1c4 /src/mem/request.hh
parent2dd699ed3d31b5aee8fbb88948c4ea6083b1c8b0 (diff)
downloadgem5-3535d746ab2adaef4c13fbf869ccc3a2e98279cd.tar.xz
style: clean up the Packet stuff
Diffstat (limited to 'src/mem/request.hh')
-rw-r--r--src/mem/request.hh391
1 files changed, 270 insertions, 121 deletions
diff --git a/src/mem/request.hh b/src/mem/request.hh
index d1e011c7d..c3a523d9b 100644
--- a/src/mem/request.hh
+++ b/src/mem/request.hh
@@ -39,79 +39,103 @@
#ifndef __MEM_REQUEST_HH__
#define __MEM_REQUEST_HH__
+#include <cassert>
+
#include "base/fast_alloc.hh"
+#include "base/flags.hh"
#include "sim/host.hh"
#include "sim/core.hh"
-#include <cassert>
-
class Request;
typedef Request* RequestPtr;
+class Request : public FastAlloc
+{
+ public:
+ typedef uint32_t FlagsType;
+ typedef ::Flags<FlagsType> Flags;
+
+ /** ASI information for this request if it exists. */
+ static const FlagsType ASI_BITS = 0x000000FF;
+ /** The request is a Load locked/store conditional. */
+ static const FlagsType LOCKED = 0x00000100;
+ /** The virtual address is also the physical address. */
+ static const FlagsType PHYSICAL = 0x00000200;
+ /** The request is an ALPHA VPTE pal access (hw_ld). */
+ static const FlagsType VPTE = 0x00000400;
+ /** Use the alternate mode bits in ALPHA. */
+ static const FlagsType ALTMODE = 0x00000800;
+ /** The request is to an uncacheable address. */
+ static const FlagsType UNCACHEABLE = 0x00001000;
+ /** The request should not cause a page fault. */
+ static const FlagsType NO_FAULT = 0x00002000;
+ /** The request should be prefetched into the exclusive state. */
+ static const FlagsType PF_EXCLUSIVE = 0x00010000;
+ /** The request should be marked as LRU. */
+ static const FlagsType EVICT_NEXT = 0x00020000;
+ /** The request should ignore unaligned access faults */
+ static const FlagsType NO_ALIGN_FAULT = 0x00040000;
+ /** The request was an instruction read. */
+ static const FlagsType INST_READ = 0x00080000;
+ /** This request is for a memory swap. */
+ static const FlagsType MEM_SWAP = 0x00100000;
+ static const FlagsType MEM_SWAP_COND = 0x00200000;
+ /** The request should ignore unaligned access faults */
+ static const FlagsType NO_HALF_WORD_ALIGN_FAULT = 0x00400000;
+ /** This request is to a memory mapped register. */
+ static const FlagsType MMAPED_IPR = 0x00800000;
-/** ASI information for this request if it exsits. */
-const uint32_t ASI_BITS = 0x000FF;
-/** The request is a Load locked/store conditional. */
-const uint32_t LOCKED = 0x00100;
-/** The virtual address is also the physical address. */
-const uint32_t PHYSICAL = 0x00200;
-/** The request is an ALPHA VPTE pal access (hw_ld). */
-const uint32_t VPTE = 0x00400;
-/** Use the alternate mode bits in ALPHA. */
-const uint32_t ALTMODE = 0x00800;
-/** The request is to an uncacheable address. */
-const uint32_t UNCACHEABLE = 0x01000;
-/** The request should not cause a page fault. */
-const uint32_t NO_FAULT = 0x02000;
-/** The request should be prefetched into the exclusive state. */
-const uint32_t PF_EXCLUSIVE = 0x10000;
-/** The request should be marked as LRU. */
-const uint32_t EVICT_NEXT = 0x20000;
-/** The request should ignore unaligned access faults */
-const uint32_t NO_ALIGN_FAULT = 0x40000;
-/** The request was an instruction read. */
-const uint32_t INST_READ = 0x80000;
-/** This request is for a memory swap. */
-const uint32_t MEM_SWAP = 0x100000;
-const uint32_t MEM_SWAP_COND = 0x200000;
-/** The request should ignore unaligned access faults */
-const uint32_t NO_HALF_WORD_ALIGN_FAULT = 0x400000;
+ private:
+ static const FlagsType PUBLIC_FLAGS = 0x00FF3FFF;
+ static const FlagsType PRIVATE_FLAGS = 0xFF000000;
+ /** Whether or not the size is valid. */
+ static const FlagsType VALID_SIZE = 0x01000000;
+ /** Whether or not paddr is valid (has been written yet). */
+ static const FlagsType VALID_PADDR = 0x02000000;
+ /** Whether or not the vaddr & asid are valid. */
+ static const FlagsType VALID_VADDR = 0x04000000;
+ /** Whether or not the pc is valid. */
+ static const FlagsType VALID_PC = 0x10000000;
+ /** Whether or not the context ID is valid. */
+ static const FlagsType VALID_CONTEXT_ID = 0x20000000;
+ static const FlagsType VALID_THREAD_ID = 0x40000000;
+ /** Whether or not the sc result is valid. */
+ static const FlagsType VALID_EXTRA_DATA = 0x80000000;
-class Request : public FastAlloc
-{
private:
/**
* The physical address of the request. Valid only if validPaddr
- * is set. */
+ * is set.
+ */
Addr paddr;
/**
* The size of the request. This field must be set when vaddr or
* paddr is written via setVirt() or setPhys(), so it is always
- * valid as long as one of the address fields is valid. */
+ * valid as long as one of the address fields is valid.
+ */
int size;
/** Flag structure for the request. */
- uint32_t flags;
+ Flags flags;
/**
* The time this request was started. Used to calculate
* latencies. This field is set to curTick any time paddr or vaddr
- * is written. */
+ * is written.
+ */
Tick time;
/** The address space ID. */
int asid;
- /** This request is to a memory mapped register. */
- bool mmapedIpr;
-
/** The virtual address of the request. */
Addr vaddr;
- /** Extra data for the request, such as the return value of
+ /**
+ * Extra data for the request, such as the return value of
* store conditional or the compare value for a CAS. */
uint64_t extraData;
@@ -123,170 +147,295 @@ class Request : public FastAlloc
/** program counter of initiating access; for tracing/debugging */
Addr pc;
- /** Whether or not paddr is valid (has been written yet). */
- bool validPaddr;
- /** Whether or not the asid & vaddr are valid. */
- bool validAsidVaddr;
- /** Whether or not the sc result is valid. */
- bool validExData;
- /** Whether or not the context ID is valid. */
- bool validContextAndThreadIds;
- /** Whether or not the pc is valid. */
- bool validPC;
-
public:
/** Minimal constructor. No fields are initialized. */
Request()
- : validPaddr(false), validAsidVaddr(false),
- validExData(false), validContextAndThreadIds(false), validPC(false)
{}
/**
* Constructor for physical (e.g. device) requests. Initializes
* just physical address, size, flags, and timestamp (to curTick).
- * These fields are adequate to perform a request. */
- Request(Addr _paddr, int _size, int _flags)
- : validContextAndThreadIds(false)
- { setPhys(_paddr, _size, _flags); }
+ * These fields are adequate to perform a request.
+ */
+ Request(Addr paddr, int size, Flags flags)
+ {
+ setPhys(paddr, size, flags);
+ }
- Request(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc,
- int _context_id, int _thread_id)
+ Request(int asid, Addr vaddr, int size, Flags flags, Addr pc,
+ int cid, int tid)
{
- setThreadContext(_context_id, _thread_id);
- setVirt(_asid, _vaddr, _size, _flags, _pc);
+ setThreadContext(cid, tid);
+ setVirt(asid, vaddr, size, flags, pc);
}
~Request() {} // for FastAlloc
/**
- * Set up CPU and thread numbers. */
- void setThreadContext(int _context_id, int _thread_id)
+ * Set up CPU and thread numbers.
+ */
+ void
+ setThreadContext(int context_id, int thread_id)
{
- _contextId = _context_id;
- _threadId = _thread_id;
- validContextAndThreadIds = true;
+ _contextId = context_id;
+ _threadId = thread_id;
+ flags.set(VALID_CONTEXT_ID|VALID_THREAD_ID);
}
/**
* Set up a physical (e.g. device) request in a previously
- * allocated Request object. */
- void setPhys(Addr _paddr, int _size, int _flags)
+ * allocated Request object.
+ */
+ void
+ setPhys(Addr _paddr, int _size, Flags _flags)
{
assert(_size >= 0);
paddr = _paddr;
size = _size;
- flags = _flags;
time = curTick;
- validPaddr = true;
- validAsidVaddr = false;
- validPC = false;
- validExData = false;
- mmapedIpr = false;
+
+ flags.set(VALID_PADDR|VALID_SIZE);
+ flags.clear(VALID_VADDR|VALID_PC|VALID_EXTRA_DATA|MMAPED_IPR);
+ flags.update(_flags, PUBLIC_FLAGS);
}
/**
* Set up a virtual (e.g., CPU) request in a previously
- * allocated Request object. */
- void setVirt(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc)
+ * allocated Request object.
+ */
+ void
+ setVirt(int _asid, Addr _vaddr, int _size, Flags _flags, Addr _pc)
{
assert(_size >= 0);
asid = _asid;
vaddr = _vaddr;
size = _size;
- flags = _flags;
pc = _pc;
time = curTick;
- validPaddr = false;
- validAsidVaddr = true;
- validPC = true;
- validExData = false;
- mmapedIpr = false;
+
+ flags.set(VALID_VADDR|VALID_SIZE|VALID_PC);
+ flags.clear(VALID_PADDR|VALID_EXTRA_DATA|MMAPED_IPR);
+ flags.update(_flags, PUBLIC_FLAGS);
}
- /** Set just the physical address. This should only be used to
+ /**
+ * Set just the physical address. This should only be used to
* record the result of a translation, and thus the vaddr must be
* valid before this method is called. Otherwise, use setPhys()
* to guarantee that the size and flags are also set.
*/
- void setPaddr(Addr _paddr)
+ void
+ setPaddr(Addr _paddr)
{
- assert(validAsidVaddr);
+ assert(flags.any(VALID_VADDR));
paddr = _paddr;
- validPaddr = true;
+ flags.set(VALID_PADDR);
+ }
+
+ /**
+ * Accessor for paddr.
+ */
+ Addr
+ getPaddr()
+ {
+ assert(flags.any(VALID_PADDR));
+ return paddr;
}
- /** Accessor for paddr. */
- Addr getPaddr() { assert(validPaddr); return paddr; }
+ /**
+ * Accessor for size.
+ */
+ int
+ getSize()
+ {
+ assert(flags.any(VALID_SIZE));
+ return size;
+ }
- /** Accessor for size. */
- int getSize() { assert(validPaddr || validAsidVaddr); return size; }
/** Accessor for time. */
- Tick getTime() { assert(validPaddr || validAsidVaddr); return time; }
- void resetTime() { assert(validPaddr || validAsidVaddr); time = curTick; }
+ Tick
+ getTime()
+ {
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
+ return time;
+ }
+
void
setTime(Tick when)
{
- assert(validPaddr || validAsidVaddr);
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
time = when;
}
+ void resetTime() { setTime(curTick); }
+
+ /** Accessor for flags. */
+ Flags
+ getFlags()
+ {
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
+ return flags & PUBLIC_FLAGS;
+ }
+
+ Flags
+ anyFlags(Flags _flags)
+ {
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
+ assert(_flags.none(~PUBLIC_FLAGS));
+ return flags.any(_flags);
+ }
+
+ Flags
+ allFlags(Flags _flags)
+ {
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
+ assert(_flags.none(~PUBLIC_FLAGS));
+ return flags.all(_flags);
+ }
+
/** Accessor for flags. */
- uint32_t getFlags() { assert(validPaddr || validAsidVaddr); return flags; }
- /** Accessor for paddr. */
- void setFlags(uint32_t _flags)
- { assert(validPaddr || validAsidVaddr); flags = _flags; }
+ void
+ setFlags(Flags _flags)
+ {
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
+ assert(_flags.none(~PUBLIC_FLAGS));
+ flags.set(_flags);
+ }
+
+ void
+ clearFlags(Flags _flags)
+ {
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
+ assert(_flags.none(~PUBLIC_FLAGS));
+ flags.clear(_flags);
+ }
+
+ void
+ clearFlags()
+ {
+ assert(flags.any(VALID_PADDR|VALID_VADDR));
+ flags.clear(PUBLIC_FLAGS);
+ }
/** Accessor function for vaddr.*/
- Addr getVaddr() { assert(validAsidVaddr); return vaddr; }
+ Addr
+ getVaddr()
+ {
+ assert(flags.any(VALID_VADDR));
+ return vaddr;
+ }
/** Accessor function for asid.*/
- int getAsid() { assert(validAsidVaddr); return asid; }
+ int
+ getAsid()
+ {
+ assert(flags.any(VALID_VADDR));
+ return asid;
+ }
/** Accessor function for asi.*/
- uint8_t getAsi() { assert(validAsidVaddr); return flags & ASI_BITS; }
+ uint8_t
+ getAsi()
+ {
+ assert(flags.any(VALID_VADDR));
+ return flags & ASI_BITS;
+ }
/** Accessor function for asi.*/
- void setAsi(uint8_t a)
- { assert(validAsidVaddr); flags = (flags & ~ASI_BITS) | a; }
+ void
+ setAsi(uint8_t a)
+ {
+ assert(flags.any(VALID_VADDR));
+ flags.update(a, ASI_BITS);
+ }
/** Accessor function for asi.*/
- bool isMmapedIpr() { assert(validPaddr); return mmapedIpr; }
+ bool
+ isMmapedIpr()
+ {
+ assert(flags.any(VALID_PADDR));
+ return flags.any(MMAPED_IPR);
+ }
/** Accessor function for asi.*/
- void setMmapedIpr(bool r) { assert(validAsidVaddr); mmapedIpr = r; }
+ void
+ setMmapedIpr(bool r)
+ {
+ assert(VALID_VADDR);
+ flags.set(MMAPED_IPR);
+ }
/** Accessor function to check if sc result is valid. */
- bool extraDataValid() { return validExData; }
+ bool
+ extraDataValid()
+ {
+ return flags.any(VALID_EXTRA_DATA);
+ }
+
/** Accessor function for store conditional return value.*/
- uint64_t getExtraData() { assert(validExData); return extraData; }
+ uint64_t
+ getExtraData() const
+ {
+ assert(flags.any(VALID_EXTRA_DATA));
+ return extraData;
+ }
+
/** Accessor function for store conditional return value.*/
- void setExtraData(uint64_t _extraData)
- { extraData = _extraData; validExData = true; }
+ void
+ setExtraData(uint64_t _extraData)
+ {
+ extraData = _extraData;
+ flags.set(VALID_EXTRA_DATA);
+ }
/** Accessor function for context ID.*/
- int contextId() { assert(validContextAndThreadIds); return _contextId; }
+ int
+ contextId() const
+ {
+ assert(flags.any(VALID_CONTEXT_ID));
+ return _contextId;
+ }
+
/** Accessor function for thread ID. */
- int threadId() { assert(validContextAndThreadIds); return _threadId; }
+ int
+ threadId() const
+ {
+ assert(flags.any(VALID_THREAD_ID));
+ return _threadId;
+ }
/** Accessor function for pc.*/
- Addr getPC() { assert(validPC); return pc; }
+ Addr
+ getPC() const
+ {
+ assert(flags.any(VALID_PC));
+ return pc;
+ }
/** Accessor Function to Check Cacheability. */
- bool isUncacheable() { return (getFlags() & UNCACHEABLE) != 0; }
-
- bool isInstRead() { return (getFlags() & INST_READ) != 0; }
+ bool isUncacheable() const { return flags.any(UNCACHEABLE); }
+ bool isInstRead() const { return flags.any(INST_READ); }
+ bool isLocked() const { return flags.any(LOCKED); }
+ bool isSwap() const { return flags.any(MEM_SWAP|MEM_SWAP_COND); }
+ bool isCondSwap() const { return flags.any(MEM_SWAP_COND); }
+
+ bool
+ isMisaligned() const
+ {
+ if (flags.any(NO_ALIGN_FAULT))
+ return false;
- bool isLocked() { return (getFlags() & LOCKED) != 0; }
+ if ((vaddr & 0x1))
+ return true;
- bool isSwap() { return (getFlags() & MEM_SWAP ||
- getFlags() & MEM_SWAP_COND); }
+ if (flags.any(NO_HALF_WORD_ALIGN_FAULT))
+ return false;
- bool isCondSwap() { return (getFlags() & MEM_SWAP_COND) != 0; }
+ if ((vaddr & 0x2))
+ return true;
- bool inline isMisaligned() {return (!(getFlags() & NO_ALIGN_FAULT) &&
- ((vaddr & 1) ||
- (!(getFlags() & NO_HALF_WORD_ALIGN_FAULT)
- && (vaddr & 0x2))));}
+ return false;
+ }
friend class Packet;
};