gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
faults.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 RISC-V Foundation
3  * Copyright (c) 2016 The University of Virginia
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Authors: Alec Roelke
30  */
31 
32 #ifndef __ARCH_RISCV_FAULTS_HH__
33 #define __ARCH_RISCV_FAULTS_HH__
34 
35 #include <string>
36 
37 #include "cpu/thread_context.hh"
38 #include "sim/faults.hh"
39 
40 namespace RiscvISA
41 {
42 
43 const uint32_t FloatInexact = 1 << 0;
44 const uint32_t FloatUnderflow = 1 << 1;
45 const uint32_t FloatOverflow = 1 << 2;
46 const uint32_t FloatDivZero = 1 << 3;
47 const uint32_t FloatInvalid = 1 << 4;
48 
64 };
65 
69 };
70 
71 class RiscvFault : public FaultBase
72 {
73  protected:
77 
79  : _name(n), _code(c), _int(i)
80  {}
81 
82  FaultName
83  name() const
84  {
85  return _name;
86  }
87 
89  exception() const
90  {
91  return _code;
92  }
93 
95  interrupt() const
96  {
97  return _int;
98  }
99 
100  virtual void
101  invoke_se(ThreadContext *tc, const StaticInstPtr &inst);
102 
103  void
104  invoke(ThreadContext *tc, const StaticInstPtr &inst);
105 };
106 
107 
109 {
110  public:
111  UnknownInstFault() : RiscvFault("Unknown instruction", INST_ILLEGAL,
112  SOFTWARE)
113  {}
114 
115  void
116  invoke_se(ThreadContext *tc, const StaticInstPtr &inst);
117 };
118 
120 {
121  private:
122  const std::string instName;
123  public:
125  : RiscvFault("Unimplemented instruction", INST_ILLEGAL, SOFTWARE),
126  instName(name)
127  {}
128 
129  void
130  invoke_se(ThreadContext *tc, const StaticInstPtr &inst);
131 };
132 
134 {
135  private:
136  const uint8_t frm;
137  public:
139  : RiscvFault("Illegal floating-point rounding mode", INST_ILLEGAL,
140  SOFTWARE),
141  frm(r)
142  {}
143 
144  void invoke_se(ThreadContext *tc, const StaticInstPtr &inst);
145 };
146 
148 {
149  public:
151  {}
152 
153  void
154  invoke_se(ThreadContext *tc, const StaticInstPtr &inst);
155 };
156 
157 class SyscallFault : public RiscvFault
158 {
159  public:
160  // TODO: replace ECALL_USER with the appropriate privilege level of the
161  // caller
163  {}
164 
165  void
166  invoke_se(ThreadContext *tc, const StaticInstPtr &inst);
167 };
168 
169 } // namespace RiscvISA
170 
171 #endif // __ARCH_RISCV_FAULTS_HH__
void invoke_se(ThreadContext *tc, const StaticInstPtr &inst)
Definition: faults.cc:88
const uint32_t FloatInexact
Definition: faults.hh:43
void invoke_se(ThreadContext *tc, const StaticInstPtr &inst)
Definition: faults.cc:60
void invoke_se(ThreadContext *tc, const StaticInstPtr &inst)
Definition: faults.cc:67
RiscvFault(FaultName n, ExceptionCode c, InterruptCode i)
Definition: faults.hh:78
const uint32_t FloatOverflow
Definition: faults.hh:45
IllegalFrmFault(uint8_t r)
Definition: faults.hh:138
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Bitfield< 31 > n
Definition: miscregs.hh:1636
UnimplementedFault(std::string name)
Definition: faults.hh:124
const std::string instName
Definition: faults.hh:122
virtual void invoke_se(ThreadContext *tc, const StaticInstPtr &inst)
Definition: faults.cc:41
InterruptCode
Definition: faults.hh:66
const char * FaultName
Definition: faults.hh:39
const uint32_t FloatUnderflow
Definition: faults.hh:44
Bitfield< 2 > i
FaultName name() const
Definition: faults.hh:83
void invoke_se(ThreadContext *tc, const StaticInstPtr &inst)
Definition: faults.cc:82
ExceptionCode
Definition: faults.hh:49
InterruptCode interrupt() const
Definition: faults.hh:95
void invoke(ThreadContext *tc, const StaticInstPtr &inst)
Definition: faults.cc:47
const InterruptCode _int
Definition: faults.hh:76
const uint8_t frm
Definition: faults.hh:136
const ExceptionCode _code
Definition: faults.hh:75
void invoke_se(ThreadContext *tc, const StaticInstPtr &inst)
Definition: faults.cc:75
const uint32_t FloatDivZero
Definition: faults.hh:46
Bitfield< 5, 3 > c
const uint32_t FloatInvalid
Definition: faults.hh:47
const FaultName _name
Definition: faults.hh:74
ExceptionCode exception() const
Definition: faults.hh:89

Generated on Fri Jun 9 2017 13:03:34 for gem5 by doxygen 1.8.6