gem5
v20.1.0.0
|
Semihosting for AArch32 and AArch64. More...
#include <semihosting.hh>
Classes | |
struct | Abi32 |
struct | Abi64 |
struct | AbiBase |
class | File |
class | FileBase |
Internal state for open files. More... | |
class | FileFeatures |
Implementation of the ':semihosting-features' magic file. More... | |
struct | InPlaceArg |
struct | SemiCall |
Semihosting call information structure. More... | |
Public Types | |
enum | { T32Imm = 0xAB, A32Imm = 0x123456, A64Imm = 0xF000, Gem5Imm = 0x5D57 } |
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 } |
typedef std::pair< uint64_t, SemiErrno > | RetErrno |
Public Types inherited from SimObject | |
typedef SimObjectParams | Params |
Public Member Functions | |
ArmSemihosting (const ArmSemihostingParams *p) | |
bool | call64 (ThreadContext *tc, bool gem5_ops) |
Perform an Arm Semihosting call from aarch64 code. More... | |
bool | call32 (ThreadContext *tc, bool gem5_ops) |
Perform an Arm Semihosting call from aarch32 code. More... | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
Public Member Functions inherited from SimObject | |
const Params * | params () const |
SimObject (const Params *_params) | |
virtual | ~SimObject () |
virtual const std::string | name () const |
virtual void | init () |
init() is called after all C++ SimObjects have been created and all ports are connected. More... | |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. More... | |
virtual void | initState () |
initState() is called on each SimObject when not restoring from a checkpoint. More... | |
virtual void | regProbePoints () |
Register probe points for this object. More... | |
virtual void | regProbeListeners () |
Register probe listeners for this object. More... | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. More... | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. More... | |
virtual void | startup () |
startup() is the final initialization call before simulation. More... | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. More... | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. More... | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. More... | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. More... | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. More... | |
Public Member Functions inherited from 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. More... | |
void | setCurTick (Tick newVal) |
EventManager (EventManager &em) | |
Event manger manages events in the event queue. More... | |
EventManager (EventManager *em) | |
EventManager (EventQueue *eq) | |
Public Member Functions inherited from Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. More... | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. More... | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Public Member Functions inherited from Drainable | |
DrainState | drainState () const |
Return the current drain state of an object. More... | |
virtual void | notifyFork () |
Notify a child process of a fork. More... | |
Public Member Functions inherited from Stats::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. More... | |
virtual | ~Group () |
virtual void | regStats () |
Callback to set stat parameters. More... | |
virtual void | resetStats () |
Callback to reset stats. More... | |
virtual void | preDumpStats () |
Callback before stats are dumped. More... | |
void | addStat (Stats::Info *info) |
Register a stat with this group. More... | |
const std::map< std::string, Group * > & | getStatGroups () const |
Get all child groups associated with this object. More... | |
const std::vector< Info * > & | getStats () const |
Get all stats associated with this object. More... | |
void | addStatGroup (const char *name, Group *block) |
Add a stat block as a child of this block. More... | |
const Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. More... | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (const Group &)=delete |
Static Public Member Functions | |
static PortProxy & | portProxy (ThreadContext *tc) |
Static Public Member Functions inherited from SimObject | |
static void | serializeAll (CheckpointOut &cp) |
Serialize all SimObjects in the system. More... | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. More... | |
Static Public Member Functions inherited from Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. More... | |
static void | serializeAll (const std::string &cpt_dir) |
Serializes all the SimObjects. More... | |
static void | unserializeGlobals (CheckpointIn &cp) |
Protected Types | |
typedef uint64_t | SemiErrno |
using | Handle = size_t |
Protected Member Functions | |
unsigned | calcTickShift () const |
uint64_t | semiTick (Tick tick) const |
void | semiExit (uint64_t code, uint64_t subcode) |
std::string | readString (ThreadContext *tc, Addr ptr, size_t len) |
Protected Member Functions inherited from Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. More... | |
void | signalDrainDone () const |
Signal that an object is drained. More... | |
Protected Attributes | |
const std::string | cmdLine |
const Addr | memReserve |
const Addr | stackSize |
const time_t | timeBase |
Base time when the simulation started. More... | |
const unsigned | tickShift |
Number of bits to right shift gem5 ticks to fit in a uint32_t. More... | |
SemiErrno | semiErrno |
std::string | filesRootDir |
std::vector< std::unique_ptr< FileBase > > | files |
FILE * | stdin |
FILE * | stdout |
FILE * | stderr |
Protected Attributes inherited from SimObject | |
const SimObjectParams * | _params |
Cached copy of the object parameters. More... | |
Protected Attributes inherited from EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. More... | |
Static Private Member Functions | |
static RetErrno | retError (SemiErrno e) |
static RetErrno | retOK (uint64_t r) |
static FILE * | getSTDIO (const char *stream_name, const std::string &name, const char *mode) |
Static Private Attributes | |
static const std::map< uint32_t, SemiCall > | calls |
static const std::vector< const char * > | fmodes |
static const std::map< uint64_t, const char * > | exitCodes |
static const std::vector< uint8_t > | features |
static const std::map< const std::string, FILE * > | stdioMap |
Semihosting for AArch32 and AArch64.
This class implements the Arm semihosting interface. This interface allows baremetal code access service, such as IO, from the simulator. It is conceptually a simplified version of gem5's more general syscall emulation mode.
Exits calls (SYS_EXIT, SYS_EXIT_EXTENDED) from the guest get translated into simualtion exits. Well-known exit codes are translated to messages on the form 'semi:ADP_.*' while unknown codes are returned in hex ('semi:0x..'). The subcode is reported in the gem5 exit event.
Definition at line 72 of file semihosting.hh.
|
protected |
Definition at line 403 of file semihosting.hh.
typedef std::pair<uint64_t, SemiErrno> ArmSemihosting::RetErrno |
Definition at line 424 of file semihosting.hh.
|
protected |
Definition at line 253 of file semihosting.hh.
anonymous enum |
Enumerator | |
---|---|
T32Imm | |
A32Imm | |
A64Imm | |
Gem5Imm |
Definition at line 76 of file semihosting.hh.
Definition at line 196 of file semihosting.hh.
ArmSemihosting::ArmSemihosting | ( | const ArmSemihostingParams * | p | ) |
Definition at line 137 of file semihosting.cc.
References mkutctime(), MipsISA::p, and ArmISA::t.
|
inlineprotected |
Definition at line 410 of file semihosting.hh.
References findMsbSet(), and SimClock::Frequency.
bool ArmSemihosting::call32 | ( | ThreadContext * | tc, |
bool | gem5_ops | ||
) |
Perform an Arm Semihosting call from aarch32 code.
Definition at line 189 of file semihosting.cc.
References ArmSemihosting::SemiCall::call32, calls, DPRINTF, ArmSemihosting::SemiCall::dump32, ArmISA::err, ArmISA::INTREG_R0, MaxStandardOp, X86ISA::op, ThreadContext::readIntReg(), and semiErrno.
Referenced by ArmSystem::callSemihosting32().
bool ArmSemihosting::call64 | ( | ThreadContext * | tc, |
bool | gem5_ops | ||
) |
Perform an Arm Semihosting call from aarch64 code.
Definition at line 163 of file semihosting.cc.
References ArmSemihosting::SemiCall::call64, calls, DPRINTF, ArmSemihosting::SemiCall::dump64, ArmISA::err, ArmISA::INTREG_X0, ArmISA::mask, MaxStandardOp, X86ISA::op, ThreadContext::readIntReg(), and semiErrno.
Referenced by ArmSystem::callSemihosting64().
|
private |
Definition at line 492 of file semihosting.cc.
References curTick(), retOK(), and SimClock::Int::s.
|
private |
Definition at line 308 of file semihosting.cc.
References DPRINTF, files, retError(), and retOK().
|
private |
Definition at line 642 of file semihosting.cc.
References ArmISA::byteOrder(), curTick(), retOK(), semiTick(), and ArmSemihosting::InPlaceArg::write().
|
private |
Definition at line 656 of file semihosting.cc.
References ArmISA::byteOrder(), curTick(), retOK(), semiTick(), and ArmSemihosting::InPlaceArg::write().
|
private |
Definition at line 514 of file semihosting.cc.
References semiErrno.
|
private |
Definition at line 608 of file semihosting.cc.
References ArmSemihosting::InPlaceArg::addr, retOK(), and semiExit().
|
private |
Definition at line 615 of file semihosting.cc.
References retOK(), and semiExit().
|
private |
Definition at line 622 of file semihosting.cc.
References retOK(), and semiExit().
|
private |
Definition at line 435 of file semihosting.cc.
References files, retError(), and retOK().
|
private |
Definition at line 713 of file semihosting.cc.
References PseudoInst::decodeAddrOffset(), retError(), and retOK().
|
private |
Definition at line 726 of file semihosting.cc.
References PseudoInst::decodeAddrOffset(), retError(), and retOK().
|
private |
Definition at line 521 of file semihosting.cc.
References addr, ArmISA::byteOrder(), cmdLine, portProxy(), ArmSemihosting::InPlaceArg::read(), retError(), retOK(), ArmSemihosting::InPlaceArg::write(), and PortProxy::writeBlob().
|
private |
Definition at line 579 of file semihosting.cc.
References ArmISA::byteOrder(), gatherHeapInfo(), portProxy(), retOK(), and PortProxy::write().
|
private |
Definition at line 594 of file semihosting.cc.
References ArmISA::byteOrder(), gatherHeapInfo(), portProxy(), retOK(), and PortProxy::write().
|
private |
Definition at line 401 of file semihosting.cc.
References retOK(), and ArmISA::status.
|
private |
Definition at line 407 of file semihosting.cc.
References files, retError(), and retOK().
|
private |
Definition at line 280 of file semihosting.cc.
References ArmSemihosting::FileBase::create(), DPRINTF, files, filesRootDir, fmodes, ArmISA::mode, readString(), retError(), and retOK().
|
private |
Definition at line 374 of file semihosting.cc.
References addr, files, panic_if, portProxy(), retOK(), and PortProxy::writeBlob().
|
private |
Definition at line 395 of file semihosting.cc.
References retOK().
|
private |
Definition at line 466 of file semihosting.cc.
References readString(), retError(), and retOK().
|
private |
Definition at line 478 of file semihosting.cc.
References readString(), retError(), and retOK().
|
private |
Definition at line 421 of file semihosting.cc.
References files, retError(), and retOK().
|
private |
Definition at line 504 of file semihosting.cc.
References readString(), retError(), and warn.
|
private |
Definition at line 664 of file semihosting.cc.
References SimClock::Frequency, retOK(), and semiTick().
|
private |
Definition at line 498 of file semihosting.cc.
References curTick(), retOK(), SimClock::Float::s, and timeBase.
|
private |
Definition at line 449 of file semihosting.cc.
References addr, Serializable::path, portProxy(), retError(), retOK(), and PortProxy::writeBlob().
|
private |
Definition at line 353 of file semihosting.cc.
References addr, files, portProxy(), and PortProxy::readBlob().
|
private |
Definition at line 341 of file semihosting.cc.
References ArmSemihosting::InPlaceArg::addr, DPRINTF, portProxy(), PortProxy::readString(), and retOK().
|
private |
Definition at line 330 of file semihosting.cc.
References ArmSemihosting::InPlaceArg::addr, ArmISA::c, DPRINTF, portProxy(), PortProxy::read(), and retOK().
|
private |
Definition at line 538 of file semihosting.cc.
References ArmISA::aarch64, fatal_if, PhysicalMemory::getConfAddrRanges(), System::getPhysMem(), ThreadContext::getSystemPtr(), inform, memReserve, panic_if, stackSize, ULL, warn, and warn_if.
Referenced by callHeapInfo32(), and callHeapInfo64().
|
staticprivate |
Definition at line 739 of file semihosting.cc.
References ArmISA::f, fatal, ArmISA::mode, SimObject::name(), and stdioMap.
|
static |
Definition at line 242 of file semihosting.cc.
References FullSystem, ThreadContext::getSystemPtr(), ThreadContext::getVirtProxy(), ArmISA::isSecure(), SETranslatingPortProxy::NextPage, and Request::SECURE.
Referenced by callGetCmdLine(), callHeapInfo32(), callHeapInfo64(), callRead(), callTmpNam(), callWrite(), callWrite0(), callWriteC(), ArmSemihosting::AbiBase::StateBase< Arg >::get(), ArmSemihosting::InPlaceArg::read(), readString(), and ArmSemihosting::InPlaceArg::write().
|
protected |
Definition at line 269 of file semihosting.cc.
References ArmISA::len, portProxy(), and PortProxy::readBlob().
Referenced by callOpen(), callRemove(), callRename(), and callSystem().
Definition at line 428 of file semihosting.hh.
References ArmISA::e.
Referenced by callClose(), callFLen(), callGem5PseudoOp32(), callGem5PseudoOp64(), callGetCmdLine(), callIsTTY(), callOpen(), callRemove(), callRename(), callSeek(), callSystem(), callTmpNam(), and unrecognizedCall().
|
inlinestaticprivate |
Definition at line 434 of file semihosting.hh.
References MipsISA::r.
Referenced by callClock(), callClose(), callElapsed32(), callElapsed64(), callExit32(), callExit64(), callExitExtended(), callFLen(), callGem5PseudoOp32(), callGem5PseudoOp64(), callGetCmdLine(), callHeapInfo32(), callHeapInfo64(), callIsError(), callIsTTY(), callOpen(), callRead(), callReadC(), callRemove(), callRename(), callSeek(), callTickFreq(), callTime(), callTmpNam(), callWrite0(), and callWriteC().
|
protected |
Definition at line 630 of file semihosting.cc.
References csprintf(), exitCodes, and exitSimLoop().
Referenced by callExit32(), callExit64(), and callExitExtended().
|
inlineprotected |
Definition at line 416 of file semihosting.hh.
References tickShift.
Referenced by callElapsed32(), callElapsed64(), and callTickFreq().
|
overridevirtual |
Serialize an object.
Output an object's state into the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 215 of file semihosting.cc.
References csprintf(), files, ArmISA::i, paramOut(), semiErrno, and SERIALIZE_SCALAR.
|
inlineprivate |
Definition at line 568 of file semihosting.hh.
References ArmISA::format, X86ISA::op, retError(), and warn.
|
overridevirtual |
Unserialize an object.
Read an object's state from the current checkpoint section.
cp | Checkpoint state |
Implements Serializable.
Definition at line 230 of file semihosting.cc.
References ArmSemihosting::FileBase::create(), csprintf(), files, ArmISA::i, paramIn(), semiErrno, and UNSERIALIZE_SCALAR.
|
staticprivate |
Definition at line 579 of file semihosting.hh.
|
protected |
Definition at line 239 of file semihosting.hh.
Referenced by callGetCmdLine().
|
staticprivate |
Definition at line 581 of file semihosting.hh.
Referenced by semiExit().
|
staticprivate |
Definition at line 582 of file semihosting.hh.
Referenced by ArmSemihosting::FileFeatures::read(), and ArmSemihosting::FileFeatures::seek().
|
protected |
Definition at line 402 of file semihosting.hh.
Referenced by callClose(), callFLen(), callIsTTY(), callOpen(), callRead(), callSeek(), callWrite(), serialize(), and unserialize().
|
protected |
Definition at line 401 of file semihosting.hh.
Referenced by callOpen().
|
staticprivate |
Definition at line 580 of file semihosting.hh.
Referenced by callOpen().
|
protected |
Definition at line 240 of file semihosting.hh.
Referenced by gatherHeapInfo().
|
protected |
Definition at line 254 of file semihosting.hh.
Referenced by call32(), call64(), callErrno(), serialize(), and unserialize().
|
protected |
Definition at line 241 of file semihosting.hh.
Referenced by gatherHeapInfo().
|
protected |
Definition at line 406 of file semihosting.hh.
|
protected |
Definition at line 404 of file semihosting.hh.
|
staticprivate |
Definition at line 583 of file semihosting.hh.
Referenced by getSTDIO().
|
protected |
Definition at line 405 of file semihosting.hh.
|
protected |
Number of bits to right shift gem5 ticks to fit in a uint32_t.
Definition at line 250 of file semihosting.hh.
Referenced by semiTick().
|
protected |
Base time when the simulation started.
This is used to calculate the time of date when the guest call SYS_TIME.
Definition at line 247 of file semihosting.hh.
Referenced by callTime().