Skip to content

Commit 7c30f5a

Browse files
Evgenii PaltsevEvgenii Paltsev
authored andcommitted
Implement ACLIC as a subset of APLIC interface
1 parent 87594d8 commit 7c30f5a

File tree

1 file changed

+60
-135
lines changed

1 file changed

+60
-135
lines changed

src/aclic.adoc

Lines changed: 60 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ Each row contains the dependencies of the extension named in the first column.
209209
| Sscsps | | x | | | |
210210
| Smtp | (x)| (x)| | | |
211211
| Smaiae | x | (x)| x | (x) | |
212-
| Smaclic | | | | | x |
213-
| Ssaclic | | | | | x |
212+
| Smaclic | | | | | |
213+
| Ssaclic | | | | | |
214214
| Smnip | | | | | x |
215215
| Ssnip | | | | | | x
216216
| Smehv | | | | | | x
@@ -243,186 +243,111 @@ so implementations can already choose to not support these.
243243

244244
== Advanced Core Local Interrupt Controller (Smaclic and Ssaclic)
245245

246-
The Smaclic and Ssaclic extensions depend on the Smaiae extension.
247-
248246
Of the main ACLIC goals, these targets are addressed here:
249247

250248
* Up to 1023 external interrupts
251249
* Low area overhead
252250
* Maximize compatibility with AIA
253251

254-
To achieve this, ACLIC builds upon the hart-level extensions of AIA,
255-
and the Advanced Platform Level Interrupt Controller (APLIC).
256-
The ACLIC is a tailored APLIC, optimized for resource efficiency, directly integrated with one hart.
257-
258-
In terms of compatibility, the goal is that a hart with Smaclic/Ssaclic extensions
259-
can be used at with the same trap handlers as one developed for AIA.
260-
261-
At config-time, the interface differs,
262-
but ACLIC uses the same structure for configuration as the APLIC.
263-
264-
=== New Interrupt Delivery Mode
265-
266-
The Incoming Message Signaled Interrupt Controller (IMSIC) contains the {eidelivery} CSR,
267-
which defines the interrupt delivery mode.
268-
A new delivery mode is defined:
269-
270-
[%autowidth,float="center",align="center",cols=">,<",grid=none,frame=none]
271-
|===
272-
|0 = | Interrupt delivery is disabled
273-
|1 = | Interrupt delivery from the interrupt file is enabled
274-
|0x20000000 = | Interrupt delivery from an ACLIC (new)
275-
|0x40000000 = | Interrupt delivery from a PLIC or APLIC is enabled
276-
|===
252+
To achieve this, ACLIC builds upon the Advanced Platform-Level Interrupt Controller (APLIC).
253+
The ACLIC is a tailored APLIC, optimized for resource efficiency and tightly integrated with a single hart. It utilizes APLIC direct delivery mode.
277254

278-
If Smaclic or Ssaclic extensions are present, reset initializes {eidelivery} to 0x20000000.
255+
=== Interface
279256

280-
When interrupts are delivered from an ACLIC, the following behavior is valid:
257+
ACLIC implements subset of AIA APLIC configuration and control interface defined by RISC-V AIA.
258+
ACLIC allows maximum of two domains for Machine and Supervisor modes respectively. Each domain may include:
281259

282-
The IMSIC registers {eithreshold}, {eipk} and {eiek} serve the same functionality as with {eidelivery} = 1.
260+
- 1 domain configuration register.
261+
- Up to 1023 source configuration registers.
262+
- 4 interrupt pending and enable control registers.
263+
- 4 interrupt delivery control registers.
283264

284-
The `eip` array and `eie` array act as an alias of the pending and enable bits of the connected APLIC domain.
265+
NOTE: Entire ACLIC interface is optimized for access by interrupt identity number (IID) to avoid unnecessary calculation of fields positions for the specific interrupt.
285266

