/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.47k | { |
16 | 1.47k | MCRegisterInfo *mri; |
17 | 1.47k | mri = cs_mem_malloc(sizeof(*mri)); |
18 | 1.47k | if (!mri) |
19 | 0 | return CS_ERR_MEM; |
20 | | |
21 | 1.47k | RISCV_init(mri); |
22 | 1.47k | ud->printer = RISCV_LLVM_printInstruction; |
23 | 1.47k | ud->printer_info = mri; |
24 | 1.47k | ud->getinsn_info = mri; |
25 | 1.47k | ud->disasm = RISCV_LLVM_getInstruction; |
26 | 1.47k | ud->post_printer = NULL; |
27 | | |
28 | 1.47k | ud->reg_name = RISCV_reg_name; |
29 | 1.47k | ud->insn_id = RISCV_get_insn_id; |
30 | 1.47k | ud->insn_name = RISCV_insn_name; |
31 | 1.47k | ud->group_name = RISCV_group_name; |
32 | 1.47k | ud->insn_map = RISCV_insns; |
33 | 1.47k | ud->insn_map_size = RISCV_insn_count; |
34 | | |
35 | 1.47k | return CS_ERR_OK; |
36 | 1.47k | } |
37 | | |
38 | | cs_err RISCV_option(cs_struct *handle, cs_opt_type type, size_t value) |
39 | 391 | { |
40 | 391 | if (type == CS_OPT_SYNTAX) { |
41 | 391 | handle->syntax = (int)value; |
42 | 391 | } else if (type == CS_OPT_MODE) { |
43 | 0 | handle->mode = (cs_mode)value; |
44 | 0 | } |
45 | | |
46 | 391 | return CS_ERR_OK; |
47 | 391 | } |
48 | | |
49 | | #endif |