gem5 v24.0.0.0
|
Semihosting for RV32 and RV64. More...
#include <semihosting.hh>
Classes | |
struct | Abi32 |
struct | Abi64 |
struct | RiscvSemihostingAbi |
Public Types | |
enum class | Opcode : uint32_t { Prefix = 0x01f01013 , EBreak = 0x00100073 , Suffix = 0x40705013 } |
enum | Operation { SYS_OPEN = 0x01 , SYS_CLOSE = 0x02 , SYS_WRITEC = 0x03 , SYS_WRITE0 = 0x04 , SYS_WRITE = 0x05 , SYS_READ = 0x06 , SYS_READC = 0x07 , SYS_ISERROR = 0x08 , SYS_ISTTY = 0x09 , SYS_SEEK = 0x0A , SYS_FLEN = 0x0C , SYS_TMPNAM = 0x0D , SYS_REMOVE = 0x0E , SYS_RENAME = 0x0F , SYS_CLOCK = 0x10 , SYS_TIME = 0x11 , SYS_SYSTEM = 0x12 , SYS_ERRNO = 0x13 , SYS_GET_CMDLINE = 0x15 , SYS_HEAPINFO = 0x16 , SYS_EXIT = 0x18 , SYS_EXIT_EXTENDED = 0x20 , SYS_ELAPSED = 0x30 , SYS_TICKFREQ = 0x31 , MaxStandardOp = 0xFF , SYS_GEM5_PSEUDO_OP = 0x100 } |
using | SemiCall = SemiCallBase<RiscvSemihosting, Abi32, Abi64> |
Public Types inherited from gem5::BaseSemihosting | |
typedef std::pair< uint64_t, SemiErrno > | RetErrno |
Public Types inherited from gem5::SimObject | |
typedef SimObjectParams | Params |
Public Member Functions | |
PortProxy & | portProxy (ThreadContext *tc) const override |
ByteOrder | byteOrder (ThreadContext *tc) const override |
RiscvSemihosting (const RiscvSemihostingParams &p) | |
bool | isSemihostingEBreak (ExecContext *xc) |
Perform a RISC-V Semihosting call. | |
bool | call (ThreadContext *tc) |
Public Member Functions inherited from gem5::BaseSemihosting | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. | |
RetErrno | callOpen (ThreadContext *tc, const Addr name_base, int fmode, size_t name_size) |
RetErrno | callClose (ThreadContext *tc, Handle handle) |
RetErrno | callWriteC (ThreadContext *tc, InPlaceArg c) |
RetErrno | callWrite0 (ThreadContext *tc, InPlaceArg str) |
RetErrno | callWrite (ThreadContext *tc, Handle handle, Addr buffer, size_t size) |
RetErrno | callRead (ThreadContext *tc, Handle handle, Addr buffer, size_t size) |
RetErrno | callReadC (ThreadContext *tc) |
RetErrno | callIsError (ThreadContext *tc, int64_t status) |
RetErrno | callIsTTY (ThreadContext *tc, Handle handle) |
RetErrno | callSeek (ThreadContext *tc, Handle handle, uint64_t pos) |
RetErrno | callFLen (ThreadContext *tc, Handle handle) |
RetErrno | callTmpNam (ThreadContext *tc, Addr buffer, uint64_t id, size_t size) |
RetErrno | callRemove (ThreadContext *tc, Addr name_base, size_t name_size) |
RetErrno | callRename (ThreadContext *tc, Addr from_addr, size_t from_size, Addr to_addr, size_t to_size) |
RetErrno | callClock (ThreadContext *tc) |
RetErrno | callTime (ThreadContext *tc) |
RetErrno | callSystem (ThreadContext *tc, Addr cmd_addr, size_t cmd_size) |
RetErrno | callErrno (ThreadContext *tc) |
RetErrno | callGetCmdLine (ThreadContext *tc, Addr addr, InPlaceArg size_arg) |
void | gatherHeapInfo (ThreadContext *tc, bool aarch64, Addr &heap_base, Addr &heap_limit, Addr &stack_base, Addr &stack_limit) |
RetErrno | callHeapInfo32 (ThreadContext *tc, Addr block_addr) |
RetErrno | callHeapInfo64 (ThreadContext *tc, Addr block_addr) |
RetErrno | callExit32 (ThreadContext *tc, InPlaceArg code) |
RetErrno | callExit64 (ThreadContext *tc, uint64_t code, uint64_t subcode) |
RetErrno | callExitExtended (ThreadContext *tc, uint64_t code, uint64_t subcode) |
RetErrno | callElapsed32 (ThreadContext *tc, InPlaceArg low, InPlaceArg high) |
RetErrno | callElapsed64 (ThreadContext *tc, InPlaceArg ticks) |
RetErrno | callTickFreq (ThreadContext *tc) |
template<typename Abi > | |
void | unrecognizedCall (ThreadContext *tc, const char *format, uint64_t op) |
Public Member Functions inherited from gem5::SimObject | |
const Params & | params () const |
SimObject (const Params &p) | |
virtual | ~SimObject () |
virtual void | init () |
init() is called after all C++ SimObjects have been created and all ports are connected. | |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. | |
virtual void | initState () |
initState() is called on each SimObject when not restoring from a checkpoint. | |
virtual void | regProbePoints () |
Register probe points for this object. | |
virtual void | regProbeListeners () |
Register probe listeners for this object. | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. | |
virtual void | startup () |
startup() is the final initialization call before simulation. | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. | |
Public Member Functions inherited from gem5::EventManager | |
EventQueue * | eventQueue () const |
void | schedule (Event &event, Tick when) |
void | deschedule (Event &event) |
void | reschedule (Event &event, Tick when, bool always=false) |
void | schedule (Event *event, Tick when) |
void | deschedule (Event *event) |
void | reschedule (Event *event, Tick when, bool always=false) |
void | wakeupEventQueue (Tick when=(Tick) -1) |
This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. | |
void | setCurTick (Tick newVal) |
EventManager (EventManager &em) | |
Event manger manages events in the event queue. | |
EventManager (EventManager *em) | |
EventManager (EventQueue *eq) | |
Public Member Functions inherited from gem5::Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Public Member Functions inherited from gem5::Drainable | |
DrainState | drainState () const |
Return the current drain state of an object. | |
virtual void | notifyFork () |
Notify a child process of a fork. | |
Public Member Functions inherited from gem5::statistics::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. | |
virtual | ~Group () |
virtual void | regStats () |
Callback to set stat parameters. | |
virtual void | resetStats () |
Callback to reset stats. | |
virtual void | preDumpStats () |
Callback before stats are dumped. | |
void | addStat (statistics::Info *info) |
Register a stat with this group. | |
const std::map< std::string, Group * > & | getStatGroups () const |
Get all child groups associated with this object. | |
const std::vector< Info * > & | getStats () const |
Get all stats associated with this object. | |
void | addStatGroup (const char *name, Group *block) |
Add a stat block as a child of this block. | |
const Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. | |
void | mergeStatGroup (Group *block) |
Merge the contents (stats & children) of a block to this block. | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (const Group &)=delete |
Public Member Functions inherited from gem5::Named | |
Named (const std::string &name_) | |
virtual | ~Named ()=default |
virtual std::string | name () const |
Static Public Member Functions | |
static PortProxy & | portProxyImpl (ThreadContext *tc) |
Static Public Member Functions inherited from gem5::BaseSemihosting | |
static FILE * | getSTDIO (const char *stream_name, const std::string &name, const char *mode) |
Static Public Member Functions inherited from gem5::SimObject | |
static void | serializeAll (const std::string &cpt_dir) |
Create a checkpoint by serializing all SimObjects in the system. | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. | |
static void | setSimObjectResolver (SimObjectResolver *resolver) |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
static SimObjectResolver * | getSimObjectResolver () |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
Static Public Member Functions inherited from gem5::Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. | |
static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
Generate a checkpoint file so that the serialization can be routed to it. | |
Protected Member Functions | |
bool | call64 (ThreadContext *tc) |
bool | call32 (ThreadContext *tc) |
Protected Member Functions inherited from gem5::BaseSemihosting | |
BaseSemihosting (const BaseSemihostingParams &p) | |
unsigned | calcTickShift () const |
uint64_t | semiTick (Tick tick) const |
void | semiExit (uint64_t code, uint64_t subcode) |
std::optional< std::string > | readString (ThreadContext *tc, Addr ptr, size_t len) |
Protected Member Functions inherited from gem5::Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. | |
void | signalDrainDone () const |
Signal that an object is drained. | |
Static Protected Attributes | |
static const std::map< uint32_t, SemiCall > | calls |
Additional Inherited Members | |
Public Attributes inherited from gem5::BaseSemihosting | |
uint16_t | tmpNameIndex = 0 |
Static Public Attributes inherited from gem5::BaseSemihosting | |
static const std::vector< const char * > | fmodes |
static const std::map< uint64_t, const char * > | exitCodes |
static const std::array< uint8_t, 5 > | features |
static const std::map< const std::string, FILE * > | stdioMap |
Protected Types inherited from gem5::BaseSemihosting | |
typedef uint64_t | SemiErrno |
using | Handle = size_t |
Static Protected Member Functions inherited from gem5::BaseSemihosting | |
static RetErrno | retError (SemiErrno e) |
static RetErrno | retOK (uint64_t r) |
Protected Attributes inherited from gem5::BaseSemihosting | |
const std::string | cmdLine |
const Addr | memReserve |
const Addr | stackSize |
const time_t | timeBase |
Base time when the simulation started. | |
const unsigned | tickShift |
Number of bits to right shift gem5 ticks to fit in a uint32_t. | |
SemiErrno | semiErrno |
std::string | filesRootDir |
std::vector< std::unique_ptr< FileBase > > | files |
FILE * | stdin |
FILE * | stdout |
FILE * | stderr |
Protected Attributes inherited from gem5::SimObject | |
const SimObjectParams & | _params |
Cached copy of the object parameters. | |
Protected Attributes inherited from gem5::EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. | |
Semihosting for RV32 and RV64.
Definition at line 55 of file semihosting.hh.
Definition at line 134 of file semihosting.hh.
|
strong |
Enumerator | |
---|---|
Prefix | |
EBreak | |
Suffix |
Definition at line 58 of file semihosting.hh.
Definition at line 102 of file semihosting.hh.
|
explicit |
Definition at line 100 of file semihosting.cc.
|
inlineoverridevirtual |
Implements gem5::BaseSemihosting.
Definition at line 73 of file semihosting.hh.
bool gem5::RiscvSemihosting::call | ( | ThreadContext * | tc | ) |
Definition at line 144 of file semihosting.cc.
References call32(), call64(), gem5::ThreadContext::getIsaPtr(), and panic_if.
|
protected |
Definition at line 124 of file semihosting.cc.
References gem5::RiscvISA::int_reg::A0, call(), calls, DPRINTF, gem5::ArmISA::err, gem5::ThreadContext::getReg(), gem5::X86ISA::op, gem5::BaseSemihosting::semiErrno, and gem5::BaseSemihosting::unrecognizedCall().
Referenced by call().
|
protected |
Definition at line 105 of file semihosting.cc.
References gem5::RiscvISA::int_reg::A0, call(), calls, DPRINTF, gem5::ArmISA::err, gem5::ThreadContext::getReg(), gem5::ArmISA::mask, gem5::X86ISA::op, gem5::BaseSemihosting::semiErrno, and gem5::BaseSemihosting::unrecognizedCall().
Referenced by call().
bool gem5::RiscvSemihosting::isSemihostingEBreak | ( | ExecContext * | xc | ) |
Perform a RISC-V Semihosting call.
Definition at line 162 of file semihosting.cc.
References DPRINTF, EBreak, gem5::gtoh(), gem5::PCStateBase::instAddr(), gem5::RiscvISA::PageBytes, gem5::ExecContext::pcState(), portProxyImpl(), Prefix, gem5::roundDown(), Suffix, gem5::ExecContext::tcBase(), and gem5::PortProxy::tryReadBlob().
|
inlineoverridevirtual |
Implements gem5::BaseSemihosting.
Definition at line 68 of file semihosting.hh.
References portProxyImpl().
|
static |
Definition at line 152 of file semihosting.cc.
References gem5::FullSystem.
Referenced by isSemihostingEBreak(), and portProxy().
|
staticprotected |
Definition at line 144 of file semihosting.hh.