Go to the documentation of this file.
38 #ifndef __ARCH_ARM_SEMIHOSTING_HH__
39 #define __ARCH_ARM_SEMIHOSTING_HH__
55 struct ArmSemihostingParams;
91 template <
typename Arg>
148 class State :
public StateBase<uint64_t>
175 return proxy.read<uint64_t>(
addr, endian);
177 return proxy.read<uint32_t>(
addr, endian);
179 panic(
"Unexpected semihosting argument size %d.",
size);
188 proxy.write<uint64_t>(
addr,
val, endian);
190 proxy.write<uint32_t>(
addr,
val, endian);
192 panic(
"Unexpected semihosting argument size %d.",
size);
280 static std::unique_ptr<FileBase>
create(
283 static std::unique_ptr<FileBase>
create(
307 virtual int64_t
open() {
return 0; }
314 virtual int64_t
close() {
return 0; }
321 virtual bool isTTY()
const {
return false; }
328 virtual int64_t
read(uint8_t *buffer, uint64_t size);
335 virtual int64_t
write(
const uint8_t *buffer, uint64_t size);
343 virtual int64_t
seek(uint64_t pos);
350 virtual int64_t
flen();
365 const char *
name,
const char *
mode);
370 int64_t
read(uint8_t *buffer, uint64_t size)
override;
371 int64_t
seek(uint64_t
pos)
override;
387 int64_t
close()
override;
388 bool isTTY()
const override;
389 int64_t
read(uint8_t *buffer, uint64_t size)
override;
390 int64_t
write(
const uint8_t *buffer, uint64_t size)
override;
391 int64_t
seek(uint64_t pos)
override;
392 int64_t
flen()
override;
413 return msb > 31 ? msb - 31 : 0;
420 void semiExit(uint64_t code, uint64_t subcode);
452 template <
typename ...Args>
458 template <
typename ...Args>
463 return (
sh->*
impl)(tc, args...);
482 template <
typename Abi,
typename ...Args>
489 return invokeSimcall<Abi>(tc, wrapper);
494 template <
typename Abi,
typename ...Args>
505 template <
typename ...Args>
514 template <
typename ...Args32,
typename ...Args64>
525 int fmode,
size_t name_size);
530 Addr buffer,
size_t size);
532 Addr buffer,
size_t size);
539 uint64_t
id,
size_t size);
542 Addr to_addr,
size_t to_size);
551 Addr &stack_base,
Addr &stack_limit);
566 template <
typename Abi>
573 invokeSimcall<Abi>(tc, retErr);
576 static FILE *
getSTDIO(
const char *stream_name,
577 const std::string &
name,
const char *
mode);
579 static const std::map<uint32_t, SemiCall>
calls;
581 static const std::map<uint64_t, const char *>
exitCodes;
583 static const std::map<const std::string, FILE *>
stdioMap;
592 template <
typename Arg>
594 typename std::enable_if<std::is_integral<Arg>::value>
::type>
599 return state.
get(tc);
603 template <
typename Arg>
605 typename std::enable_if<std::is_integral<Arg>::value>
::type>
610 if (std::is_signed<Arg>::value)
611 return sext<32>(state.get(tc));
613 return state.get(tc);
617 template <
typename Abi>
619 std::is_base_of<ArmSemihosting::AbiBase, Abi>::value>
::type>
625 state.getAddr(),
sizeof(
typename Abi::State::ArgType));
651 #endif // __ARCH_ARM_SEMIHOSTING_HH__
void gatherHeapInfo(ThreadContext *tc, bool aarch64, Addr &heap_base, Addr &heap_limit, Addr &stack_base, Addr &stack_limit)
static ArmSemihosting::InPlaceArg get(ThreadContext *tc, typename Abi::State &state)
Implementation of the ':semihosting-features' magic file.
static std::unique_ptr< FileBase > create(ArmSemihosting &parent, const std::string &fname, const char *mode)
static RetErrno retError(SemiErrno e)
RetErrno callWrite0(ThreadContext *tc, InPlaceArg str)
RetErrno callWrite(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
RetErrno callExit64(ThreadContext *tc, uint64_t code, uint64_t subcode)
virtual int64_t flen()
Get the length of a file in bytes.
RetErrno callElapsed32(ThreadContext *tc, InPlaceArg low, InPlaceArg high)
static const std::map< const std::string, FILE * > stdioMap
RetErrno callTickFreq(ThreadContext *tc)
RetErrno callRename(ThreadContext *tc, Addr from_addr, size_t from_size, Addr to_addr, size_t to_size)
static RetErrno retOK(uint64_t r)
RetErrno callElapsed64(ThreadContext *tc, InPlaceArg ticks)
RetErrno callWriteC(ThreadContext *tc, InPlaceArg c)
ByteOrder byteOrder(const ThreadContext *tc)
int findMsbSet(uint64_t val)
Returns the bit position of the MSB that is set in the input.
std::function< RetErrno(ArmSemihosting *sh, ThreadContext *tc)> Dispatcher
Basic support for object serialization.
RetErrno callOpen(ThreadContext *tc, const Addr name_base, int fmode, size_t name_size)
int64_t openImpl(bool unserialize)
uint64_t semiTick(Tick tick) const
const std::string cmdLine
static const std::vector< uint8_t > features
static Dumper buildDumper(const char *name, Implementation< Args... > impl)
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
uint64_t Tick
Tick count type.
static const std::vector< const char * > fmodes
RetErrno callErrno(ThreadContext *tc)
RetErrno callRemove(ThreadContext *tc, Addr name_base, size_t name_size)
virtual int64_t seek(uint64_t pos)
Seek to an absolute position in the file.
RetErrno callExit32(ThreadContext *tc, InPlaceArg code)
RetErrno callClock(ThreadContext *tc)
Arg get(ThreadContext *tc)
virtual int64_t open()
Open the the file.
bool call32(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch32 code.
const std::string & fileName()
RetErrno callGetCmdLine(ThreadContext *tc, Addr addr, InPlaceArg size_arg)
void write(ThreadContext *tc, uint64_t val, ByteOrder endian)
RetErrno callSeek(ThreadContext *tc, Handle handle, uint64_t pos)
RetErrno callTime(ThreadContext *tc)
State(const ThreadContext *tc)
int64_t flen() override
Get the length of a file in bytes.
RetErrno callHeapInfo32(ThreadContext *tc, Addr block_addr)
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
static Dispatcher buildDispatcher(Implementation< Args... > impl)
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
int64_t open() override
Open the the file.
File(ArmSemihosting &_parent, const char *name, const char *mode)
FileBase(ArmSemihosting &_parent, const char *name, const char *_mode)
virtual int64_t read(uint8_t *buffer, uint64_t size)
Read data from file.
static std::function< RetErrno(ThreadContext *tc, Args... args)> wrapImpl(ArmSemihosting *sh, Implementation< Args... > impl)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
bool call64(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch64 code.
bool isTTY() const override
Check if a file corresponds to a TTY device.
static const std::map< uint32_t, SemiCall > calls
RetErrno callSystem(ThreadContext *tc, Addr cmd_addr, size_t cmd_size)
std::string readString(ThreadContext *tc, Addr ptr, size_t len)
RetErrno callIsTTY(ThreadContext *tc, Handle handle)
RetErrno callHeapInfo64(ThreadContext *tc, Addr block_addr)
static const std::map< uint64_t, const char * > exitCodes
const unsigned tickShift
Number of bits to right shift gem5 ticks to fit in a uint32_t.
SemiCall(const char *_name, Implementation< Args32... > impl32, Implementation< Args64... > impl64)
int64_t close() override
Close the file.
void semiExit(uint64_t code, uint64_t subcode)
StateBase(const ThreadContext *tc, Addr arg_pointer)
virtual bool isTTY() const
Check if a file corresponds to a TTY device.
SemiCall(const char *_name, Implementation< Args... > common)
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
RetErrno(ArmSemihosting::*)(ThreadContext *tc, Args... args) Implementation
void serialize(CheckpointOut &cp) const override
Serialize an object.
static FILE * getSTDIO(const char *stream_name, const std::string &name, const char *mode)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
uint64_t read(ThreadContext *tc, ByteOrder endian)
static Arg get(ThreadContext *tc, ArmSemihosting::Abi32::State &state)
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
virtual const std::string name() const
RetErrno callGem5PseudoOp32(ThreadContext *tc, uint32_t encoded_func)
RetErrno callExitExtended(ThreadContext *tc, uint64_t code, uint64_t subcode)
Base class for serial devices such as terminals.
InPlaceArg(Addr _addr, size_t _size)
static PortProxy & portProxy(ThreadContext *tc)
std::function< std::string(ThreadContext *tc)> Dumper
This object is a proxy for a port or other object which implements the functional response protocol,...
Semihosting call information structure.
void serialize(CheckpointOut &cp) const override
Serialize an object.
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
virtual int64_t close()
Close the file.
static Arg get(ThreadContext *tc, ArmSemihosting::Abi64::State &state)
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
RetErrno callFLen(ThreadContext *tc, Handle handle)
ArmSemihosting(const ArmSemihostingParams *p)
RetErrno callReadC(ThreadContext *tc)
FileFeatures(ArmSemihosting &_parent, const char *name, const char *mode)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void unrecognizedCall(ThreadContext *tc, const char *format, uint64_t op)
int64_t write(const uint8_t *buffer, uint64_t size) override
Write data to file.
virtual int64_t write(const uint8_t *buffer, uint64_t size)
Write data to file.
std::ostream CheckpointOut
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
const char * name
Call name.
Bitfield< 31, 29 > format
unsigned calcTickShift() const
RetErrno callClose(ThreadContext *tc, Handle handle)
std::vector< std::unique_ptr< FileBase > > files
const time_t timeBase
Base time when the simulation started.
Semihosting for AArch32 and AArch64.
RetErrno callTmpNam(ThreadContext *tc, Addr buffer, uint64_t id, size_t size)
RetErrno callRead(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
State(const ThreadContext *tc)
void serialize(CheckpointOut &cp) const override
Serialize an object.
RetErrno callIsError(ThreadContext *tc, int64_t status)
std::pair< uint64_t, SemiErrno > RetErrno
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::ostream & operator<<(std::ostream &os, const ArmSemihosting::InPlaceArg &ipa)
std::string dumpSimcall(std::string name, ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target=std::function< Ret(ThreadContext *, Args...)>())
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Internal state for open files.
RetErrno callGem5PseudoOp64(ThreadContext *tc, uint64_t encoded_func)
#define panic(...)
This implements a cprintf based panic() function.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Abstract superclass for simulation objects.
Generated on Wed Sep 30 2020 14:02:01 for gem5 by doxygen 1.8.17