1/* 2 * Copyright (c) 2016 RISC-V Foundation 3 * Copyright (c) 2016 The University of Virginia 4 * Copyright (c) 2018 TU Dresden 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 57 unchanged lines hidden (view full) --- 66 prv = PRV_S; 67 } 68 if (pp == PRV_U && 69 bits(tc->readMiscReg(MISCREG_SEDELEG), _code) != 0) { 70 prv = PRV_U; 71 } 72 73 // Set fault registers and status |
74 MiscRegIndex cause, epc, tvec, tval; |
75 switch (prv) { 76 case PRV_U: 77 cause = MISCREG_UCAUSE; 78 epc = MISCREG_UEPC; 79 tvec = MISCREG_UTVEC; |
80 tval = MISCREG_UTVAL; |
81 82 status.upie = status.uie; 83 status.uie = 0; 84 break; 85 case PRV_S: 86 cause = MISCREG_SCAUSE; 87 epc = MISCREG_SEPC; 88 tvec = MISCREG_STVEC; |
89 tval = MISCREG_STVAL; |
90 91 status.spp = pp; 92 status.spie = status.sie; 93 status.sie = 0; 94 break; 95 case PRV_M: 96 cause = MISCREG_MCAUSE; 97 epc = MISCREG_MEPC; 98 tvec = MISCREG_MTVEC; |
99 tval = MISCREG_MTVAL; |
100 101 status.mpp = pp; 102 status.mpie = status.sie; 103 status.mie = 0; 104 break; 105 default: 106 panic("Unknown privilege mode %d.", prv); 107 break; 108 } 109 110 // Set fault cause, privilege, and return PC 111 tc->setMiscReg(cause, 112 (isInterrupt() << (sizeof(MiscReg) * 4 - 1)) | _code); 113 tc->setMiscReg(epc, tc->instAddr()); |
114 tc->setMiscReg(tval, trap_value()); |
115 tc->setMiscReg(MISCREG_PRV, prv); 116 tc->setMiscReg(MISCREG_STATUS, status); 117 118 // Set PC to fault handler address 119 pcState.set(tc->readMiscReg(tvec) >> 2); 120 } else { 121 invokeSE(tc, inst); 122 advancePC(pcState, inst); --- 59 unchanged lines hidden --- |