1 /* Capstone Disassembly Engine */ 2 /* By Dang Hoang Vu <danghvu@gmail.com> 2013 */ 3 4 #ifdef CAPSTONE_HAS_ARM64 5 6 #include "../../utils.h" 7 #include "../../MCRegisterInfo.h" 8 #include "AArch64Disassembler.h" 9 #include "AArch64InstPrinter.h" 10 #include "AArch64Mapping.h" 11 init(cs_struct * ud)12static cs_err init(cs_struct *ud) 13 { 14 MCRegisterInfo *mri; 15 16 // verify if requested mode is valid 17 if (ud->mode & ~(CS_MODE_LITTLE_ENDIAN | CS_MODE_ARM | CS_MODE_BIG_ENDIAN)) 18 return CS_ERR_MODE; 19 20 mri = cs_mem_malloc(sizeof(*mri)); 21 22 AArch64_init(mri); 23 ud->printer = AArch64_printInst; 24 ud->printer_info = mri; 25 ud->getinsn_info = mri; 26 ud->disasm = AArch64_getInstruction; 27 ud->reg_name = AArch64_reg_name; 28 ud->insn_id = AArch64_get_insn_id; 29 ud->insn_name = AArch64_insn_name; 30 ud->group_name = AArch64_group_name; 31 ud->post_printer = AArch64_post_printer; 32 33 return CS_ERR_OK; 34 } 35 option(cs_struct * handle,cs_opt_type type,size_t value)36static cs_err option(cs_struct *handle, cs_opt_type type, size_t value) 37 { 38 if (type == CS_OPT_MODE) { 39 handle->big_endian = (((cs_mode)value & CS_MODE_BIG_ENDIAN) != 0); 40 } 41 42 return CS_ERR_OK; 43 } 44 destroy(cs_struct * handle)45static void destroy(cs_struct *handle) 46 { 47 } 48 AArch64_enable(void)49void AArch64_enable(void) 50 { 51 arch_init[CS_ARCH_ARM64] = init; 52 arch_option[CS_ARCH_ARM64] = option; 53 arch_destroy[CS_ARCH_ARM64] = destroy; 54 55 // support this arch 56 all_arch |= (1 << CS_ARCH_ARM64); 57 } 58 59 #endif 60