39 #ifndef __ARCH_ARM_SEMIHOSTING_HH__ 40 #define __ARCH_ARM_SEMIHOSTING_HH__ 50 struct ArmSemihostingParams;
125 static std::unique_ptr<FileBase>
create(
128 static std::unique_ptr<FileBase>
create(
152 virtual int64_t
open() {
return 0; }
159 virtual int64_t
close() {
return 0; }
166 virtual bool isTTY()
const {
return false; }
173 virtual int64_t
read(uint8_t *buffer, uint64_t size);
180 virtual int64_t
write(
const uint8_t *buffer, uint64_t size);
188 virtual int64_t
seek(uint64_t pos);
195 virtual int64_t
flen();
210 const char *
name,
const char *
mode);
215 int64_t
read(uint8_t *buffer, uint64_t size)
override;
216 int64_t
seek(uint64_t pos)
override;
231 int64_t
open()
override {
return openImpl(
false); }
232 int64_t
close()
override;
233 bool isTTY()
const override;
234 int64_t
read(uint8_t *buffer, uint64_t size)
override;
235 int64_t
write(
const uint8_t *buffer, uint64_t size)
override;
236 int64_t
seek(uint64_t pos)
override;
237 int64_t
flen()
override;
240 int64_t openImpl(
bool unserialize);
255 return msb > 31 ? msb - 31 : 0;
260 void semiExit(uint64_t code, uint64_t subcode);
316 #define SEMI_CALL(N) \ 317 RetErrno call ## N (ThreadContext *tc, \ 318 bool aarch64, std::vector<uint64_t> &argv) 349 static FILE *
getSTDIO(
const char *stream_name,
350 const std::string &
name,
const char *
mode);
352 static const std::map<uint32_t, SemiCall>
calls;
354 static const std::map<uint64_t, const char *>
exitCodes;
356 static const std::map<const std::string, FILE *>
stdioMap;
359 #endif // __ARCH_ARM_SEMIHOSTING_HH__
Implementation of the ':semihosting-features' magic file.
void serialize(CheckpointOut &cp) const override
Serialize an object.
static FILE * getSTDIO(const char *stream_name, const std::string &name, const char *mode)
ArmSemihosting(const ArmSemihostingParams *p)
static std::unique_ptr< FileBase > create(ArmSemihosting &parent, const std::string &fname, const char *mode)
std::vector< std::unique_ptr< FileBase > > files
static const std::map< const std::string, FILE * > stdioMap
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
int argc64
Number of aarch32 arguments to read from guest memory.
static RetErrno retError(SemiErrno e)
PortProxy & physProxy(ThreadContext *tc)
const char * name
Call name.
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
virtual int64_t read(uint8_t *buffer, uint64_t size)
Read data from file.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
virtual int64_t seek(uint64_t pos)
Seek to an absolute position in the file.
virtual int64_t open()
Open the the file.
static const std::vector< const char * > fmodes
const std::string cmdLine
Internal state for open files.
virtual bool isTTY() const
Check if a file corresponds to a TTY device.
uint64_t Tick
Tick count type.
const std::string & fileName()
Semihosting for AArch32 and AArch64.
uint64_t semiTick(Tick tick) const
uint32_t call32(ThreadContext *tc, uint32_t op, uint32_t param)
Perform an Arm Semihosting call from aarch32 code.
static const std::map< uint32_t, SemiCall > calls
FileBase(ArmSemihosting &_parent, const char *name, const char *_mode)
std::unique_ptr< PortProxy > physProxyS
std::pair< uint64_t, SemiErrno > RetErrno
Base class for serial devices such as terminals.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual const std::string name() const
std::string readString(ThreadContext *tc, Addr ptr, size_t len)
static RetErrno retOK(uint64_t r)
Basic support for object serialization.
static const std::vector< uint8_t > features
This object is a proxy for a port or other object which implements the functional response protocol...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static const std::map< uint64_t, const char * > exitCodes
std::ostream CheckpointOut
static const SemiCall * getCall(uint32_t op, bool aarch64)
bool implemented64() const
Is call implemented in aarch64?
void semiExit(uint64_t code, uint64_t subcode)
virtual int64_t close()
Close the file.
int findMsbSet(uint64_t val)
Returns the bit position of the MSB that is set in the input.
const unsigned tickShift
Number of bits to right shift gem5 ticks to fit in a uint32_t.
const time_t timeBase
Base time when the simulation started.
int64_t open() override
Open the the file.
unsigned calcTickShift() const
bool implemented32() const
Is call implemented in aarch32?
int argc32
Number of aarch32 arguments to read from guest memory.
Semihosting call information structure.
virtual int64_t write(const uint8_t *buffer, uint64_t size)
Write data to file.
virtual int64_t flen()
Get the length of a file in bytes.
Abstract superclass for simulation objects.
uint64_t call64(ThreadContext *tc, uint32_t op, uint64_t param)
Perform an Arm Semihosting call from aarch64 code.