gem5  v21.1.0.2
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/regs/int.hh"
49 #include "arch/arm/utility.hh"
50 #include "cpu/thread_context.hh"
51 #include "mem/port_proxy.hh"
52 #include "sim/core.hh"
53 #include "sim/guest_abi.hh"
54 #include "sim/sim_object.hh"
55 
56 namespace gem5
57 {
58 
59 struct ArmSemihostingParams;
60 class SerialDevice;
61 
76 class ArmSemihosting : public SimObject
77 {
78  public:
79  enum
80  {
81  // Standard ARM immediate values which trigger semihosting.
82  T32Imm = 0xAB,
83  A32Imm = 0x123456,
84  A64Imm = 0xF000,
85 
86  // The immediate value which enables gem5 semihosting calls. Use the
87  // standard value for thumb.
88  Gem5Imm = 0x5D57
89  };
90 
91  static PortProxy &portProxy(ThreadContext *tc);
92 
93  struct AbiBase
94  {
95  template <typename Arg>
96  class StateBase
97  {
98  private:
100  ByteOrder endian;
101 
102  public:
103  StateBase(const ThreadContext *tc, Addr arg_pointer) :
104  argPointer(arg_pointer), endian(ArmISA::byteOrder(tc))
105  {}
106 
107  /*
108  * These two methods are used to both read an argument or its
109  * address, and to move position on to the next location. Normally
110  * State would be more passive, but since it behaves almost the
111  * same no matter what the argument type is we can simplify and
112  * consolidate a little bit by centralizing these methods.
113  */
114 
115  // Return the address of an argument slot and move past it.
116  Addr
118  {
119  Addr addr = argPointer;
120  argPointer += sizeof(Arg);
121  return addr;
122  }
123 
124  // Read the value in an argument slot and move past it.
125  Arg
127  {
128  Arg arg = ArmSemihosting::portProxy(tc).read<Arg>(
129  argPointer, endian);
130  argPointer += sizeof(Arg);
131  return arg;
132  }
133 
134  using ArgType = Arg;
135  };
136  };
137 
138  struct Abi64 : public AbiBase
139  {
140  using UintPtr = uint64_t;
141 
142  class State : public StateBase<uint64_t>
143  {
144  public:
145  // For 64 bit semihosting, the params are pointer to by X1.
146  explicit State(const ThreadContext *tc) :
147  StateBase<uint64_t>(tc, tc->readIntReg(ArmISA::INTREG_X1))
148  {}
149  };
150  };
151 
152  struct Abi32 : public AbiBase
153  {
154  using UintPtr = uint32_t;
155 
156  class State : public StateBase<uint64_t>
157  {
158  public:
159  // For 32 bit semihosting, the params are pointer to by R1.
160  explicit State(const ThreadContext *tc) :
161  StateBase<uint64_t>(tc, tc->readIntReg(ArmISA::INTREG_R1))
162  {}
163  };
164  };
165 
166  // Use this argument type when you need to modify an argument in place.
167  // This will give you the address of the argument itself and the size of
168  // each argument slot, rather than the actual value of the argument.
169  struct InPlaceArg
170  {
172  size_t size;
173 
174  InPlaceArg(Addr _addr, size_t _size) : addr(_addr), size(_size) {}
175 
176  // A helper function to read the argument since the guest ABI mechanism
177  // didn't do that for us.
178  uint64_t
179  read(ThreadContext *tc, ByteOrder endian)
180  {
181  auto &proxy = ArmSemihosting::portProxy(tc);
182  if (size == 8)
183  return proxy.read<uint64_t>(addr, endian);
184  else if (size == 4)
185  return proxy.read<uint32_t>(addr, endian);
186  else
187  panic("Unexpected semihosting argument size %d.", size);
188  }
189 
190  // A helper function to write to the argument's slot in the params.
191  void
192  write(ThreadContext *tc, uint64_t val, ByteOrder endian)
193  {
194  auto &proxy = ArmSemihosting::portProxy(tc);
195  if (size == 8)
196  proxy.write<uint64_t>(addr, val, endian);
197  else if (size == 4)
198  proxy.write<uint32_t>(addr, val, endian);
199  else
200  panic("Unexpected semihosting argument size %d.", size);
201  }
202  };
203 
205  {
206  SYS_OPEN = 0x01,
207  SYS_CLOSE = 0x02,
208  SYS_WRITEC = 0x03,
209  SYS_WRITE0 = 0x04,
210  SYS_WRITE = 0x05,
211  SYS_READ = 0x06,
212  SYS_READC = 0x07,
213  SYS_ISERROR = 0x08,
214  SYS_ISTTY = 0x09,
215  SYS_SEEK = 0x0A,
216  SYS_FLEN = 0x0C,
217  SYS_TMPNAM = 0x0D,
218  SYS_REMOVE = 0x0E,
219  SYS_RENAME = 0x0F,
220  SYS_CLOCK = 0x10,
221  SYS_TIME = 0x11,
222  SYS_SYSTEM = 0x12,
223  SYS_ERRNO = 0x13,
225  SYS_HEAPINFO = 0x16,
226  SYS_EXIT = 0x18,
228  SYS_ELAPSED = 0x30,
229  SYS_TICKFREQ = 0x31,
230 
232 
234  };
235 
236  ArmSemihosting(const ArmSemihostingParams &p);
237 
239  bool call64(ThreadContext *tc, bool gem5_ops);
241  bool call32(ThreadContext *tc, bool gem5_ops);
242 
243  public: // SimObject and related interfaces
244  void serialize(CheckpointOut &cp) const override;
245  void unserialize(CheckpointIn &cp) override;
246 
247  protected: // Configuration
248  const std::string cmdLine;
251 
256  const time_t timeBase;
257 
259  const unsigned tickShift;
260 
261  protected: // Internal state
262  typedef uint64_t SemiErrno;
264 
265  protected: // File IO
279  class FileBase : public Serializable
280  {
281  public:
282  FileBase(ArmSemihosting &_parent, const char *name, const char *_mode)
283  : parent(_parent), _name(name), mode(_mode) {}
284  virtual ~FileBase() {};
285 
286  FileBase() = delete;
287  FileBase(FileBase &) = delete;
288 
289  static std::unique_ptr<FileBase> create(
290  ArmSemihosting &parent, const std::string &fname,
291  const char *mode);
292  static std::unique_ptr<FileBase> create(
293  ArmSemihosting &parent, CheckpointIn &cp, const std::string &sec);
294 
295  void serialize(CheckpointOut &cp) const override;
296  void unserialize(CheckpointIn &cp) override;
297 
298  const std::string &fileName() { return _name; }
299 
300  public:
316  virtual int64_t open() { return 0; }
317 
323  virtual int64_t close() { return 0; }
324 
330  virtual bool isTTY() const { return false; }
331 
337  virtual int64_t read(uint8_t *buffer, uint64_t size);
338 
344  virtual int64_t write(const uint8_t *buffer, uint64_t size);
345 
352  virtual int64_t seek(uint64_t pos);
353 
359  virtual int64_t flen();
360 
363  protected:
365  std::string _name;
366  std::string mode;
367  };
368 
370  class FileFeatures : public FileBase
371  {
372  public:
373  FileFeatures(ArmSemihosting &_parent,
374  const char *name, const char *mode);
375 
376  void serialize(CheckpointOut &cp) const override;
377  void unserialize(CheckpointIn &cp) override;
378 
379  int64_t read(uint8_t *buffer, uint64_t size) override;
380  int64_t seek(uint64_t pos) override;
381 
382  protected:
383  size_t pos;
384  };
385 
386  class File : public FileBase
387  {
388  public:
389  File(ArmSemihosting &_parent, const char *name, const char *mode);
390  ~File();
391 
392  void serialize(CheckpointOut &cp) const override;
393  void unserialize(CheckpointIn &cp) override;
394 
395  int64_t open() override { return openImpl(false); }
396  int64_t close() override;
397  bool isTTY() const override;
398  int64_t read(uint8_t *buffer, uint64_t size) override;
399  int64_t write(const uint8_t *buffer, uint64_t size) override;
400  int64_t seek(uint64_t pos) override;
401  int64_t flen() override;
402 
403  protected:
404  int64_t openImpl(bool unserialize);
405  bool needClose() const { return !isTTY(); }
406 
407  FILE *file;
408  };
409 
410  std::string filesRootDir;
412  using Handle = size_t;
413  FILE *stdin;
414  FILE *stdout;
415  FILE *stderr;
416 
417  protected: // Helper functions
418  unsigned
420  {
421  int msb = findMsbSet(sim_clock::Frequency);
422  return msb > 31 ? msb - 31 : 0;
423  }
424  uint64_t
425  semiTick(Tick tick) const
426  {
427  return tick >> tickShift;
428  }
429  void semiExit(uint64_t code, uint64_t subcode);
430  std::string readString(ThreadContext *tc, Addr ptr, size_t len);
431 
432  public:
434 
435  private:
436  static RetErrno
438  {
439  return RetErrno((uint64_t)-1, e);
440  }
441 
442  static RetErrno
443  retOK(uint64_t r)
444  {
445  return RetErrno(r, 0);
446  }
447 
455  struct SemiCall
456  {
458  const char *name;
459 
460  // A type for member functions implementing semihosting calls.
461  template <typename ...Args>
462  using Implementation =
463  RetErrno (ArmSemihosting::*)(ThreadContext *tc, Args... args);
464 
465  // Since guest ABI doesn't know how to call member function pointers,
466  // this template builds a wrapper that takes care of that.
467  template <typename ...Args>
468  static inline std::function<RetErrno(ThreadContext *tc, Args... args)>
470  {
471  return [sh, impl](ThreadContext *tc, Args... args) {
472  return (sh->*impl)(tc, args...);
473  };
474  }
475 
476  // A type for functions which dispatch semihosting calls through the
477  // guest ABI mechanism.
478  using Dispatcher =
479  std::function<RetErrno(ArmSemihosting *sh, ThreadContext *tc)>;
480  using Dumper = std::function<std::string(ThreadContext *tc)>;
481 
482  // Dispatchers for 32 and 64 bits.
485 
486  // Dumpers which print semihosting calls and their arguments.
489 
490  // A function which builds a dispatcher for a semihosting call.
491  template <typename Abi, typename ...Args>
492  static inline Dispatcher
494  {
495  // This lambda is the dispatcher we're building.
496  return [impl](ArmSemihosting *sh, ThreadContext *tc) {
497  auto wrapper = wrapImpl(sh, impl);
498  return invokeSimcall<Abi>(tc, wrapper);
499  };
500  }
501 
502  // A function which builds a dumper for a semihosting call.
503  template <typename Abi, typename ...Args>
504  static inline Dumper
506  {
507  // This lambda is the dumper we're building.
508  return [name](ThreadContext *tc) -> std::string {
509  return dumpSimcall<Abi, RetErrno, Args...>(name, tc);
510  };
511  }
512 
513  // When there's one implementation, use it for both 32 and 64 bits.
514  template <typename ...Args>
515  SemiCall(const char *_name, Implementation<Args...> common) :
516  name(_name), call32(buildDispatcher<Abi32>(common)),
517  call64(buildDispatcher<Abi64>(common)),
518  dump32(buildDumper<Abi32>(_name, common)),
519  dump64(buildDumper<Abi64>(_name, common))
520  {}
521 
522  // When there are two, use one for 32 bits and one for 64 bits.
523  template <typename ...Args32, typename ...Args64>
525  Implementation<Args64...> impl64) :
526  name(_name), call32(buildDispatcher<Abi32>(impl32)),
527  call64(buildDispatcher<Abi64>(impl64)),
528  dump32(buildDumper<Abi32>(_name, impl32)),
529  dump64(buildDumper<Abi64>(_name, impl64))
530  {}
531  };
532 
533  RetErrno callOpen(ThreadContext *tc, const Addr name_base,
534  int fmode, size_t name_size);
535  RetErrno callClose(ThreadContext *tc, Handle handle);
536  RetErrno callWriteC(ThreadContext *tc, InPlaceArg c);
537  RetErrno callWrite0(ThreadContext *tc, InPlaceArg str);
539  Addr buffer, size_t size);
541  Addr buffer, size_t size);
544  RetErrno callIsTTY(ThreadContext *tc, Handle handle);
545  RetErrno callSeek(ThreadContext *tc, Handle handle, uint64_t pos);
546  RetErrno callFLen(ThreadContext *tc, Handle handle);
548  uint64_t id, size_t size);
549  RetErrno callRemove(ThreadContext *tc, Addr name_base, size_t name_size);
550  RetErrno callRename(ThreadContext *tc, Addr from_addr, size_t from_size,
551  Addr to_addr, size_t to_size);
554  RetErrno callSystem(ThreadContext *tc, Addr cmd_addr, size_t cmd_size);
556  RetErrno callGetCmdLine(ThreadContext *tc, Addr addr, InPlaceArg size_arg);
557 
558  void gatherHeapInfo(ThreadContext *tc, bool aarch64,
559  Addr &heap_base, Addr &heap_limit,
560  Addr &stack_base, Addr &stack_limit);
561  RetErrno callHeapInfo32(ThreadContext *tc, Addr block_addr);
562  RetErrno callHeapInfo64(ThreadContext *tc, Addr block_addr);
563  RetErrno callExit32(ThreadContext *tc, InPlaceArg code);
564  RetErrno callExit64(ThreadContext *tc, uint64_t code, uint64_t subcode);
565  RetErrno callExitExtended(ThreadContext *tc, uint64_t code,
566  uint64_t subcode);
567 
568  RetErrno callElapsed32(ThreadContext *tc, InPlaceArg low, InPlaceArg high);
569  RetErrno callElapsed64(ThreadContext *tc, InPlaceArg ticks);
571 
572  RetErrno callGem5PseudoOp32(ThreadContext *tc, uint32_t encoded_func);
573  RetErrno callGem5PseudoOp64(ThreadContext *tc, uint64_t encoded_func);
574 
575  template <typename Abi>
576  void
577  unrecognizedCall(ThreadContext *tc, const char *format, uint64_t op)
578  {
579  warn(format, op);
580  std::function<RetErrno(ThreadContext *tc)> retErr =
581  [](ThreadContext *tc) { return retError(EINVAL); };
582  invokeSimcall<Abi>(tc, retErr);
583  }
584 
585  static FILE *getSTDIO(const char *stream_name,
586  const std::string &name, const char *mode);
587 
588  static const std::map<uint32_t, SemiCall> calls;
590  static const std::map<uint64_t, const char *> exitCodes;
592  static const std::map<const std::string, FILE *> stdioMap;
593 
594  // used in callTmpNam() to deterministically generate a temp filename
595  uint16_t tmpNameIndex = 0;
596 
597 };
598 
599 std::ostream &operator << (
600  std::ostream &os, const ArmSemihosting::InPlaceArg &ipa);
601 
602 GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi);
603 namespace guest_abi
604 {
605 
606 template <typename Arg>
607 struct Argument<ArmSemihosting::Abi64, Arg,
608  typename std::enable_if_t<std::is_integral<Arg>::value>>
609 {
610  static Arg
612  {
613  return state.get(tc);
614  }
615 };
616 
617 template <typename Arg>
618 struct Argument<ArmSemihosting::Abi32, Arg,
619  typename std::enable_if_t<std::is_integral<Arg>::value>>
620 {
621  static Arg
623  {
624  if (std::is_signed<Arg>::value)
625  return sext<32>(state.get(tc));
626  else
627  return state.get(tc);
628  }
629 };
630 
631 template <typename Abi>
632 struct Argument<Abi, ArmSemihosting::InPlaceArg, typename std::enable_if_t<
633  std::is_base_of<ArmSemihosting::AbiBase, Abi>::value>>
634 {
636  get(ThreadContext *tc, typename Abi::State &state)
637  {
639  state.getAddr(), sizeof(typename Abi::State::ArgType));
640  }
641 };
642 
643 template <>
645 {
646  static void
648  {
649  tc->setIntReg(ArmISA::INTREG_R0, err.first);
650  }
651 };
652 
653 template <>
655 {
656  static void
658  {
659  tc->setIntReg(ArmISA::INTREG_X0, err.first);
660  }
661 };
662 
663 } // namespace guest_abi
664 } // namespace gem5
665 
666 #endif // __ARCH_ARM_SEMIHOSTING_HH__
gem5::ThreadContext::setIntReg
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
gem5::ArmSemihosting::FileBase::fileName
const std::string & fileName()
Definition: semihosting.hh:298
gem5::operator<<
std::ostream & operator<<(std::ostream &os, const ArmSemihosting::InPlaceArg &ipa)
Definition: semihosting.cc:1045
gem5::ArmSemihosting::callFLen
RetErrno callFLen(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:442
gem5::ArmSemihosting::stderr
FILE * stderr
Definition: semihosting.hh:415
gem5::ArmSemihosting::Abi32::State
Definition: semihosting.hh:156
gem5::ArmSemihosting::callReadC
RetErrno callReadC(ThreadContext *tc)
Definition: semihosting.cc:402
gem5::ArmSemihosting::callExitExtended
RetErrno callExitExtended(ThreadContext *tc, uint64_t code, uint64_t subcode)
Definition: semihosting.cc:634
gem5::guest_abi::Argument< Abi, ArmSemihosting::InPlaceArg, typename std::enable_if_t< std::is_base_of< ArmSemihosting::AbiBase, Abi >::value > >::get
static ArmSemihosting::InPlaceArg get(ThreadContext *tc, typename Abi::State &state)
Definition: semihosting.hh:636
gem5::ArmSemihosting::timeBase
const time_t timeBase
Base time when the simulation started.
Definition: semihosting.hh:256
gem5::ArmSemihosting::callExit64
RetErrno callExit64(ThreadContext *tc, uint64_t code, uint64_t subcode)
Definition: semihosting.cc:627
gem5::ArmSemihosting::callClose
RetErrno callClose(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:315
gem5::ArmISA::len
Bitfield< 18, 16 > len
Definition: misc_types.hh:444
gem5::guest_abi::Argument< ArmSemihosting::Abi64, Arg, typename std::enable_if_t< std::is_integral< Arg >::value > >::get
static Arg get(ThreadContext *tc, ArmSemihosting::Abi64::State &state)
Definition: semihosting.hh:611
warn
#define warn(...)
Definition: logging.hh:245
gem5::ArmISA::format
Bitfield< 31, 29 > format
Definition: misc_types.hh:646
gem5::MipsISA::impl
Bitfield< 19, 16 > impl
Definition: mt_constants.hh:90
gem5::ArmSemihosting::FileFeatures::pos
size_t pos
Definition: semihosting.hh:383
gem5::ArmSemihosting::SYS_WRITE
@ SYS_WRITE
Definition: semihosting.hh:210
gem5::ArmSemihosting::FileBase::mode
std::string mode
Definition: semihosting.hh:366
gem5::ArmSemihosting::File::write
int64_t write(const uint8_t *buffer, uint64_t size) override
Write data to file.
Definition: semihosting.cc:965
gem5::ArmSemihosting::SemiCall::SemiCall
SemiCall(const char *_name, Implementation< Args32... > impl32, Implementation< Args64... > impl64)
Definition: semihosting.hh:524
gem5::ArmSemihosting::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:237
gem5::ArmSemihosting::ArmSemihosting
ArmSemihosting(const ArmSemihostingParams &p)
Definition: semihosting.cc:144
gem5::ArmSemihosting::SemiCall::name
const char * name
Call name.
Definition: semihosting.hh:458
gem5::ArmISA::aarch64
Bitfield< 34 > aarch64
Definition: types.hh:81
gem5::ArmSemihosting::AbiBase::StateBase
Definition: semihosting.hh:96
gem5::ArmSemihosting::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:222
gem5::ArmSemihosting::InPlaceArg::write
void write(ThreadContext *tc, uint64_t val, ByteOrder endian)
Definition: semihosting.hh:192
gem5::ArmSemihosting::SemiCall::call32
Dispatcher call32
Definition: semihosting.hh:483
gem5::ArmSemihosting::callRemove
RetErrno callRemove(ThreadContext *tc, Addr name_base, size_t name_size)
Definition: semihosting.cc:478
gem5::ArmSemihosting::FileBase
Internal state for open files.
Definition: semihosting.hh:279
gem5::ArmSemihosting::File::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:1027
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::ArmSemihosting::SemiCall::Dumper
std::function< std::string(ThreadContext *tc)> Dumper
Definition: semihosting.hh:480
gem5::ArmSemihosting::Abi64
Definition: semihosting.hh:138
gem5::ArmSemihosting::semiTick
uint64_t semiTick(Tick tick) const
Definition: semihosting.hh:425
gem5::ArmSemihosting::FileBase::parent
ArmSemihosting & parent
Definition: semihosting.hh:364
gem5::ArmISA::err
Bitfield< 6 > err
Definition: misc_types.hh:750
gem5::ArmSemihosting::Operation
Operation
Definition: semihosting.hh:204
gem5::ArmSemihosting::exitCodes
static const std::map< uint64_t, const char * > exitCodes
Definition: semihosting.hh:590
gem5::ArmSemihosting::callIsTTY
RetErrno callIsTTY(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:414
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:64
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:775
gem5::sim_clock::Frequency
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
Definition: core.cc:48
gem5::ArmSemihosting::SYS_CLOCK
@ SYS_CLOCK
Definition: semihosting.hh:220
gem5::ArmSemihosting::File::close
int64_t close() override
Close the file.
Definition: semihosting.cc:929
gem5::ArmSemihosting::AbiBase::StateBase::ArgType
Arg ArgType
Definition: semihosting.hh:134
gem5::ArmSemihosting::RetErrno
std::pair< uint64_t, SemiErrno > RetErrno
Definition: semihosting.hh:433
gem5::ArmSemihosting::SYS_WRITEC
@ SYS_WRITEC
Definition: semihosting.hh:208
gem5::ArmSemihosting::SYS_SYSTEM
@ SYS_SYSTEM
Definition: semihosting.hh:222
gem5::ArmSemihosting::SYS_GET_CMDLINE
@ SYS_GET_CMDLINE
Definition: semihosting.hh:224
gem5::ArmSemihosting::SYS_FLEN
@ SYS_FLEN
Definition: semihosting.hh:216
gem5::ArmSemihosting::File::~File
~File()
Definition: semihosting.cc:893
gem5::ArmSemihosting::portProxy
static PortProxy & portProxy(ThreadContext *tc)
Definition: semihosting.cc:249
gem5::ArmISA::byteOrder
ByteOrder byteOrder(const ThreadContext *tc)
Definition: utility.hh:412
gem5::ArmSemihosting::callHeapInfo32
RetErrno callHeapInfo32(ThreadContext *tc, Addr block_addr)
Definition: semihosting.cc:591
gem5::ArmSemihosting::SemiCall::SemiCall
SemiCall(const char *_name, Implementation< Args... > common)
Definition: semihosting.hh:515
gem5::ArmSemihosting::FileFeatures
Implementation of the ':semihosting-features' magic file.
Definition: semihosting.hh:370
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ArmSemihosting::SemiErrno
uint64_t SemiErrno
Definition: semihosting.hh:262
gem5::ArmSemihosting::SYS_ELAPSED
@ SYS_ELAPSED
Definition: semihosting.hh:228
gem5::ArmSemihosting::SYS_REMOVE
@ SYS_REMOVE
Definition: semihosting.hh:218
gem5::ArmSemihosting::callErrno
RetErrno callErrno(ThreadContext *tc)
Definition: semihosting.cc:526
gem5::ArmSemihosting::File::File
File(ArmSemihosting &_parent, const char *name, const char *mode)
Definition: semihosting.cc:886
gem5::ArmSemihosting::semiExit
void semiExit(uint64_t code, uint64_t subcode)
Definition: semihosting.cc:642
gem5::ArmSemihosting::File
Definition: semihosting.hh:386
gem5::ArmSemihosting::File::isTTY
bool isTTY() const override
Check if a file corresponds to a TTY device.
Definition: semihosting.cc:942
gem5::ArmSemihosting::File::file
FILE * file
Definition: semihosting.hh:407
gem5::ArmSemihosting::SemiCall::dump32
Dumper dump32
Definition: semihosting.hh:487
gem5::ArmSemihosting::FileBase::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:804
gem5::ArmSemihosting::FileFeatures::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:878
gem5::ArmSemihosting::call32
bool call32(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch32 code.
Definition: semihosting.cc:196
gem5::ArmSemihosting::stdout
FILE * stdout
Definition: semihosting.hh:414
gem5::ArmSemihosting::FileFeatures::FileFeatures
FileFeatures(ArmSemihosting &_parent, const char *name, const char *mode)
Definition: semihosting.cc:842
gem5::ArmSemihosting::SYS_ERRNO
@ SYS_ERRNO
Definition: semihosting.hh:223
gem5::ArmSemihosting::SYS_EXIT
@ SYS_EXIT
Definition: semihosting.hh:226
gem5::ArmSemihosting::FileBase::close
virtual int64_t close()
Close the file.
Definition: semihosting.hh:323
gem5::ArmSemihosting::semiErrno
SemiErrno semiErrno
Definition: semihosting.hh:263
gem5::ArmSemihosting::InPlaceArg::addr
Addr addr
Definition: semihosting.hh:171
gem5::ArmSemihosting::InPlaceArg
Definition: semihosting.hh:169
gem5::guest_abi::Result< ArmSemihosting::Abi32, ArmSemihosting::RetErrno >::store
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
Definition: semihosting.hh:647
gem5::ArmSemihosting::callIsError
RetErrno callIsError(ThreadContext *tc, int64_t status)
Definition: semihosting.cc:408
gem5::ArmSemihosting::File::read
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
Definition: semihosting.cc:950
gem5::ArmSemihosting::callSystem
RetErrno callSystem(ThreadContext *tc, Addr cmd_addr, size_t cmd_size)
Definition: semihosting.cc:516
gem5::ArmSemihosting::callGem5PseudoOp64
RetErrno callGem5PseudoOp64(ThreadContext *tc, uint64_t encoded_func)
Definition: semihosting.cc:739
gem5::Serializable
Basic support for object serialization.
Definition: serialize.hh:169
gem5::ArmSemihosting::callGetCmdLine
RetErrno callGetCmdLine(ThreadContext *tc, Addr addr, InPlaceArg size_arg)
Definition: semihosting.cc:533
gem5::ArmSemihosting::SemiCall::Dispatcher
std::function< RetErrno(ArmSemihosting *sh, ThreadContext *tc)> Dispatcher
Definition: semihosting.hh:479
gem5::ArmSemihosting::callExit32
RetErrno callExit32(ThreadContext *tc, InPlaceArg code)
Definition: semihosting.cc:620
gem5::ArmSemihosting::FileBase::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:811
gem5::ArmSemihosting::callWrite
RetErrno callWrite(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
Definition: semihosting.cc:360
gem5::high
high
Definition: intmath.hh:176
gem5::ArmSemihosting::SemiCall::buildDispatcher
static Dispatcher buildDispatcher(Implementation< Args... > impl)
Definition: semihosting.hh:493
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:93
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::ArmSemihosting::fmodes
static const std::vector< const char * > fmodes
Definition: semihosting.hh:589
sim_object.hh
gem5::ArmSemihosting::AbiBase::StateBase::getAddr
Addr getAddr()
Definition: semihosting.hh:117
gem5::ArmSemihosting::InPlaceArg::size
size_t size
Definition: semihosting.hh:172
gem5::ArmSemihosting::SYS_ISTTY
@ SYS_ISTTY
Definition: semihosting.hh:214
gem5::ArmSemihosting::T32Imm
@ T32Imm
Definition: semihosting.hh:82
gem5::ArmSemihosting::File::seek
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
Definition: semihosting.cc:981
gem5::ArmSemihosting::filesRootDir
std::string filesRootDir
Definition: semihosting.hh:410
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::ArmSemihosting::retError
static RetErrno retError(SemiErrno e)
Definition: semihosting.hh:437
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::ArmSemihosting::tickShift
const unsigned tickShift
Number of bits to right shift gem5 ticks to fit in a uint32_t.
Definition: semihosting.hh:259
gem5::PortProxy::read
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:287
gem5::dumpSimcall
std::string dumpSimcall(std::string name, ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target=std::function< Ret(ThreadContext *, Args...)>())
Definition: guest_abi.hh:111
gem5::ArmSemihosting::retOK
static RetErrno retOK(uint64_t r)
Definition: semihosting.hh:443
gem5::ArmSemihosting::File::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:1015
gem5::ArmSemihosting::SemiCall::Implementation
RetErrno(ArmSemihosting::*)(ThreadContext *tc, Args... args) Implementation
Definition: semihosting.hh:463
gem5::ArmSemihosting::InPlaceArg::InPlaceArg
InPlaceArg(Addr _addr, size_t _size)
Definition: semihosting.hh:174
gem5::ArmSemihosting::callRead
RetErrno callRead(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
Definition: semihosting.cc:381
port_proxy.hh
gem5::ArmSemihosting::FileBase::FileBase
FileBase(ArmSemihosting &_parent, const char *name, const char *_mode)
Definition: semihosting.hh:282
gem5::ArmSemihosting::AbiBase
Definition: semihosting.hh:93
gem5::guest_abi::Result< ArmSemihosting::Abi64, ArmSemihosting::RetErrno >::store
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
Definition: semihosting.hh:657
gem5::PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:86
gem5::ArmSemihosting::unrecognizedCall
void unrecognizedCall(ThreadContext *tc, const char *format, uint64_t op)
Definition: semihosting.hh:577
gem5::ArmSemihosting::File::flen
int64_t flen() override
Get the length of a file in bytes.
Definition: semihosting.cc:993
gem5::ArmSemihosting::Abi32::State::State
State(const ThreadContext *tc)
Definition: semihosting.hh:160
gem5::ArmSemihosting::InPlaceArg::read
uint64_t read(ThreadContext *tc, ByteOrder endian)
Definition: semihosting.hh:179
gem5::ArmSemihosting::Abi64::State
Definition: semihosting.hh:142
gem5::ArmSemihosting::AbiBase::StateBase::StateBase
StateBase(const ThreadContext *tc, Addr arg_pointer)
Definition: semihosting.hh:103
gem5::ArmSemihosting::Abi64::UintPtr
uint64_t UintPtr
Definition: semihosting.hh:140
gem5::ArmSemihosting::callGem5PseudoOp32
RetErrno callGem5PseudoOp32(ThreadContext *tc, uint32_t encoded_func)
Definition: semihosting.cc:726
gem5::ArmSemihosting::Abi32::UintPtr
uint32_t UintPtr
Definition: semihosting.hh:154
gem5::ArmSemihosting::callElapsed32
RetErrno callElapsed32(ThreadContext *tc, InPlaceArg low, InPlaceArg high)
Definition: semihosting.cc:654
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::ArmSemihosting::Abi64::State::State
State(const ThreadContext *tc)
Definition: semihosting.hh:146
std::pair
STL pair class.
Definition: stl.hh:58
gem5::ArmISA::c
Bitfield< 29 > c
Definition: misc_types.hh:53
gem5::ArmSemihosting::call64
bool call64(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch64 code.
Definition: semihosting.cc:170
core.hh
gem5::ArmSemihosting::callWrite0
RetErrno callWrite0(ThreadContext *tc, InPlaceArg str)
Definition: semihosting.cc:348
gem5::ArmSemihosting::FileFeatures::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:871
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ArmSemihosting::FileFeatures::read
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
Definition: semihosting.cc:849
gem5::ArmSemihosting::callTime
RetErrno callTime(ThreadContext *tc)
Definition: semihosting.cc:510
gem5::ArmSemihosting::A64Imm
@ A64Imm
Definition: semihosting.hh:84
gem5::ArmSemihosting::Gem5Imm
@ Gem5Imm
Definition: semihosting.hh:88
gem5::ArmSemihosting::SYS_CLOSE
@ SYS_CLOSE
Definition: semihosting.hh:207
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::ArmSemihosting::callSeek
RetErrno callSeek(ThreadContext *tc, Handle handle, uint64_t pos)
Definition: semihosting.cc:428
gem5::ArmSemihosting::cmdLine
const std::string cmdLine
Definition: semihosting.hh:248
gem5::ArmSemihosting::SYS_TIME
@ SYS_TIME
Definition: semihosting.hh:221
gem5::ArmSemihosting::SYS_TICKFREQ
@ SYS_TICKFREQ
Definition: semihosting.hh:229
gem5::ArmSemihosting
Semihosting for AArch32 and AArch64.
Definition: semihosting.hh:76
gem5::ArmSemihosting::FileBase::flen
virtual int64_t flen()
Get the length of a file in bytes.
Definition: semihosting.cc:836
gem5::ArmSemihosting::Abi32
Definition: semihosting.hh:152
gem5::ArmSemihosting::SYS_GEM5_PSEUDO_OP
@ SYS_GEM5_PSEUDO_OP
Definition: semihosting.hh:233
utility.hh
gem5::ArmSemihosting::FileBase::create
static std::unique_ptr< FileBase > create(ArmSemihosting &parent, const std::string &fname, const char *mode)
Definition: semihosting.cc:769
gem5::ArmSemihosting::stackSize
const Addr stackSize
Definition: semihosting.hh:250
gem5::ArmSemihosting::FileBase::_name
std::string _name
Definition: semihosting.hh:365
gem5::ArmSemihosting::SYS_WRITE0
@ SYS_WRITE0
Definition: semihosting.hh:209
gem5::ArmSemihosting::getSTDIO
static FILE * getSTDIO(const char *stream_name, const std::string &name, const char *mode)
Definition: semihosting.cc:752
gem5::ArmSemihosting::FileBase::read
virtual int64_t read(uint8_t *buffer, uint64_t size)
Read data from file.
Definition: semihosting.cc:818
gem5::ArmISA::sh
Bitfield< 8, 7 > sh
Definition: misc_types.hh:660
gem5::ArmSemihosting::callElapsed64
RetErrno callElapsed64(ThreadContext *tc, InPlaceArg ticks)
Definition: semihosting.cc:668
gem5::ArmSemihosting::callTickFreq
RetErrno callTickFreq(ThreadContext *tc)
Definition: semihosting.cc:676
gem5::ArmSemihosting::SYS_SEEK
@ SYS_SEEK
Definition: semihosting.hh:215
gem5::ArmSemihosting::FileBase::seek
virtual int64_t seek(uint64_t pos)
Seek to an absolute position in the file.
Definition: semihosting.cc:830
gem5::ArmSemihosting::SemiCall::dump64
Dumper dump64
Definition: semihosting.hh:488
gem5::ArmSemihosting::readString
std::string readString(ThreadContext *tc, Addr ptr, size_t len)
Definition: semihosting.cc:276
gem5::ArmSemihosting::FileBase::~FileBase
virtual ~FileBase()
Definition: semihosting.hh:284
gem5::ArmSemihosting::FileBase::isTTY
virtual bool isTTY() const
Check if a file corresponds to a TTY device.
Definition: semihosting.hh:330
gem5::ArmSemihosting::stdin
FILE * stdin
Definition: semihosting.hh:413
gem5::ArmSemihosting::SYS_READC
@ SYS_READC
Definition: semihosting.hh:212
gem5::ArmSemihosting::callWriteC
RetErrno callWriteC(ThreadContext *tc, InPlaceArg c)
Definition: semihosting.cc:337
gem5::ArmSemihosting::gatherHeapInfo
void gatherHeapInfo(ThreadContext *tc, bool aarch64, Addr &heap_base, Addr &heap_limit, Addr &stack_base, Addr &stack_limit)
Definition: semihosting.cc:550
gem5::ArmSemihosting::calcTickShift
unsigned calcTickShift() const
Definition: semihosting.hh:419
gem5::ArmSemihosting::stdioMap
static const std::map< const std::string, FILE * > stdioMap
Definition: semihosting.hh:592
gem5::ArmSemihosting::AbiBase::StateBase::get
Arg get(ThreadContext *tc)
Definition: semihosting.hh:126
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:809
gem5::ArmSemihosting::SemiCall::call64
Dispatcher call64
Definition: semihosting.hh:484
gem5::ArmSemihosting::SYS_TMPNAM
@ SYS_TMPNAM
Definition: semihosting.hh:217
gem5::ArmSemihosting::SYS_RENAME
@ SYS_RENAME
Definition: semihosting.hh:219
gem5::ArmSemihosting::SemiCall::buildDumper
static Dumper buildDumper(const char *name, Implementation< Args... > impl)
Definition: semihosting.hh:505
gem5::ArmSemihosting::calls
static const std::map< uint32_t, SemiCall > calls
Definition: semihosting.hh:588
gem5::ArmSemihosting::FileFeatures::seek
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
Definition: semihosting.cc:860
guest_abi.hh
gem5::ArmSemihosting::FileBase::write
virtual int64_t write(const uint8_t *buffer, uint64_t size)
Write data to file.
Definition: semihosting.cc:824
gem5::ArmSemihosting::callHeapInfo64
RetErrno callHeapInfo64(ThreadContext *tc, Addr block_addr)
Definition: semihosting.cc:606
gem5::ArmSemihosting::SYS_OPEN
@ SYS_OPEN
Definition: semihosting.hh:206
gem5::findMsbSet
constexpr int findMsbSet(uint64_t val)
Returns the bit position of the MSB that is set in the input.
Definition: bitfield.hh:263
gem5::MipsISA::r
r
Definition: pra_constants.hh:98
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::ArmSemihosting::File::open
int64_t open() override
Open the the file.
Definition: semihosting.hh:395
gem5::guest_abi::Argument
Definition: definition.hh:99
gem5::ArmSemihosting::features
static const std::vector< uint8_t > features
Definition: semihosting.hh:591
gem5::ArmSemihosting::AbiBase::StateBase::endian
ByteOrder endian
Definition: semihosting.hh:100
gem5::ArmSemihosting::AbiBase::StateBase::argPointer
Addr argPointer
Definition: semihosting.hh:99
gem5::ArmSemihosting::FileBase::FileBase
FileBase()=delete
gem5::ArmSemihosting::SYS_READ
@ SYS_READ
Definition: semihosting.hh:211
gem5::ArmSemihosting::memReserve
const Addr memReserve
Definition: semihosting.hh:249
gem5::ArmSemihosting::SemiCall::wrapImpl
static std::function< RetErrno(ThreadContext *tc, Args... args)> wrapImpl(ArmSemihosting *sh, Implementation< Args... > impl)
Definition: semihosting.hh:469
gem5::ArmSemihosting::SYS_ISERROR
@ SYS_ISERROR
Definition: semihosting.hh:213
gem5::ArmSemihosting::callClock
RetErrno callClock(ThreadContext *tc)
Definition: semihosting.cc:504
gem5::guest_abi::Result
Definition: definition.hh:64
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ArmSemihosting::callRename
RetErrno callRename(ThreadContext *tc, Addr from_addr, size_t from_size, Addr to_addr, size_t to_size)
Definition: semihosting.cc:490
gem5::ArmSemihosting::SYS_EXIT_EXTENDED
@ SYS_EXIT_EXTENDED
Definition: semihosting.hh:227
gem5::ArmSemihosting::MaxStandardOp
@ MaxStandardOp
Definition: semihosting.hh:231
int.hh
gem5::ArmSemihosting::File::openImpl
int64_t openImpl(bool unserialize)
Definition: semihosting.cc:900
gem5::ArmSemihosting::SemiCall
Semihosting call information structure.
Definition: semihosting.hh:455
gem5::ArmSemihosting::callTmpNam
RetErrno callTmpNam(ThreadContext *tc, Addr buffer, uint64_t id, size_t size)
Definition: semihosting.cc:456
gem5::X86ISA::op
Bitfield< 4 > op
Definition: types.hh:83
gem5::ArmSemihosting::tmpNameIndex
uint16_t tmpNameIndex
Definition: semihosting.hh:595
gem5::ArmSemihosting::callOpen
RetErrno callOpen(ThreadContext *tc, const Addr name_base, int fmode, size_t name_size)
Definition: semihosting.cc:287
thread_context.hh
gem5::guest_abi::Argument< ArmSemihosting::Abi32, Arg, typename std::enable_if_t< std::is_integral< Arg >::value > >::get
static Arg get(ThreadContext *tc, ArmSemihosting::Abi32::State &state)
Definition: semihosting.hh:622
gem5::ArmSemihosting::FileBase::open
virtual int64_t open()
Open the the file.
Definition: semihosting.hh:316
gem5::ArmSemihosting::Handle
size_t Handle
Definition: semihosting.hh:412
gem5::ArmSemihosting::SYS_HEAPINFO
@ SYS_HEAPINFO
Definition: semihosting.hh:225
gem5::Named::_name
const std::string _name
Definition: named.hh:41
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177
gem5::ArmSemihosting::File::needClose
bool needClose() const
Definition: semihosting.hh:405
gem5::ArmSemihosting::A32Imm
@ A32Imm
Definition: semihosting.hh:83
gem5::ArmISA::status
Bitfield< 5, 0 > status
Definition: misc_types.hh:422
gem5::ArmISA::mode
Bitfield< 4, 0 > mode
Definition: misc_types.hh:73
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::ArmSemihosting::files
std::vector< std::unique_ptr< FileBase > > files
Definition: semihosting.hh:411

Generated on Tue Sep 21 2021 12:24:46 for gem5 by doxygen 1.8.17