|
| 1 | +# yaml-language-server: $schema=../../schemas/csr_schema.json |
| 2 | + |
| 3 | +$schema: "csr_schema.json#" |
| 4 | +kind: csr |
| 5 | +name: mnstatus |
| 6 | +long_name: Machine NMI Status |
| 7 | +address: 0x744 |
| 8 | +priv_mode: M |
| 9 | + |
| 10 | +# length is MXLEN-bit |
| 11 | +length: MXLEN |
| 12 | +description: The mnstatus register tracks and controls the hart's current NMI operating state. |
| 13 | +definedBy: Smrnmi |
| 14 | +fields: |
| 15 | + MNPP: |
| 16 | + location: 12-11 |
| 17 | + description: | |
| 18 | + M-mode NMI Previous Privilege. |
| 19 | +
|
| 20 | + Written by hardware in two cases: |
| 21 | +
|
| 22 | + * Written with the prior nominal privilege level when entering M-mode NMI from an exception/interrupt. |
| 23 | + * Written with 0 when executing an `mnret` instruction to return from a double exception / NMI in M-mode. |
| 24 | +
|
| 25 | + Can also be written by software without immediate side-effect. |
| 26 | +
|
| 27 | + Affects execution in two cases: |
| 28 | +
|
| 29 | + * On a return from a double exception / NMI from M-mode, the machine will |
| 30 | + enter the privilege level stored in MNPP before clearing the field. |
| 31 | + * When `mnstatus.MNPRV` is set, loads and stores behave as if the current privilege level were MNPP. |
| 32 | + type: RW-H |
| 33 | + reset_value: UNDEFINED_LEGAL |
| 34 | + sw_write(csr_value): | |
| 35 | + if (csr_value.MNPP == 2'b01 && !implemented?(ExtensionName::S)) { |
| 36 | + return UNDEFINED_LEGAL_DETERMINISTIC; |
| 37 | + } else if (csr_value.MNPP == 2'b00 && !implemented?(ExtensionName::U)) { |
| 38 | + return UNDEFINED_LEGAL_DETERMINISTIC; |
| 39 | + } else if (csr_value.MNPP == 2'b10) { |
| 40 | + # never a valid value |
| 41 | + return UNDEFINED_LEGAL_DETERMINISTIC; |
| 42 | + } else { |
| 43 | + return csr_value.MNPP; |
| 44 | + } |
| 45 | + legal?(csr_value): | |
| 46 | + if (csr_value.MNPP == 2'b01 && !implemented?(ExtensionName::S)) { |
| 47 | + return false; |
| 48 | + } else if (csr_value.MNPP == 2'b00 && !implemented?(ExtensionName::U)) { |
| 49 | + return false; |
| 50 | + } else if (csr_value.MNPP == 2'b10) { |
| 51 | + # never a valid value |
| 52 | + return false; |
| 53 | + } else { |
| 54 | + return true; |
| 55 | + } |
| 56 | + MNPV: |
| 57 | + location: 7 |
| 58 | + description: | |
| 59 | + *Machine Previous NMI Virtualization mode* |
| 60 | +
|
| 61 | + Written with the prior virtualization mode when entering M-mode from an exception/interrupt. |
| 62 | + When returning via an MRET instruction, the virtualization mode becomes the value of MPV unless MPP=3, in which case the virtualization mode is always 0. |
| 63 | + Can also be written by software. |
| 64 | + type: RW-H |
| 65 | + reset_value: UNDEFINED_LEGAL |
| 66 | + definedBy: H |
| 67 | + NMIE: |
| 68 | + location: 3 |
| 69 | + description: | |
| 70 | + *M-mode NMI Enable* |
| 71 | +
|
| 72 | + Written by hardware in two cases: |
| 73 | +
|
| 74 | + * Written with the value 0 when entering M-mode NMI. |
| 75 | + * Written with the value 0 when entering M-mode double trap. |
| 76 | +
|
| 77 | + Written by software in one case only: |
| 78 | +
|
| 79 | + * The NMIE is 0 on reset for boot code to initialize system to service NMIs. Once SW writes NMIE to 1, it cannot be changed anymore by SW. |
| 80 | +
|
| 81 | + Affects execution by: |
| 82 | +
|
| 83 | + * When 0, all non-maskable interrupts and exceptions are disabled when the current privilege level is M. |
| 84 | + * When 1, NMI or double trap is possible. |
| 85 | +
|
| 86 | + type: RW-H |
| 87 | + reset_value: 0 |
0 commit comments