1 /* Capstone Disassembly Engine */
2 /* By Dang Hoang Vu <danghvu@gmail.com> 2013 */
3 
4 #ifdef CAPSTONE_HAS_ARM
5 
6 #include "../../cs_priv.h"
7 #include "../../MCRegisterInfo.h"
8 #include "ARMDisassembler.h"
9 #include "ARMInstPrinter.h"
10 #include "ARMMapping.h"
11 #include "ARMModule.h"
12 
ARM_global_init(cs_struct * ud)13 cs_err ARM_global_init(cs_struct *ud)
14 {
15 	MCRegisterInfo *mri;
16 	mri = cs_mem_malloc(sizeof(*mri));
17 
18 	ARM_init(mri);
19 	ARM_getRegName(ud, 0);	// use default get_regname
20 
21 	ud->printer = ARM_printInst;
22 	ud->printer_info = mri;
23 	ud->reg_name = ARM_reg_name;
24 	ud->insn_id = ARM_get_insn_id;
25 	ud->insn_name = ARM_insn_name;
26 	ud->group_name = ARM_group_name;
27 	ud->post_printer = ARM_post_printer;
28 #ifndef CAPSTONE_DIET
29 	ud->reg_access = ARM_reg_access;
30 #endif
31 
32 	if (ud->mode & CS_MODE_THUMB)
33 		ud->disasm = Thumb_getInstruction;
34 	else
35 		ud->disasm = ARM_getInstruction;
36 
37 	return CS_ERR_OK;
38 }
39 
ARM_option(cs_struct * handle,cs_opt_type type,size_t value)40 cs_err ARM_option(cs_struct *handle, cs_opt_type type, size_t value)
41 {
42 	switch(type) {
43 		case CS_OPT_MODE:
44 			if (value & CS_MODE_THUMB)
45 				handle->disasm = Thumb_getInstruction;
46 			else
47 				handle->disasm = ARM_getInstruction;
48 
49 			handle->mode = (cs_mode)value;
50 
51 			break;
52 		case CS_OPT_SYNTAX:
53 			ARM_getRegName(handle, (int)value);
54 			handle->syntax = (int)value;
55 			break;
56 		default:
57 			break;
58 	}
59 
60 	return CS_ERR_OK;
61 }
62 
63 #endif
64