Re: [PATCH V3 1/2] riscv-platform-spec: PLIC and CLINT for Linux-2022 platform

Alistair Francis

On Fri, 2021-05-07 at 09:25 -0700, Greg Favor wrote:
I notice many uses of the word "recommend".  My understanding is that
there should be no recommendations in the platform spec - just
requirements.  (To be more precise, I believe the Platforms Policy
doc puts non-normative content in separate chapters.)
Why are we removing recommendations?

For the embedded spec we don't want to force vendors to meet certain
requirements if they have a good reason not to. For example if they
share IP or memory maps across different product lines we want to allow
that. As that will make it easier for them and their customers to
transition to RISC-V.

On the other hand if vendors are picking addresses or IP we want to
encourage them to use a standard. Hence the recommendations.



On Fri, May 7, 2021 at 9:01 AM Abner Chang <renba.chang@...>
From: Abner Chang <renba.chang@...>

Initial description of PLIC  CLINT section of Linux-2022 platform.

Is this what we want to see of CLINT/Machine mode timer in the
platform spec?

On v3 commit,
- Address review comments.

On v2 commit,
- CLINT is not deprecated.

- Add a standalone section for Machine Mode Timer in System
  Do you think this is a good place for Machine Mode Timer?
  @Mayuresh, please check if you are ok with this change, not sure
  overlaps with your text or not (The timer setion). I can remove
  if you prefer to put this with your patch.

- In Embedded-2022, refer to Machine Mode Timer in System
  section and CLINT in Linux-2022 Platform.
  @Alistair, is this ok?

On v1 commit,
- Not sure where to put the [DEPRECATED].
- Change the reference of PLIC in section 2.2.2. Interrupt
to PLIC + CLINT section.

Signed-off-by: Abner Chang <renba.chang@...>
Cc: Alistair Francis <alistair.francis@...>
Cc: Sunil V L <sunilvl@...>
Cc: Mayuresh Chitale <mchitale@...>
 riscv-platform-spec.adoc | 88 +++++++++++++++++++++++-------------
 1 file changed, 50 insertions(+), 38 deletions(-)

diff --git a/riscv-platform-spec.adoc b/riscv-platform-spec.adoc
index 160c74a..91c2abb 100644
--- a/riscv-platform-spec.adoc
+++ b/riscv-platform-spec.adoc
@@ -49,14 +49,56 @@ include::profiles.adoc[]
 * Start Address

 ==== Interrupt Controller
-* AIA
-* Interrupt Assignments
+===== AIA
+The Platform Level Interrupt Controller (PLIC) provides facilities
to route
+the non-local interrupts to the external interrupt of a hart
+with a given privilege mode in a given hart. The number of non-
+sources supported by PLIC and how does each of them connect to the
+context is PLIC core implementation-specific. +
+(Refer to[RISC-V
PLIC Specification]
+for the implementation reference of PLIC operation parameters)
+===== CLINT[[CLINT]]
+On the contrast to PLIC, the Core Local Interrupt (CLINT) provides
+facilities to trigger local interrupt of
mode timer>>
+to hart.
+===== Interrupt Assignments

 ==== System Peripherals
 * UART/Serial Console
 * Clocks
 * Timers
+===== Machine Mode Timer[[MachineModeTimer]]
+Machine mode timer is required for Linux-2022 platform and
incorporate with
+CLINT for the local interrupt to hart. The format of the operation
+(`mtime` and `mtimecmp` registers) must compliant with RISC-V
+specification section 3.1.10. The base address of the memory map
+of Machine mode timer is platform implementation-specific, however
the offset
+of `mtime` and `mtimecmp` registers are fixed as below,
+.Registers layout of mtimecmp
+|*Offset*|*Register (8-byte) for RV64*|*Register (4-byte) for
+|`0x4000` |mtimecmp for hart 0 |mtimecmp low for hart 0
+|`0x4004` ||mtimecmp high for hart 0
+|`0x4008` |mtimecmp for hart 1 |mtimecmp low for hart 1
+|`0x400c` ||mtimecmp high for hart 1
+|... ||
+|`0xbff0` |mtimecmp for hart 4094|mtimecmp low for hart 4094
+|`0xbff4` ||mtimecmp high for hart 4094
+.Registers layout of mtime
+|*Offset*|*Register (8-byte) for RV64*|*Register (4-byte) for
+|`0xbff8` |mtime|mtime low
+|`0xbffc` ||mtime high
 * Watchdog Timers

 ==== Boot Process
@@ -289,9 +331,8 @@ Any RISC-V system that uses at least RV32/64G
meet the Embedded-2022

 ==== Interrupt Controller
-Embedded systems are recommended to use a spec compliant
-[PLIC], a spec compliant
+Embedded systems are recommended to use a spec compliant
<<PLIC,PLIC>>, a spec
 or both a CLIC and and PLIC.

 If using just a PLIC the system must continue to use the original
@@ -303,38 +344,9 @@ must be supported.
 Embedded systems cannot use a non-compliant interrupt controller
 call it a PLIC or CLIC.

-==== Machine Timer
-The RISC-V machine timer (controlled via `mtime` and `mtimecmp`)
must be
-implemented. The two registers must be memory mapped as required
the RISC-V
-The Embedded-2022 specification requires that the registers be
-adjacent to each other with the `mtime` region at the lower
-The starting address of this region can be located anywhere in
-memory, including inside other peripherals, as long as the start
address is
-4 byte aligned.
-An example of the memory layout for a 32-bit system with a single
hart is below
-| 0x00 |  mtime low     |
-| 0x04 |  mtime high    |
-| 0x08 |  mtimecmp low  |
-| 0x0C |  mtimecmp high |
-and for a 64-bit system with 2 harts
-| 0x00 |  mtime           |
-| 0x08 |  mtimecmp hart 1 |
-| 0x10 |  mtimecmp hart 2 |
+==== Machine Mode Timer
+The Embedded-2022 specification requires RISC-V
<<MachineModeTimer,Machine mode timer>>
+to be implemented and incorporated with the Core Local Interrupt

 ==== Memory Map
 It is recommended that main memory and loadable code (not ROM)

Join to automatically receive all group messages.