286-
The {eithreshold} CSR is an alias of the {ithreshold}.
287-
For the interrupt enable and interrupt pending bits {eipk} and {eiek},
288-
a write with the value 1 performs a write access with the value 1 to the corresponding {setip} or {setie} register,
289-
while a write with the value 0 performs a write access with value 1 to the corresponding {in_clrip} or {clrie} register.
290-
On read of {eipk} or {eiek}, these CSRs are an alias of {setip}[_k_] and {setie}[_k_], respectively.
267+
==== Interrupt Domain Configuration (domaincfg)
291268

292-
For XLEN=32, {eipk} and {eiek} access {setip}[_k_]/{in_clrip}[_k_] and {setie}[_k_]/{clrie}[_k_], respectively.
293-
For XLEN=64, {eipk} and {eiek} only exist for even numbered indices of _k_. In this case,
294-
{eipk} and {eiek} access {setip}[_k_]/{in_clrip}[_k_] and {setie}[_k_]/{clrie}[_k_] in the lower half of the CSR,
295-
and {setip}[_k+1_]/{in_clrip}[_k_] and {setie}[_k+1_]/{clrie}[_k_] in the upper half of the CSR, respectively.
296-
297-
NOTE: Mirroring these APLIC registers at a core level has several advantages.
298-
* It removes unnecessary resource duplication between IMSIC and APLIC when integrated with a single hart.
299-
* It simplifies the address decoding logic within the interrupt controller by using CSR access over memory mapped ones.
300-
* It simplifies the handling of level-sensitive interrupts, avoiding additional checking of the pending flag in the APLIC in a handler of a level sensitive interrupt.
301-
* It provides a unified interface for all harts from a SW point of view, without the need to know a platform defined start address.
302-
* It simplifies the register interface, as CSR instructions have single bit operations
303-
304-
The {xtopei} registers work analogous to the IMSIC operation,
305-
but map to the current highest-priority pending-and-enabled interrupt of the connected APLIC domain.
306-
In this delivery mode, the {xtopei} CSR reflect both the interrupt identity and the interrupt priority.
307-
308-
[%autowidth,float="center",align="center",cols=">,<",grid=none,frame=none]
269+
[%autowidth]
309270
|===
310-
|bits 26:16| Interrupt identity
311-
|bits 10:0 | Interrupt priority (configured target[identity].iprio)
271+
| Field | Position | Access | Description
272+
| IE | 8 | RW | Domain wide interrupt-enable
273+
| DM | 3:2 | RW | Delivery Mode (fixed to `direct delivery`)
312274
|===
313275

314-
=== Indirect CSR access to APLIC registers
276+
Rest of the optional bits are implemented as read-only zeros.
315277

316-
The APLIC registers used in the ACLIC configuration can all be accessed by indirect CSRs,
317-
eliminating the overheads associated with a memory mapped device,
318-
and presenting a consistent SW interface for any hart.
278+
==== Interrupt Source Configuration (sourcecfgK)
319279

320-
To have full control over the necessary APLIC registers, the following indirect CSR access is added.
280+
Each implemented ACLIC interrupt has dedicated source configuration register which integrates all parameters dedicated to this interrupt.
321281

322-
==== Interrupt Priority (iprio)
282+
The register layout depends on value of delegation flag `D`, which is accessible in M-domain configuration and is
283+
always read-only zero in S-domain configuration (assuming S-domain has no children).
323284

324-
When XLEN = 32, each `xireg` register controls the ACLIC priority setting of four interrupts.
285+
sourcecfgK format, when interrupt source is delegated to a child domain:
325286

326287
[%autowidth]
327288
|===
328-
| `xiselect` | `xireg` size | `xireg` state
329-
| 0x1000 | 4B | `xacliciprio0`
330-
| ... | ... | ...
331-
| 0x1100 | 4B | `xacliciprio255`
289+
| Field | Position | Access | Description
290+
| D = 1 | 10 | RW | M-domain interrupt source delegation is enabled
291+
| Child Index = 0 | 9:0 | RO | Read-only zero (as M-domain has only one child)
332292
|===
333293

