• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include <cpuinfo.h>
4 #include <cpuinfo/common.h>
5 
6 /**
7  * Definition of a RISC-V Linux processor. It is composed of the base processor
8  * definition in "include/cpuinfo.h" and flags specific to RISC-V Linux
9  * implementations.
10  */
11 struct cpuinfo_riscv_linux_processor {
12 	/* Public ABI cpuinfo structures. */
13 	struct cpuinfo_processor processor;
14 	struct cpuinfo_core core;
15 	struct cpuinfo_cluster cluster;
16 	struct cpuinfo_package package;
17 
18 	/**
19 	 * Linux-specific flags for the logical processor:
20 	 * - Bit field that can be masked with CPUINFO_LINUX_FLAG_*.
21 	 */
22 	uint32_t flags;
23 
24 	/**
25 	 * Minimum processor ID on the cluster which includes this logical
26 	 * processor. This value can serve as an ID for the cluster of logical
27 	 * processors: it is the same for all logical processors on the same
28 	 * package.
29 	 */
30 	uint32_t cluster_leader_id;
31 
32 	/**
33 	 * Minimum processor ID on the core which includes this logical
34 	 * processor. This value can serve as an ID for the core of logical
35 	 * processors: it is the same for all logical processors on the same
36 	 * core.
37 	 */
38 	uint32_t core_leader_id;
39 
40 	/**
41 	 * Minimum processor ID on the package which includes this logical
42 	 * processor. This value can serve as an ID for the package of logical
43 	 * processors: it is the same for all logical processors on the same
44 	 * package.
45 	 */
46 	uint32_t package_leader_id;
47 };
48 
49 /**
50  * Reads AT_HWCAP from `getauxval` and populates the cpuinfo_riscv_isa
51  * structure.
52  *
53  * @param[isa] - Reference to cpuinfo_riscv_isa structure to populate.
54  */
55 CPUINFO_INTERNAL void cpuinfo_riscv_linux_decode_isa_from_hwcap(struct cpuinfo_riscv_isa isa[restrict static 1]);
56 
57 /**
58  * Reads `sys_riscv_hwprobe` and determines the processor vendor and
59  * micro-architecture.
60  *
61  * @param[processor] - The Linux ID of the target processor.
62  * @param[vendor] - Reference to the cpuinfo_vendor to populate.
63  * @param[uarch] - Reference to the cpuinfo_uarch to populate.
64  */
65 CPUINFO_INTERNAL void cpuinfo_riscv_linux_decode_vendor_uarch_from_hwprobe(
66 	uint32_t processor,
67 	enum cpuinfo_vendor vendor[restrict static 1],
68 	enum cpuinfo_uarch uarch[restrict static 1]);
69 
70 /* Used to determine which uarch is associated with the current thread. */
71 extern CPUINFO_INTERNAL const uint32_t* cpuinfo_linux_cpu_to_uarch_index_map;
72