gem5  v20.1.0.0
semihosting.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, 2019 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __ARCH_ARM_SEMIHOSTING_HH__
39 #define __ARCH_ARM_SEMIHOSTING_HH__
40 
41 #include <cstdio>
42 #include <functional>
43 #include <map>
44 #include <memory>
45 #include <utility>
46 #include <vector>
47 
48 #include "arch/arm/intregs.hh"
49 #include "arch/arm/utility.hh"
50 #include "cpu/thread_context.hh"
51 #include "mem/port_proxy.hh"
52 #include "sim/guest_abi.hh"
53 #include "sim/sim_object.hh"
54 
55 struct ArmSemihostingParams;
56 class SerialDevice;
57 
72 class ArmSemihosting : public SimObject
73 {
74  public:
75 
76  enum {
77  // Standard ARM immediate values which trigger semihosting.
78  T32Imm = 0xAB,
79  A32Imm = 0x123456,
80  A64Imm = 0xF000,
81 
82  // The immediate value which enables gem5 semihosting calls. Use the
83  // standard value for thumb.
84  Gem5Imm = 0x5D57
85  };
86 
87  static PortProxy &portProxy(ThreadContext *tc);
88 
89  struct AbiBase
90  {
91  template <typename Arg>
92  class StateBase
93  {
94  private:
96  ByteOrder endian;
97 
98  public:
99  StateBase(const ThreadContext *tc, Addr arg_pointer) :
100  argPointer(arg_pointer), endian(ArmISA::byteOrder(tc))
101  {}
102 
103  /*
104  * These two methods are used to both read an argument or its
105  * address, and to move position on to the next location. Normally
106  * State would be more passive, but since it behaves almost the
107  * same no matter what the argument type is we can simplify and
108  * consolidate a little bit by centralizing these methods.
109  */
110 
111  // Return the address of an argument slot and move past it.
112  Addr
114  {
115  Addr addr = argPointer;
116  argPointer += sizeof(Arg);
117  return addr;
118  }
119 
120  // Read the value in an argument slot and move past it.
121  Arg
123  {
124  Arg arg = ArmSemihosting::portProxy(tc).read<Arg>(
125  argPointer, endian);
126  argPointer += sizeof(Arg);
127  return arg;
128  }
129 
130  using ArgType = Arg;
131  };
132  };
133 
134  struct Abi64 : public AbiBase
135  {
136  class State : public StateBase<uint64_t>
137  {
138  public:
139  // For 64 bit semihosting, the params are pointer to by X1.
140  explicit State(const ThreadContext *tc) :
141  StateBase<uint64_t>(tc, tc->readIntReg(ArmISA::INTREG_X1))
142  {}
143  };
144  };
145 
146  struct Abi32 : public AbiBase
147  {
148  class State : public StateBase<uint64_t>
149  {
150  public:
151  // For 32 bit semihosting, the params are pointer to by R1.
152  explicit State(const ThreadContext *tc) :
153  StateBase<uint64_t>(tc, tc->readIntReg(ArmISA::INTREG_R1))
154  {}
155  };
156  };
157 
158  // Use this argument type when you need to modify an argument in place.
159  // This will give you the address of the argument itself and the size of
160  // each argument slot, rather than the actual value of the argument.
161  struct InPlaceArg
162  {
164  size_t size;
165 
166  InPlaceArg(Addr _addr, size_t _size) : addr(_addr), size(_size) {}
167 
168  // A helper function to read the argument since the guest ABI mechanism
169  // didn't do that for us.
170  uint64_t
171  read(ThreadContext *tc, ByteOrder endian)
172  {
173  auto &proxy = ArmSemihosting::portProxy(tc);
174  if (size == 8)
175  return proxy.read<uint64_t>(addr, endian);
176  else if (size == 4)
177  return proxy.read<uint32_t>(addr, endian);
178  else
179  panic("Unexpected semihosting argument size %d.", size);
180  }
181 
182  // A helper function to write to the argument's slot in the params.
183  void
184  write(ThreadContext *tc, uint64_t val, ByteOrder endian)
185  {
186  auto &proxy = ArmSemihosting::portProxy(tc);
187  if (size == 8)
188  proxy.write<uint64_t>(addr, val, endian);
189  else if (size == 4)
190  proxy.write<uint32_t>(addr, val, endian);
191  else
192  panic("Unexpected semihosting argument size %d.", size);
193  }
194  };
195 
196  enum Operation {
197  SYS_OPEN = 0x01,
198  SYS_CLOSE = 0x02,
199  SYS_WRITEC = 0x03,
200  SYS_WRITE0 = 0x04,
201  SYS_WRITE = 0x05,
202  SYS_READ = 0x06,
203  SYS_READC = 0x07,
204  SYS_ISERROR = 0x08,
205  SYS_ISTTY = 0x09,
206  SYS_SEEK = 0x0A,
207  SYS_FLEN = 0x0C,
208  SYS_TMPNAM = 0x0D,
209  SYS_REMOVE = 0x0E,
210  SYS_RENAME = 0x0F,
211  SYS_CLOCK = 0x10,
212  SYS_TIME = 0x11,
213  SYS_SYSTEM = 0x12,
214  SYS_ERRNO = 0x13,
216  SYS_HEAPINFO = 0x16,
217  SYS_EXIT = 0x18,
219  SYS_ELAPSED = 0x30,
220  SYS_TICKFREQ = 0x31,
221 
223 
225  };
226 
227  ArmSemihosting(const ArmSemihostingParams *p);
228 
230  bool call64(ThreadContext *tc, bool gem5_ops);
232  bool call32(ThreadContext *tc, bool gem5_ops);
233 
234  public: // SimObject and related interfaces
235  void serialize(CheckpointOut &cp) const override;
236  void unserialize(CheckpointIn &cp) override;
237 
238  protected: // Configuration
239  const std::string cmdLine;
242 
247  const time_t timeBase;
248 
250  const unsigned tickShift;
251 
252  protected: // Internal state
253  typedef uint64_t SemiErrno;
255 
256  protected: // File IO
270  class FileBase : public Serializable
271  {
272  public:
273  FileBase(ArmSemihosting &_parent, const char *name, const char *_mode)
274  : parent(_parent), _name(name), mode(_mode) {}
275  virtual ~FileBase() {};
276 
277  FileBase() = delete;
278  FileBase(FileBase &) = delete;
279 
280  static std::unique_ptr<FileBase> create(
281  ArmSemihosting &parent, const std::string &fname,
282  const char *mode);
283  static std::unique_ptr<FileBase> create(
284  ArmSemihosting &parent, CheckpointIn &cp, const std::string &sec);
285 
286  void serialize(CheckpointOut &cp) const override;
287  void unserialize(CheckpointIn &cp) override;
288 
289  const std::string &fileName() { return _name; }
290 
291  public:
307  virtual int64_t open() { return 0; }
308 
314  virtual int64_t close() { return 0; }
315 
321  virtual bool isTTY() const { return false; }
322 
328  virtual int64_t read(uint8_t *buffer, uint64_t size);
329 
335  virtual int64_t write(const uint8_t *buffer, uint64_t size);
336 
343  virtual int64_t seek(uint64_t pos);
344 
350  virtual int64_t flen();
351 
354  protected:
356  std::string _name;
357  std::string mode;
358  };
359 
361  class FileFeatures : public FileBase
362  {
363  public:
364  FileFeatures(ArmSemihosting &_parent,
365  const char *name, const char *mode);
366 
367  void serialize(CheckpointOut &cp) const override;
368  void unserialize(CheckpointIn &cp) override;
369 
370  int64_t read(uint8_t *buffer, uint64_t size) override;
371  int64_t seek(uint64_t pos) override;
372 
373  protected:
374  size_t pos;
375  };
376 
377  class File : public FileBase
378  {
379  public:
380  File(ArmSemihosting &_parent, const char *name, const char *mode);
381  ~File();
382 
383  void serialize(CheckpointOut &cp) const override;
384  void unserialize(CheckpointIn &cp) override;
385 
386  int64_t open() override { return openImpl(false); }
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;
393 
394  protected:
395  int64_t openImpl(bool unserialize);
396  bool needClose() const { return !isTTY(); }
397 
398  FILE *file;
399  };
400 
401  std::string filesRootDir;
403  using Handle = size_t;
404  FILE *stdin;
405  FILE *stdout;
406  FILE *stderr;
407 
408  protected: // Helper functions
409  unsigned
411  {
412  int msb = findMsbSet(SimClock::Frequency);
413  return msb > 31 ? msb - 31 : 0;
414  }
415  uint64_t
416  semiTick(Tick tick) const
417  {
418  return tick >> tickShift;
419  }
420  void semiExit(uint64_t code, uint64_t subcode);
421  std::string readString(ThreadContext *tc, Addr ptr, size_t len);
422 
423  public:
425 
426  private:
427  static RetErrno
429  {
430  return RetErrno((uint64_t)-1, e);
431  }
432 
433  static RetErrno
434  retOK(uint64_t r)
435  {
436  return RetErrno(r, 0);
437  }
438 
446  struct SemiCall
447  {
449  const char *name;
450 
451  // A type for member functions implementing semihosting calls.
452  template <typename ...Args>
453  using Implementation =
454  RetErrno (ArmSemihosting::*)(ThreadContext *tc, Args... args);
455 
456  // Since guest ABI doesn't know how to call member function pointers,
457  // this template builds a wrapper that takes care of that.
458  template <typename ...Args>
459  static inline std::function<RetErrno(ThreadContext *tc, Args... args)>
461  {
462  return [sh, impl](ThreadContext *tc, Args... args) {
463  return (sh->*impl)(tc, args...);
464  };
465  }
466 
467  // A type for functions which dispatch semihosting calls through the
468  // guest ABI mechanism.
469  using Dispatcher =
470  std::function<RetErrno(ArmSemihosting *sh, ThreadContext *tc)>;
471  using Dumper = std::function<std::string(ThreadContext *tc)>;
472 
473  // Dispatchers for 32 and 64 bits.
476 
477  // Dumpers which print semihosting calls and their arguments.
480 
481  // A function which builds a dispatcher for a semihosting call.
482  template <typename Abi, typename ...Args>
483  static inline Dispatcher
485  {
486  // This lambda is the dispatcher we're building.
487  return [impl](ArmSemihosting *sh, ThreadContext *tc) {
488  auto wrapper = wrapImpl(sh, impl);
489  return invokeSimcall<Abi>(tc, wrapper);
490  };
491  }
492 
493  // A function which builds a dumper for a semihosting call.
494  template <typename Abi, typename ...Args>
495  static inline Dumper
497  {
498  // This lambda is the dumper we're building.
499  return [name](ThreadContext *tc) -> std::string {
500  return dumpSimcall<Abi, RetErrno, Args...>(name, tc);
501  };
502  }
503 
504  // When there's one implementation, use it for both 32 and 64 bits.
505  template <typename ...Args>
506  SemiCall(const char *_name, Implementation<Args...> common) :
507  name(_name), call32(buildDispatcher<Abi32>(common)),
508  call64(buildDispatcher<Abi64>(common)),
509  dump32(buildDumper<Abi32>(_name, common)),
510  dump64(buildDumper<Abi64>(_name, common))
511  {}
512 
513  // When there are two, use one for 32 bits and one for 64 bits.
514  template <typename ...Args32, typename ...Args64>
515  SemiCall(const char *_name, Implementation<Args32...> impl32,
516  Implementation<Args64...> impl64) :
517  name(_name), call32(buildDispatcher<Abi32>(impl32)),
518  call64(buildDispatcher<Abi64>(impl64)),
519  dump32(buildDumper<Abi32>(_name, impl32)),
520  dump64(buildDumper<Abi64>(_name, impl64))
521  {}
522  };
523 
524  RetErrno callOpen(ThreadContext *tc, const Addr name_base,
525  int fmode, size_t name_size);
526  RetErrno callClose(ThreadContext *tc, Handle handle);
527  RetErrno callWriteC(ThreadContext *tc, InPlaceArg c);
528  RetErrno callWrite0(ThreadContext *tc, InPlaceArg str);
530  Addr buffer, size_t size);
532  Addr buffer, size_t size);
535  RetErrno callIsTTY(ThreadContext *tc, Handle handle);
536  RetErrno callSeek(ThreadContext *tc, Handle handle, uint64_t pos);
537  RetErrno callFLen(ThreadContext *tc, Handle handle);
539  uint64_t id, size_t size);
540  RetErrno callRemove(ThreadContext *tc, Addr name_base, size_t name_size);
541  RetErrno callRename(ThreadContext *tc, Addr from_addr, size_t from_size,
542  Addr to_addr, size_t to_size);
545  RetErrno callSystem(ThreadContext *tc, Addr cmd_addr, size_t cmd_size);
547  RetErrno callGetCmdLine(ThreadContext *tc, Addr addr, InPlaceArg size_arg);
548 
549  void gatherHeapInfo(ThreadContext *tc, bool aarch64,
550  Addr &heap_base, Addr &heap_limit,
551  Addr &stack_base, Addr &stack_limit);
552  RetErrno callHeapInfo32(ThreadContext *tc, Addr block_addr);
553  RetErrno callHeapInfo64(ThreadContext *tc, Addr block_addr);
554  RetErrno callExit32(ThreadContext *tc, InPlaceArg code);
555  RetErrno callExit64(ThreadContext *tc, uint64_t code, uint64_t subcode);
556  RetErrno callExitExtended(ThreadContext *tc, uint64_t code,
557  uint64_t subcode);
558 
559  RetErrno callElapsed32(ThreadContext *tc, InPlaceArg low, InPlaceArg high);
560  RetErrno callElapsed64(ThreadContext *tc, InPlaceArg ticks);
562 
563  RetErrno callGem5PseudoOp32(ThreadContext *tc, uint32_t encoded_func);
564  RetErrno callGem5PseudoOp64(ThreadContext *tc, uint64_t encoded_func);
565 
566  template <typename Abi>
567  void
568  unrecognizedCall(ThreadContext *tc, const char *format, uint64_t op)
569  {
570  warn(format, op);
571  std::function<RetErrno(ThreadContext *tc)> retErr =
572  [](ThreadContext *tc) { return retError(EINVAL); };
573  invokeSimcall<Abi>(tc, retErr);
574  }
575 
576  static FILE *getSTDIO(const char *stream_name,
577  const std::string &name, const char *mode);
578 
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;
584 };
585 
586 std::ostream &operator << (
587  std::ostream &os, const ArmSemihosting::InPlaceArg &ipa);
588 
589 namespace GuestABI
590 {
591 
592 template <typename Arg>
593 struct Argument<ArmSemihosting::Abi64, Arg,
594  typename std::enable_if<std::is_integral<Arg>::value>::type>
595 {
596  static Arg
598  {
599  return state.get(tc);
600  }
601 };
602 
603 template <typename Arg>
604 struct Argument<ArmSemihosting::Abi32, Arg,
605  typename std::enable_if<std::is_integral<Arg>::value>::type>
606 {
607  static Arg
609  {
610  if (std::is_signed<Arg>::value)
611  return sext<32>(state.get(tc));
612  else
613  return state.get(tc);
614  }
615 };
616 
617 template <typename Abi>
618 struct Argument<Abi, ArmSemihosting::InPlaceArg, typename std::enable_if<
619  std::is_base_of<ArmSemihosting::AbiBase, Abi>::value>::type>
620 {
622  get(ThreadContext *tc, typename Abi::State &state)
623  {
625  state.getAddr(), sizeof(typename Abi::State::ArgType));
626  }
627 };
628 
629 template <>
631 {
632  static void
634  {
635  tc->setIntReg(ArmISA::INTREG_R0, err.first);
636  }
637 };
638 
639 template <>
641 {
642  static void
644  {
645  tc->setIntReg(ArmISA::INTREG_X0, err.first);
646  }
647 };
648 
649 } // namespace GuestABI
650 
651 #endif // __ARCH_ARM_SEMIHOSTING_HH__
ArmSemihosting::gatherHeapInfo
void gatherHeapInfo(ThreadContext *tc, bool aarch64, Addr &heap_base, Addr &heap_limit, Addr &stack_base, Addr &stack_limit)
Definition: semihosting.cc:538
GuestABI::Argument< Abi, ArmSemihosting::InPlaceArg, typename std::enable_if< std::is_base_of< ArmSemihosting::AbiBase, Abi >::value >::type >::get
static ArmSemihosting::InPlaceArg get(ThreadContext *tc, typename Abi::State &state)
Definition: semihosting.hh:622
ArmSemihosting::FileFeatures
Implementation of the ':semihosting-features' magic file.
Definition: semihosting.hh:361
ArmSemihosting::FileBase::create
static std::unique_ptr< FileBase > create(ArmSemihosting &parent, const std::string &fname, const char *mode)
Definition: semihosting.cc:756
ArmSemihosting::retError
static RetErrno retError(SemiErrno e)
Definition: semihosting.hh:428
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
ArmSemihosting::callWrite0
RetErrno callWrite0(ThreadContext *tc, InPlaceArg str)
Definition: semihosting.cc:341
ArmSemihosting::callWrite
RetErrno callWrite(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
Definition: semihosting.cc:353
ArmSemihosting::SYS_WRITE
@ SYS_WRITE
Definition: semihosting.hh:201
ArmSemihosting::Abi32
Definition: semihosting.hh:146
ArmSemihosting::semiErrno
SemiErrno semiErrno
Definition: semihosting.hh:254
ArmSemihosting::callExit64
RetErrno callExit64(ThreadContext *tc, uint64_t code, uint64_t subcode)
Definition: semihosting.cc:615
ArmSemihosting::FileBase::flen
virtual int64_t flen()
Get the length of a file in bytes.
Definition: semihosting.cc:823
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
warn
#define warn(...)
Definition: logging.hh:239
ArmSemihosting::SYS_TMPNAM
@ SYS_TMPNAM
Definition: semihosting.hh:208
ArmSemihosting::SYS_HEAPINFO
@ SYS_HEAPINFO
Definition: semihosting.hh:216
ArmSemihosting::callElapsed32
RetErrno callElapsed32(ThreadContext *tc, InPlaceArg low, InPlaceArg high)
Definition: semihosting.cc:642
ArmSemihosting::stdioMap
static const std::map< const std::string, FILE * > stdioMap
Definition: semihosting.hh:583
ArmISA::sh
Bitfield< 8, 7 > sh
Definition: miscregs_types.hh:654
ArmSemihosting::callTickFreq
RetErrno callTickFreq(ThreadContext *tc)
Definition: semihosting.cc:664
ArmSemihosting::callRename
RetErrno callRename(ThreadContext *tc, Addr from_addr, size_t from_size, Addr to_addr, size_t to_size)
Definition: semihosting.cc:478
ArmSemihosting::SYS_SEEK
@ SYS_SEEK
Definition: semihosting.hh:206
ArmSemihosting::filesRootDir
std::string filesRootDir
Definition: semihosting.hh:401
ArmSemihosting::retOK
static RetErrno retOK(uint64_t r)
Definition: semihosting.hh:434
ArmSemihosting::callElapsed64
RetErrno callElapsed64(ThreadContext *tc, InPlaceArg ticks)
Definition: semihosting.cc:656
ArmSemihosting::SYS_READC
@ SYS_READC
Definition: semihosting.hh:203
ArmSemihosting::callWriteC
RetErrno callWriteC(ThreadContext *tc, InPlaceArg c)
Definition: semihosting.cc:330
ArmISA::byteOrder
ByteOrder byteOrder(const ThreadContext *tc)
Definition: utility.hh:449
ArmSemihosting::File::~File
~File()
Definition: semihosting.cc:880
findMsbSet
int findMsbSet(uint64_t val)
Returns the bit position of the MSB that is set in the input.
Definition: bitfield.hh:234
ArmSemihosting::SemiCall::Dispatcher
std::function< RetErrno(ArmSemihosting *sh, ThreadContext *tc)> Dispatcher
Definition: semihosting.hh:470
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
ArmSemihosting::callOpen
RetErrno callOpen(ThreadContext *tc, const Addr name_base, int fmode, size_t name_size)
Definition: semihosting.cc:280
ArmSemihosting::File::openImpl
int64_t openImpl(bool unserialize)
Definition: semihosting.cc:887
ArmSemihosting::semiTick
uint64_t semiTick(Tick tick) const
Definition: semihosting.hh:416
ArmSemihosting::cmdLine
const std::string cmdLine
Definition: semihosting.hh:239
ArmSemihosting::File
Definition: semihosting.hh:377
ArmSemihosting::features
static const std::vector< uint8_t > features
Definition: semihosting.hh:582
ArmSemihosting::SemiCall::buildDumper
static Dumper buildDumper(const char *name, Implementation< Args... > impl)
Definition: semihosting.hh:496
type
uint8_t type
Definition: inet.hh:421
ThreadContext::setIntReg
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
ArmSemihosting::SYS_OPEN
@ SYS_OPEN
Definition: semihosting.hh:197
ArmSemihosting::SYS_ERRNO
@ SYS_ERRNO
Definition: semihosting.hh:214
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
ArmSemihosting::fmodes
static const std::vector< const char * > fmodes
Definition: semihosting.hh:580
ArmSemihosting::callErrno
RetErrno callErrno(ThreadContext *tc)
Definition: semihosting.cc:514
ArmSemihosting::callRemove
RetErrno callRemove(ThreadContext *tc, Addr name_base, size_t name_size)
Definition: semihosting.cc:466
ArmSemihosting::AbiBase::StateBase
Definition: semihosting.hh:92
ArmSemihosting::FileBase::seek
virtual int64_t seek(uint64_t pos)
Seek to an absolute position in the file.
Definition: semihosting.cc:817
X86ISA::op
Bitfield< 4 > op
Definition: types.hh:78
ArmSemihosting::FileBase::FileBase
FileBase()=delete
ArmSemihosting::callExit32
RetErrno callExit32(ThreadContext *tc, InPlaceArg code)
Definition: semihosting.cc:608
ArmSemihosting::callClock
RetErrno callClock(ThreadContext *tc)
Definition: semihosting.cc:492
std::vector
STL vector class.
Definition: stl.hh:37
ArmSemihosting::AbiBase::StateBase::get
Arg get(ThreadContext *tc)
Definition: semihosting.hh:122
ArmSemihosting::FileBase::open
virtual int64_t open()
Open the the file.
Definition: semihosting.hh:307
ArmSemihosting::call32
bool call32(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch32 code.
Definition: semihosting.cc:189
ArmSemihosting::FileBase::fileName
const std::string & fileName()
Definition: semihosting.hh:289
ArmSemihosting::FileBase::_name
std::string _name
Definition: semihosting.hh:356
ArmSemihosting::SYS_EXIT
@ SYS_EXIT
Definition: semihosting.hh:217
ArmSemihosting::SYS_CLOCK
@ SYS_CLOCK
Definition: semihosting.hh:211
ArmSemihosting::SYS_ISERROR
@ SYS_ISERROR
Definition: semihosting.hh:204
ArmSemihosting::callGetCmdLine
RetErrno callGetCmdLine(ThreadContext *tc, Addr addr, InPlaceArg size_arg)
Definition: semihosting.cc:521
ArmSemihosting::InPlaceArg::write
void write(ThreadContext *tc, uint64_t val, ByteOrder endian)
Definition: semihosting.hh:184
ArmSemihosting::SYS_TIME
@ SYS_TIME
Definition: semihosting.hh:212
ArmSemihosting::callSeek
RetErrno callSeek(ThreadContext *tc, Handle handle, uint64_t pos)
Definition: semihosting.cc:421
ArmISA
Definition: ccregs.hh:41
ArmSemihosting::SemiCall::dump32
Dumper dump32
Definition: semihosting.hh:478
ArmSemihosting::SYS_RENAME
@ SYS_RENAME
Definition: semihosting.hh:210
ArmSemihosting::callTime
RetErrno callTime(ThreadContext *tc)
Definition: semihosting.cc:498
ArmSemihosting::Abi32::State::State
State(const ThreadContext *tc)
Definition: semihosting.hh:152
ArmSemihosting::File::flen
int64_t flen() override
Get the length of a file in bytes.
Definition: semihosting.cc:980
ArmSemihosting::FileFeatures::pos
size_t pos
Definition: semihosting.hh:374
ArmSemihosting::callHeapInfo32
RetErrno callHeapInfo32(ThreadContext *tc, Addr block_addr)
Definition: semihosting.cc:579
SimClock::Frequency
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
Definition: core.cc:46
ArmISA::aarch64
Bitfield< 34 > aarch64
Definition: types.hh:90
ArmSemihosting::SemiCall::buildDispatcher
static Dispatcher buildDispatcher(Implementation< Args... > impl)
Definition: semihosting.hh:484
ArmSemihosting::FileFeatures::read
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
Definition: semihosting.cc:836
ArmSemihosting::File::open
int64_t open() override
Open the the file.
Definition: semihosting.hh:386
ArmSemihosting::SYS_REMOVE
@ SYS_REMOVE
Definition: semihosting.hh:209
ArmSemihosting::File::File
File(ArmSemihosting &_parent, const char *name, const char *mode)
Definition: semihosting.cc:873
cp
Definition: cprintf.cc:40
ArmSemihosting::FileBase::FileBase
FileBase(ArmSemihosting &_parent, const char *name, const char *_mode)
Definition: semihosting.hh:273
ArmSemihosting::FileBase::read
virtual int64_t read(uint8_t *buffer, uint64_t size)
Read data from file.
Definition: semihosting.cc:805
ArmSemihosting::SYS_GET_CMDLINE
@ SYS_GET_CMDLINE
Definition: semihosting.hh:215
ArmSemihosting::SemiCall::wrapImpl
static std::function< RetErrno(ThreadContext *tc, Args... args)> wrapImpl(ArmSemihosting *sh, Implementation< Args... > impl)
Definition: semihosting.hh:460
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ArmISA::INTREG_R0
@ INTREG_R0
Definition: intregs.hh:54
ArmSemihosting::stderr
FILE * stderr
Definition: semihosting.hh:406
ArmSemihosting::SYS_EXIT_EXTENDED
@ SYS_EXIT_EXTENDED
Definition: semihosting.hh:218
MipsISA::impl
Bitfield< 19, 16 > impl
Definition: mt_constants.hh:87
sim_object.hh
GuestABI
Definition: aapcs32.hh:66
ArmSemihosting::call64
bool call64(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch64 code.
Definition: semihosting.cc:163
ArmSemihosting::Abi32::State
Definition: semihosting.hh:148
ArmSemihosting::File::isTTY
bool isTTY() const override
Check if a file corresponds to a TTY device.
Definition: semihosting.cc:929
ArmSemihosting::calls
static const std::map< uint32_t, SemiCall > calls
Definition: semihosting.hh:579
ArmSemihosting::callSystem
RetErrno callSystem(ThreadContext *tc, Addr cmd_addr, size_t cmd_size)
Definition: semihosting.cc:504
ArmISA::INTREG_R1
@ INTREG_R1
Definition: intregs.hh:55
ArmSemihosting::InPlaceArg::size
size_t size
Definition: semihosting.hh:164
ArmSemihosting::readString
std::string readString(ThreadContext *tc, Addr ptr, size_t len)
Definition: semihosting.cc:269
ArmSemihosting::callIsTTY
RetErrno callIsTTY(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:407
ArmSemihosting::callHeapInfo64
RetErrno callHeapInfo64(ThreadContext *tc, Addr block_addr)
Definition: semihosting.cc:594
ArmSemihosting::exitCodes
static const std::map< uint64_t, const char * > exitCodes
Definition: semihosting.hh:581
ArmSemihosting::stackSize
const Addr stackSize
Definition: semihosting.hh:241
MipsISA::r
r
Definition: pra_constants.hh:95
ArmSemihosting::tickShift
const unsigned tickShift
Number of bits to right shift gem5 ticks to fit in a uint32_t.
Definition: semihosting.hh:250
ArmSemihosting::stdout
FILE * stdout
Definition: semihosting.hh:405
ArmSemihosting::SemiCall::SemiCall
SemiCall(const char *_name, Implementation< Args32... > impl32, Implementation< Args64... > impl64)
Definition: semihosting.hh:515
ArmSemihosting::AbiBase::StateBase::endian
ByteOrder endian
Definition: semihosting.hh:96
GuestABI::Argument
Definition: definition.hh:93
port_proxy.hh
ArmISA::mode
Bitfield< 4, 0 > mode
Definition: miscregs_types.hh:70
ArmSemihosting::SYS_SYSTEM
@ SYS_SYSTEM
Definition: semihosting.hh:213
ArmSemihosting::File::close
int64_t close() override
Close the file.
Definition: semihosting.cc:916
ArmSemihosting::semiExit
void semiExit(uint64_t code, uint64_t subcode)
Definition: semihosting.cc:630
ArmSemihosting::AbiBase::StateBase::StateBase
StateBase(const ThreadContext *tc, Addr arg_pointer)
Definition: semihosting.hh:99
intregs.hh
ArmSemihosting::FileBase::isTTY
virtual bool isTTY() const
Check if a file corresponds to a TTY device.
Definition: semihosting.hh:321
ArmSemihosting::InPlaceArg::addr
Addr addr
Definition: semihosting.hh:163
ArmSemihosting::SYS_GEM5_PSEUDO_OP
@ SYS_GEM5_PSEUDO_OP
Definition: semihosting.hh:224
ArmISA::INTREG_X0
@ INTREG_X0
Definition: intregs.hh:127
ArmSemihosting::SemiCall::SemiCall
SemiCall(const char *_name, Implementation< Args... > common)
Definition: semihosting.hh:506
ArmSemihosting::File::seek
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
Definition: semihosting.cc:968
ArmSemihosting::SemiErrno
uint64_t SemiErrno
Definition: semihosting.hh:253
std::pair
STL pair class.
Definition: stl.hh:58
ArmSemihosting::SYS_CLOSE
@ SYS_CLOSE
Definition: semihosting.hh:198
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
ArmSemihosting::SemiCall::Implementation
RetErrno(ArmSemihosting::*)(ThreadContext *tc, Args... args) Implementation
Definition: semihosting.hh:454
ArmSemihosting::SYS_WRITE0
@ SYS_WRITE0
Definition: semihosting.hh:200
ArmSemihosting::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:215
ArmSemihosting::getSTDIO
static FILE * getSTDIO(const char *stream_name, const std::string &name, const char *mode)
Definition: semihosting.cc:739
ArmSemihosting::SYS_TICKFREQ
@ SYS_TICKFREQ
Definition: semihosting.hh:220
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ArmSemihosting::InPlaceArg
Definition: semihosting.hh:161
ArmSemihosting::FileFeatures::seek
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
Definition: semihosting.cc:847
ArmSemihosting::SYS_ELAPSED
@ SYS_ELAPSED
Definition: semihosting.hh:219
ArmSemihosting::T32Imm
@ T32Imm
Definition: semihosting.hh:78
utility.hh
ArmSemihosting::InPlaceArg::read
uint64_t read(ThreadContext *tc, ByteOrder endian)
Definition: semihosting.hh:171
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
ArmISA::INTREG_X1
@ INTREG_X1
Definition: intregs.hh:128
GuestABI::Argument< ArmSemihosting::Abi32, Arg, typename std::enable_if< std::is_integral< Arg >::value >::type >::get
static Arg get(ThreadContext *tc, ArmSemihosting::Abi32::State &state)
Definition: semihosting.hh:608
ArmSemihosting::memReserve
const Addr memReserve
Definition: semihosting.hh:240
GuestABI::Result< ArmSemihosting::Abi64, ArmSemihosting::RetErrno >::store
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
Definition: semihosting.hh:643
ArmSemihosting::File::file
FILE * file
Definition: semihosting.hh:398
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
ArmSemihosting::SYS_FLEN
@ SYS_FLEN
Definition: semihosting.hh:207
ArmSemihosting::callGem5PseudoOp32
RetErrno callGem5PseudoOp32(ThreadContext *tc, uint32_t encoded_func)
Definition: semihosting.cc:713
ArmSemihosting::FileBase::mode
std::string mode
Definition: semihosting.hh:357
ArmSemihosting::callExitExtended
RetErrno callExitExtended(ThreadContext *tc, uint64_t code, uint64_t subcode)
Definition: semihosting.cc:622
ArmSemihosting::SemiCall::call64
Dispatcher call64
Definition: semihosting.hh:475
ArmSemihosting::stdin
FILE * stdin
Definition: semihosting.hh:404
ArmSemihosting::Abi64::State
Definition: semihosting.hh:136
SerialDevice
Base class for serial devices such as terminals.
Definition: serial.hh:91
ArmSemihosting::InPlaceArg::InPlaceArg
InPlaceArg(Addr _addr, size_t _size)
Definition: semihosting.hh:166
ArmSemihosting::portProxy
static PortProxy & portProxy(ThreadContext *tc)
Definition: semihosting.cc:242
ArmSemihosting::Handle
size_t Handle
Definition: semihosting.hh:403
ArmSemihosting::MaxStandardOp
@ MaxStandardOp
Definition: semihosting.hh:222
ArmSemihosting::SYS_WRITEC
@ SYS_WRITEC
Definition: semihosting.hh:199
GuestABI::Result
Definition: definition.hh:58
ArmSemihosting::SemiCall::Dumper
std::function< std::string(ThreadContext *tc)> Dumper
Definition: semihosting.hh:471
ArmSemihosting::A64Imm
@ A64Imm
Definition: semihosting.hh:80
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
ArmSemihosting::SemiCall
Semihosting call information structure.
Definition: semihosting.hh:446
ArmSemihosting::File::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:1002
PortProxy::read
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:282
ArmSemihosting::FileBase::close
virtual int64_t close()
Close the file.
Definition: semihosting.hh:314
GuestABI::Argument< ArmSemihosting::Abi64, Arg, typename std::enable_if< std::is_integral< Arg >::value >::type >::get
static Arg get(ThreadContext *tc, ArmSemihosting::Abi64::State &state)
Definition: semihosting.hh:597
ArmSemihosting::File::read
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
Definition: semihosting.cc:937
ArmSemihosting::FileBase::~FileBase
virtual ~FileBase()
Definition: semihosting.hh:275
ArmSemihosting::SYS_READ
@ SYS_READ
Definition: semihosting.hh:202
ArmSemihosting::callFLen
RetErrno callFLen(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:435
ArmSemihosting::File::needClose
bool needClose() const
Definition: semihosting.hh:396
ArmSemihosting::ArmSemihosting
ArmSemihosting(const ArmSemihostingParams *p)
Definition: semihosting.cc:137
ArmSemihosting::callReadC
RetErrno callReadC(ThreadContext *tc)
Definition: semihosting.cc:395
ArmISA::len
Bitfield< 18, 16 > len
Definition: miscregs_types.hh:439
guest_abi.hh
ArmSemihosting::FileFeatures::FileFeatures
FileFeatures(ArmSemihosting &_parent, const char *name, const char *mode)
Definition: semihosting.cc:829
addr
ip6_addr_t addr
Definition: inet.hh:423
ArmSemihosting::FileBase::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:798
ArmSemihosting::File::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:1014
ArmSemihosting::A32Imm
@ A32Imm
Definition: semihosting.hh:79
ArmSemihosting::unrecognizedCall
void unrecognizedCall(ThreadContext *tc, const char *format, uint64_t op)
Definition: semihosting.hh:568
ArmSemihosting::File::write
int64_t write(const uint8_t *buffer, uint64_t size) override
Write data to file.
Definition: semihosting.cc:952
ArmSemihosting::FileBase::write
virtual int64_t write(const uint8_t *buffer, uint64_t size)
Write data to file.
Definition: semihosting.cc:811
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
ArmSemihosting::AbiBase::StateBase::getAddr
Addr getAddr()
Definition: semihosting.hh:113
GuestABI::Result< ArmSemihosting::Abi32, ArmSemihosting::RetErrno >::store
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
Definition: semihosting.hh:633
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
ArmSemihosting::SemiCall::name
const char * name
Call name.
Definition: semihosting.hh:449
ArmISA::format
Bitfield< 31, 29 > format
Definition: miscregs_types.hh:640
ArmSemihosting::SemiCall::dump64
Dumper dump64
Definition: semihosting.hh:479
ArmSemihosting::AbiBase::StateBase::argPointer
Addr argPointer
Definition: semihosting.hh:95
ArmISA::err
Bitfield< 6 > err
Definition: miscregs_types.hh:744
ArmSemihosting::calcTickShift
unsigned calcTickShift() const
Definition: semihosting.hh:410
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
ArmSemihosting::callClose
RetErrno callClose(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:308
ArmSemihosting::SYS_ISTTY
@ SYS_ISTTY
Definition: semihosting.hh:205
ArmSemihosting::files
std::vector< std::unique_ptr< FileBase > > files
Definition: semihosting.hh:402
CheckpointIn
Definition: serialize.hh:67
ArmSemihosting::AbiBase
Definition: semihosting.hh:89
ArmSemihosting::SemiCall::call32
Dispatcher call32
Definition: semihosting.hh:474
ArmSemihosting::timeBase
const time_t timeBase
Base time when the simulation started.
Definition: semihosting.hh:247
ArmSemihosting
Semihosting for AArch32 and AArch64.
Definition: semihosting.hh:72
ArmSemihosting::callTmpNam
RetErrno callTmpNam(ThreadContext *tc, Addr buffer, uint64_t id, size_t size)
Definition: semihosting.cc:449
ArmSemihosting::Operation
Operation
Definition: semihosting.hh:196
ArmSemihosting::callRead
RetErrno callRead(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
Definition: semihosting.cc:374
ArmSemihosting::Abi64::State::State
State(const ThreadContext *tc)
Definition: semihosting.hh:140
ArmSemihosting::FileBase::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:791
ArmSemihosting::callIsError
RetErrno callIsError(ThreadContext *tc, int64_t status)
Definition: semihosting.cc:401
ArmSemihosting::RetErrno
std::pair< uint64_t, SemiErrno > RetErrno
Definition: semihosting.hh:424
ArmSemihosting::FileFeatures::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:858
thread_context.hh
operator<<
std::ostream & operator<<(std::ostream &os, const ArmSemihosting::InPlaceArg &ipa)
Definition: semihosting.cc:1032
ArmSemihosting::FileBase::parent
ArmSemihosting & parent
Definition: semihosting.hh:355
ArmSemihosting::Gem5Imm
@ Gem5Imm
Definition: semihosting.hh:84
ArmSemihosting::Abi64
Definition: semihosting.hh:134
dumpSimcall
std::string dumpSimcall(std::string name, ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target=std::function< Ret(ThreadContext *, Args...)>())
Definition: guest_abi.hh:107
ArmSemihosting::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:230
ArmSemihosting::FileBase
Internal state for open files.
Definition: semihosting.hh:270
ArmSemihosting::callGem5PseudoOp64
RetErrno callGem5PseudoOp64(ThreadContext *tc, uint64_t encoded_func)
Definition: semihosting.cc:726
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
ArmSemihosting::AbiBase::StateBase::ArgType
Arg ArgType
Definition: semihosting.hh:130
ArmSemihosting::FileFeatures::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:865
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:01 for gem5 by doxygen 1.8.17