Skip to content

Commit 34f6f87

Browse files
authored
Merge branch 'main' into ref_resolve
2 parents b602097 + 5e6c568 commit 34f6f87

File tree

12 files changed

+414
-214
lines changed

12 files changed

+414
-214
lines changed

arch/csr/I/mcounteren.layout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ fields:
104104
When `hcounteren.CY` && `scounteren.CY` are both set, `cycle` is futher accessible to VU-mode.
105105
<%%- end -%>
106106
type(): |
107-
if (MCOUNTENABLE_EN[2]) {
107+
if (MCOUNTENABLE_EN[0]) {
108108
return CsrFieldType::RW;
109109
} else {
110110
return CsrFieldType::RO;
111111
}
112112
reset_value(): |
113-
if (MCOUNTENABLE_EN[2]) {
113+
if (MCOUNTENABLE_EN[0]) {
114114
return UNDEFINED_LEGAL;
115115
} else {
116116
return 0;

arch/csr/I/mcounteren.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ fields:
107107
When `hcounteren.CY` && `scounteren.CY` are both set, `cycle` is futher accessible to VU-mode.
108108
<%- end -%>
109109
type(): |
110-
if (MCOUNTENABLE_EN[2]) {
110+
if (MCOUNTENABLE_EN[0]) {
111111
return CsrFieldType::RW;
112112
} else {
113113
return CsrFieldType::RO;
114114
}
115115
reset_value(): |
116-
if (MCOUNTENABLE_EN[2]) {
116+
if (MCOUNTENABLE_EN[0]) {
117117
return UNDEFINED_LEGAL;
118118
} else {
119119
return 0;

arch/csr/mhartid.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ address: 0xf14
88
priv_mode: M
99
length: MXLEN
1010
description: Reports the unique hart-specific ID in the system.
11-
definedBy: I
11+
definedBy: Sm
1212
fields:
1313
ID:
1414
location_rv32: 31-0
@@ -17,4 +17,4 @@ fields:
1717
description: hart-specific ID.
1818
reset_value: UNDEFINED_LEGAL
1919
sw_read(): |
20-
return hartid();
20+
return hartid();

arch/csr/mie.yaml

Lines changed: 3 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -7,147 +7,9 @@ long_name: Machine Interrupt Enable
77
address: 0x304
88
priv_mode: M
99
length: MXLEN
10-
definedBy: I
11-
description: |
12-
Per-type interrupt enables.
13-
14-
For a detailed description of interrupt handling, see <%= link_to(:section, 'sec:interrupts') %>.
15-
16-
The `mie` register is an
17-
MXLEN-bit read/write register containing interrupt enable bits.
18-
Interrupt cause number _i_ (as reported in CSR `mcause`) corresponds with
19-
bit _i_ in
20-
`mie`. Bits 15:0 are allocated to standard interrupt causes only, while
21-
bits 16 and above are designated for platform use.
22-
23-
NOTE: Interrupts designated for platform use may be designated for custom use
24-
at the platform's discretion.
25-
26-
An interrupt _i_ will trap to M-mode (causing the privilege mode to
27-
change to M-mode) if all of the following are true:
28-
29-
* either the current privilege mode is M and the MIE bit in the
30-
`mstatus` register is set, or the current privilege mode has less
31-
privilege than M-mode;
32-
* bit _i_ is set in both `mip` and `mie`;
33-
* if register `mideleg` exists, bit _i_ is not set in `mideleg`.
34-
35-
These conditions for an interrupt trap to occur must be evaluated in a
36-
bounded amount of time from when an interrupt becomes, or ceases to be,
37-
pending in `mip`, and must also be evaluated immediately following the
38-
execution of an __x__RET instruction or an explicit write to a CSR on
39-
which these interrupt trap conditions expressly depend (including `mip`,
40-
`mie`, `mstatus`, and `mideleg`).
41-
42-
Interrupts to M-mode take priority over any interrupts to lower
43-
privilege modes.
44-
45-
A bit in `mie` must be writable if the corresponding interrupt can ever
46-
become pending. Bits of `mie` that are not writable must be read-only
47-
zero.
48-
49-
[NOTE]
50-
====
51-
The machine-level interrupt registers handle a few root interrupt
52-
sources which are assigned a fixed service priority for simplicity,
53-
while separate external interrupt controllers can implement a more
54-
complex prioritization scheme over a much larger set of interrupts that
55-
are then muxed into the machine-level interrupt sources.
56-
57-
'''
58-
59-
The non-maskable interrupt is not made visible via the `mip` register as
60-
its presence is implicitly known when executing the NMI trap handler.
61-
====
62-
63-
If supervisor mode is implemented, bits `mip`.SEIP and `mie`.SEIE are
64-
the interrupt-pending and interrupt-enable bits for supervisor-level
65-
external interrupts. SEIP is writable in `mip`, and may be written by
66-
M-mode software to indicate to S-mode that an external interrupt is
67-
pending. Additionally, the platform-level interrupt controller may
68-
generate supervisor-level external interrupts. Supervisor-level external
69-
interrupts are made pending based on the logical-OR of the
70-
software-writable SEIP bit and the signal from the external interrupt
71-
controller. When `mip` is read with a CSR instruction, the value of the
72-
SEIP bit returned in the `rd` destination register is the logical-OR of
73-
the software-writable bit and the interrupt signal from the interrupt
74-
controller, but the signal from the interrupt controller is not used to
75-
calculate the value written to SEIP. Only the software-writable SEIP bit
76-
participates in the read-modify-write sequence of a CSRRS or CSRRC
77-
instruction.
78-
79-
[NOTE]
80-
====
81-
For example, if we name the software-writable SEIP bit `B` and the
82-
signal from the external interrupt controller `E`, then if
83-
`csrrs t0, mip, t1` is executed, `t0[9]` is written with `B || E`, then
84-
`B` is written with `B || t1[9]`. If `csrrw t0, mip, t1` is executed,
85-
then `t0[9]` is written with `B || E`, and `B` is simply written with
86-
`t1[9]`. In neither case does `B` depend upon `E`.
87-
88-
The SEIP field behavior is designed to allow a higher privilege layer to
89-
mimic external interrupts cleanly, without losing any real external
90-
interrupts. The behavior of the CSR instructions is slightly modified
91-
from regular CSR accesses as a result.
92-
====
93-
94-
If supervisor mode is implemented, bits `mip`.STIP and `mie`.STIE are
95-
the interrupt-pending and interrupt-enable bits for supervisor-level
96-
timer interrupts. STIP is writable in `mip`, and may be written by
97-
M-mode software to deliver timer interrupts to S-mode.
98-
99-
If supervisor mode is implemented, bits `mip`.SSIP and `mie`.SSIE are
100-
the interrupt-pending and interrupt-enable bits for supervisor-level
101-
software interrupts. SSIP is writable in `mip` and may also be set to 1
102-
by a platform-specific interrupt controller.
103-
104-
<%- if ext?(:Sscofpmf) -%>
105-
Bits `mip`.LCOFIP and `mie`.LCOFIE
106-
are the interrupt-pending and interrupt-enable bits for local counter-overflow
107-
interrupts.
108-
LCOFIP is read-write in `mip` and reflects the occurrence of a local
109-
counter-overflow overflow interrupt request resulting from any of the
110-
`mhpmevent__n__`.OF bits being set.
111-
If the Sscofpmf extension is not implemented, `mip`.LCOFIP and `mie`.LCOFIE are
112-
read-only zeros.
113-
<%- end -%>
114-
115-
Multiple simultaneous interrupts destined for M-mode are handled in the
116-
following decreasing priority order: MEI, MSI, MTI, SEI, SSI, STI, LCOFI.
117-
118-
[NOTE]
119-
====
120-
The machine-level interrupt fixed-priority ordering rules were developed
121-
with the following rationale.
122-
123-
Interrupts for higher privilege modes must be serviced before interrupts
124-
for lower privilege modes to support preemption.
125-
126-
The platform-specific machine-level interrupt sources in bits 16 and
127-
above have platform-specific priority, but are typically chosen to have
128-
the highest service priority to support very fast local vectored
129-
interrupts.
130-
131-
External interrupts are handled before internal (timer/software)
132-
interrupts as external interrupts are usually generated by devices that
133-
might require low interrupt service times.
134-
135-
Software interrupts are handled before internal timer interrupts,
136-
because internal timer interrupts are usually intended for time slicing,
137-
where time precision is less important, whereas software interrupts are
138-
used for inter-processor messaging. Software interrupts can be avoided
139-
when high-precision timing is required, or high-precision timer
140-
interrupts can be routed via a different interrupt path. Software
141-
interrupts are located in the lowest four bits of `mip` as these are
142-
often written by software, and this position allows the use of a single
143-
CSR instruction with a five-bit immediate.
144-
====
145-
146-
Restricted views of the `mip` and `mie` registers appear as the `sip`
147-
and `sie` registers for supervisor level. If an interrupt is delegated
148-
to S-mode by setting a bit in the `mideleg` register, it becomes visible
149-
in the `sip` register and is maskable using the `sie` register.
150-
Otherwise, the corresponding bits in `sip` and `sie` are read-only zero.
10+
definedBy: Sm
11+
description:
12+
$copy: "mip.yaml#/description"
15113
fields:
15214
SSIE:
15315
location: 1

arch/csr/mip.yaml

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,153 @@ name: mip
66
long_name: Machine Interrupt Pending
77
address: 0x344
88
priv_mode: M
9-
description: Machine Interrupt Pending bits
9+
10+
# Description is shared with mie CSR (it copies it from here).
11+
description: |
12+
The `mie` and `mip` CSRs are MXLEN-bit read/write registers used when
13+
the CLINT or PLIC interrupt controllers are present.
14+
Note that the CLINT refers to an interrupt controller
15+
used by some RISC-V implementations but isn't a ratified
16+
RISC-V International standard.
17+
18+
The `mip` CSR contains information on pending interrupts, while `mie` is the corresponding
19+
CSR containing interrupt enable bits.
20+
Interrupt cause number _i_ (as reported in the `mcause` CSR)
21+
corresponds to bit _i_ in both `mip` and `mie`.
22+
Bits 15:0 are allocated to standard interrupt causes only, while
23+
bits 16 and above are designated for platform use.
24+
25+
NOTE: Interrupts designated for platform use may be designated for custom use
26+
at the platform's discretion.
27+
28+
An interrupt _i_ will trap to M-mode (causing the privilege mode to
29+
change to M-mode) if all of the following are true:
30+
31+
* either the current privilege mode is M and the MIE bit in the `mstatus` register is
32+
set, or the current privilege mode has less privilege than M-mode;
33+
* bit _i_ is set in both `mip` and `mie`
34+
* if register `mideleg` exists, bit _i_ is not set in `mideleg`.
35+
36+
These conditions for an interrupt trap to occur must be evaluated in a
37+
bounded amount of time from when an interrupt becomes, or ceases to be,
38+
pending in `mip`, and must also be evaluated immediately following the
39+
execution of an __x__RET instruction or an explicit write to a CSR on
40+
which these interrupt trap conditions expressly depend (including `mip`,
41+
`mie`, `mstatus`, and `mideleg`).
42+
43+
Interrupts to M-mode take priority over any interrupts to lower
44+
privilege modes.
45+
46+
Each individual bit in register `mip` may be writable or may be
47+
read-only. When bit _i_ in `mip` is writable, a pending interrupt _i_
48+
can be cleared by writing 0 to this bit. If interrupt _i_ can become
49+
pending but bit _i_ in `mip` is read-only, the implementation must
50+
provide some other mechanism for clearing the pending interrupt.
51+
52+
A bit in `mie` must be writable if the corresponding interrupt can ever
53+
become pending. Bits of `mie` that are not writable must be read-only
54+
zero.
55+
56+
[NOTE]
57+
====
58+
The machine-level interrupt registers handle a few root interrupt
59+
sources which are assigned a fixed service priority for simplicity,
60+
while separate external interrupt controllers can implement a more
61+
complex prioritization scheme over a much larger set of interrupts that
62+
are then muxed into the machine-level interrupt sources.
63+
64+
'''
65+
66+
The non-maskable interrupt is not made visible via the `mip` register as
67+
its presence is implicitly known when executing the NMI trap handler.
68+
====
69+
70+
If supervisor mode is implemented, bits `mip`.SEIP and `mie`.SEIE are
71+
the interrupt-pending and interrupt-enable bits for supervisor-level
72+
external interrupts. SEIP is writable in `mip`, and may be written by
73+
M-mode software to indicate to S-mode that an external interrupt is
74+
pending. Additionally, the platform-level interrupt controller may
75+
generate supervisor-level external interrupts. Supervisor-level external
76+
interrupts are made pending based on the logical-OR of the
77+
software-writable SEIP bit and the signal from the external interrupt
78+
controller. When `mip` is read with a CSR instruction, the value of the
79+
SEIP bit returned in the `rd` destination register is the logical-OR of
80+
the software-writable bit and the interrupt signal from the interrupt
81+
controller, but the signal from the interrupt controller is not used to
82+
calculate the value written to SEIP. Only the software-writable SEIP bit
83+
participates in the read-modify-write sequence of a CSRRS or CSRRC
84+
instruction.
85+
86+
[NOTE]
87+
====
88+
For example, if we name the software-writable SEIP bit `B` and the
89+
signal from the external interrupt controller `E`, then if
90+
`csrrs t0, mip, t1` is executed, `t0[9]` is written with `B || E`, then
91+
`B` is written with `B || t1[9]`. If `csrrw t0, mip, t1` is executed,
92+
then `t0[9]` is written with `B || E`, and `B` is simply written with
93+
`t1[9]`. In neither case does `B` depend upon `E`.
94+
95+
The SEIP field behavior is designed to allow a higher privilege layer to
96+
mimic external interrupts cleanly, without losing any real external
97+
interrupts. The behavior of the CSR instructions is slightly modified
98+
from regular CSR accesses as a result.
99+
====
100+
101+
If supervisor mode is implemented, bits `mip`.STIP and `mie`.STIE are
102+
the interrupt-pending and interrupt-enable bits for supervisor-level
103+
timer interrupts. STIP is writable in `mip`, and may be written by
104+
M-mode software to deliver timer interrupts to S-mode.
105+
106+
If supervisor mode is implemented, bits `mip`.SSIP and `mie`.SSIE are
107+
the interrupt-pending and interrupt-enable bits for supervisor-level
108+
software interrupts. SSIP is writable in `mip` and may also be set to 1
109+
by a platform-specific interrupt controller.
110+
111+
<% if ext?(:Sscofpmf) -%>
112+
bits `mip`.LCOFIP and `mie`.LCOFIE
113+
are the interrupt-pending and interrupt-enable bits for local counter-overflow
114+
interrupts.
115+
LCOFIP is read-write in `mip` and reflects the occurrence of a local
116+
counter-overflow overflow interrupt request resulting from any of the
117+
`mhpmevent__n__`.OF bits being set.
118+
<% end -%>
119+
120+
Multiple simultaneous interrupts destined for M-mode are handled in the
121+
following decreasing priority order: MEI, MSI, MTI, SEI, SSI, STI, LCOFI.
122+
123+
[NOTE]
124+
====
125+
The machine-level interrupt fixed-priority ordering rules were developed
126+
with the following rationale.
127+
128+
Interrupts for higher privilege modes must be serviced before interrupts
129+
for lower privilege modes to support preemption.
130+
131+
The platform-specific machine-level interrupt sources in bits 16 and
132+
above have platform-specific priority, but are typically chosen to have
133+
the highest service priority to support very fast local vectored
134+
interrupts.
135+
136+
External interrupts are handled before internal (timer/software)
137+
interrupts as external interrupts are usually generated by devices that
138+
might require low interrupt service times.
139+
140+
Software interrupts are handled before internal timer interrupts,
141+
because internal timer interrupts are usually intended for time slicing,
142+
where time precision is less important, whereas software interrupts are
143+
used for inter-processor messaging. Software interrupts can be avoided
144+
when high-precision timing is required, or high-precision timer
145+
interrupts can be routed via a different interrupt path. Software
146+
interrupts are located in the lowest four bits of `mip` as these are
147+
often written by software, and this position allows the use of a single
148+
CSR instruction with a five-bit immediate.
149+
====
150+
151+
Restricted views of the `mip` and `mie` registers appear as the `sip`
152+
and `sie` registers for supervisor level. If an interrupt is delegated
153+
to S-mode by setting a bit in the `mideleg` register, it becomes visible
154+
in the `sip` register and is maskable using the `sie` register.
155+
Otherwise, the corresponding bits in `sip` and `sie` are read-only zero.
10156
length: MXLEN
11157
definedBy: Sm
12158
fields:
@@ -256,4 +402,4 @@ fields:
256402
<%- end -%>
257403
type: RW-H
258404
reset_value: 0
259-
definedBy: Sscofpmf
405+
definedBy: Sscofpmf

0 commit comments

Comments
 (0)