HomeFreeBSD

riscv: Rework CPU identification (first part)

Description

riscv: Rework CPU identification (first part)

Make better use of the RISC-V identification CSRs: mvendorid, marchid,
and mimpid. This code was written before these registers were
well-specified, or even available to the kernel. It currently fails to
recognize any CPU or platform.

Per the privileged specification, mvendorid contains the JEDEC vendor ID,
or zero.

The marchid register denotes the CPU microarchitecture. This is either
one of the globally allocated open-source implementation IDs, or the
field has a custom encoding. Therefore, for known vendors (SiFive) we
can also maintain a list of known marchid values. If we can not give a
name to the CPU but marchid is non-zero, then just print its value in
the report.

The mimpid (implementation ID) could be used in the future to more
uniquely identify the micro-architecture, but it really remains to be
seen how it gets used. For now we just print its value.

Thank you to Danjel Qyteza <danq1222@gmail.com> who submitted an early
version of this change to me, although it has been almost entirely
rewritten.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39809

(cherry picked from commit 88b4d124efc5a2d45660551fe0750acc0be6d3cd)

Details

Provenance
mhorneAuthored on May 22 2023, 11:48 PM
Differential Revision
D39809: riscv: rework CPU identification [1/6]
Parents
rGc10e56732217: lib/csu: do not compile the body of handle_static_init() for PIC build at all
Branches
Unknown
Tags
Unknown