32 #ifndef __ARCH_X86_MEMHELPERS_HH__ 33 #define __ARCH_X86_MEMHELPERS_HH__ 59 mem = pkt->
getLE<uint8_t>();
62 mem = pkt->
getLE<uint16_t>();
65 mem = pkt->
getLE<uint32_t>();
68 mem = pkt->
getLE<uint64_t>();
71 panic(
"Unhandled size in getMem.\n");
77 template <
typename T,
size_t N>
81 std::array<T, N> real_mem = pkt->
getLE<std::array<T, N> >();
82 for (
int i = 0;
i < N;
i++)
93 getPackedMem<uint32_t, N>(pkt,
mem, dataSize);
96 getPackedMem<uint64_t, N>(pkt,
mem, dataSize);
99 panic(
"Unhandled element size in getMem.\n");
110 memset(&mem, 0,
sizeof(mem));
111 Fault fault = xc->
readMem(addr, (uint8_t *)&mem, dataSize, flags);
123 template <
typename T,
size_t N>
128 std::array<T, N> real_mem;
130 sizeof(T) * N, flags);
132 real_mem =
letoh(real_mem);
133 for (
int i = 0;
i < N;
i++)
134 mem[
i] = real_mem[
i];
142 std::array<uint64_t, N> &
mem,
unsigned dataSize,
149 fault = readPackedMemAtomic<uint32_t, N>(xc,
addr,
mem, flags);
152 fault = readPackedMemAtomic<uint64_t, N>(xc,
addr,
mem, flags);
155 panic(
"Unhandled element size in readMemAtomic\n");
157 if (fault ==
NoFault && traceData)
162 template <
typename T,
size_t N>
165 unsigned flags, uint64_t *res)
167 std::array<T, N> real_mem;
168 for (
int i = 0;
i < N;
i++)
169 real_mem[
i] = mem[
i];
170 real_mem =
htole(real_mem);
171 return xc->
writeMem((uint8_t *)&real_mem,
sizeof(T) * N,
183 return xc->
writeMem((uint8_t *)&mem, dataSize, addr, flags, res);
189 std::array<uint64_t, N> &
mem,
unsigned dataSize,
190 Addr addr,
unsigned flags, uint64_t *res)
197 return writePackedMem<uint32_t, N>(xc,
mem,
addr, flags, res);
199 return writePackedMem<uint64_t, N>(xc,
mem,
addr, flags, res);
201 panic(
"Unhandled element size in writeMemTiming.\n");
212 uint64_t host_mem =
htole(mem);
214 xc->
writeMem((uint8_t *)&host_mem, dataSize, addr, flags, res);
223 std::array<uint64_t, N> &
mem,
unsigned dataSize,
224 Addr addr,
unsigned flags, uint64_t *res)
232 fault = writePackedMem<uint32_t, N>(xc,
mem,
addr, flags, res);
235 fault = writePackedMem<uint64_t, N>(xc,
mem,
addr, flags, res);
238 panic(
"Unhandled element size in writeMemAtomic.\n");
#define panic(...)
This implements a cprintf based panic() function.
static Fault initiateMemRead(ExecContext *xc, Trace::InstRecord *traceData, Addr addr, unsigned dataSize, Request::Flags flags)
Initiate a read from memory in timing mode.
decltype(nullptr) constexpr NoFault
static Fault writeMemTiming(ExecContext *xc, Trace::InstRecord *traceData, uint64_t mem, unsigned dataSize, Addr addr, Request::Flags flags, uint64_t *res)
virtual Fault initiateMemRead(Addr addr, unsigned int size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Initiate a timing memory read operation.
static Fault writeMemAtomic(ExecContext *xc, Trace::InstRecord *traceData, uint64_t mem, unsigned dataSize, Addr addr, Request::Flags flags, uint64_t *res)
virtual Fault writeMem(uint8_t *data, unsigned int size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable=std::vector< bool >())=0
For atomic-mode contexts, perform an atomic memory write operation.
static Fault writePackedMem(ExecContext *xc, std::array< uint64_t, N > &mem, Addr addr, unsigned flags, uint64_t *res)
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
static Fault readMemAtomic(ExecContext *xc, Trace::InstRecord *traceData, Addr addr, uint64_t &mem, unsigned dataSize, Request::Flags flags)
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
static void getPackedMem(PacketPtr pkt, std::array< uint64_t, N > &mem, unsigned dataSize)
void setData(std::array< T, N > d)
static void getMem(PacketPtr pkt, uint64_t &mem, unsigned dataSize, Trace::InstRecord *traceData)
This is exposed globally, independent of the ISA.
static Fault readPackedMemAtomic(ExecContext *xc, Addr addr, std::array< uint64_t, N > &mem, unsigned flags)
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
virtual Fault readMem(Addr addr, uint8_t *data, unsigned int size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Perform an atomic memory read operation.
std::shared_ptr< FaultBase > Fault