arch/riscv/include/asm/sbi.h
Source file repositories/reference/linux-study-clean/arch/riscv/include/asm/sbi.h
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/include/asm/sbi.h- Extension
.h- Size
- 21334 bytes
- Lines
- 708
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/cpumask.hlinux/jump_label.h
Detected Declarations
struct riscv_pmu_snapshot_datastruct riscv_pmu_event_infostruct sbi_sta_structstruct sbi_dbtr_data_msgstruct sbi_dbtr_id_msgstruct sbiretenum sbi_ext_idenum sbi_ext_base_fidenum sbi_ext_time_fidenum sbi_ext_ipi_fidenum sbi_ext_rfence_fidenum sbi_ext_hsm_fidenum sbi_hsm_hart_stateenum sbi_ext_srst_fidenum sbi_srst_reset_typeenum sbi_srst_reset_reasonenum sbi_ext_susp_fidenum sbi_ext_susp_sleep_typeenum sbi_ext_pmu_fidenum sbi_pmu_hw_generic_events_tenum sbi_pmu_fw_generic_events_tenum sbi_pmu_event_typeenum sbi_pmu_ctr_typeenum sbi_ext_dbcn_fidenum sbi_ext_sta_fidenum sbi_ext_nacl_fidenum sbi_ext_nacl_featureenum sbi_fwft_feature_tenum sbi_ext_mpxy_fidenum sbi_mpxy_attribute_idenum sbi_mpxy_msgproto_idenum sbi_mpxy_rpmi_attribute_idenum sbi_ext_dbtr_fidfunction sbi_console_putcharfunction sbi_fwft_set_online_cpusfunction sbi_spec_is_0_1function sbi_major_versionfunction sbi_minor_versionfunction sbi_mk_versionfunction sbi_err_map_linux_errnofunction sbi_remote_fence_ifunction sbi_initfunction riscv_use_sbi_for_rfencefunction sbi_ipi_init
Annotated Snippet
struct riscv_pmu_snapshot_data {
u64 ctr_overflow_mask;
u64 ctr_values[64];
u64 reserved[447];
};
struct riscv_pmu_event_info {
u32 event_idx;
u32 output;
u64 event_data;
};
#define RISCV_PMU_EVENT_INFO_OUTPUT_MASK 0x01
#define RISCV_PMU_RAW_EVENT_MASK GENMASK_ULL(47, 0)
#define RISCV_PMU_PLAT_FW_EVENT_MASK GENMASK_ULL(61, 0)
/* SBI v3.0 allows extended hpmeventX width value */
#define RISCV_PMU_RAW_EVENT_V2_MASK GENMASK_ULL(55, 0)
#define RISCV_PMU_RAW_EVENT_IDX 0x20000
#define RISCV_PMU_RAW_EVENT_V2_IDX 0x30000
#define RISCV_PLAT_FW_EVENT 0xFFFF
/** General pmu event codes specified in SBI PMU extension */
enum sbi_pmu_hw_generic_events_t {
SBI_PMU_HW_NO_EVENT = 0,
SBI_PMU_HW_CPU_CYCLES = 1,
SBI_PMU_HW_INSTRUCTIONS = 2,
SBI_PMU_HW_CACHE_REFERENCES = 3,
SBI_PMU_HW_CACHE_MISSES = 4,
SBI_PMU_HW_BRANCH_INSTRUCTIONS = 5,
SBI_PMU_HW_BRANCH_MISSES = 6,
SBI_PMU_HW_BUS_CYCLES = 7,
SBI_PMU_HW_STALLED_CYCLES_FRONTEND = 8,
SBI_PMU_HW_STALLED_CYCLES_BACKEND = 9,
SBI_PMU_HW_REF_CPU_CYCLES = 10,
SBI_PMU_HW_GENERAL_MAX,
};
/**
* Special "firmware" events provided by the firmware, even if the hardware
* does not support performance events. These events are encoded as a raw
* event type in Linux kernel perf framework.
*/
enum sbi_pmu_fw_generic_events_t {
SBI_PMU_FW_MISALIGNED_LOAD = 0,
SBI_PMU_FW_MISALIGNED_STORE = 1,
SBI_PMU_FW_ACCESS_LOAD = 2,
SBI_PMU_FW_ACCESS_STORE = 3,
SBI_PMU_FW_ILLEGAL_INSN = 4,
SBI_PMU_FW_SET_TIMER = 5,
SBI_PMU_FW_IPI_SENT = 6,
SBI_PMU_FW_IPI_RCVD = 7,
SBI_PMU_FW_FENCE_I_SENT = 8,
SBI_PMU_FW_FENCE_I_RCVD = 9,
SBI_PMU_FW_SFENCE_VMA_SENT = 10,
SBI_PMU_FW_SFENCE_VMA_RCVD = 11,
SBI_PMU_FW_SFENCE_VMA_ASID_SENT = 12,
SBI_PMU_FW_SFENCE_VMA_ASID_RCVD = 13,
SBI_PMU_FW_HFENCE_GVMA_SENT = 14,
SBI_PMU_FW_HFENCE_GVMA_RCVD = 15,
SBI_PMU_FW_HFENCE_GVMA_VMID_SENT = 16,
SBI_PMU_FW_HFENCE_GVMA_VMID_RCVD = 17,
SBI_PMU_FW_HFENCE_VVMA_SENT = 18,
SBI_PMU_FW_HFENCE_VVMA_RCVD = 19,
SBI_PMU_FW_HFENCE_VVMA_ASID_SENT = 20,
SBI_PMU_FW_HFENCE_VVMA_ASID_RCVD = 21,
SBI_PMU_FW_MAX,
};
/* SBI PMU event types */
enum sbi_pmu_event_type {
SBI_PMU_EVENT_TYPE_HW = 0x0,
SBI_PMU_EVENT_TYPE_CACHE = 0x1,
SBI_PMU_EVENT_TYPE_RAW = 0x2,
SBI_PMU_EVENT_TYPE_RAW_V2 = 0x3,
SBI_PMU_EVENT_TYPE_FW = 0xf,
};
/* SBI PMU event types */
enum sbi_pmu_ctr_type {
SBI_PMU_CTR_TYPE_HW = 0x0,
SBI_PMU_CTR_TYPE_FW,
};
/* Helper macros to decode event idx */
#define SBI_PMU_EVENT_IDX_OFFSET 20
#define SBI_PMU_EVENT_IDX_MASK 0xFFFFF
Annotation
- Immediate include surface: `linux/types.h`, `linux/cpumask.h`, `linux/jump_label.h`.
- Detected declarations: `struct riscv_pmu_snapshot_data`, `struct riscv_pmu_event_info`, `struct sbi_sta_struct`, `struct sbi_dbtr_data_msg`, `struct sbi_dbtr_id_msg`, `struct sbiret`, `enum sbi_ext_id`, `enum sbi_ext_base_fid`, `enum sbi_ext_time_fid`, `enum sbi_ext_ipi_fid`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.