OpenOCD
opcodes.h File Reference
Include dependency graph for opcodes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX_CSR_NUM   4095
 
#define MAX_FPR_NUM   31
 
#define MAX_GPR_NUM   31
 
#define MAX_INT12   0x7ff
 
#define MAX_INT13   0xfff
 
#define MAX_INT21   0xfffff
 
#define MAX_UINT11   0x7ff
 
#define MAX_UINT12   0xfff
 
#define MAX_UINT5   0x1f
 
#define MAX_VREG_NUM   31
 
#define MIN_INT12   (-0x800)
 
#define MIN_INT13   (-0x1000)
 
#define MIN_INT21   (-0x100000)
 
#define S0   8
 
#define S1   9
 
#define T0   5
 
#define ZERO   0
 

Functions

static uint32_t addi (unsigned int dest, unsigned int src, int16_t imm) __attribute__((unused))
 
static uint32_t auipc (unsigned int dest) __attribute__((unused))
 
static uint32_t bit (uint32_t value, unsigned int b)
 
static uint32_t bits (uint32_t value, unsigned int hi, unsigned int lo)
 
static uint32_t csrr (unsigned int rd, unsigned int csr) __attribute__((unused))
 
static uint32_t csrrci (unsigned int rd, uint8_t zimm, unsigned int csr) __attribute__((unused))
 
static uint32_t csrrs (unsigned int rd, unsigned int rs, unsigned int csr) __attribute__((unused))
 
static uint32_t csrrsi (unsigned int rd, uint8_t zimm, unsigned int csr) __attribute__((unused))
 
static uint32_t csrrw (unsigned int rd, unsigned int rs, unsigned int csr) __attribute__((unused))
 
static uint32_t csrsi (unsigned int csr, uint8_t imm) __attribute__((unused))
 
static uint32_t csrw (unsigned int source, unsigned int csr) __attribute__((unused))
 
static uint32_t ebreak (void) __attribute__((unused))
 
static uint32_t ebreak_c (void) __attribute__((unused))
 
static uint32_t fence_i (void) __attribute__((unused))
 
static uint32_t fence_rw_rw (void) __attribute__((unused))
 
