gem5  v20.1.0.0
faults.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2005 The Regents of The University of Michigan
3  * Copyright (c) 2007 MIPS Technologies, Inc.
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 
30 #include "arch/mips/faults.hh"
31 
33 #include "base/trace.hh"
34 #include "cpu/base.hh"
35 #include "cpu/thread_context.hh"
36 #include "debug/MipsPRA.hh"
37 #include "mem/page_table.hh"
38 #include "sim/process.hh"
39 
40 namespace MipsISA
41 {
42 
44 
46  { "Syscall", 0x180, ExcCodeSys };
47 
49  { "Reserved Instruction Fault", 0x180, ExcCodeRI };
50 
52  { "Thread Fault", 0x180, ExcCodeDummy };
53 
55  { "Integer Overflow Exception", 0x180, ExcCodeOv };
56 
58  { "Trap", 0x180, ExcCodeTr };
59 
61  { "Breakpoint", 0x180, ExcCodeBp };
62 
64  { "DSP Disabled Fault", 0x180, ExcCodeDummy };
65 
67  { "Machine Check", 0x180, ExcCodeMCheck };
68 
70  { "Reset Fault", 0x000, ExcCodeDummy };
71 
73  { "Soft Reset Fault", 0x000, ExcCodeDummy };
74 
76  { "Non Maskable Interrupt", 0x000, ExcCodeDummy };
77 
79  { "Coprocessor Unusable Fault", 0x180, ExcCodeCpU };
80 
82  { "Interrupt", 0x000, ExcCodeInt };
83 
85  { "Address Error", 0x180, ExcCodeDummy };
86 
88  { "Invalid TLB Entry Exception", 0x180, ExcCodeDummy };
89 
91  { "TLB Refill Exception", 0x180, ExcCodeDummy };
92 
94  { "TLB Modified Exception", 0x180, ExcCodeMod };
95 
96 void
98 {
99  // modify SRS Ctl - Save CSS, put ESS into CSS
100  StatusReg status = tc->readMiscReg(MISCREG_STATUS);
101  if (status.exl != 1 && status.bev != 1) {
102  // SRS Ctl is modified only if Status_EXL and Status_BEV are not set
103  SRSCtlReg srsCtl = tc->readMiscReg(MISCREG_SRSCTL);
104  srsCtl.pss = srsCtl.css;
105  srsCtl.css = srsCtl.ess;
106  tc->setMiscRegNoEffect(MISCREG_SRSCTL, srsCtl);
107  }
108 
109  // set EXL bit (don't care if it is already set!)
110  status.exl = 1;
112 
113  // write EPC
114  PCState pc = tc->pcState();
115  DPRINTF(MipsPRA, "PC: %s\n", pc);
116  bool delay_slot = pc.pc() + sizeof(MachInst) != pc.npc();
118  pc.pc() - (delay_slot ? sizeof(MachInst) : 0));
119 
120  // Set Cause_EXCCODE field
121  CauseReg cause = tc->readMiscReg(MISCREG_CAUSE);
122  cause.excCode = excCode;
123  cause.bd = delay_slot ? 1 : 0;
124  cause.ce = 0;
125  tc->setMiscRegNoEffect(MISCREG_CAUSE, cause);
126 }
127 
128 void
130 {
131  if (FullSystem) {
132  DPRINTF(MipsPRA, "Fault %s encountered.\n", name());
133  setExceptionState(tc, code());
134  tc->pcState(vect(tc));
135  } else {
136  panic("Fault %s encountered.\n", name());
137  }
138 }
139 
140 void
142 {
143  if (FullSystem) {
144  DPRINTF(MipsPRA, "%s encountered.\n", name());
145  /* All reset activity must be invoked from here */
146  Addr handler = vect(tc);
147  tc->pcState(handler);
148  DPRINTF(MipsPRA, "ResetFault::invoke : PC set to %x", handler);
149  }
150 
151  // Set Coprocessor 1 (Floating Point) To Usable
152  StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS);
153  status.cu.cu1 = 1;
155 }
156 
157 void
159 {
160  panic("Soft reset not implemented.\n");
161 }
162 
163 void
165 {
166  panic("Non maskable interrupt not implemented.\n");
167 }
168 
169 } // namespace MipsISA
170 
ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
MipsISA::ExcCodeMod
@ ExcCodeMod
Definition: faults.hh:49
MipsISA::excCode
Bitfield< 6, 2 > excCode
Definition: pra_constants.hh:196
MipsISA::ExcCodeSys
@ ExcCodeSys
Definition: faults.hh:56
faults.hh
pra_constants.hh
MipsISA::MipsFaultBase::setExceptionState
void setExceptionState(ThreadContext *, uint8_t)
Definition: faults.cc:97
MipsISA::ExcCodeInt
@ ExcCodeInt
Definition: faults.hh:48
MipsISA::MISCREG_CAUSE
@ MISCREG_CAUSE
Definition: registers.hh:184
FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:132
MipsISA::MipsFaultBase::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:129
MipsISA
Definition: decoder.cc:31
MipsISA::MipsFaultBase::code
virtual ExcCode code() const =0
MipsISA::MipsFaultBase::FaultVals
Definition: faults.hh:73
MipsISA::MISCREG_STATUS
@ MISCREG_STATUS
Definition: registers.hh:179
MipsISA::MipsFault
Definition: faults.hh:104
MipsISA::ExcCodeMCheck
@ ExcCodeMCheck
Definition: faults.hh:65
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
MipsISA::MachInst
uint32_t MachInst
Definition: types.hh:38
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
MipsISA::ExcCodeDummy
@ ExcCodeDummy
Definition: faults.hh:46
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
MipsISA::NonMaskableInterrupt::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:164
process.hh
MipsISA::ExcCodeBp
@ ExcCodeBp
Definition: faults.hh:57
MipsISA::ResetFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:141
GenericISA::DelaySlotPCState
Definition: types.hh:312
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
MipsISA::ExcCodeCpU
@ ExcCodeCpU
Definition: faults.hh:59
MipsISA::MipsFault< ResetFault >::name
FaultName name() const
Definition: faults.hh:109
ThreadContext::pcState
virtual TheISA::PCState pcState() const =0
MipsISA::ExcCodeRI
@ ExcCodeRI
Definition: faults.hh:58
MipsISA::FaultVals
MipsFaultBase::FaultVals FaultVals
Definition: faults.cc:43
MipsISA::MipsFaultBase::vect
FaultVect vect(ThreadContext *tc) const
Definition: faults.hh:94
base.hh
MipsISA::MISCREG_EPC
@ MISCREG_EPC
Definition: registers.hh:186
ThreadContext::readMiscReg
virtual RegVal readMiscReg(RegIndex misc_reg)=0
ThreadContext::setMiscReg
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
MipsISA::SoftResetFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:158
MipsISA::ExcCodeTr
@ ExcCodeTr
Definition: faults.hh:61
RefCountingPtr< StaticInst >
trace.hh
FaultBase::name
virtual FaultName name() const =0
ThreadContext::setMiscRegNoEffect
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
MipsISA::MISCREG_SRSCTL
@ MISCREG_SRSCTL
Definition: registers.hh:181
page_table.hh
thread_context.hh
MipsISA::ExcCodeOv
@ ExcCodeOv
Definition: faults.hh:60
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17