Skip to content

Commit e3bb1ef

Browse files
Evgenii PaltsevEvgenii Paltsev
authored andcommitted
Major & external interrupts unification
1 parent a892d94 commit e3bb1ef

File tree

1 file changed

+19
-61
lines changed

1 file changed

+19
-61
lines changed

src/aclic.adoc

Lines changed: 19 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ The table below provides a summary of the ACLIC extensions.
183183
| Smaiae | Advanced Interrupt Architecture for Embedded Systems
184184
| Smaclic | Advanced Core Local Interrupt Controller at Machine level
185185
| Ssaclic | Advanced Core Local Interrupt Controller at Supervisor level
186-
| Smivt | Support for interrupt vector table at Machine level
187-
| Ssivt | Support for interrupt vector table at Supervisor level
188186
| Smehv | Synchronous exceptions hardware vectoring
189187
| Smcsps | Conditional stack pointer swap at Machine level
190188
| Sscsps | Conditional stack pointer swap at Supervisor level
@@ -203,8 +201,6 @@ Each row contains the dependencies of the extension named in the first column.
203201
[%autowidth]
204202
|===
205203
| Extension Name | Sm | Ss | Smcsrind | Sscsrind | Smaiae | Smnip
206-
| Smivt | x | | | | |
207-
| Ssivt | | x | | | |
208204
| Smcsps | x | | | | |
209205
| Sscsps | | x | | | |
210206
| Smtp | (x)| (x)| | | |
@@ -413,6 +409,10 @@ Therefore, the registers setipnum, clripnum, setienum, clrienum, setipnum_be, an
413409
The iprio portion of it can be accessed as described in the section on indirect access.
414410
The rest is not required.
415411

412+
=== Major interrupt redirection to ACLIC
413+
414+
In ACLIC mode major interrupt sources are forwarded to ACLIC, according to their major identity numbers. In that mode CLINT is not used and ACLIC becomes the only source of interrupts for M/S-modes.
415+
416416
=== State Enable
417417

418418
Access to existing and repurposed AIA CSRs is already controlled by the state enables defined in Smaia/Ssaia.
@@ -782,89 +782,45 @@ and the conditions for a virtual instruction exception apply,
782782
in which case a virtual instruction exception is raised
783783
when in VS or VU mode instead of an illegal instruction exception.
784784

785-
== Support for interrupt vector table (Smivt, Ssivt)
786-
787-
These extensions adds a new mode for taking interrupts via a dedicated interrupt vector table.
788-
789-
This increases the range of reachable addresses to the entire address space.
790-
This is useful when handlers are more than 2 MiB away from the vector table entry.
785+
== Smaclic / Ssaclic Changes to {xtvec} CSR Mode
791786

792-
In this new mode, when an interrupt is taken, the hart hardware loads the vector
793-
table entry for the associated interrupt (table pointed to new {xivt} or {xeivt} CSR),
794-
masks off the least-significant bit (for IALIGN=16) or masks of the 2 least-significant bits (for IALIGN=32),
795-
and then jumps to the masked address.
796-
797-
=== Changed and new CSRs
787+
=== Changed CSRs
798788

799789
[source]
800790
----
801791
Number Name Description
802792
0x305 mtvec M-mode Trap-handler base address / interrupt mode
803-
(NEW) 0x307 mivt M-mode Interrupt-handler vector table base address
804-
(NEW) 0x308 meivt M-mode External Interrupt-handler vector table base address
805793
0x105 stvec S-mode Trap-handler base address / interrupt mode
806-
(NEW) 0x107 sivt S-mode Interrupt-handler vector table base address
807-
(NEW) 0x108 seivt S-mode External Interrupt-handler vector table base address
808794
----
809795

