gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::RiscvSemihosting Class Reference

Semihosting for RV32 and RV64. More...

#include <semihosting.hh>

Inheritance diagram for gem5::RiscvSemihosting:
gem5::BaseSemihosting gem5::SimObject gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named

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, SemiErrnoRetErrno
 
- Public Types inherited from gem5::SimObject
typedef SimObjectParams Params
 

Public Member Functions

PortProxyportProxy (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 Paramsparams () 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.
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object.
 
virtual PortgetPort (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
EventQueueeventQueue () 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 InforesolveStat (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
 
Groupoperator= (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 PortProxyportProxyImpl (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 SimObjectfind (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 SimObjectResolvergetSimObjectResolver ()
 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, SemiCallcalls
 

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
EventQueueeventq
 A pointer to this object's event queue.
 

Detailed Description

Semihosting for RV32 and RV64.

Definition at line 55 of file semihosting.hh.

Member Typedef Documentation

◆ SemiCall

Member Enumeration Documentation

◆ Opcode

enum class gem5::RiscvSemihosting::Opcode : uint32_t
strong
Enumerator
Prefix 
EBreak 
Suffix 

Definition at line 58 of file semihosting.hh.

◆ Operation

Enumerator
SYS_OPEN 
SYS_CLOSE 
SYS_WRITEC 
SYS_WRITE0 
SYS_WRITE 
SYS_READ 
SYS_READC 
SYS_ISERROR 
SYS_ISTTY 
SYS_SEEK 
SYS_FLEN 
SYS_TMPNAM 
SYS_REMOVE 
SYS_RENAME 
SYS_CLOCK 
SYS_TIME 
SYS_SYSTEM 
SYS_ERRNO 
SYS_GET_CMDLINE 
SYS_HEAPINFO 
SYS_EXIT 
SYS_EXIT_EXTENDED 
SYS_ELAPSED 
SYS_TICKFREQ 
MaxStandardOp 
SYS_GEM5_PSEUDO_OP 

Definition at line 102 of file semihosting.hh.

Constructor & Destructor Documentation

◆ RiscvSemihosting()

gem5::RiscvSemihosting::RiscvSemihosting ( const RiscvSemihostingParams & p)
explicit

Definition at line 100 of file semihosting.cc.

Member Function Documentation

◆ byteOrder()

ByteOrder gem5::RiscvSemihosting::byteOrder ( ThreadContext * tc) const
inlineoverridevirtual

Implements gem5::BaseSemihosting.

Definition at line 73 of file semihosting.hh.

◆ call()

bool gem5::RiscvSemihosting::call ( ThreadContext * tc)

Definition at line 144 of file semihosting.cc.

References call32(), call64(), gem5::ThreadContext::getIsaPtr(), and panic_if.

Referenced by call32(), and call64().

◆ call32()

◆ call64()

◆ isSemihostingEBreak()

bool gem5::RiscvSemihosting::isSemihostingEBreak ( ExecContext * xc)

◆ portProxy()

PortProxy & gem5::RiscvSemihosting::portProxy ( ThreadContext * tc) const
inlineoverridevirtual

Implements gem5::BaseSemihosting.

Definition at line 68 of file semihosting.hh.

References portProxyImpl().

◆ portProxyImpl()

PortProxy & gem5::RiscvSemihosting::portProxyImpl ( ThreadContext * tc)
static

Definition at line 152 of file semihosting.cc.

References gem5::FullSystem.

Referenced by isSemihostingEBreak(), and portProxy().

Member Data Documentation

◆ calls

const std::map< uint32_t, RiscvSemihosting::SemiCall > gem5::RiscvSemihosting::calls
staticprotected

Definition at line 144 of file semihosting.hh.

Referenced by call32(), and call64().


The documentation for this class was generated from the following files:

Generated on Tue Jun 18 2024 16:24:14 for gem5 by doxygen 1.11.0