summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorTuan Ta <qtt2@cornell.edu>2018-01-22 13:00:35 -0500
committerTuan Ta <qtt2@cornell.edu>2018-06-14 22:41:23 +0000
commit78fb2c1a5d5e422bf14f134d677a83e3022238f1 (patch)
treed315ea11d7fdbd95a95b8adac5e2cbe065ee26b2 /src/arch
parent7bab1d0aff897bc23b5677a51ae67b8cc32953dc (diff)
downloadgem5-78fb2c1a5d5e422bf14f134d677a83e3022238f1.tar.xz
arch: support issuing Atomic Mem Operation (AMO) requests
This patch adds two new functions named amoMemAtomic used in Atomic CPU model and initiateMemAMO used in Timing CPU models to issue AMO requests to the memory system. Change-Id: I962bdc0e5f25b72c170d96ebc136f29a2b230d5e Reviewed-on: https://gem5-review.googlesource.com/8186 Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/generic/memhelpers.hh32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/arch/generic/memhelpers.hh b/src/arch/generic/memhelpers.hh
index 35e666b92..6fe1707a0 100644
--- a/src/arch/generic/memhelpers.hh
+++ b/src/arch/generic/memhelpers.hh
@@ -121,4 +121,36 @@ writeMemAtomic(XC *xc, Trace::InstRecord *traceData, const MemT &mem,
return fault;
}
+/// Do atomic read-modify-write (AMO) in atomic mode
+template <class XC, class MemT>
+Fault
+amoMemAtomic(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr,
+ Request::Flags flags, AtomicOpFunctor *amo_op)
+{
+ assert(amo_op);
+
+ // mem will hold the previous value at addr after the AMO completes
+ memset(&mem, 0, sizeof(mem));
+
+ Fault fault = xc->amoMem(addr, (uint8_t *)&mem, sizeof(MemT), flags,
+ amo_op);
+
+ if (fault == NoFault) {
+ mem = TheISA::gtoh(mem);
+ if (traceData)
+ traceData->setData(mem);
+ }
+ return fault;
+}
+
+/// Do atomic read-modify-wrote (AMO) in timing mode
+template <class XC, class MemT>
+Fault
+initiateMemAMO(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT& mem,
+ Request::Flags flags, AtomicOpFunctor *amo_op)
+{
+ assert(amo_op);
+ return xc->initiateMemAMO(addr, sizeof(MemT), flags, amo_op);
+}
+
#endif