334-
Indirect access to `xacliciprio[k]` mirror `target[k*4].iprio` up to `target[k*4+3].iprio`.
335-
336-
When XLEN = 64, only the even-numbered registers exist and each register controls the priority setting of eight interrupts.
337-
Indirect access to `xacliciprio[k]` mirror `target[k*4].iprio` up to `target[k*4+7].iprio`.
338-
339-
==== Source Configuration (sourcecfg)
340-
341-
When accessing the source configuration via indirect CSR, only the lower 16b are accessible,
342-
as the rest of the register is reserved.
343-
344-
When XLEN = 32, the `xireg2` and `xireg3` registers combined control the source configuration of four interrupts.
294+
sourcecfgK format, when interrupt source is not delegated to a child domain:
345295

346296
[%autowidth]
347297
|===
348-
| `xiselect` | `xireg2/3` size | `xireg2` state | `xireg3` state
349-
| 0x1000 | 4B | `xaclicsourcecfg0` | `xaclicsourcecfg1`
350-
| ... | ... | ... | ...
351-
| 0x1100 | 4B | `xaclicsourcecfg510` | `xaclicsourcecfg511`
298+
| Field | Position | Access | Description
299+
| IE | 31 | RO | Read-only interrupt-enable
300+
| IP | 30 | RO | Read-only (rectified) interrupt-pending
301+
| IPRIO | 23:16 | RW | Interrupt priority
302+
| D = 0 | 10 | RW | M-domain interrupt source delegation, read-only zero in S-domain
303+
| SM | 2:0 | RW | Source mode
352304
|===
353305

354-
Indirect access to `xaclicsourcecfg[k]` mirrors `sourcecfg[k*2][15:0]` up to `sourcecfg[k*2+1][15:0]`.
355-
356-
When XLEN = 64, only the even-numbered registers exist and the `xireg2` and `xireg3` registers combined control the source configuration of eight interrupts.
357-
Indirect access to `xaclicsourcecfg[k]` mirrors `sourcecfg[k*4][15:0]` up to `sourcecfg[k*4+3][15:0]`.
306+
The IE and IP fields are specific to ACLIC (reserved in case of APLIC) and provide read-only view
307+
of the interrupt-pending and interrupt-enable bits replacing the pending and enable arrays used by APLIC.
358308

359-
=== APLIC configured for ACLIC operation
309+
To reduce registers addresses reservation the IPRIO field is moved from APLIC targetK[1..1023] registers.
360310

361-
The APLIC contains a per-domain configuration register,
362-
which, among other things, allows selecting the delivery mode.
363-
The `DM` field is extended to two bits,
364-
which allows encoding a new mode for ACLIC delivery.
311+
The effective value of the non-delegated source configuration in S-domain is read-only zero.
365312

366-
[%autowidth,float="center",align="center",cols=">,<",grid=none,frame=none]
367-
|===
368-
|0 = |direct delivery mode
369-
|1 =|MSI delivery mode
370-
|2 =|ACLIC delivery mode (new)
371-
|===
313+
==== Interrupt-Enable and Interrupt-Pending Control Registers
372314

373-
If Smaclic and/or Ssaclic are implemented,
374-
the reset value of the delivery mode for the respective domains shall be 'ACLIC delivery mode'.
315+
ACLIC implements subset of interrupt-pending and interrupt-enable APLIC control interface. In addition to set / clear bit by number there are read-only interrupt-pending and interrupt-enable bits mirrored in the sourcecfgK register.
375316

