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 * Authors: Gabe Black 30 * Korey Sewell 31 * Jaidev Patwardhan 32 */ 33 34#include "arch/mips/faults.hh" 35#include "arch/mips/pra_constants.hh" 36#include "base/trace.hh" 37#include "cpu/base.hh" 38#include "cpu/thread_context.hh" 39#include "debug/MipsPRA.hh" 40 41#if !FULL_SYSTEM 42#include "mem/page_table.hh" 43#include "sim/process.hh" 44#endif 45 46namespace MipsISA 47{ 48 49typedef MipsFaultBase::FaultVals FaultVals; 50 51template <> FaultVals MipsFault<MachineCheckFault>::vals = 52 { "Machine Check", 0x0401 }; 53 54template <> FaultVals MipsFault<ResetFault>::vals = 55#if FULL_SYSTEM 56 { "Reset Fault", 0xBFC00000}; 57#else 58 { "Reset Fault", 0x001}; 59#endif 60 61template <> FaultVals MipsFault<AddressErrorFault>::vals = 62 { "Address Error", 0x0180 }; 63 64template <> FaultVals MipsFault<SystemCallFault>::vals = 65 { "Syscall", 0x0180 }; 66 67template <> FaultVals MipsFault<CoprocessorUnusableFault>::vals = 68 { "Coprocessor Unusable Fault", 0x180 }; 69 70template <> FaultVals MipsFault<ReservedInstructionFault>::vals = 71 { "Reserved Instruction Fault", 0x0180 }; 72 73template <> FaultVals MipsFault<ThreadFault>::vals = 74 { "Thread Fault", 0x00F1 }; 75 76template <> FaultVals MipsFault<IntegerOverflowFault>::vals = 77 { "Integer Overflow Exception", 0x180 }; 78 79template <> FaultVals MipsFault<InterruptFault>::vals = 80 { "interrupt", 0x0180 }; 81 82template <> FaultVals MipsFault<TrapFault>::vals = 83 { "Trap", 0x0180 }; 84 85template <> FaultVals MipsFault<BreakpointFault>::vals = 86 { "Breakpoint", 0x0180 }; 87 88template <> FaultVals MipsFault<TlbInvalidFault>::vals = 89 { "Invalid TLB Entry Exception", 0x0180 }; 90 91template <> FaultVals MipsFault<TlbRefillFault>::vals = 92 { "TLB Refill Exception", 0x0180 }; 93 94template <> FaultVals MipsFault<TLBModifiedFault>::vals = 95 { "TLB Modified Exception", 0x0180 }; 96 97template <> FaultVals MipsFault<DspStateDisabledFault>::vals = 98 { "DSP Disabled Fault", 0x001a }; 99
| 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 * Authors: Gabe Black 30 * Korey Sewell 31 * Jaidev Patwardhan 32 */ 33 34#include "arch/mips/faults.hh" 35#include "arch/mips/pra_constants.hh" 36#include "base/trace.hh" 37#include "cpu/base.hh" 38#include "cpu/thread_context.hh" 39#include "debug/MipsPRA.hh" 40 41#if !FULL_SYSTEM 42#include "mem/page_table.hh" 43#include "sim/process.hh" 44#endif 45 46namespace MipsISA 47{ 48 49typedef MipsFaultBase::FaultVals FaultVals; 50 51template <> FaultVals MipsFault<MachineCheckFault>::vals = 52 { "Machine Check", 0x0401 }; 53 54template <> FaultVals MipsFault<ResetFault>::vals = 55#if FULL_SYSTEM 56 { "Reset Fault", 0xBFC00000}; 57#else 58 { "Reset Fault", 0x001}; 59#endif 60 61template <> FaultVals MipsFault<AddressErrorFault>::vals = 62 { "Address Error", 0x0180 }; 63 64template <> FaultVals MipsFault<SystemCallFault>::vals = 65 { "Syscall", 0x0180 }; 66 67template <> FaultVals MipsFault<CoprocessorUnusableFault>::vals = 68 { "Coprocessor Unusable Fault", 0x180 }; 69 70template <> FaultVals MipsFault<ReservedInstructionFault>::vals = 71 { "Reserved Instruction Fault", 0x0180 }; 72 73template <> FaultVals MipsFault<ThreadFault>::vals = 74 { "Thread Fault", 0x00F1 }; 75 76template <> FaultVals MipsFault<IntegerOverflowFault>::vals = 77 { "Integer Overflow Exception", 0x180 }; 78 79template <> FaultVals MipsFault<InterruptFault>::vals = 80 { "interrupt", 0x0180 }; 81 82template <> FaultVals MipsFault<TrapFault>::vals = 83 { "Trap", 0x0180 }; 84 85template <> FaultVals MipsFault<BreakpointFault>::vals = 86 { "Breakpoint", 0x0180 }; 87 88template <> FaultVals MipsFault<TlbInvalidFault>::vals = 89 { "Invalid TLB Entry Exception", 0x0180 }; 90 91template <> FaultVals MipsFault<TlbRefillFault>::vals = 92 { "TLB Refill Exception", 0x0180 }; 93 94template <> FaultVals MipsFault<TLBModifiedFault>::vals = 95 { "TLB Modified Exception", 0x0180 }; 96 97template <> FaultVals MipsFault<DspStateDisabledFault>::vals = 98 { "DSP Disabled Fault", 0x001a }; 99
|
151IntegerOverflowFault::invoke(ThreadContext *tc, StaticInstPtr inst) 152{ 153 DPRINTF(MipsPRA, "%s encountered.\n", name()); 154 setExceptionState(tc, 0xC); 155 156 // Set new PC 157 Addr HandlerBase; 158 StatusReg status = tc->readMiscReg(MISCREG_STATUS); 159 // Here, the handler is dependent on BEV, which is not modified by 160 // setExceptionState() 161 if (!status.bev) { 162 // See MIPS ARM Vol 3, Revision 2, Page 38 163 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 164 } else { 165 HandlerBase = 0xBFC00200; 166 } 167 setHandlerPC(HandlerBase, tc); 168} 169 170void 171TrapFault::invoke(ThreadContext *tc, StaticInstPtr inst) 172{ 173 DPRINTF(MipsPRA, "%s encountered.\n", name()); 174 setExceptionState(tc, 0xD); 175 176 // Set new PC 177 Addr HandlerBase; 178 // Offset 0x180 - General Exception Vector 179 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 180 setHandlerPC(HandlerBase, tc); 181} 182 183void 184BreakpointFault::invoke(ThreadContext *tc, StaticInstPtr inst) 185{ 186 setExceptionState(tc, 0x9); 187 188 // Set new PC 189 Addr HandlerBase; 190 // Offset 0x180 - General Exception Vector 191 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 192 setHandlerPC(HandlerBase, tc); 193} 194 195void 196TlbInvalidFault::invoke(ThreadContext *tc, StaticInstPtr inst) 197{ 198 DPRINTF(MipsPRA, "%s encountered.\n", name()); 199 setExceptionState(tc, store ? 0x3 : 0x2); 200 201 tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 202 EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 203 entryHi.asid = entryHiAsid; 204 entryHi.vpn2 = entryHiVPN2; 205 entryHi.vpn2x = entryHiVPN2X; 206 tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 207 208 ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 209 context.badVPN2 = contextBadVPN2; 210 tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 211 212 // Set new PC 213 Addr HandlerBase; 214 // Offset 0x180 - General Exception Vector 215 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 216 setHandlerPC(HandlerBase, tc); 217} 218 219void 220AddressErrorFault::invoke(ThreadContext *tc, StaticInstPtr inst) 221{ 222 DPRINTF(MipsPRA, "%s encountered.\n", name()); 223 setExceptionState(tc, store ? 0x5 : 0x4); 224 tc->setMiscRegNoEffect(MISCREG_BADVADDR, vaddr); 225 226 // Set new PC 227 Addr HandlerBase; 228 // Offset 0x180 - General Exception Vector 229 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 230 setHandlerPC(HandlerBase, tc); 231} 232 233void 234TlbRefillFault::invoke(ThreadContext *tc, StaticInstPtr inst) 235{ 236 DPRINTF(MipsPRA, "%s encountered (%x).\n", name(), MISCREG_BADVADDR); 237 setExceptionState(tc, store ? 0x3 : 0x2); 238 239 Addr HandlerBase; 240 tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 241 EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 242 entryHi.asid = entryHiAsid; 243 entryHi.vpn2 = entryHiVPN2; 244 entryHi.vpn2x = entryHiVPN2X; 245 tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 246 ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 247 context.badVPN2 = contextBadVPN2; 248 tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 249 250 StatusReg status = tc->readMiscReg(MISCREG_STATUS); 251 // Since handler depends on EXL bit, must check EXL bit before setting it!! 252 // See MIPS ARM Vol 3, Revision 2, Page 38 253 if (status.exl == 1) { 254 // Offset 0x180 - General Exception Vector 255 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 256 } else { 257 // Offset 0x000 258 HandlerBase = tc->readMiscReg(MISCREG_EBASE); 259 } 260 setHandlerPC(HandlerBase, tc); 261} 262 263void 264TLBModifiedFault::invoke(ThreadContext *tc, StaticInstPtr inst) 265{ 266 DPRINTF(MipsPRA, "%s encountered.\n", name()); 267 tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 268 EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 269 entryHi.asid = entryHiAsid; 270 entryHi.vpn2 = entryHiVPN2; 271 entryHi.vpn2x = entryHiVPN2X; 272 tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 273 274 ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 275 context.badVPN2 = contextBadVPN2; 276 tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 277 278 // Set new PC 279 Addr HandlerBase; 280 // Offset 0x180 - General Exception Vector 281 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 282 setExceptionState(tc, 0x1); 283 setHandlerPC(HandlerBase, tc); 284 285} 286 287void 288SystemCallFault::invoke(ThreadContext *tc, StaticInstPtr inst) 289{ 290 DPRINTF(MipsPRA, "%s encountered.\n", name()); 291 setExceptionState(tc, 0x8); 292 293 // Set new PC 294 Addr HandlerBase; 295 // Offset 0x180 - General Exception Vector 296 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 297 setHandlerPC(HandlerBase, tc); 298} 299 300void 301InterruptFault::invoke(ThreadContext *tc, StaticInstPtr inst) 302{ 303#if FULL_SYSTEM 304 DPRINTF(MipsPRA, "%s encountered.\n", name()); 305 setExceptionState(tc, 0x0A); 306 Addr HandlerBase; 307 308 CauseReg cause = tc->readMiscRegNoEffect(MISCREG_CAUSE); 309 if (cause.iv) { 310 // Offset 200 for release 2 311 HandlerBase = 0x20 + vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 312 } else { 313 //Ofset at 180 for release 1 314 HandlerBase = vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 315 } 316 317 setHandlerPC(HandlerBase, tc); 318#endif 319} 320 321#endif // FULL_SYSTEM 322 323void 324ResetFault::invoke(ThreadContext *tc, StaticInstPtr inst) 325{ 326#if FULL_SYSTEM 327 DPRINTF(MipsPRA, "%s encountered.\n", name()); 328 /* All reset activity must be invoked from here */ 329 tc->setPC(vect()); 330 tc->setNextPC(vect() + sizeof(MachInst)); 331 tc->setNextNPC(vect() + sizeof(MachInst) + sizeof(MachInst)); 332 DPRINTF(MipsPRA, "ResetFault::invoke : PC set to %x", tc->readPC()); 333#endif 334 335 // Set Coprocessor 1 (Floating Point) To Usable 336 StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS); 337 status.cu.cu1 = 1; 338 tc->setMiscReg(MISCREG_STATUS, status); 339} 340 341void 342ReservedInstructionFault::invoke(ThreadContext *tc, StaticInstPtr inst) 343{ 344#if FULL_SYSTEM 345 DPRINTF(MipsPRA, "%s encountered.\n", name()); 346 setExceptionState(tc, 0x0A); 347 Addr HandlerBase; 348 // Offset 0x180 - General Exception Vector 349 HandlerBase = vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 350 setHandlerPC(HandlerBase, tc); 351#else 352 panic("%s encountered.\n", name()); 353#endif 354} 355 356void 357ThreadFault::invoke(ThreadContext *tc, StaticInstPtr inst) 358{ 359 DPRINTF(MipsPRA, "%s encountered.\n", name()); 360 panic("%s encountered.\n", name()); 361} 362 363void 364DspStateDisabledFault::invoke(ThreadContext *tc, StaticInstPtr inst) 365{ 366 DPRINTF(MipsPRA, "%s encountered.\n", name()); 367 panic("%s encountered.\n", name()); 368} 369 370void 371CoprocessorUnusableFault::invoke(ThreadContext *tc, StaticInstPtr inst) 372{ 373#if FULL_SYSTEM 374 DPRINTF(MipsPRA, "%s encountered.\n", name()); 375 setExceptionState(tc, 0xb); 376 // The ID of the coprocessor causing the exception is stored in 377 // CoprocessorUnusableFault::coProcID 378 CauseReg cause = tc->readMiscReg(MISCREG_CAUSE); 379 cause.ce = coProcID; 380 tc->setMiscRegNoEffect(MISCREG_CAUSE, cause); 381 382 Addr HandlerBase; 383 // Offset 0x180 - General Exception Vector 384 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 385 setHandlerPC(HandlerBase, tc); 386 387#else 388 warn("%s (CP%d) encountered.\n", name(), coProcID); 389#endif 390} 391 392} // namespace MipsISA 393
| 142IntegerOverflowFault::invoke(ThreadContext *tc, StaticInstPtr inst) 143{ 144 DPRINTF(MipsPRA, "%s encountered.\n", name()); 145 setExceptionState(tc, 0xC); 146 147 // Set new PC 148 Addr HandlerBase; 149 StatusReg status = tc->readMiscReg(MISCREG_STATUS); 150 // Here, the handler is dependent on BEV, which is not modified by 151 // setExceptionState() 152 if (!status.bev) { 153 // See MIPS ARM Vol 3, Revision 2, Page 38 154 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 155 } else { 156 HandlerBase = 0xBFC00200; 157 } 158 setHandlerPC(HandlerBase, tc); 159} 160 161void 162TrapFault::invoke(ThreadContext *tc, StaticInstPtr inst) 163{ 164 DPRINTF(MipsPRA, "%s encountered.\n", name()); 165 setExceptionState(tc, 0xD); 166 167 // Set new PC 168 Addr HandlerBase; 169 // Offset 0x180 - General Exception Vector 170 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 171 setHandlerPC(HandlerBase, tc); 172} 173 174void 175BreakpointFault::invoke(ThreadContext *tc, StaticInstPtr inst) 176{ 177 setExceptionState(tc, 0x9); 178 179 // Set new PC 180 Addr HandlerBase; 181 // Offset 0x180 - General Exception Vector 182 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 183 setHandlerPC(HandlerBase, tc); 184} 185 186void 187TlbInvalidFault::invoke(ThreadContext *tc, StaticInstPtr inst) 188{ 189 DPRINTF(MipsPRA, "%s encountered.\n", name()); 190 setExceptionState(tc, store ? 0x3 : 0x2); 191 192 tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 193 EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 194 entryHi.asid = entryHiAsid; 195 entryHi.vpn2 = entryHiVPN2; 196 entryHi.vpn2x = entryHiVPN2X; 197 tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 198 199 ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 200 context.badVPN2 = contextBadVPN2; 201 tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 202 203 // Set new PC 204 Addr HandlerBase; 205 // Offset 0x180 - General Exception Vector 206 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 207 setHandlerPC(HandlerBase, tc); 208} 209 210void 211AddressErrorFault::invoke(ThreadContext *tc, StaticInstPtr inst) 212{ 213 DPRINTF(MipsPRA, "%s encountered.\n", name()); 214 setExceptionState(tc, store ? 0x5 : 0x4); 215 tc->setMiscRegNoEffect(MISCREG_BADVADDR, vaddr); 216 217 // Set new PC 218 Addr HandlerBase; 219 // Offset 0x180 - General Exception Vector 220 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 221 setHandlerPC(HandlerBase, tc); 222} 223 224void 225TlbRefillFault::invoke(ThreadContext *tc, StaticInstPtr inst) 226{ 227 DPRINTF(MipsPRA, "%s encountered (%x).\n", name(), MISCREG_BADVADDR); 228 setExceptionState(tc, store ? 0x3 : 0x2); 229 230 Addr HandlerBase; 231 tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 232 EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 233 entryHi.asid = entryHiAsid; 234 entryHi.vpn2 = entryHiVPN2; 235 entryHi.vpn2x = entryHiVPN2X; 236 tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 237 ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 238 context.badVPN2 = contextBadVPN2; 239 tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 240 241 StatusReg status = tc->readMiscReg(MISCREG_STATUS); 242 // Since handler depends on EXL bit, must check EXL bit before setting it!! 243 // See MIPS ARM Vol 3, Revision 2, Page 38 244 if (status.exl == 1) { 245 // Offset 0x180 - General Exception Vector 246 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 247 } else { 248 // Offset 0x000 249 HandlerBase = tc->readMiscReg(MISCREG_EBASE); 250 } 251 setHandlerPC(HandlerBase, tc); 252} 253 254void 255TLBModifiedFault::invoke(ThreadContext *tc, StaticInstPtr inst) 256{ 257 DPRINTF(MipsPRA, "%s encountered.\n", name()); 258 tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 259 EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 260 entryHi.asid = entryHiAsid; 261 entryHi.vpn2 = entryHiVPN2; 262 entryHi.vpn2x = entryHiVPN2X; 263 tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 264 265 ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 266 context.badVPN2 = contextBadVPN2; 267 tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 268 269 // Set new PC 270 Addr HandlerBase; 271 // Offset 0x180 - General Exception Vector 272 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 273 setExceptionState(tc, 0x1); 274 setHandlerPC(HandlerBase, tc); 275 276} 277 278void 279SystemCallFault::invoke(ThreadContext *tc, StaticInstPtr inst) 280{ 281 DPRINTF(MipsPRA, "%s encountered.\n", name()); 282 setExceptionState(tc, 0x8); 283 284 // Set new PC 285 Addr HandlerBase; 286 // Offset 0x180 - General Exception Vector 287 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 288 setHandlerPC(HandlerBase, tc); 289} 290 291void 292InterruptFault::invoke(ThreadContext *tc, StaticInstPtr inst) 293{ 294#if FULL_SYSTEM 295 DPRINTF(MipsPRA, "%s encountered.\n", name()); 296 setExceptionState(tc, 0x0A); 297 Addr HandlerBase; 298 299 CauseReg cause = tc->readMiscRegNoEffect(MISCREG_CAUSE); 300 if (cause.iv) { 301 // Offset 200 for release 2 302 HandlerBase = 0x20 + vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 303 } else { 304 //Ofset at 180 for release 1 305 HandlerBase = vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 306 } 307 308 setHandlerPC(HandlerBase, tc); 309#endif 310} 311 312#endif // FULL_SYSTEM 313 314void 315ResetFault::invoke(ThreadContext *tc, StaticInstPtr inst) 316{ 317#if FULL_SYSTEM 318 DPRINTF(MipsPRA, "%s encountered.\n", name()); 319 /* All reset activity must be invoked from here */ 320 tc->setPC(vect()); 321 tc->setNextPC(vect() + sizeof(MachInst)); 322 tc->setNextNPC(vect() + sizeof(MachInst) + sizeof(MachInst)); 323 DPRINTF(MipsPRA, "ResetFault::invoke : PC set to %x", tc->readPC()); 324#endif 325 326 // Set Coprocessor 1 (Floating Point) To Usable 327 StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS); 328 status.cu.cu1 = 1; 329 tc->setMiscReg(MISCREG_STATUS, status); 330} 331 332void 333ReservedInstructionFault::invoke(ThreadContext *tc, StaticInstPtr inst) 334{ 335#if FULL_SYSTEM 336 DPRINTF(MipsPRA, "%s encountered.\n", name()); 337 setExceptionState(tc, 0x0A); 338 Addr HandlerBase; 339 // Offset 0x180 - General Exception Vector 340 HandlerBase = vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 341 setHandlerPC(HandlerBase, tc); 342#else 343 panic("%s encountered.\n", name()); 344#endif 345} 346 347void 348ThreadFault::invoke(ThreadContext *tc, StaticInstPtr inst) 349{ 350 DPRINTF(MipsPRA, "%s encountered.\n", name()); 351 panic("%s encountered.\n", name()); 352} 353 354void 355DspStateDisabledFault::invoke(ThreadContext *tc, StaticInstPtr inst) 356{ 357 DPRINTF(MipsPRA, "%s encountered.\n", name()); 358 panic("%s encountered.\n", name()); 359} 360 361void 362CoprocessorUnusableFault::invoke(ThreadContext *tc, StaticInstPtr inst) 363{ 364#if FULL_SYSTEM 365 DPRINTF(MipsPRA, "%s encountered.\n", name()); 366 setExceptionState(tc, 0xb); 367 // The ID of the coprocessor causing the exception is stored in 368 // CoprocessorUnusableFault::coProcID 369 CauseReg cause = tc->readMiscReg(MISCREG_CAUSE); 370 cause.ce = coProcID; 371 tc->setMiscRegNoEffect(MISCREG_CAUSE, cause); 372 373 Addr HandlerBase; 374 // Offset 0x180 - General Exception Vector 375 HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 376 setHandlerPC(HandlerBase, tc); 377 378#else 379 warn("%s (CP%d) encountered.\n", name(), coProcID); 380#endif 381} 382 383} // namespace MipsISA 384
|