gem5  v22.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/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->getReg(ArmISA::int_reg::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->getReg(ArmISA::int_reg::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 
233  SYS_GEM5_PSEUDO_OP = 0x100
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>
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_v<Arg>>>
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_v<Arg>>>
620 {
621  static Arg
623  {
624  if (std::is_signed_v<Arg>)
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_v<ArmSemihosting::AbiBase, Abi>>>
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->setReg(ArmISA::int_reg::R0, err.first);
650  }
651 };
652 
653 template <>
655 {
656  static void
658  {
659  tc->setReg(ArmISA::int_reg::X0, err.first);
660  }
661 };
662 
663 } // namespace guest_abi
664 } // namespace gem5
665 
666 #endif // __ARCH_ARM_SEMIHOSTING_HH__
State(const ThreadContext *tc)
Definition: semihosting.hh:160
State(const ThreadContext *tc)
Definition: semihosting.hh:146
StateBase(const ThreadContext *tc, Addr arg_pointer)
Definition: semihosting.hh:103
Internal state for open files.
Definition: semihosting.hh:280
FileBase(FileBase &)=delete
virtual bool isTTY() const
Check if a file corresponds to a TTY device.
Definition: semihosting.hh:330
virtual int64_t seek(uint64_t pos)
Seek to an absolute position in the file.
Definition: semihosting.cc:839
virtual int64_t write(const uint8_t *buffer, uint64_t size)
Write data to file.
Definition: semihosting.cc:833
FileBase(ArmSemihosting &_parent, const char *name, const char *_mode)
Definition: semihosting.hh:282
virtual int64_t read(uint8_t *buffer, uint64_t size)
Read data from file.
Definition: semihosting.cc:827
virtual int64_t flen()
Get the length of a file in bytes.
Definition: semihosting.cc:845
virtual int64_t close()
Close the file.
Definition: semihosting.hh:323
virtual int64_t open()
Open the the file.
Definition: semihosting.hh:316
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:813
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:820
static std::unique_ptr< FileBase > create(ArmSemihosting &parent, const std::string &fname, const char *mode)
Definition: semihosting.cc:778
const std::string & fileName()
Definition: semihosting.hh:298
Implementation of the ':semihosting-features' magic file.
Definition: semihosting.hh:371
FileFeatures(ArmSemihosting &_parent, const char *name, const char *mode)
Definition: semihosting.cc:851
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
Definition: semihosting.cc:869
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:887
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
Definition: semihosting.cc:858
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:880
int64_t open() override
Open the the file.
Definition: semihosting.hh:395
File(ArmSemihosting &_parent, const char *name, const char *mode)
Definition: semihosting.cc:895
int64_t openImpl(bool unserialize)
Definition: semihosting.cc:909
int64_t write(const uint8_t *buffer, uint64_t size) override
Write data to file.
Definition: semihosting.cc:974
int64_t seek(uint64_t pos) override
Seek to an absolute position in the file.
Definition: semihosting.cc:990
int64_t close() override
Close the file.
Definition: semihosting.cc:938
void serialize(CheckpointOut &cp) const override
Serialize an object.
bool isTTY() const override
Check if a file corresponds to a TTY device.
Definition: semihosting.cc:951
int64_t read(uint8_t *buffer, uint64_t size) override
Read data from file.
Definition: semihosting.cc:959
int64_t flen() override
Get the length of a file in bytes.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Semihosting for AArch32 and AArch64.
Definition: semihosting.hh:77
std::pair< uint64_t, SemiErrno > RetErrno
Definition: semihosting.hh:433
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: semihosting.cc:222
RetErrno callSeek(ThreadContext *tc, Handle handle, uint64_t pos)
Definition: semihosting.cc:437
RetErrno callReadC(ThreadContext *tc)
Definition: semihosting.cc:411
static const std::map< uint32_t, SemiCall > calls
Definition: semihosting.hh:588
unsigned calcTickShift() const
Definition: semihosting.hh:419
RetErrno callSystem(ThreadContext *tc, Addr cmd_addr, size_t cmd_size)
Definition: semihosting.cc:525
RetErrno callExitExtended(ThreadContext *tc, uint64_t code, uint64_t subcode)
Definition: semihosting.cc:643
RetErrno callRename(ThreadContext *tc, Addr from_addr, size_t from_size, Addr to_addr, size_t to_size)
Definition: semihosting.cc:499
RetErrno callClock(ThreadContext *tc)
Definition: semihosting.cc:513
bool call32(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch32 code.
Definition: semihosting.cc:196
RetErrno callTickFreq(ThreadContext *tc)
Definition: semihosting.cc:685
RetErrno callWriteC(ThreadContext *tc, InPlaceArg c)
Definition: semihosting.cc:346
RetErrno callTime(ThreadContext *tc)
Definition: semihosting.cc:519
static const std::map< const std::string, FILE * > stdioMap
Definition: semihosting.hh:592
const unsigned tickShift
Number of bits to right shift gem5 ticks to fit in a uint32_t.
Definition: semihosting.hh:259
static RetErrno retOK(uint64_t r)
Definition: semihosting.hh:443
RetErrno callGetCmdLine(ThreadContext *tc, Addr addr, InPlaceArg size_arg)
Definition: semihosting.cc:542
RetErrno callIsError(ThreadContext *tc, int64_t status)
Definition: semihosting.cc:417
std::string filesRootDir
Definition: semihosting.hh:410
void gatherHeapInfo(ThreadContext *tc, bool aarch64, Addr &heap_base, Addr &heap_limit, Addr &stack_base, Addr &stack_limit)
Definition: semihosting.cc:559
static PortProxy & portProxy(ThreadContext *tc)
Definition: semihosting.cc:249
std::string readString(ThreadContext *tc, Addr ptr, size_t len)
Definition: semihosting.cc:285
RetErrno callWrite0(ThreadContext *tc, InPlaceArg str)
Definition: semihosting.cc:357
bool call64(ThreadContext *tc, bool gem5_ops)
Perform an Arm Semihosting call from aarch64 code.
Definition: semihosting.cc:170
RetErrno callElapsed64(ThreadContext *tc, InPlaceArg ticks)
Definition: semihosting.cc:677
void semiExit(uint64_t code, uint64_t subcode)
Definition: semihosting.cc:651
const time_t timeBase
Base time when the simulation started.
Definition: semihosting.hh:256
static FILE * getSTDIO(const char *stream_name, const std::string &name, const char *mode)
Definition: semihosting.cc:761
void unrecognizedCall(ThreadContext *tc, const char *format, uint64_t op)
Definition: semihosting.hh:577
static const std::map< uint64_t, const char * > exitCodes
Definition: semihosting.hh:590
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: semihosting.cc:237
RetErrno callRemove(ThreadContext *tc, Addr name_base, size_t name_size)
Definition: semihosting.cc:487
RetErrno callFLen(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:451
RetErrno callIsTTY(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:423
RetErrno callClose(ThreadContext *tc, Handle handle)
Definition: semihosting.cc:324
RetErrno callHeapInfo64(ThreadContext *tc, Addr block_addr)
Definition: semihosting.cc:615
std::vector< std::unique_ptr< FileBase > > files
Definition: semihosting.hh:411
RetErrno callExit64(ThreadContext *tc, uint64_t code, uint64_t subcode)
Definition: semihosting.cc:636
RetErrno callGem5PseudoOp32(ThreadContext *tc, uint32_t encoded_func)
Definition: semihosting.cc:735
RetErrno callTmpNam(ThreadContext *tc, Addr buffer, uint64_t id, size_t size)
Definition: semihosting.cc:465
RetErrno callRead(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
Definition: semihosting.cc:390
static const std::vector< uint8_t > features
Definition: semihosting.hh:591
RetErrno callHeapInfo32(ThreadContext *tc, Addr block_addr)
Definition: semihosting.cc:600
ArmSemihosting(const ArmSemihostingParams &p)
Definition: semihosting.cc:144
uint64_t semiTick(Tick tick) const
Definition: semihosting.hh:425
static const std::vector< const char * > fmodes
Definition: semihosting.hh:589
RetErrno callWrite(ThreadContext *tc, Handle handle, Addr buffer, size_t size)
Definition: semihosting.cc:369
RetErrno callGem5PseudoOp64(ThreadContext *tc, uint64_t encoded_func)
Definition: semihosting.cc:748
RetErrno callExit32(ThreadContext *tc, InPlaceArg code)
Definition: semihosting.cc:629
RetErrno callOpen(ThreadContext *tc, const Addr name_base, int fmode, size_t name_size)
Definition: semihosting.cc:296
static RetErrno retError(SemiErrno e)
Definition: semihosting.hh:437
RetErrno callElapsed32(ThreadContext *tc, InPlaceArg low, InPlaceArg high)
Definition: semihosting.cc:663
RetErrno callErrno(ThreadContext *tc)
Definition: semihosting.cc:535
const std::string cmdLine
Definition: semihosting.hh:248
const std::string _name
Definition: named.hh:41
virtual std::string name() const
Definition: named.hh:47
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:87
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:287
Basic support for object serialization.
Definition: serialize.hh:170
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void setReg(const RegId &reg, RegVal val)
STL pair class.
Definition: stl.hh:58
STL vector class.
Definition: stl.hh:37
constexpr int findMsbSet(uint64_t val)
Returns the bit position of the MSB that is set in the input.
Definition: bitfield.hh:260
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
atomic_var_t state
Definition: helpers.cc:188
uint16_t len
Definition: helpers.cc:62
#define warn(...)
Definition: logging.hh:246
constexpr RegId X0
Definition: int.hh:240
constexpr RegId X1
Definition: int.hh:241
constexpr RegId R1
Definition: int.hh:187
constexpr RegId R0
Definition: int.hh:186
ByteOrder byteOrder(const ThreadContext *tc)
Definition: utility.hh:357
Bitfield< 4, 0 > mode
Definition: misc_types.hh:74
Bitfield< 8, 7 > sh
Definition: misc_types.hh:667
Bitfield< 6 > err
Definition: misc_types.hh:809
Bitfield< 9 > e
Definition: misc_types.hh:65
Bitfield< 31, 29 > format
Definition: misc_types.hh:653
Bitfield< 5, 0 > status
Definition: misc_types.hh:429
Bitfield< 34 > aarch64
Definition: types.hh:81
Bitfield< 19, 16 > impl
Definition: mt_constants.hh:90
Bitfield< 5 > r
Definition: pagetable.hh:60
Bitfield< 2 > c
Definition: pagetable.hh:63
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 17 > os
Definition: misc.hh:810
Bitfield< 4 > op
Definition: types.hh:83
Bitfield< 63 > val
Definition: misc.hh:776
Bitfield< 3 > addr
Definition: types.hh:84
struct IsAapcs64Hfa< E[N], typename std::enable_if_t< std::is_floating_point_v< E > &&N<=4 > > :public std::true_type{};template< typename T >constexpr bool IsAapcs64HfaV=IsAapcs64Hfa< T >::value;template< typename T, typename Enabled=void >struct IsAapcs64Hva :public std::false_type {};template< typename E, size_t N >struct IsAapcs64Hva< E[N], typename std::enable_if_t< IsAapcs64ShortVectorV< E > &&N<=4 > > :public std::true_type{};template< typename T >constexpr bool IsAapcs64HvaV=IsAapcs64Hva< T >::value;template< typename T, typename Enabled=void >struct IsAapcs64Hxa :public std::false_type {};template< typename T >struct IsAapcs64Hxa< T, typename std::enable_if_t< IsAapcs64HfaV< T >||IsAapcs64HvaV< T > > > :public std::true_type{};template< typename T >constexpr bool IsAapcs64HxaV=IsAapcs64Hxa< T >::value;struct Aapcs64ArgumentBase{ template< typename T > static T loadFromStack(ThreadContext *tc, Aapcs64::State &state) { size_t align=std::max< size_t >(8, alignof(T));size_t size=roundUp(sizeof(T), 8);state.nsaa=roundUp(state.nsaa, align);ConstVPtr< T > val(state.nsaa, tc);state.nsaa+=size;return gtoh(*val, ArmISA::byteOrder(tc));}};template< typename Float >struct Argument< Aapcs64, Float, typename std::enable_if_t< std::is_floating_point_v< Float >||IsAapcs64ShortVectorV< Float > > > :public Aapcs64ArgumentBase{ static Float get(ThreadContext *tc, Aapcs64::State &state) { if(state.nsrn<=state.MAX_SRN) { RegId id=ArmISA::vecRegClass[state.nsrn++];ArmISA::VecRegContainer vc;tc->getReg(id, &vc);return vc.as< Float >()[0];} return loadFromStack< Float >(tc, state);}};template< typename Float >struct Result< Aapcs64, Float, typename std::enable_if_t< std::is_floating_point_v< Float >||IsAapcs64ShortVectorV< Float > > >{ static void store(ThreadContext *tc, const Float &f) { RegId id=ArmISA::vecRegClass[0];ArmISA::VecRegContainer reg;tc-> getReg(id, &reg)
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
Definition: core.cc:48
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::string dumpSimcall(std::string name, ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target=std::function< Ret(ThreadContext *, Args...)>())
Definition: guest_abi.hh:111
high
Definition: intmath.hh:176
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
std::ostream & operator<<(std::ostream &os, const ArmSemihosting::InPlaceArg &ipa)
uint64_t Tick
Tick count type.
Definition: types.hh:58
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
PortProxy Object Declaration.
uint64_t read(ThreadContext *tc, ByteOrder endian)
Definition: semihosting.hh:179
InPlaceArg(Addr _addr, size_t _size)
Definition: semihosting.hh:174
void write(ThreadContext *tc, uint64_t val, ByteOrder endian)
Definition: semihosting.hh:192
Semihosting call information structure.
Definition: semihosting.hh:456
SemiCall(const char *_name, Implementation< Args32... > impl32, Implementation< Args64... > impl64)
Definition: semihosting.hh:524
SemiCall(const char *_name, Implementation< Args... > common)
Definition: semihosting.hh:515
std::function< RetErrno(ArmSemihosting *sh, ThreadContext *tc)> Dispatcher
Definition: semihosting.hh:479
std::function< std::string(ThreadContext *tc)> Dumper
Definition: semihosting.hh:480
static Dispatcher buildDispatcher(Implementation< Args... > impl)
Definition: semihosting.hh:493
const char * name
Call name.
Definition: semihosting.hh:458
RetErrno(ArmSemihosting::*)(ThreadContext *tc, Args... args) Implementation
Definition: semihosting.hh:463
static Dumper buildDumper(const char *name, Implementation< Args... > impl)
Definition: semihosting.hh:505
static std::function< RetErrno(ThreadContext *tc, Args... args)> wrapImpl(ArmSemihosting *sh, Implementation< Args... > impl)
Definition: semihosting.hh:469
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
Definition: semihosting.hh:647
static void store(ThreadContext *tc, const ArmSemihosting::RetErrno &err)
Definition: semihosting.hh:657

Generated on Wed Dec 21 2022 10:22:27 for gem5 by doxygen 1.9.1