1 /* Capstone Disassembly Engine */
2 /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 */
3 
4 #ifdef CAPSTONE_HAS_XCORE
5 
6 #include "../../utils.h"
7 #include "../../MCRegisterInfo.h"
8 #include "XCoreDisassembler.h"
9 #include "XCoreInstPrinter.h"
10 #include "XCoreMapping.h"
11 
init(cs_struct * ud)12 static cs_err init(cs_struct *ud)
13 {
14 	MCRegisterInfo *mri;
15 	mri = cs_mem_malloc(sizeof(*mri));
16 
17 	XCore_init(mri);
18 	ud->printer = XCore_printInst;
19 	ud->printer_info = mri;
20 	ud->getinsn_info = mri;
21 	ud->disasm = XCore_getInstruction;
22 	ud->post_printer = XCore_post_printer;
23 
24 	ud->reg_name = XCore_reg_name;
25 	ud->insn_id = XCore_get_insn_id;
26 	ud->insn_name = XCore_insn_name;
27 	ud->group_name = XCore_group_name;
28 
29 	return CS_ERR_OK;
30 }
31 
option(cs_struct * handle,cs_opt_type type,size_t value)32 static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
33 {
34 	// Do not set mode because only CS_MODE_BIG_ENDIAN is valid; we cannot
35 	// test for CS_MODE_LITTLE_ENDIAN because it is 0
36 
37 	return CS_ERR_OK;
38 }
39 
destroy(cs_struct * handle)40 static void destroy(cs_struct *handle)
41 {
42 }
43 
XCore_enable(void)44 void XCore_enable(void)
45 {
46 	arch_init[CS_ARCH_XCORE] = init;
47 	arch_option[CS_ARCH_XCORE] = option;
48 	arch_destroy[CS_ARCH_XCORE] = destroy;
49 	arch_disallowed_mode_mask[CS_ARCH_XCORE] = ~CS_MODE_BIG_ENDIAN;
50 
51 	// support this arch
52 	all_arch |= (1 << CS_ARCH_XCORE);
53 }
54 
55 #endif
56