The Pedigree Project  0.1
decode.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef __X86EMU_DECODE_H
21 #define __X86EMU_DECODE_H
22 
23 /*---------------------- Macros and type definitions ----------------------*/
24 
25 /* Instruction Decoding Stuff */
26 
27 #define FETCH_DECODE_MODRM(mod, rh, rl) fetch_decode_modrm(&mod, &rh, &rl)
28 #define DECODE_RM_BYTE_REGISTER(r) decode_rm_byte_register(r)
29 #define DECODE_RM_WORD_REGISTER(r) decode_rm_word_register(r)
30 #define DECODE_RM_LONG_REGISTER(r) decode_rm_long_register(r)
31 #define DECODE_CLEAR_SEGOVR() M.x86.mode &= ~SYSMODE_CLRMASK
32 
33 /*-------------------------- Function Prototypes --------------------------*/
34 
35 #ifdef __cplusplus
36 extern "C" { /* Use "C" linkage when in C++ mode */
37 #endif
38 
39 void x86emu_intr_raise(u8 type);
40 void fetch_decode_modrm(int *mod, int *regh, int *regl);
41 u8 fetch_byte_imm(void);
42 u16 fetch_word_imm(void);
43 u32 fetch_long_imm(void);
44 u8 fetch_data_byte(uint offset);
45 u8 fetch_data_byte_abs(uint segment, uint offset);
46 u16 fetch_data_word(uint offset);
47 u16 fetch_data_word_abs(uint segment, uint offset);
48 u32 fetch_data_long(uint offset);
49 u32 fetch_data_long_abs(uint segment, uint offset);
50 void store_data_byte(uint offset, u8 val);
51 void store_data_byte_abs(uint segment, uint offset, u8 val);
52 void store_data_word(uint offset, u16 val);
53 void store_data_word_abs(uint segment, uint offset, u16 val);
54 void store_data_long(uint offset, u32 val);
55 void store_data_long_abs(uint segment, uint offset, u32 val);
56 u8 *decode_rm_byte_register(int reg);
57 u16 *decode_rm_word_register(int reg);
58 u32 *decode_rm_long_register(int reg);
59 u16 *decode_rm_seg_register(int reg);
60 u32 decode_rm00_address(int rm);
61 u32 decode_rm01_address(int rm);
62 u32 decode_rm10_address(int rm);
63 u32 decode_sib_address(int sib, int mod);
64 
65 #ifdef __cplusplus
66 } /* End of "C" linkage for C++ */
67 #endif
68 
69 #endif /* __X86EMU_DECODE_H */