[PATCH 0/9] T-Head: Allow read access to th.mxstatus CSR
Christoph Müllner
christoph.muellner at vrull.eu
Wed Mar 27 03:11:28 PDT 2024
On T-Head C9xx harts, the th.mxstatus CSR provides valuable information
about the available vendor extensions. As this CSR is only accessible in
M-mode, we need to provide a mechanism for other modes to access this
information. This patchset solves this by extending the existing
platform abstraction such that platforms (or platform overrides)
can provide a CSR read/write handler.
A CSR read-handler for th.mxstatus is then added that is utilized by
the Allwinner D1, the T-Head TH1520, and the Sophgo SG2042.
Further, a generic mvendorid-based platform override is added that also
enables the CSR read-handler for th.mxstatus (needed for QEMU).
The CSR is documented here:
https://github.com/T-head-Semi/thead-extension-spec/pull/45
For QEMU this patch depends on
https://lists.gnu.org/archive/html/qemu-devel/2024-03/msg06368.html
Christoph Müllner (9):
sbi_platform: Add mechanism to handle CSR reads/writes in platform
platform: generic: Add mechanism to handle CSR reads/writes in
overrides
lib: sbi_emulate_csr: Utilize platform hooks for unknown CSRs
platform: generic: thead: Add CSR read handler for T-Head C9xx
{allwinner/sun20i-d1,sophgo/sg2042,thead-generic}: Enable T-Head CSR
read access
platform: thead: Rename thead-generic to thead-th1520
platform: generic: Add mechanism to match via mvendorid
platform: generic: thead: Add definition of T-Head's vendor ID
platform: generic: Add generic T-Head override
include/sbi/sbi_platform.h | 48 +++++++++++++++
lib/sbi/sbi_emulate_csr.c | 8 ++-
platform/generic/Kconfig | 12 +++-
platform/generic/allwinner/sun20i-d1.c | 2 +
platform/generic/configs/defconfig | 3 +-
platform/generic/include/platform_override.h | 5 ++
platform/generic/include/thead/c9xx_csr.h | 16 +++++
.../generic/include/thead/c9xx_encoding.h | 2 +
platform/generic/platform.c | 58 ++++++++++++++++++-
platform/generic/sophgo/sg2042.c | 2 +
platform/generic/thead/Kconfig | 4 ++
platform/generic/thead/objects.mk | 9 ++-
platform/generic/thead/thead-generic.c | 42 +++-----------
platform/generic/thead/thead-th1520.c | 55 ++++++++++++++++++
platform/generic/thead/thead_c9xx_csr.c | 30 ++++++++++
15 files changed, 252 insertions(+), 44 deletions(-)
create mode 100644 platform/generic/include/thead/c9xx_csr.h
create mode 100644 platform/generic/thead/thead-th1520.c
create mode 100644 platform/generic/thead/thead_c9xx_csr.c
--
2.44.0
More information about the opensbi
mailing list