[PATCH v3] Base boot and runtime requirements - initial commit

Rahul Pathak

Initial changes for the Base Boot & Runtime requirements.
The sections which are currently in-progress are marked as TBD.
These changes can serve as the starting point and more details/changes
can be done tailored for RISC-V.

Updated the section "Storage and Partition" along with details on
SBI Extensions in Runtime Section.

There is an patch to add RISC-V details in the EBBR spec sent by Atish.
That patch is not yet merged in the EBBR. The section on the
"Startup Protocol" in this spec will refer to the requirements there
and currently that link is marked as TBD.

Signed-off-by: Rahul Pathak <rpathak@...>
riscv-platform-spec.adoc | 134 +++++++++++++++++++++++++++++++++++++--
1 file changed, 127 insertions(+), 7 deletions(-)

diff --git a/riscv-platform-spec.adoc b/riscv-platform-spec.adoc
index 160c74a..dccb1a4 100644
--- a/riscv-platform-spec.adoc
+++ b/riscv-platform-spec.adoc
@@ -34,6 +34,36 @@ include::profiles.adoc[]
// Linux-2022 Platform
== Linux-2022 Platform

+=== Terminology
+[cols="1,2", width=80%, align="left", options="header"]
+|SBI | Supervisor Binary Interface
+|UEFI | Unified Extensible Firmware Interface
+|ACPI | Advanced Configuration and Power Interface
+|SMBIOS | System Management Basic I/O System
+|DTS | Devicetree source file
+|DTB | Devicetree binary
+|RVA22 | RISC-V Application 2022
+|EE | Execution Environment
+|RV32GC | RISC-V 32-bit general purpose ISA described as RV32IMAFDC.
+|RV64GC | RISC-V 64-bit general purpose ISA described as RV64IMAFDC.
+=== Specifications
+[cols="1,2", width=80%, align="left", options="header"]
+|link:https://uefi.org/sites/default/files/resources/UEFI_Spec_2_9_2021_03_18.pdf[UEFI Specification] | v2.9
+|link:https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.3[Devicetree Specification] | v0.3
+|link:https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc[SBI Specification] | v0.3-rc0
+|link:[RVA22 Specification] | TBD
+|link:https://arm-software.github.io/ebbr/[EBBR Specification] | v2.0.0-pre1
+|link:https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf[ACPI Specification] | v6.4
+|link:https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.4.0.pdf[SMBIOS Specification] | v3.4.0
+|link:[Platform Policy] | TBD
// Base feature set for Linux-2022 Platform
=== Base
==== Architecture
@@ -59,14 +89,104 @@ include::profiles.adoc[]
* Timers
* Watchdog Timers

-==== Boot Process
-* Firmware
-* Boot-Loader
-* Discovery Mechanisms
+==== Boot and Runtime Requirements
+- The base specification defines the interface between the firmware and the
+operating system suitable for the RISC-V platforms with rich operating
+- These requirements specifies the required boot and runtime services, device
+discovery mechanism, etc.
+- The requirements are operating system agnostic, specific firmware/bootloader
+implementation agnostic.
+- Any RV32GC or RV64GC platform seeking compliance with the base specification
+require to implement all three privilege modes i.e. M, S and U mode.
+- For the generic mandatory requirements this base specification will refer to
+the EBBR Specification. Any deviation from the EBBR will be explicitly
+mentioned in the requirements.
+- Specifications followed are mentioned in the
+<<Specifications,Specification Section>>
+===== Firmware
+- UEFI Platform is required to adhere to RISC-V Platform requirements on
+calling conventions, ABI support specific to RISC-V. Refer Chapter - 2.3.7
+RISC-V Platforms of UEFI specification.
+- For compliance with base specification platform is required to implement
+link:https://arm-software.github.io/ebbr/#required-elements[EBBR - UEFI Required Elements],
+link:https://arm-software.github.io/ebbr/#required-platform-specific-elements[EBBR - UEFI Platform Specific Elements]
+and following
+link:https://arm-software.github.io/ebbr/#required-global-variables[EBBR - Global Variables].
+====== Storage and Partitioning
+- Firmware is required to implement requirements as per the
+link:https://arm-software.github.io/ebbr/#firmware-storage[EBBR Firmware Storage].
+- For shared storage base spec requires GPT partitioning, MBR is deprecated.
+===== Boot Services
+- All functions defined as boot services are required. Methods for
+unsupported or unimplemented behavior must return an appropriate error
+====== Startup Protocol
+- UEFI firmware could be executed in either Machine mode or Supervisor mode
+during the entire POST, according to the hart capability and the platform
+design. For detailed requirements on startup protocol refer link:[**TBD** - EBBR LINK FOR STARTUP PROTOCOL]
+and UEFI chapter 2.3.7 RISC-V Platforms.
+====== Memory Map
+- Base specification requires UEFI environment to provide a system memory map
+as per the requirements link:https://arm-software.github.io/ebbr/#memory-map[EBBR - Memory Map].
+===== Discovery Mechanisms
+- Devicetree is the required mechanism for system description.
+- System is required to implement link:https://arm-software.github.io/ebbr/#devicetree[EBBR - Devicetree requirements]
+to comply with this base specification. Also refer Devicetree tables section in
+chapter - 4.6 EFI Configuration Table & Properties Table of UEFI specification.
+===== Runtime Services
+====== SBI

-==== Runtime services
-* SBI
+- Required SBI spec version is 3.0 or higher.
+- Legacy Extensions from the SBI Specification are deprecated.
+- Required SBI extensions -
+[cols="1,2", width=80%, align="left", options="header"]
+|SBI TIME | if **stimecmp** CSR not available
+- Required responsibilities of M-Mode runtime also includes -
+ ** Interrupt and Exception Delegation
+ ** Misaligned Load & Stores handling
+ ** Missing CSRs emulation
+ ** PMP Configuration
+- Wherever applicable firmware must implement UEFI interfaces over similar
+interfaces and services present in the SBI specification. For example, UEFI
+runtime services must implement ResetSystem() via SBI Reset extension.
+====== UEFI
+- Firmware must conform to the
+link:https://arm-software.github.io/ebbr/#uefi-runtime-services[EBBR - UEFI EFI_RUNTIME_SERVICES requirements].
+- Firmware must meet the requirements for
+link:https://arm-software.github.io/ebbr/#runtime-device-mappings[EBBR - Runtime Device Mappings]
+to avoid conflict between the firmware and OS when accessing the mapped
+- Compliant UEFI runtime environment must meet the requirements for the
+link:https://arm-software.github.io/ebbr/#runtime-variable-access[EBBR - Runtime Variable Access].
+- Compliant implementation must meet the Realtime Clock requirements
+link:https://arm-software.github.io/ebbr/#real-time-clock-rtc[EBBR - UEFI RTC interface]
+if RTC is present in the system.
+- OS should prioritize calling the UEFI interfaces before the SBI or Platform
+specific mechanisms.

// Server extension for Linux-2022 Platform
=== Server Extension