static uint32_t fld (unsigned int dest, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t flw (unsigned int dest, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t fmv_d_x (unsigned int dest, unsigned int src) __attribute__((unused))
 
static uint32_t fmv_w_x (unsigned int dest, unsigned int src) __attribute__((unused))
 
static uint32_t fmv_x_d (unsigned int dest, unsigned int src) __attribute__((unused))
 
static uint32_t fmv_x_w (unsigned int dest, unsigned int src) __attribute__((unused))
 
static uint32_t fsd (unsigned int src, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t fsw (unsigned int src, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t imm_b (uint32_t imm) __attribute__((unused))
 
static uint32_t imm_i (uint32_t imm) __attribute__((unused))
 
static uint32_t imm_j (uint32_t imm) __attribute__((unused))
 
static uint32_t imm_s (uint32_t imm) __attribute__((unused))
 
static uint32_t imm_u (uint32_t imm) __attribute__((unused))
 
static uint32_t inst_rd (uint32_t r) __attribute__((unused))
 
static uint32_t inst_rs1 (uint32_t r) __attribute__((unused))
 
static uint32_t inst_rs2 (uint32_t r) __attribute__((unused))
 
static uint32_t jal (unsigned int rd, int32_t imm) __attribute__((unused))
 
static uint32_t lb (unsigned int rd, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t ld (unsigned int rd, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t lh (unsigned int rd, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t lui (unsigned int dest, uint32_t imm) __attribute__((unused))
 
static uint32_t lw (unsigned int rd, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t sb (unsigned int src, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t sd (unsigned int src, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t sh (unsigned int src, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t srli (unsigned int dest, unsigned int src, uint8_t shamt) __attribute__((unused))
 
static uint32_t sw (unsigned int src, unsigned int base, int16_t offset) __attribute__((unused))
 
static uint32_t vmv_s_x (unsigned int vd, unsigned int rs2) __attribute__((unused))
 
static uint32_t vmv_x_s (unsigned int rd, unsigned int vs2) __attribute__((unused))
 
static uint32_t vsetvl (unsigned int rd, unsigned int rs1, unsigned int rs2) __attribute__((unused))
 
static uint32_t vsetvli (unsigned int dest, unsigned int src, uint16_t vtypei) __attribute__((unused))
 
static uint32_t vslide1down_vx (unsigned int vd, unsigned int vs2, unsigned int rs1, bool vm) __attribute__((unused))
 
static uint32_t wfi (void) __attribute__((unused))
 
static uint32_t xori (unsigned int dest, unsigned int src, int16_t imm) __attribute__((unused))
 

Macro Definition Documentation

◆ MAX_CSR_NUM

#define MAX_CSR_NUM   4095

Definition at line 19 of file opcodes.h.

◆ MAX_FPR_NUM

#define MAX_FPR_NUM   31

Definition at line 17 of file opcodes.h.

◆ MAX_GPR_NUM

#define MAX_GPR_NUM   31

Definition at line 16 of file opcodes.h.

◆ MAX_INT12

#define MAX_INT12   0x7ff

Definition at line 22 of file opcodes.h.

◆ MAX_INT13

#define MAX_INT13   0xfff

Definition at line 25 of file opcodes.h.

◆ MAX_INT21

#define MAX_INT21   0xfffff

Definition at line 28 of file opcodes.h.

◆ MAX_UINT11

#define MAX_UINT11   0x7ff

Definition at line 31 of file opcodes.h.

◆ MAX_UINT12

#define MAX_UINT12   0xfff

Definition at line 32 of file opcodes.h.

◆ MAX_UINT5

#define MAX_UINT5   0x1f

Definition at line 30 of file opcodes.h.

◆ MAX_VREG_NUM

#define MAX_VREG_NUM   31

Definition at line 18 of file opcodes.h.

◆ MIN_INT12

#define MIN_INT12   (-0x800)

Definition at line 21 of file opcodes.h.

◆ MIN_INT13

#define MIN_INT13   (-0x1000)

Definition at line 24 of file opcodes.h.

◆ MIN_INT21

#define MIN_INT21   (-0x100000)

Definition at line 27 of file opcodes.h.

◆ S0

#define S0   8

Definition at line 13 of file opcodes.h.

◆ S1

#define S1   9

Definition at line 14 of file opcodes.h.

◆ T0

#define T0   5

Definition at line 12 of file opcodes.h.

◆ ZERO

#define ZERO   0

Definition at line 11 of file opcodes.h.

Function Documentation

◆ addi()

static uint32_t addi ( unsigned int  dest,
unsigned int  src,
int16_t  imm 
)
static

Definition at line 201 of file opcodes.h.

References imm_i(), inst_rd(), inst_rs1(), MATCH_ADDI, MAX_GPR_NUM, MAX_INT12, and MIN_INT12.

Referenced by riscv_program_addi(), and setup_write_memory().

◆ auipc()

static uint32_t auipc ( unsigned int  dest)
static

Definition at line 392 of file opcodes.h.

References inst_rd(), MATCH_AUIPC, and MAX_GPR_NUM.

Referenced by examine_progbuf().

◆ bit()

◆ bits()

static uint32_t bits ( uint32_t  value,
unsigned int  hi,
unsigned int  lo 
)
static

Definition at line 34 of file opcodes.h.

Referenced by imm_b(), imm_i(), imm_j(), imm_s(), imm_u(), inst_rd(), inst_rs1(), inst_rs2(), lui(), and vsetvli().

◆ csrr()

static uint32_t csrr ( unsigned int  rd,
unsigned int  csr 
)
static

◆ csrrci()

static uint32_t csrrci ( unsigned int  rd,
uint8_t  zimm,
unsigned int  csr 
)
static

Definition at line 240 of file opcodes.h.

References csr, imm_i(), inst_rd(), inst_rs1(), MATCH_CSRRCI, MAX_CSR_NUM, MAX_GPR_NUM, and MAX_UINT5.

Referenced by riscv_program_csrrci().

◆ csrrs()

static uint32_t csrrs ( unsigned int  rd,
unsigned int  rs,
unsigned int  csr 
)
static

Definition at line 220 of file opcodes.h.

References csr, imm_i(), inst_rd(), inst_rs1(), MATCH_CSRRS, MAX_CSR_NUM, MAX_GPR_NUM, and rs.

Referenced by riscv_program_csrr().

◆ csrrsi()

static uint32_t csrrsi ( unsigned int  rd,
uint8_t  zimm,
unsigned int  csr 
)
static

Definition at line 250 of file opcodes.h.

References csr, imm_i(), inst_rd(), inst_rs1(), MATCH_CSRRSI, MAX_CSR_NUM, MAX_GPR_NUM, and MAX_UINT5.

Referenced by riscv_program_csrrsi().

◆ csrrw()

static uint32_t csrrw ( unsigned int  rd,
unsigned int  rs,
unsigned int  csr 
)
static

Definition at line 230 of file opcodes.h.

References csr, imm_i(), inst_rd(), inst_rs1(), MATCH_CSRRW, MAX_CSR_NUM, MAX_GPR_NUM, and rs.

Referenced by riscv_program_csrw().

◆ csrsi()

static uint32_t csrsi ( unsigned int  csr,
uint8_t  imm 
)
static

Definition at line 103 of file opcodes.h.

References csr, imm_i(), inst_rs1(), MATCH_CSRRSI, MAX_CSR_NUM, and MAX_UINT5.

Referenced by halt().

◆ csrw()

static uint32_t csrw ( unsigned int  source,
unsigned int  csr 
)
static

◆ ebreak()

static uint32_t ebreak ( void  )
static

Definition at line 336 of file opcodes.h.

References MATCH_EBREAK.

Referenced by riscv_add_breakpoint(), and riscv_program_ebreak().

◆ ebreak_c()

static uint32_t ebreak_c ( void  )
static

Definition at line 341 of file opcodes.h.

References MATCH_C_EBREAK.

Referenced by riscv_add_breakpoint().

◆ fence_i()

static uint32_t fence_i ( void  )
static

Definition at line 350 of file opcodes.h.

References MATCH_FENCE_I.

Referenced by execute_resume(), and riscv_program_fence_i().

◆ fence_rw_rw()

static uint32_t fence_rw_rw ( void  )
static

Definition at line 385 of file opcodes.h.

References MATCH_FENCE.

Referenced by riscv_program_fence_rw_rw().

◆ fld()

static uint32_t fld ( unsigned int  dest,
unsigned int  base,
int16_t  offset 
)
static

Definition at line 290 of file opcodes.h.

References imm_i(), inst_rd(), inst_rs1(), MATCH_FLD, MAX_FPR_NUM, MAX_GPR_NUM, MAX_INT12, MIN_INT12, and offset.

Referenced by fpr_write_progbuf(), and register_write().

◆ flw()

static uint32_t flw ( unsigned int  dest,
unsigned int  base,
int16_t  offset 
)
static

Definition at line 280 of file opcodes.h.

References imm_i(), inst_rd(), inst_rs1(), MATCH_FLW, MAX_FPR_NUM, MAX_GPR_NUM, MAX_INT12, MIN_INT12, and offset.

Referenced by register_write().

◆ fmv_d_x()

static uint32_t fmv_d_x ( unsigned int  dest,
unsigned int  src 
)
static

Definition at line 327 of file opcodes.h.

References inst_rd(), inst_rs1(), MATCH_FMV_D_X, MAX_FPR_NUM, and MAX_GPR_NUM.

Referenced by fpr_write_progbuf().

◆ fmv_w_x()

static uint32_t fmv_w_x ( unsigned int  dest,
unsigned int  src 
)
static

Definition at line 318 of file opcodes.h.

References inst_rd(), inst_rs1(), MATCH_FMV_W_X, MAX_FPR_NUM, and MAX_GPR_NUM.

Referenced by fpr_write_progbuf().

◆ fmv_x_d()

static uint32_t fmv_x_d ( unsigned int  dest,
unsigned int  src 
)
static

Definition at line 309 of file opcodes.h.

References inst_rd(), inst_rs1(), MATCH_FMV_X_D, MAX_FPR_NUM, and MAX_GPR_NUM.

Referenced by fpr_read_progbuf().

◆ fmv_x_w()

static uint32_t fmv_x_w ( unsigned int  dest,
unsigned int  src 
)
static

Definition at line 300 of file opcodes.h.

References inst_rd(), inst_rs1(), MATCH_FMV_X_W, MAX_FPR_NUM, and MAX_GPR_NUM.

Referenced by fpr_read_progbuf().

◆ fsd()

static uint32_t fsd ( unsigned int  src,
unsigned int  base,
int16_t  offset 
)
static

◆ fsw()

static uint32_t fsw ( unsigned int  src,
unsigned int  base,
int16_t  offset 
)
static

Definition at line 260 of file opcodes.h.

References imm_s(), inst_rs1(), inst_rs2(), MATCH_FSW, MAX_FPR_NUM, MAX_GPR_NUM, MAX_INT12, MIN_INT12, and offset.

Referenced by riscv011_get_register().

◆ imm_b()

static uint32_t imm_b ( uint32_t  imm)
static

Definition at line 75 of file opcodes.h.

References bit(), and bits().

◆ imm_i()

static uint32_t imm_i ( uint32_t  imm)
static

Definition at line 63 of file opcodes.h.

References bits().

Referenced by addi(), csrr(), csrrci(), csrrs(), csrrsi(), csrrw(), csrsi(), csrw(), fld(), flw(), lb(), ld(), lh(), lw(), and xori().

◆ imm_j()

static uint32_t imm_j ( uint32_t  imm)
static

Definition at line 87 of file opcodes.h.

References bit(), and bits().

Referenced by jal().

◆ imm_s()

static uint32_t imm_s ( uint32_t  imm)
static

Definition at line 69 of file opcodes.h.

References bits().

Referenced by fsd(), fsw(), sb(), sd(), sh(), and sw().

◆ imm_u()

static uint32_t imm_u ( uint32_t  imm)
static

Definition at line 81 of file opcodes.h.

References bits().

Referenced by lui().

◆ inst_rd()

static uint32_t inst_rd ( uint32_t  r)
static

◆ inst_rs1()

static uint32_t inst_rs1 ( uint32_t  r)
static

◆ inst_rs2()

static uint32_t inst_rs2 ( uint32_t  r)
static

Definition at line 57 of file opcodes.h.

References bits().

Referenced by fsd(), fsw(), sb(), sd(), sh(), srli(), sw(), vmv_x_s(), vsetvl(), and vslide1down_vx().

◆ jal()

static uint32_t jal ( unsigned int  rd,
int32_t  imm 
)
static

Definition at line 93 of file opcodes.h.

References imm_j(), inst_rd(), MATCH_JAL, MAX_GPR_NUM, MAX_INT21, and MIN_INT21.

Referenced by cache_set_jump(), dram_write_jump(), and scans_add_write_jump().

◆ lb()

static uint32_t lb ( unsigned int  rd,
unsigned int  base,
int16_t  offset 
)
static

◆ ld()

static uint32_t ld ( unsigned int  rd,
unsigned int  base,
int16_t  offset 
)
static

Definition at line 152 of file opcodes.h.

References imm_i(), inst_rd(), inst_rs1(), MATCH_LD, MAX_GPR_NUM, MAX_INT12, MIN_INT12, and offset.

Referenced by load(), and riscv_program_ldr().

◆ lh()

◆ lui()

static uint32_t lui ( unsigned int  dest,
uint32_t  imm 
)
static

Definition at line 356 of file opcodes.h.

References bits(), imm_u(), inst_rd(), MATCH_LUI, and MAX_GPR_NUM.

◆ lw()

static uint32_t lw ( unsigned int  rd,
unsigned int  base,
int16_t  offset 
)
static

◆ sb()

static uint32_t sb ( unsigned int  src,
unsigned int  base,
int16_t  offset 
)
static

◆ sd()

static uint32_t sd ( unsigned int  src,
unsigned int  base,
int16_t  offset 
)
static

Definition at line 122 of file opcodes.h.

References imm_s(), inst_rs1(), inst_rs2(), MATCH_SD, MAX_GPR_NUM, MAX_INT12, MIN_INT12, and offset.

Referenced by riscv_program_sdr(), and store().

◆ sh()

static uint32_t sh ( unsigned int  src,
unsigned int  base,
int16_t  offset 
)
static

Definition at line 132 of file opcodes.h.

References imm_s(), inst_rs1(), inst_rs2(), MATCH_SH, MAX_GPR_NUM, MAX_INT12, MIN_INT12, and offset.

Referenced by riscv_program_shr(), and setup_write_memory().

◆ srli()

static uint32_t srli ( unsigned int  dest,
unsigned int  src,
uint8_t  shamt 
)
static

Definition at line 375 of file opcodes.h.

References inst_rd(), inst_rs1(), inst_rs2(), MATCH_SRLI, MAX_GPR_NUM, and MAX_UINT5.

Referenced by examine().

◆ sw()

static uint32_t sw ( unsigned int  src,
unsigned int  base,
int16_t  offset 
)
static

◆ vmv_s_x()

static uint32_t vmv_s_x ( unsigned int  vd,
unsigned int  rs2 
)
static

Definition at line 429 of file opcodes.h.

References inst_rd(), inst_rs1(), MATCH_VMV_S_X, MAX_GPR_NUM, and MAX_VREG_NUM.

◆ vmv_x_s()

static uint32_t vmv_x_s ( unsigned int  rd,
unsigned int  vs2 
)
static

Definition at line 420 of file opcodes.h.

References inst_rd(), inst_rs2(), MATCH_VMV_X_S, MAX_GPR_NUM, and MAX_VREG_NUM.

Referenced by riscv013_get_register_buf().

◆ vsetvl()

static uint32_t vsetvl ( unsigned int  rd,
unsigned int  rs1,
unsigned int  rs2 
)
static

Definition at line 410 of file opcodes.h.

References inst_rd(), inst_rs1(), inst_rs2(), MATCH_VSETVL, and MAX_GPR_NUM.

Referenced by vl_write_progbuf(), and vtype_write_progbuf().

◆ vsetvli()

static uint32_t vsetvli ( unsigned int  dest,
unsigned int  src,
uint16_t  vtypei 
)
static

Definition at line 400 of file opcodes.h.

References bits(), inst_rd(), inst_rs1(), MATCH_VSETVLI, MAX_GPR_NUM, and MAX_UINT11.

◆ vslide1down_vx()

static uint32_t vslide1down_vx ( unsigned int  vd,
unsigned int  vs2,
unsigned int  rs1,
bool  vm 
)
static

◆ wfi()

static uint32_t wfi ( void  )
static

Definition at line 347 of file opcodes.h.

References MATCH_WFI.

◆ xori()

static uint32_t xori ( unsigned int  dest,
unsigned int  src,
int16_t  imm 
)
static

Definition at line 365 of file opcodes.h.

References imm_i(), inst_rd(), inst_rs1(), MATCH_XORI, MAX_GPR_NUM, MAX_INT12, and MIN_INT12.

Referenced by examine().