Re: [Proposal] Introduction to the Spec


On Tue, 2020-10-06 at 17:32 -0600, Al Stone wrote:
What follows is a proposed introduction to the platform spec. I have
tried to tie together all the threads of conversations and
that have been floating about around several topics -- profiles and
platforms and interfaces, for instance -- and mold them into some
of framework to be used in developing the content for the rest of the
spec. This is the result.

Paring it down to a bare minimum, this introduction defines what we
mean by 'profile' (a defined set of interfaces) and how we can in
use a profile to define the requirements for a platform.

The next steps would be to first come to an agreement on a Linux (or
rich OS) profile, and the interfaces required. After that, we would
need to go through those interfaces to be sure we are clear on what
we need, and we know what is yet to do. And then, voila! We have a
draft spec :).

This is currently in asciidoc format. It can be easier to read in
HTML and can be converted pretty easily with asciidoctor:

$ asciidoctor -d book -b html introduction.adoc

Signed-off-by: Al Stone <ahs3@...>


// SPDX-License-Identifier: CC-BY-4.0
// introduction.adoc: provide an introduction to the document
// Provide a basic introduction to the overall document, defining
// key terms and usages.

# Introduction

This document is the RISC-V Platform Specification (RVPS).

This specification defines the hardware and firmware required to be
to install and use one or more operating systems (OSs) on a platform
built around the RISC-V Instruction Set Architecture (ISA). The
is to capture the constraints necessary for a hardware platform so
an operating system can be assured it is compatible with that
if the platform is in compliance with this specification.

Constraints on the hardware and firmware comprising part of a
are key to this specification. For an OS to work correctly, it needs
be able to make some basic assumptions about the platform in order to
if there are too many variations possible, it becomes unmanageable
for the
OS vendor and could preclude using the platform at all. We would
like to
ensure this does not happen.

This specification also sets out any necessary constraints on the
Instruction Set Architecture (ISA) -- at all privilege levels -- that
required to provide a consistent and predictable environment for
operating systems.

The intent is to provide only the constraints necessary, and not to

## Platforms
The term _platform_ has already been used several times. The
used here is that a platform is the sum total of the hardware,
and software comprising a usable computer system. Examples include
smartphones, laptops, data center servers, single-board computers,
and almost anything in between. While this is not terribly precise,
is intentional; this specification is not meant to constrain what a
platform is, but to clarify what software can expect of it.

## Profiles
The term _profile_ is frequently used in the RISC-V world. For the
of this specification, we use a reasonably precise definition of the
and how it is to be used. We do this since the specification itself
down requirements on the basis of what a profile needs.

Consider a platform as being built up by connecting together a number
different interfaces -- the interfaces between hardware and firmware,
firmware and software, or software and the end-user.

What we would like to do is define just the interfaces between the
that constitute a platform. This allows the implementations to be
they need to be, as long as they abide by the interface
definition. For
example, we may need a UEFI interface. Whether that is implemented
EDK2 source, or is an interface to linuxboot is irrelevant. The
defined by the interface is the important part.

Of particular interest in this specification are:

* The User Interface: how the end-user of a system interacts with it.
Examples might be various Linux-, BSD- or Windows based systems;
might also include a specific application developed for a specific

* The Firmware Interface: how the User Interface makes use of S-
mode. For
example, UEFI Runtime Services, or ACPI -- the former a list of the
services needed in order to allow the User Interface to work
and the latter a means to identify hardware that cannot identify
I am not sure how to represent this without ambiguity.
There will be two kinds of firmware interfaces. UEFI/ACPI that will use
SBI internally for some of the runtime services (Not All). S-mdoe OS
will still need SBI interface to interact with M-Mode in additio to

Non-UEFI/ACPI will completely rely on SBI.

How are going encode both these information via profile ?

* The Hardware Interface: what the User and Firmware Interfaces can
expect to
be present; in a way this is the interface to the outside world,
but most
likely it would be a list of the hardware components that are
to be present, and what standards they comply with.

* The Processor Interface: this interface defines what to expect of
processor. In the case of RISC-V this would include the parts of
the ISA
that and are not implemented.

* The Boot Interface: this is what one would see at a cold start of
system -- for the most part these days, this includes U-Boot or
though it could just as easily be linuxboot or coreboot. This
would also
define some of the functionality needed to boot the system, update
firmware and possibly manage the system remotely.
Are we going to add different boot interface provided by other boot
loaders here as well ? Such as booti/bootm from U-Boot,
coreboot/linuxboot ?

