gem5  v22.1.0.0
se_workload.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Google Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __ARCH_SPARC_SE_WORKLOAD_HH__
29 #define __ARCH_SPARC_SE_WORKLOAD_HH__
30 
31 #include <vector>
32 
33 #include "arch/sparc/regs/int.hh"
34 #include "arch/sparc/regs/misc.hh"
35 #include "arch/sparc/remote_gdb.hh"
37 #include "cpu/thread_context.hh"
38 #include "params/SparcSEWorkload.hh"
39 #include "sim/se_workload.hh"
40 #include "sim/syscall_abi.hh"
41 
42 namespace gem5
43 {
44 
45 namespace SparcISA
46 {
47 
49 {
50  public:
51  PARAMS(SparcSEWorkload);
53 
54  void
55  setSystem(System *sys) override
56  {
58  gdb = BaseRemoteGDB::build<RemoteGDB>(
59  params().remote_gdb_port, system);
60  }
61 
62  virtual void handleTrap(ThreadContext *tc, int trapNum);
63  virtual void flushWindows(ThreadContext *tc);
64 
65  bool is64(ThreadContext *tc);
66 
68  {
70  };
71 
73  public BaseSyscallABI
74  {};
75 
77  public BaseSyscallABI
78  {};
79 };
80 
81 } // namespace SparcISA
82 
83 GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi);
84 namespace guest_abi
85 {
86 
87 template <typename ABI>
88 struct Result<ABI, SyscallReturn,
89  typename std::enable_if_t<std::is_base_of_v<
90  SparcISA::SEWorkload::BaseSyscallABI, ABI>>>
91 {
92  static void
94  {
95  // check for error condition. SPARC syscall convention is to
96  // indicate success/failure in reg the carry bit of the ccr
97  // and put the return value itself in the standard return value reg.
98  SparcISA::PSTATE pstate =
100  SparcISA::CCR ccr = tc->getReg(SparcISA::int_reg::Ccr);
101  RegVal val;
102  if (ret.successful()) {
103  ccr.xcc.c = ccr.icc.c = 0;
104  val = ret.returnValue();
105  } else {
106  ccr.xcc.c = ccr.icc.c = 1;
107  val = ret.errnoValue();
108  }
109  tc->setReg(SparcISA::int_reg::Ccr, ccr);
110  if (pstate.am)
111  val = bits(val, 31, 0);
113  if (ret.count() == 2)
115  }
116 };
117 
118 template <typename Arg>
119 struct Argument<SparcISA::SEWorkload::SyscallABI32, Arg,
120  typename std::enable_if_t<
121  std::is_integral_v<Arg> &&
122  SparcISA::SEWorkload::SyscallABI32::IsWideV<Arg>>>
123 {
125 
126  static Arg
128  {
129  panic_if(state + 1 >= ABI::ArgumentRegs.size(),
130  "Ran out of syscall argument registers.");
131  auto high = ABI::ArgumentRegs[state++];
132  auto low = ABI::ArgumentRegs[state++];
133  return (Arg)ABI::mergeRegs(tc, low, high);
134  }
135 };
136 
137 } // namespace guest_abi
138 } // namespace gem5
139 
140 #endif // __ARCH_SPARC_SE_WORKLOAD_HH__
SEWorkload(const Params &p, Addr page_shift)
Definition: se_workload.hh:47
void setSystem(System *sys) override
Definition: se_workload.hh:52
PARAMS(SparcSEWorkload)
virtual void handleTrap(ThreadContext *tc, int trapNum)
Definition: se_workload.cc:56
bool is64(ThreadContext *tc)
Definition: se_workload.cc:50
void setSystem(System *sys) override
Definition: se_workload.hh:55
virtual void flushWindows(ThreadContext *tc)
Definition: se_workload.cc:98
This class represents the return value from an emulated system call, including any errno setting.
int64_t returnValue() const
The return value.
int count() const
How many values did the syscall attempt to return?
int64_t value2() const
bool successful() const
Was the system call successful?
int errnoValue() const
The errno value.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId &reg) const
virtual void setReg(const RegId &reg, RegVal val)
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
BaseRemoteGDB * gdb
Definition: workload.hh:76
System * system
Definition: workload.hh:80
STL vector class.
Definition: stl.hh:37
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
const Params & params() const
Definition: sim_object.hh:176
atomic_var_t state
Definition: helpers.cc:188
constexpr RegId ArgumentRegs[]
Definition: int.hh:147
constexpr RegId Ccr
Definition: int.hh:132
@ MISCREG_PSTATE
Definition: misc.hh:67
constexpr auto & SyscallPseudoReturnReg
Definition: int.hh:174
constexpr auto & ReturnValueReg
Definition: int.hh:169
Bitfield< 63 > val
Definition: misc.hh:776
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
high
Definition: intmath.hh:176
uint64_t RegVal
Definition: types.hh:173
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Overload hash function for BasicBlockRange type.
Definition: misc.hh:2826
static const std::vector< RegId > ArgumentRegs
Definition: se_workload.hh:69

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