Skip to content

Commit c897499

Browse files
Evgenii PaltsevEvgenii Paltsev
authored andcommitted
Major & external interrupts unification
1 parent 161c0a8 commit c897499

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.
@@ -783,89 +783,45 @@ and the conditions for a virtual instruction exception apply,
783783
in which case a virtual instruction exception is raised
784784
when in VS or VU mode instead of an illegal instruction exception.
785785

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

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

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

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

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

864-
In interrupt vector table mode, when interrupts are taken, the interrupt behavior is modified as follows:
820+
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:
865821
After executing the required side-effects as required with the existing behavior,
866822
the hart then fetches an XLEN-bit handler address with permissions corresponding to the handler's mode
867-
from the in-memory table whose base address (VTBASE).
868-
The trap handler function address is fetched from `VTBASE+XLEN/8*exccode`.
823+
from the in-memory table whose base address (OBASE).
824+
The trap handler function address is fetched from `OBASE+XLEN/8*exccode`.
869825
If the fetch is successful, the hart clears the low bit(s) (depending on IALIGN) of the handler address,
870826
and sets the PC to this handler address.
871827
The masked vector table entry bit(s) are reserved and should be zero.
@@ -884,7 +840,7 @@ Memory writes to the vector table require an instruction barrier (_fence.i_) to
884840

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

887-
==== Vector table fault handling
843+
=== Vector table fault handling
888844

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

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

914-
==== State Enable
870+
=== State Enable
915871

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

926882
== Synchronous exceptions hardware vectoring- Smehv
927883

884+
NOTE: TBD
885+
928886
The Smehv extension depends upon the Smivt extension.
929887

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

0 commit comments

Comments
 (0)