376-
The extended `domaincfg` register has this format:
377-
378-
[%autowidth,float="center",align="center",cols="<,<",grid=none,frame=none]
317+
[%autowidth]
379318
|===
380-
|bits 31:24 |read-only 0x80
381-
|bit 8|IE
382-
|bit 7|read-only 0
383-
|bits 3:2 |DM (*WARL*)
384-
|bit 0 |BE (*WARL*)
319+
| Offset | Register name | Access | Description
320+
| 0x1000 | setipnum | RW | Set interrupt-pending by number
321+
| 0x1001 | clripnum | RW | Clear interrupt-pending by number
322+
| 0x1002 | setienum | RW | Set interrupt-enable by number
323+
| 0x1003 | clrienum | RW | Clear interrupt-enable by number
385324
|===
386325

387-
All other register bits are reserved and read as zeros.
326+
NOTE: Interface is optimized for access by interrupt identity number (IID) to
327+
avoid unnecessary calculation of the bit positions. Hardware implementation is also
328+
simplified as there is no need to construct 32-bit pending/enable values based
329+
on per-interrupt delegation configuration.
330+
331+
==== Interrupt Delivery Control Registers
388332

389-
When in ACLIC delivery mode, the following, additional restrictions are applied:
333+
Similar to the APLIC in direct delivery mode, ACLIC provides the interrupt delivery control (IDC)
334+
registers structure to control the interrupt handling.
390335

391-
[%autowidth,float="center",align="center",cols="<,<",grid=none,frame=none]
336+
[%autowidth]
392337
|===
393-
|bits 31:24 |read-only 0x80
394-
|bit 8|IE = 1 (read-only)
395-
|bit 7|read-only 0
396-
|bits 3:2 |DM = 2
397-
|bit 0 |BE (*WARL*)
338+
| Offset | Register name | Access | Description
339+
| 0x1004 | idelivery | RW | External interrupt delivery enable
340+
| 0x1006 | ithreshold | RW | External interrupt threshold
341+
| 0x1007 | topi | RO | Top priority external interrupt information
342+
| 0x1008 | claimi | RW | Top priority external interrupt claim
398343
|===
399344

400-
Specifically, = `IE` bit is fixed to 1, as its functionality is subsumed by the {xstatus}.`xIE` bits at the hart.
401-
402-
If Smaclic and/or Ssaclic are implemented,
403-
the reset value of the delivery mode for the respective domains shall be 'ACLIC delivery mode'.
404-
In ACLIC-only systems, access to this register is not needed, and therefore no indirect CSR access is provided.
405-
406-
In the ACLIC delivery mode, there the following registers are not accessible and not used:
407-
408-
* As the ACLIC is not MSI capable, xmsiaddrcfg[h] and genmsi registers are not required.
409-
* Interrupt delivery control (IDC) structure is only needed in direct delivery mode, and not applicable to ACLIC delivery.
410-
* The indirect CSR access simplifies setting and clearing of individual bits in the pending and enable arrays.
411-
Therefore, the registers setipnum, clripnum, setienum, clrienum, setipnum_be, and setipnum_le are not used in the ACLIC configuration.
412-
* The target registers are not fully implemented.
413-
The iprio portion of it can be accessed as described in the section on indirect access.
414-
The rest is not required.
415-
416345
=== State Enable
417346

418-
Access to existing and repurposed AIA CSRs is already controlled by the state enables defined in Smaia/Ssaia.
419-
420-
Additional control is provided for the newly added registers `xacliciprio[k]` and `xaclicsourcecfg[k]`.
421-
422347
If the Smstateen extension is implemented,
423348
then the bit ?? in mstateen0 is implemented.
424349
If bit ?? of a controlling mstateen0 CSR is zero,
425-
then access to the new CSRs (`macliciprio[k]`, `maclicsourcecfg[k]`, `sacliciprio[k]`, `saclicsourcecfg[k]`) by S-mode or a lower privilege mode
350+
then access to the ACLIC CSRs by S-mode or a lower privilege mode
426351
results in an illegal instruction exception,
427352
except if the hypervisor extension is implemented,
428353
and the conditions for a virtual instruction exception apply,

0 commit comments

Comments
 (0)