gem5  v22.0.0.1
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 "sim/se_workload.hh"
39 #include "sim/syscall_abi.hh"
40 
41 namespace gem5
42 {
43 
44 namespace SparcISA
45 {
46 
48 {
49  public:
51 
52  void
53  setSystem(System *sys) override
54  {
56  gdb = BaseRemoteGDB::build<RemoteGDB>(system);
57  }
58 
59  virtual void handleTrap(ThreadContext *tc, int trapNum);
60  virtual void flushWindows(ThreadContext *tc);
61 
62  bool is64(ThreadContext *tc);
63 
65  {
67  };
68 
70  public BaseSyscallABI
71  {};
72 
74  public BaseSyscallABI
75  {};
76 };
77 
78 } // namespace SparcISA
79 
80 GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi);
81 namespace guest_abi
82 {
83 
84 template <typename ABI>
85 struct Result<ABI, SyscallReturn,
86  typename std::enable_if_t<std::is_base_of_v<
87  SparcISA::SEWorkload::BaseSyscallABI, ABI>>>
88 {
89  static void
91  {
92  // check for error condition. SPARC syscall convention is to
93  // indicate success/failure in reg the carry bit of the ccr
94  // and put the return value itself in the standard return value reg.
95  SparcISA::PSTATE pstate =
97  SparcISA::CCR ccr = tc->readIntReg(SparcISA::INTREG_CCR);
98  RegVal val;
99  if (ret.successful()) {
100  ccr.xcc.c = ccr.icc.c = 0;
101  val = ret.returnValue();
102  } else {
103  ccr.xcc.c = ccr.icc.c = 1;
104  val = ret.errnoValue();
105  }
107  if (pstate.am)
108  val = bits(val, 31, 0);
110  if (ret.count() == 2)
112  }
113 };
114 
115 template <typename Arg>
116 struct Argument<SparcISA::SEWorkload::SyscallABI32, Arg,
117  typename std::enable_if_t<
118  std::is_integral_v<Arg> &&
119  SparcISA::SEWorkload::SyscallABI32::IsWideV<Arg>>>
120 {
122 
123  static Arg
125  {
126  panic_if(state + 1 >= ABI::ArgumentRegs.size(),
127  "Ran out of syscall argument registers.");
128  auto high = ABI::ArgumentRegs[state++];
129  auto low = ABI::ArgumentRegs[state++];
130  return (Arg)ABI::mergeRegs(tc, low, high);
131  }
132 };
133 
134 } // namespace guest_abi
135 } // namespace gem5
136 
137 #endif // __ARCH_SPARC_SE_WORKLOAD_HH__
gem5::ArmISA::SEWorkload::SEWorkload
SEWorkload(const Params &p, Addr page_shift)
Definition: se_workload.hh:47
misc.hh
gem5::SyscallReturn::returnValue
int64_t returnValue() const
The return value.
Definition: syscall_return.hh:107
gem5::SyscallReturn::errnoValue
int errnoValue() const
The errno value.
Definition: syscall_return.hh:115
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::RiscvISA::ArgumentRegs
const std::vector< int > ArgumentRegs
Definition: int.hh:67
gem5::SyscallReturn
This class represents the return value from an emulated system call, including any errno setting.
Definition: syscall_return.hh:55
gem5::GenericSyscallABI::State
int State
Definition: syscall_abi.hh:44
gem5::Workload::gdb
BaseRemoteGDB * gdb
Definition: workload.hh:76
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
gem5::GenericSyscallABI64
Definition: syscall_abi.hh:47
std::vector< int >
syscall_abi.hh
remote_gdb.hh
gem5::SparcISA::SEWorkload::setSystem
void setSystem(System *sys) override
Definition: se_workload.hh:53
gem5::guest_abi::Argument< SparcISA::SEWorkload::SyscallABI32, Arg, typename std::enable_if_t< std::is_integral_v< Arg > &&SparcISA::SEWorkload::SyscallABI32::IsWideV< Arg > > >::get
static Arg get(ThreadContext *tc, typename ABI::State &state)
Definition: se_workload.hh:124
gem5::SparcISA::INTREG_CCR
@ INTREG_CCR
Definition: int.hh:59
gem5::high
high
Definition: intmath.hh:176
gem5::System
Definition: system.hh:75
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:94
gem5::ThreadContext::readIntReg
RegVal readIntReg(RegIndex reg_idx) const
Definition: thread_context.hh:204
gem5::SparcISA::ReturnValueReg
const int ReturnValueReg
Definition: int.hh:72
gem5::SparcISA::SEWorkload::BaseSyscallABI
Definition: se_workload.hh:64
gem5::guest_abi::Result< ABI, SyscallReturn, typename std::enable_if_t< std::is_base_of_v< SparcISA::SEWorkload::BaseSyscallABI, ABI > > >::store
static void store(ThreadContext *tc, const SyscallReturn &ret)
Definition: se_workload.hh:90
int.hh
gem5::bits
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
gem5::SparcISA::SyscallPseudoReturnReg
const int SyscallPseudoReturnReg
Definition: int.hh:77
gem5::SparcISA::SEWorkload
Definition: se_workload.hh:47
gem5::ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
gem5::ArmISA::SEWorkload
Definition: se_workload.hh:42
gem5::ArmISA::SEWorkload::SyscallABI32
RegABI32 SyscallABI32
Definition: se_workload.hh:60
gem5::SparcISA::SEWorkload::SyscallABI64
Definition: se_workload.hh:73
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::GenericSyscallABI32
Definition: syscall_abi.hh:52
state
atomic_var_t state
Definition: helpers.cc:188
gem5::SparcISA::SEWorkload::SyscallABI32
Definition: se_workload.hh:69
panic_if
#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
gem5::ArmISA::SEWorkload::setSystem
void setSystem(System *sys) override
Definition: se_workload.hh:52
std
Overload hash function for BasicBlockRange type.
Definition: misc.hh:2388
gem5::SyscallReturn::count
int count() const
How many values did the syscall attempt to return?
Definition: syscall_return.hh:103
gem5::SyscallReturn::value2
int64_t value2() const
Definition: syscall_return.hh:123
gem5::SparcISA::MISCREG_PSTATE
@ MISCREG_PSTATE
Definition: misc.hh:65
gem5::Workload::system
System * system
Definition: workload.hh:80
gem5::guest_abi::Argument
Definition: definition.hh:99
gem5::SparcISA::SEWorkload::flushWindows
virtual void flushWindows(ThreadContext *tc)
Definition: se_workload.cc:97
gem5::SparcISA::SEWorkload::handleTrap
virtual void handleTrap(ThreadContext *tc, int trapNum)
Definition: se_workload.cc:55
gem5::guest_abi::Result
Definition: definition.hh:64
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::SparcISA::SEWorkload::is64
bool is64(ThreadContext *tc)
Definition: se_workload.cc:49
object_file.hh
gem5::SparcISA::SEWorkload::BaseSyscallABI::ArgumentRegs
static const std::vector< int > ArgumentRegs
Definition: se_workload.hh:66
thread_context.hh
gem5::ThreadContext::setIntReg
void setIntReg(RegIndex reg_idx, RegVal val)
Definition: thread_context.hh:241
gem5::SyscallReturn::successful
bool successful() const
Was the system call successful?
Definition: syscall_return.hh:91
se_workload.hh

Generated on Sat Jun 18 2022 08:12:14 for gem5 by doxygen 1.8.17