810-
==== New {xivt} and {xeivt} CSR
811-
812-
Two new base addresses for vector tables are introduced.
813-
One for internal interrupt (major and local interrupts),
814-
and one for external interrupts.
815-
816-
Both {xivt} and {xeivt} are WARL XLEN-bit CSRs,
817-
which hold the base address of the interrupt vector table.
818-
The address held in {xeivt} is aligned on a 64-byte or greater power-of-two boundary.
819-
Values other than 0 in the low 6 bits are reserved of {xeivt} are reserved.
820-
821-
NOTE: The actual alignment can be determined
822-
by writing ones to the low-order bits
823-
then reading them back.
824-
825-
NOTE: The resulting vector tables, especially for external interrupts,
826-
can consume non-negligible memory space.
827-
To limit the overall memory footprint,
828-
{xivt} or {xeivt} values at different privilege levels may be configured to the same values, respectively.
829-
830-
==== New {xtvec} CSR Mode
831-
832-
Interrupt vector table mode is encoded as a new state in the
833-
existing {xtvec} WARL register, where {xtvec}.`mode` (the two
834-
least-significant bits) is `11`.
835-
836-
==== Smivt Changes to {xtvec} CSR Mode
837-
838796
The PC upon interrupt is changed as follows:
839797

840798
[source]
841799
----
842800
mode PC on Interrupt
843801
00 OBASE # Direct mode
844-
01 OBASE+4*exccode # Vectored mode
845-
11 M[VTBASE+XLEN/8*vtoffset] & VTMASK # Interrupt vector table mode
802+
01 VECT # Vectored mode
803+
11 Reserved
846804
10 Reserved
847805
848806
where:
849807
M[a] = Contents of memory address at address "a"
850808
VTMASK = ~0x1 if IALIGN=16 or ~0x3 if IALIGN=32
851809
exccode = xcause.Exception Code
810+
vtoffset = Minor Interrupt Identity # Corresponds to ACLIC topi[25:16]
852811
853812
OBASE = xtvec[XLEN-1:2]<<2 # Vector base is at least 4-byte aligned
854-
if external interrupt:
855-
VTBASE = xeivt[XLEN-1:6]<<6 # External Interrupt Vector Table base is at least 64-byte aligned
856-
vtoffset = Minor Interrupt Identity
857-
# Corresponds to xtopei[26:16] with interrupt delivery from interrupt file or ACLIC
813+
if APLIC mode:
814+
VECT = M[OBASE+XLEN/8*vtoffset] & VTMASK
858815
else
859-
VTBASE = xivt[XLEN-1:2]<<2 # Interrupt Vector Table base is at least 4-byte aligned
860-
vtoffset = Major Interrupt Identity
816+
VECT = OBASE+4*exccode
861817
----
862818

863-
In interrupt vector table mode, when interrupts are taken, the interrupt behavior is modified as follows:
819+
If vectored mode is selected in {xtvec}, and APLIC mode is selected in {eidelivery}, when interrupts are taken, the interrupt behavior is modified as follows:
864820
After executing the required side-effects as required with the existing behavior,
865821
the hart then fetches an XLEN-bit handler address with permissions corresponding to the handler's mode
866-
from the in-memory table whose base address (VTBASE).
867-
The trap handler function address is fetched from `VTBASE+XLEN/8*exccode`.
822+
from the in-memory table whose base address (OBASE).
823+
The trap handler function address is fetched from `OBASE+XLEN/8*exccode`.
868824
If the fetch is successful, the hart clears the low bit(s) (depending on IALIGN) of the handler address,
869825
and sets the PC to this handler address.
870826
The masked vector table entry bit(s) are reserved and should be zero.
@@ -883,7 +839,7 @@ Memory writes to the vector table require an instruction barrier (_fence.i_) to
883839

884840
It is recommended that the second fetch be ignored for hardware triggers and breakpoints.
885841

886-
==== Vector table fault handling
842+
=== Vector table fault handling
887843

888844
Faults that occur during the fetch of interrupt vector table entries are only recoverable,
889845
if the double trap extension(s) are implemented.
@@ -910,7 +866,7 @@ side-affects of the trap may only be executed if they allow resuming of operatio
910866

911867
NOTE: Resuming after a fault on a vector table fetch is currently only seen as useful for instruction page faults.
912868

913-
==== State Enable
869+
=== State Enable
914870

915871
If the Smstateen extension is implemented,
916872
then the bit 53 (ACLIC) in mstateen0 is implemented.
@@ -924,6 +880,8 @@ when in VS or VU mode instead of an illegal instruction exception.
924880

925881
== Synchronous exceptions hardware vectoring- Smehv
926882

883+
NOTE: TBD
884+
927885
The Smehv extension depends upon the Smivt extension.
928886

929887
Accelerating synchronous exception handlers through vectoring may reduce interrupt latency.

0 commit comments

Comments
 (0)