arch/riscv/include/asm/insn.h
Source file repositories/reference/linux-study-clean/arch/riscv/include/asm/insn.h
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/include/asm/insn.h- Extension
.h- Size
- 20987 bytes
- Lines
- 604
- 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.
Dependency Surface
linux/bits.h
Detected Declarations
function riscv_insn_is_systemfunction riscv_insn_is_branchfunction riscv_insn_is_c_jrfunction riscv_insn_is_c_jalrfunction riscv_insn_extract_jtype_immfunction riscv_insn_insert_jtype_immfunction riscv_insn_extract_utype_itype_immfunction instructions
Annotated Snippet
#ifndef _ASM_RISCV_INSN_H
#define _ASM_RISCV_INSN_H
#include <linux/bits.h>
#define RV_INSN_FUNCT3_MASK GENMASK(14, 12)
#define RV_INSN_FUNCT3_OPOFF 12
#define RV_INSN_OPCODE_MASK GENMASK(6, 0)
#define RV_INSN_OPCODE_OPOFF 0
#define RV_INSN_FUNCT12_OPOFF 20
#define RV_ENCODE_FUNCT3(f_) (RVG_FUNCT3_##f_ << RV_INSN_FUNCT3_OPOFF)
#define RV_ENCODE_FUNCT12(f_) (RVG_FUNCT12_##f_ << RV_INSN_FUNCT12_OPOFF)
/* The bit field of immediate value in I-type instruction */
#define RV_I_IMM_SIGN_OPOFF 31
#define RV_I_IMM_11_0_OPOFF 20
#define RV_I_IMM_SIGN_OFF 12
#define RV_I_IMM_11_0_OFF 0
#define RV_I_IMM_11_0_MASK GENMASK(11, 0)
/* The bit field of immediate value in J-type instruction */
#define RV_J_IMM_SIGN_OPOFF 31
#define RV_J_IMM_10_1_OPOFF 21
#define RV_J_IMM_11_OPOFF 20
#define RV_J_IMM_19_12_OPOFF 12
#define RV_J_IMM_SIGN_OFF 20
#define RV_J_IMM_10_1_OFF 1
#define RV_J_IMM_11_OFF 11
#define RV_J_IMM_19_12_OFF 12
#define RV_J_IMM_10_1_MASK GENMASK(9, 0)
#define RV_J_IMM_11_MASK GENMASK(0, 0)
#define RV_J_IMM_19_12_MASK GENMASK(7, 0)
/*
* U-type IMMs contain the upper 20bits [31:20] of an immediate with
* the rest filled in by zeros, so no shifting required. Similarly,
* bit31 contains the signed state, so no sign extension necessary.
*/
#define RV_U_IMM_SIGN_OPOFF 31
#define RV_U_IMM_31_12_OPOFF 0
#define RV_U_IMM_31_12_MASK GENMASK(31, 12)
/* The bit field of immediate value in B-type instruction */
#define RV_B_IMM_SIGN_OPOFF 31
#define RV_B_IMM_10_5_OPOFF 25
#define RV_B_IMM_4_1_OPOFF 8
#define RV_B_IMM_11_OPOFF 7
#define RV_B_IMM_SIGN_OFF 12
#define RV_B_IMM_10_5_OFF 5
#define RV_B_IMM_4_1_OFF 1
#define RV_B_IMM_11_OFF 11
#define RV_B_IMM_10_5_MASK GENMASK(5, 0)
#define RV_B_IMM_4_1_MASK GENMASK(3, 0)
#define RV_B_IMM_11_MASK GENMASK(0, 0)
/* The register offset in RVG instruction */
#define RVG_RS1_OPOFF 15
#define RVG_RS2_OPOFF 20
#define RVG_RD_OPOFF 7
#define RVG_RS1_MASK GENMASK(4, 0)
#define RVG_RS2_MASK GENMASK(4, 0)
#define RVG_RD_MASK GENMASK(4, 0)
/* The bit field of immediate value in RVC J instruction */
#define RVC_J_IMM_SIGN_OPOFF 12
#define RVC_J_IMM_4_OPOFF 11
#define RVC_J_IMM_9_8_OPOFF 9
#define RVC_J_IMM_10_OPOFF 8
#define RVC_J_IMM_6_OPOFF 7
#define RVC_J_IMM_7_OPOFF 6
#define RVC_J_IMM_3_1_OPOFF 3
#define RVC_J_IMM_5_OPOFF 2
#define RVC_J_IMM_SIGN_OFF 11
#define RVC_J_IMM_4_OFF 4
#define RVC_J_IMM_9_8_OFF 8
#define RVC_J_IMM_10_OFF 10
#define RVC_J_IMM_6_OFF 6
#define RVC_J_IMM_7_OFF 7
#define RVC_J_IMM_3_1_OFF 1
#define RVC_J_IMM_5_OFF 5
#define RVC_J_IMM_4_MASK GENMASK(0, 0)
#define RVC_J_IMM_9_8_MASK GENMASK(1, 0)
#define RVC_J_IMM_10_MASK GENMASK(0, 0)
#define RVC_J_IMM_6_MASK GENMASK(0, 0)
#define RVC_J_IMM_7_MASK GENMASK(0, 0)
#define RVC_J_IMM_3_1_MASK GENMASK(2, 0)
#define RVC_J_IMM_5_MASK GENMASK(0, 0)
/* The bit field of immediate value in RVC B instruction */
Annotation
- Immediate include surface: `linux/bits.h`.
- Detected declarations: `function riscv_insn_is_system`, `function riscv_insn_is_branch`, `function riscv_insn_is_c_jr`, `function riscv_insn_is_c_jalr`, `function riscv_insn_extract_jtype_imm`, `function riscv_insn_insert_jtype_imm`, `function riscv_insn_extract_utype_itype_imm`, `function instructions`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source implementation candidate.
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.