gem5  v21.0.1.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/miscregs.hh"
35 #include "cpu/thread_context.hh"
36 #include "sim/se_workload.hh"
37 #include "sim/syscall_abi.hh"
38 
39 namespace SparcISA
40 {
41 
42 class SEWorkload : public ::SEWorkload
43 {
44  public:
45  using ::SEWorkload::SEWorkload;
46 
47  virtual void handleTrap(ThreadContext *tc, int trapNum);
48  virtual void flushWindows(ThreadContext *tc);
49 
50  bool is64(ThreadContext *tc);
51 
53  {
55  };
56 
58  public BaseSyscallABI
59  {};
60 
62  public BaseSyscallABI
63  {};
64 };
65 
66 } // namespace SparcISA
67 
68 namespace GuestABI
69 {
70 
71 template <typename ABI>
72 struct Result<ABI, SyscallReturn,
73  typename std::enable_if_t<std::is_base_of<
74  SparcISA::SEWorkload::BaseSyscallABI, ABI>::value>>
75 {
76  static void
78  {
79  if (ret.suppressed() || ret.needsRetry())
80  return;
81 
82  // check for error condition. SPARC syscall convention is to
83  // indicate success/failure in reg the carry bit of the ccr
84  // and put the return value itself in the standard return value reg.
85  SparcISA::PSTATE pstate =
87  SparcISA::CCR ccr = tc->readIntReg(SparcISA::INTREG_CCR);
88  RegVal val;
89  if (ret.successful()) {
90  ccr.xcc.c = ccr.icc.c = 0;
91  val = ret.returnValue();
92  } else {
93  ccr.xcc.c = ccr.icc.c = 1;
94  val = ret.errnoValue();
95  }
97  if (pstate.am)
98  val = bits(val, 31, 0);
100  if (ret.count() == 2)
102  }
103 };
104 
105 template <typename Arg>
106 struct Argument<SparcISA::SEWorkload::SyscallABI32, Arg,
107  typename std::enable_if_t<
108  std::is_integral<Arg>::value &&
109  SparcISA::SEWorkload::SyscallABI32::IsWide<Arg>::value>>
110 {
112 
113  static Arg
114  get(ThreadContext *tc, typename ABI::State &state)
115  {
116  panic_if(state + 1 >= ABI::ArgumentRegs.size(),
117  "Ran out of syscall argument registers.");
118  auto high = ABI::ArgumentRegs[state++];
119  auto low = ABI::ArgumentRegs[state++];
120  return (Arg)ABI::mergeRegs(tc, low, high);
121  }
122 };
123 
124 } // namespace GuestABI
125 
126 #endif // __ARCH_SPARC_SE_WORKLOAD_HH__
ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
SparcISA::MISCREG_PSTATE
@ MISCREG_PSTATE
Definition: miscregs.hh:62
RiscvISA::ArgumentRegs
const std::vector< int > ArgumentRegs
Definition: registers.hh:127
GenericSyscallABI::State
int State
Definition: syscall_abi.hh:41
SparcISA::SEWorkload::handleTrap
virtual void handleTrap(ThreadContext *tc, int trapNum)
Definition: se_workload.cc:50
GenericSyscallABI64
Definition: syscall_abi.hh:44
ThreadContext::setIntReg
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
SyscallReturn::value2
int64_t value2() const
Definition: syscall_return.hh:120
std::vector< int >
syscall_abi.hh
GuestABI::Result< ABI, SyscallReturn, typename std::enable_if_t< std::is_base_of< SparcISA::SEWorkload::BaseSyscallABI, ABI >::value > >::store
static void store(ThreadContext *tc, const SyscallReturn &ret)
Definition: se_workload.hh:77
SparcISA::SEWorkload::flushWindows
virtual void flushWindows(ThreadContext *tc)
Definition: se_workload.cc:92
SparcISA
Definition: asi.cc:31
SyscallReturn::returnValue
int64_t returnValue() const
The return value.
Definition: syscall_return.hh:104
SyscallReturn::suppressed
bool suppressed() const
Should returning this value be suppressed?
Definition: syscall_return.hh:97
miscregs.hh
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
SyscallReturn::errnoValue
int errnoValue() const
The errno value.
Definition: syscall_return.hh:112
GuestABI
Definition: aapcs32.hh:66
SyscallReturn::needsRetry
bool needsRetry() const
Does the syscall need to be retried?
Definition: syscall_return.hh:94
SparcISA::SEWorkload
Definition: se_workload.hh:42
GuestABI::Argument
Definition: definition.hh:93
SparcISA::SEWorkload::SyscallABI32
Definition: se_workload.hh:57
SparcISA::INTREG_CCR
@ INTREG_CCR
Definition: registers.hh:75
GuestABI::Argument< SparcISA::SEWorkload::SyscallABI32, Arg, typename std::enable_if_t< std::is_integral< Arg >::value &&SparcISA::SEWorkload::SyscallABI32::IsWide< Arg >::value > >::get
static Arg get(ThreadContext *tc, typename ABI::State &state)
Definition: se_workload.hh:114
SparcISA::SEWorkload::is64
bool is64(ThreadContext *tc)
Definition: se_workload.cc:44
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
SyscallReturn
This class represents the return value from an emulated system call, including any errno setting.
Definition: syscall_return.hh:52
SparcISA::SEWorkload::BaseSyscallABI::ArgumentRegs
static const std::vector< int > ArgumentRegs
Definition: se_workload.hh:54
SparcISA::SEWorkload::SyscallABI64
Definition: se_workload.hh:61
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:197
GuestABI::Result
Definition: definition.hh:58
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
SyscallReturn::count
int count() const
How many values did the syscall attempt to return?
Definition: syscall_return.hh:100
SparcISA::ReturnValueReg
const int ReturnValueReg
Definition: registers.hh:89
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:73
ThreadContext::readIntReg
virtual RegVal readIntReg(RegIndex reg_idx) const =0
SparcISA::SyscallPseudoReturnReg
const int SyscallPseudoReturnReg
Definition: registers.hh:94
object_file.hh
GenericSyscallABI32
Definition: syscall_abi.hh:49
thread_context.hh
SparcISA::SEWorkload::BaseSyscallABI
Definition: se_workload.hh:52
RegVal
uint64_t RegVal
Definition: types.hh:174
se_workload.hh
SyscallReturn::successful
bool successful() const
Was the system call successful?
Definition: syscall_return.hh:88

Generated on Tue Jun 22 2021 15:28:20 for gem5 by doxygen 1.8.17