%(ea_code)s;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicLE(xc, traceData, EA, Mem, memAccessFlags);
%(memacc_code)s;
}
%(fp_enable_check)s;
%(op_decl)s;
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA,
memAccessFlags, NULL);
}
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA,
memAccessFlags, &write_result);
}
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA,
+ fault = writeMemTimingLE(xc, traceData, Mem, EA,
memAccessFlags, NULL);
}
%(preacc_code)s;
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
- &memData);
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA,
+ memAccessFlags, &memData);
}
if (fault == NoFault) {
%(preacc_code)s;
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
- &memData);
+ fault = writeMemTimingLE(xc, traceData, Mem, EA,
+ memAccessFlags, &memData);
}
} else {
xc->setPredicate(false);
if (%(predicate_test)s)
{
// ARM instructions will not have a pkt if the predicate is false
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
uint64_t memData = Mem;
%(postacc_code)s;
if (%(predicate_test)s)
{
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicLE(
+ xc, traceData, EA, Mem, memAccessFlags);
%(memacc_code)s;
}
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA,
memAccessFlags, NULL);
}
uint64_t writeResult;
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
- &writeResult);
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA,
+ memAccessFlags, &writeResult);
}
if (fault == NoFault) {
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
- NULL);
+ fault = writeMemTimingLE(xc, traceData, Mem, EA,
+ memAccessFlags, NULL);
}
} else {
xc->setPredicate(false);
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
- NULL);
+ fault = writeMemTimingLE(xc, traceData, Mem, EA,
+ memAccessFlags, NULL);
}
} else {
xc->setPredicate(false);
if (%(predicate_test)s)
{
// ARM instructions will not have a pkt if the predicate is false
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
%(ea_code)s;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicLE(xc, traceData, EA, Mem, memAccessFlags);
%(memacc_code)s;
}
%(ea_code)s;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicLE(xc, traceData, EA, Mem, memAccessFlags);
}
if (fault == NoFault) {
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA,
- memAccessFlags, NULL);
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA,
+ memAccessFlags, NULL);
}
if (fault == NoFault) {
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
- NULL);
+ fault = writeMemTimingLE(xc, traceData, Mem, EA, memAccessFlags,
+ NULL);
}
return fault;
uint64_t writeResult = 0;
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
- &writeResult);
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA, memAccessFlags,
+ &writeResult);
}
if (fault == NoFault) {
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
- NULL);
+ fault = writeMemTimingLE(xc, traceData, Mem, EA, memAccessFlags,
+ NULL);
}
return fault;
%(op_rd)s;
// ARM instructions will not have a pkt if the predicate is false
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
%(amo_code)s;
assert(amo_op);
- const Fault fault = amoMemAtomic(xc, traceData, Mem, EA,
- memAccessFlags, amo_op);
+ const Fault fault = amoMemAtomicLE(xc, traceData, Mem, EA,
+ memAccessFlags, amo_op);
if (fault == NoFault) {
%(postacc_code)s;
%(op_rd)s;
// ARM instructions will not have a pkt if the predicate is false
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
%(postacc_code)s;
MemElemType memData;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, memData,
+ fault = readMemAtomicLE(xc, traceData, EA, memData,
this->memAccessFlags);
%(memacc_code)s;
}
%(op_rd)s;
MemElemType memData;
- getMem(pkt, memData, traceData);
+ getMemLE(pkt, memData, traceData);
if (fault == NoFault) {
%(memacc_code)s;
int index = elemIndex;
if (%(pred_check_code)s) {
- fault = readMemAtomic(xc, traceData, EA, memData,
+ fault = readMemAtomicLE(xc, traceData, EA, memData,
this->memAccessFlags);
}
MemElemType memData = 0;
if (xc->readMemAccPredicate()) {
- getMem(pkt, memData, traceData);
+ getMemLE(pkt, memData, traceData);
}
%(memacc_code)s;
int index = elemIndex;
if (%(pred_check_code)s) {
- fault = writeMemAtomic(xc, traceData, memData, EA,
- this->memAccessFlags, NULL);
+ fault = writeMemAtomicLE(xc, traceData, memData, EA,
+ this->memAccessFlags, NULL);
}
if (fault == NoFault) {
int index = elemIndex;
if (%(pred_check_code)s) {
- fault = writeMemTiming(xc, traceData, memData, EA,
+ fault = writeMemTimingLE(xc, traceData, memData, EA,
this->memAccessFlags, NULL);
} else {
xc->setPredicate(false);
}
/// Extract the data returned from a timing mode read.
-template <class MemT>
+template <ByteOrder Order, class MemT>
void
getMem(PacketPtr pkt, MemT &mem, Trace::InstRecord *traceData)
{
- mem = pkt->get<MemT>(TheISA::GuestByteOrder);
+ mem = pkt->get<MemT>(Order);
if (traceData)
traceData->setData(mem);
}
+template <class MemT>
+void
+getMemLE(PacketPtr pkt, MemT &mem, Trace::InstRecord *traceData)
+{
+ getMem<LittleEndianByteOrder>(pkt, mem, traceData);
+}
+
+template <class MemT>
+void
+getMemBE(PacketPtr pkt, MemT &mem, Trace::InstRecord *traceData)
+{
+ getMem<BigEndianByteOrder>(pkt, mem, traceData);
+}
+
/// Read from memory in atomic mode.
-template <class XC, class MemT>
+template <ByteOrder Order, class XC, class MemT>
Fault
readMemAtomic(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT &mem,
Request::Flags flags)
memset(&mem, 0, sizeof(mem));
Fault fault = xc->readMem(addr, (uint8_t *)&mem, sizeof(MemT), flags);
if (fault == NoFault) {
- mem = TheISA::gtoh(mem);
+ mem = gtoh(mem, Order);
if (traceData)
traceData->setData(mem);
}
return fault;
}
-/// Write to memory in timing mode.
template <class XC, class MemT>
Fault
+readMemAtomicLE(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT &mem,
+ Request::Flags flags)
+{
+ return readMemAtomic<LittleEndianByteOrder>(
+ xc, traceData, addr, mem, flags);
+}
+
+template <class XC, class MemT>
+Fault
+readMemAtomicBE(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT &mem,
+ Request::Flags flags)
+{
+ return readMemAtomic<BigEndianByteOrder>(xc, traceData, addr, mem, flags);
+}
+
+/// Write to memory in timing mode.
+template <ByteOrder Order, class XC, class MemT>
+Fault
writeMemTiming(XC *xc, Trace::InstRecord *traceData, MemT mem, Addr addr,
Request::Flags flags, uint64_t *res)
{
if (traceData) {
traceData->setData(mem);
}
- mem = TheISA::htog(mem);
+ mem = htog(mem, Order);
return xc->writeMem((uint8_t *)&mem, sizeof(MemT), addr, flags, res);
}
-/// Write to memory in atomic mode.
template <class XC, class MemT>
Fault
+writeMemTimingLE(XC *xc, Trace::InstRecord *traceData, MemT mem, Addr addr,
+ Request::Flags flags, uint64_t *res)
+{
+ return writeMemTiming<LittleEndianByteOrder>(
+ xc, traceData, mem, addr, flags, res);
+}
+
+template <class XC, class MemT>
+Fault
+writeMemTimingBE(XC *xc, Trace::InstRecord *traceData, MemT mem, Addr addr,
+ Request::Flags flags, uint64_t *res)
+{
+ return writeMemTiming<BigEndianByteOrder>(
+ xc, traceData, mem, addr, flags, res);
+}
+
+/// Write to memory in atomic mode.
+template <ByteOrder Order, class XC, class MemT>
+Fault
writeMemAtomic(XC *xc, Trace::InstRecord *traceData, const MemT &mem,
Addr addr, Request::Flags flags, uint64_t *res)
{
if (traceData) {
traceData->setData(mem);
}
- MemT host_mem = TheISA::htog(mem);
+ MemT host_mem = htog(mem, Order);
Fault fault =
xc->writeMem((uint8_t *)&host_mem, sizeof(MemT), addr, flags, res);
if (fault == NoFault && res != NULL) {
if (flags & Request::MEM_SWAP || flags & Request::MEM_SWAP_COND)
- *(MemT *)res = TheISA::gtoh(*(MemT *)res);
+ *(MemT *)res = gtoh(*(MemT *)res, Order);
else
- *res = TheISA::gtoh(*res);
+ *res = gtoh(*res, Order);
}
return fault;
}
-/// Do atomic read-modify-write (AMO) in atomic mode
template <class XC, class MemT>
Fault
+writeMemAtomicLE(XC *xc, Trace::InstRecord *traceData, const MemT &mem,
+ Addr addr, Request::Flags flags, uint64_t *res)
+{
+ return writeMemAtomic<LittleEndianByteOrder>(
+ xc, traceData, mem, addr, flags, res);
+}
+
+template <class XC, class MemT>
+Fault
+writeMemAtomicBE(XC *xc, Trace::InstRecord *traceData, const MemT &mem,
+ Addr addr, Request::Flags flags, uint64_t *res)
+{
+ return writeMemAtomic<BigEndianByteOrder>(
+ xc, traceData, mem, addr, flags, res);
+}
+
+/// Do atomic read-modify-write (AMO) in atomic mode
+template <ByteOrder Order, class XC, class MemT>
+Fault
amoMemAtomic(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr,
Request::Flags flags, AtomicOpFunctor *_amo_op)
{
std::move(amo_op));
if (fault == NoFault) {
- mem = TheISA::gtoh(mem);
+ mem = gtoh(mem, Order);
if (traceData)
traceData->setData(mem);
}
return fault;
}
+template <class XC, class MemT>
+Fault
+amoMemAtomicLE(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr,
+ Request::Flags flags, AtomicOpFunctor *_amo_op)
+{
+ return amoMemAtomic<LittleEndianByteOrder>(
+ xc, traceData, mem, addr, flags, _amo_op);
+}
+
+template <class XC, class MemT>
+Fault
+amoMemAtomicBE(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr,
+ Request::Flags flags, AtomicOpFunctor *_amo_op)
+{
+ return amoMemAtomic<BigEndianByteOrder>(
+ xc, traceData, mem, addr, flags, _amo_op);
+}
+
/// Do atomic read-modify-wrote (AMO) in timing mode
template <class XC, class MemT>
Fault
%(ea_code)s;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicLE(xc, traceData, EA, Mem, memAccessFlags);
%(memacc_code)s;
}
%(op_decl)s;
%(op_rd)s;
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA, memAccessFlags,
NULL);
}
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA, memAccessFlags,
NULL);
}
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA, memAccessFlags,
&write_result);
}
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemTimingLE(xc, traceData, Mem, EA, memAccessFlags,
NULL);
}
uint32_t byte_offset = unaligned_addr & 3;
if (GuestByteOrder == BigEndianByteOrder)
byte_offset ^= 3;
- fault = readMemAtomic(xc, traceData, EA, mem_word, memAccessFlags);
+ fault = readMemAtomicLE(xc, traceData, EA, mem_word, memAccessFlags);
'''
memacc_code = decl_code + memacc_code + '\nMem = mem_word;\n'
%(ea_code)s;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicBE(xc, traceData, EA, Mem, memAccessFlags);
%(memacc_code)s;
}
EA = pkt->req->getVaddr();
- getMem(pkt, Mem, traceData);
+ getMemBE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemAtomicBE(xc, traceData, Mem, EA, memAccessFlags,
NULL);
}
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemTimingBE(xc, traceData, Mem, EA, memAccessFlags,
NULL);
}
%(ea_code)s;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicLE(xc, traceData, EA, Mem, memAccessFlags);
%(memacc_code)s;
}
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA, memAccessFlags,
&result);
// RISC-V has the opposite convention gem5 has for success flags,
// so we invert the result here.
assert(amo_op);
if (fault == NoFault) {
- fault = amoMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
+ fault = amoMemAtomicLE(xc, traceData, Mem, EA, memAccessFlags,
amo_op);
%(memacc_code)s;
}
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA,
+ fault = writeMemTimingLE(xc, traceData, Mem, EA,
memAccessFlags, nullptr);
}
%(op_decl)s;
%(op_rd)s;
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
%(op_decl)s;
%(op_rd)s;
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
%(ea_code)s;
if (fault == NoFault) {
- fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
+ fault = readMemAtomicLE(xc, traceData, EA, Mem, memAccessFlags);
%(memacc_code)s;
}
%(op_decl)s;
%(op_rd)s;
- getMem(pkt, Mem, traceData);
+ getMemLE(pkt, Mem, traceData);
if (fault == NoFault) {
%(memacc_code)s;
}
if (fault == NoFault) {
- fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
+ fault = writeMemAtomicLE(xc, traceData, Mem, EA, memAccessFlags,
nullptr);
}
}
if (fault == NoFault) {
- fault = writeMemTiming(xc, traceData, Mem, EA,
+ fault = writeMemTimingLE(xc, traceData, Mem, EA,
memAccessFlags, nullptr);
}
}
if (storeCond && fault == NoFault) {
%(EA_trunc)s
- fault = writeMemAtomic(xc, traceData, Mem, EA,
+ fault = writeMemAtomicBE(xc, traceData, Mem, EA,
%(asi_val)s, &mem_data);
}
if (fault == NoFault) {
}
if (fault == NoFault) {
%(EA_trunc)s
- fault = writeMemTiming(xc, traceData, Mem, EA, %(asi_val)s,
+ fault = writeMemTimingBE(xc, traceData, Mem, EA, %(asi_val)s,
&mem_data);
}
return fault;
Fault fault = NoFault;
%(op_decl)s;
- getMem(pkt, Mem, traceData);
+ getMemBE(pkt, Mem, traceData);
uint64_t mem_data = Mem;
if (fault == NoFault) {
%(fault_check)s;
if (fault == NoFault) {
%(EA_trunc)s
- fault = readMemAtomic(xc, traceData, EA, Mem, %(asi_val)s);
+ fault = readMemAtomicBE(xc, traceData, EA, Mem, %(asi_val)s);
}
if (fault == NoFault) {
%(code)s;
Fault fault = NoFault;
%(op_decl)s;
%(op_rd)s;
- getMem(pkt, Mem, traceData);
+ getMemBE(pkt, Mem, traceData);
%(code)s;
if (fault == NoFault) {
%(op_wb)s;
}
if (storeCond && fault == NoFault) {
%(EA_trunc)s
- fault = writeMemAtomic(xc, traceData, Mem, EA, %(asi_val)s, 0);
+ fault = writeMemAtomicBE(
+ xc, traceData, Mem, EA, %(asi_val)s, 0);
}
if (fault == NoFault) {
// Write the resulting state to the execution context
}
if (storeCond && fault == NoFault) {
%(EA_trunc)s
- fault = writeMemTiming(xc, traceData, Mem, EA, %(asi_val)s, 0);
+ fault = writeMemTimingBE(
+ xc, traceData, Mem, EA, %(asi_val)s, 0);
}
return fault;
}