51#include "debug/Semihosting.hh"
56#include "params/RiscvSemihosting.hh"
109 if (it ==
calls.end()) {
115 DPRINTF(Semihosting,
"Semihosting call64: %s\n",
call.dump64(tc));
116 auto err =
call.call64(
this, tc);
118 DPRINTF(Semihosting,
"\t ->: 0x%x, %i\n",
err.first,
err.second);
128 if (it ==
calls.end()) {
130 tc,
"Unknown aarch32 semihosting call: op = 0x%x",
op);
135 DPRINTF(Semihosting,
"Semihosting call32: %s\n",
call.dump32(tc));
136 auto err =
call.call32(
this, tc);
138 DPRINTF(Semihosting,
"\t ->: 0x%x, %i\n",
err.first,
err.second);
147 panic_if(!isa,
"Cannot derive rv_type from non-riscv isa");
148 return isa->rvType() == enums::RV32 ?
call32(tc) :
call64(tc);
154 static std::unique_ptr<PortProxy> port_proxy([=]() {
171 "Ebreak cannot be a semihosting ebreak since previous "
172 "and next instruction are on different pages\n");
175 uint32_t instSequence[3];
176 if (!proxy.
tryReadBlob(PrevInstAddr, instSequence,
sizeof(instSequence))) {
178 "Ebreak cannot be a semihosting ebreak since surrounding "
179 "instructions at %#x cannot be accessed\n");
182 uint32_t PrevInst =
gtoh(instSequence[0], ByteOrder::little);
183 uint32_t EBreakInst =
gtoh(instSequence[1], ByteOrder::little);
184 uint32_t NextInst =
gtoh(instSequence[2], ByteOrder::little);
186 "Checking ebreak for semihosting: Prev=%#x EBreak=%#x Next=%#x\n",
187 PrevInst, EBreakInst, NextInst);
Semihosting for AArch32, AArch64, RISCV-32 and RISCV-64: https://github.com/ARM-software/abi-aa/blob/...
RetErrno callReadC(ThreadContext *tc)
RetErrno callElapsed32(ThreadContext *tc, InPlaceArg low, InPlaceArg high)
RetErrno callExit64(ThreadContext *tc, uint64_t code, uint64_t subcode)
RetErrno callFLen(ThreadContext *tc, Handle handle)
void unrecognizedCall(ThreadContext *tc, const char *format, uint64_t op)
RetErrno callTickFreq(ThreadContext *tc)
RetErrno callRename(ThreadContext *tc, Addr from_addr, size_t from_size, Addr to_addr, size_t to_size)
RetErrno callExitExtended(ThreadContext *tc, uint64_t code, uint64_t subcode)
RetErrno callTmpNam(ThreadContext *tc, Addr buffer, uint64_t id, size_t size)
RetErrno callSeek(ThreadContext *tc, Handle handle, uint64_t pos)
RetErrno callSystem(ThreadContext *tc, Addr cmd_addr, size_t cmd_size)
RetErrno callWrite(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
RetErrno callOpen(ThreadContext *tc, const Addr name_base, int fmode, size_t name_size)
RetErrno callIsError(ThreadContext *tc, int64_t status)
RetErrno callElapsed64(ThreadContext *tc, InPlaceArg ticks)
RetErrno callRead(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
RetErrno callExit32(ThreadContext *tc, InPlaceArg code)
RetErrno callGetCmdLine(ThreadContext *tc, Addr addr, InPlaceArg size_arg)
RetErrno callHeapInfo32(ThreadContext *tc, Addr block_addr)
RetErrno callClock(ThreadContext *tc)
RetErrno callRemove(ThreadContext *tc, Addr name_base, size_t name_size)
RetErrno callHeapInfo64(ThreadContext *tc, Addr block_addr)
RetErrno callIsTTY(ThreadContext *tc, Handle handle)
RetErrno callWriteC(ThreadContext *tc, InPlaceArg c)
RetErrno callErrno(ThreadContext *tc)
RetErrno callTime(ThreadContext *tc)
RetErrno callWrite0(ThreadContext *tc, InPlaceArg str)
RetErrno callClose(ThreadContext *tc, Handle handle)
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
virtual const PCStateBase & pcState() const =0
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
This object is a proxy for a port or other object which implements the functional response protocol,...
virtual bool tryReadBlob(Addr addr, void *p, uint64_t size) const
Methods to override in base classes.
bool call64(ThreadContext *tc)
static PortProxy & portProxyImpl(ThreadContext *tc)
RiscvSemihosting(const RiscvSemihostingParams &p)
static const std::map< uint32_t, SemiCall > calls
SemiCallBase< RiscvSemihosting, Abi32, Abi64 > SemiCall
bool call(ThreadContext *tc)
bool isSemihostingEBreak(ExecContext *xc)
Perform a RISC-V Semihosting call.
bool call32(ThreadContext *tc)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId ®) const
virtual BaseISA * getIsaPtr() const =0
This proxy attempts to translate virtual addresses using the TLBs.
static constexpr T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
T gtoh(T value, ByteOrder guest_byte_order)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.