memhelpers.hh (13234:dea0fbed3f19) | memhelpers.hh (14297:b4519e586f5e) |
---|---|
1/* 2 * Copyright (c) 2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 111 unchanged lines hidden (view full) --- 120 } 121 return fault; 122} 123 124/// Do atomic read-modify-write (AMO) in atomic mode 125template <class XC, class MemT> 126Fault 127amoMemAtomic(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr, | 1/* 2 * Copyright (c) 2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 111 unchanged lines hidden (view full) --- 120 } 121 return fault; 122} 123 124/// Do atomic read-modify-write (AMO) in atomic mode 125template <class XC, class MemT> 126Fault 127amoMemAtomic(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr, |
128 Request::Flags flags, AtomicOpFunctor *amo_op) | 128 Request::Flags flags, AtomicOpFunctor *_amo_op) |
129{ | 129{ |
130 assert(amo_op); | 130 assert(_amo_op); |
131 132 // mem will hold the previous value at addr after the AMO completes 133 memset(&mem, 0, sizeof(mem)); 134 | 131 132 // mem will hold the previous value at addr after the AMO completes 133 memset(&mem, 0, sizeof(mem)); 134 |
135 AtomicOpFunctorPtr amo_op = AtomicOpFunctorPtr(_amo_op); |
|
135 Fault fault = xc->amoMem(addr, (uint8_t *)&mem, sizeof(MemT), flags, | 136 Fault fault = xc->amoMem(addr, (uint8_t *)&mem, sizeof(MemT), flags, |
136 amo_op); | 137 std::move(amo_op)); |
137 138 if (fault == NoFault) { 139 mem = TheISA::gtoh(mem); 140 if (traceData) 141 traceData->setData(mem); 142 } 143 return fault; 144} 145 146/// Do atomic read-modify-wrote (AMO) in timing mode 147template <class XC, class MemT> 148Fault 149initiateMemAMO(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT& mem, | 138 139 if (fault == NoFault) { 140 mem = TheISA::gtoh(mem); 141 if (traceData) 142 traceData->setData(mem); 143 } 144 return fault; 145} 146 147/// Do atomic read-modify-wrote (AMO) in timing mode 148template <class XC, class MemT> 149Fault 150initiateMemAMO(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT& mem, |
150 Request::Flags flags, AtomicOpFunctor *amo_op) | 151 Request::Flags flags, AtomicOpFunctor *_amo_op) |
151{ | 152{ |
152 assert(amo_op); 153 return xc->initiateMemAMO(addr, sizeof(MemT), flags, amo_op); | 153 assert(_amo_op); 154 AtomicOpFunctorPtr amo_op = AtomicOpFunctorPtr(_amo_op); 155 return xc->initiateMemAMO(addr, sizeof(MemT), flags, std::move(amo_op)); |
154} 155 156#endif | 156} 157 158#endif |