/src/capstonenext/arch/RISCV/RISCVModule.c
Line | Count | Source |
1 | | /* Capstone Disassembly Engine */ |
2 | | /* RISC-V Backend By Rodrigo Cortes Porto <porto703@gmail.com> & |
3 | | Shawn Chang <citypw@gmail.com>, HardenedLinux@2018 */ |
4 | | |
5 | | #ifdef CAPSTONE_HAS_RISCV |
6 | | |
7 | | #include "../../utils.h" |
8 | | #include "../../MCRegisterInfo.h" |
9 | | #include "RISCVInstPrinter.h" |
10 | | #include "RISCVMapping.h" |
11 | | #include "RISCVModule.h" |
12 | | #include "RISCVLinkage.h" |
13 | | |
14 | | cs_err RISCV_global_init(cs_struct *ud) |
15 | 1.56k | { |
16 | 1.56k | MCRegisterInfo *mri; |
17 | 1.56k | mri = cs_mem_malloc(sizeof(*mri)); |
18 | 1.56k | if (!mri) |
19 | 0 | return CS_ERR_MEM; |
20 | | |
21 | 1.56k | RISCV_init(mri); |
22 | 1.56k | ud->printer = RISCV_LLVM_printInstruction; |
23 | 1.56k | ud->printer_info = mri; |
24 | 1.56k | ud->getinsn_info = mri; |
25 | 1.56k | ud->disasm = RISCV_LLVM_getInstruction; |
26 | 1.56k | ud->post_printer = NULL; |
27 | | |
28 | 1.56k | ud->reg_name = RISCV_reg_name; |
29 | 1.56k | ud->insn_id = RISCV_get_insn_id; |
30 | 1.56k | ud->insn_name = RISCV_insn_name; |
31 | 1.56k | ud->group_name = RISCV_group_name; |
32 | 1.56k | ud->insn_map = RISCV_insns; |
33 | 1.56k | ud->insn_map_size = RISCV_insn_count; |
34 | 1.56k | ud->reg_access = RISCV_reg_access; |
35 | | |
36 | 1.56k | return CS_ERR_OK; |
37 | 1.56k | } |
38 | | |
39 | | cs_err RISCV_option(cs_struct *handle, cs_opt_type type, size_t value) |
40 | 373 | { |
41 | 373 | if (type == CS_OPT_SYNTAX) { |
42 | 373 | handle->syntax |= (int)value; |
43 | 373 | } else if (type == CS_OPT_MODE) { |
44 | 0 | handle->mode = (cs_mode)value; |
45 | 0 | } |
46 | | |
47 | 373 | return CS_ERR_OK; |
48 | 373 | } |
49 | | |
50 | | #endif |