For each of the interfaces listed above, there is a domain of
Let us look at each domain of interfaces as an element in an n-tuple
as follows:

N = { user, firmware, hardware, processor, boot }

Not all of the permutations of this set make sense. Not all of them
necessarily useful. However, it does allow us to provide a more
definition of a profile -- a _profile_ is a value in **_N_**, a
if you will.

### An Example Profile
The test of any formalism is whether or not it is usable. So, let’s
a general purpose Linux platform that could be used to run one of the
Linux distributions such as RHEL, Fedora, SuSE, Debian, ArchLinux or
even Gentoo and Slackware. The profile might be:

LinuxDistro = { Linux, UEFI, general, RV64GC, UEFI }

This is just an example of what _could_ be; it is not definitive. A
profile for Linux distributions will be provided later in this
Regardless, this could tell us:

* The User Interface is a Linux system of some flavor.
* The Firmware Interface is UEFI and ACPI, built upon SBI, so we now
know how
to enumerate the physical devices in Linux
* The Hardware Interface is for general purpose computing -- defining
this is
where we would have to list what devices that implies.
* The Processor Interface is RV64GC (U-mode, and S-mode)
* The Boot Interface is UEFI and possibly the UEFI Shell.

And, as long as the interface definitions are fairly clear, we can
determine what would be in a platform that supports the
profile. It is the purview of this platform specification to (a)
the profiles of interest, and then (b) ensure that each of the terms
in the n-tuple -- the interfaces -- are clearly defined.

### Other Distros
While the definition of a ```LinuxDistro``` profile used above would
to preclude non-Linux operating systems, defining a profile as a
tuple gives
us a way of handling this. For example, let’s suppose we define
for Windows and most BSD-based systems:

WindowsDistro = { Windows, UEFI, general, RV64GC, UEFI }

BSDDistro = { BSD, UEFI, general, RV64G, UEFI }

Again, these are only examples, and not definitive. Given what we
about these sorts of systems, we could assert the following:

LinuxDistro = WindowsDistro = BSDDistro

That is, all of these are essentially identical in the things that
to this specification. We know that’s not exactly true, of course,
but this
does give us the tool to start reasoning about such things.

### Notation
Whilst set notation is all well and good, we need something a bit
practical. For that, we can borrow from the example provided by GCC.
A profile tuple would then be:

N = user-firmware-hardware-processor-boot

Or, for the example profiles listed above:

linux-distro = linux-uefi-general-rv64gc-uefi
windows-distro = windows-uefi-general-rv64gc-uefi
bsd-distro = bsd-uefi-general-rv64gc-uefi

For the long term, these could be converted into values and captured
firmware to be relayed to the OS, perhaps as a byte for each element
the tuple (how this is to happen is TBD). In this manner, the
would describe itself, instead of the OS having to make an educated
How about encoding this tuple in a DT ? The boot loader/firmware are
parsing DT anyways. It can parse the tuple and know exactly which boot
interface to be used ?

In case of desired boot interface is not available, it will fallback to
the default method or a shell.

### Revisions
Over time, the definitions of the elements in this profile-tuple will
change. It’s simply the nature of the problem -- new hardware will
defined, and ultimately will be assumed to be present, or old
will get deprecated (e.g., CXL, and perhaps some day UARTs,
Hence, we will need to be able to note the revision of an element
for a profile definition to be complete. Again, we could have the
convey this information to the OS as an additional byte string (how
is TBD).
For practical use, we may wish to append the revisions to the tuple

N = user-firmware-hardware-processor-boot:ur-fr-hr-pr-br

Or, for the example profiles listed above:

linux-distro = linux-uefi-general-rv64g-uefi:0-0-0-0
windows-distro = windows-uefi-general-rv64g-uefi:0-3-5-5
bsd-distro = bsd-uefi-general-rv64g-uefi:1-0-3-4
Should the firmware need to verify the UEFI version supported with
implemented? I think yes and it can done easily with DT parsing.

### Some Notes
* Profiles are _only_ a property of platforms, _not_ harts.
* This section uses example profiles; these are not intended to be
Proper profile definitions will appear in following sections of the
* This section presents the current definition of a platform-
tuple. This
may change as we know more.

Join to automatically receive all group messages.