xref: /OK3568_Linux_fs/u-boot/drivers/bios_emulator/include/x86emu/decode.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /****************************************************************************
2*4882a593Smuzhiyun *
3*4882a593Smuzhiyun *                       Realmode X86 Emulator Library
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun *               Copyright (C) 1991-2004 SciTech Software, Inc.
6*4882a593Smuzhiyun *                    Copyright (C) David Mosberger-Tang
7*4882a593Smuzhiyun *                      Copyright (C) 1999 Egbert Eich
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun *  ========================================================================
10*4882a593Smuzhiyun *
11*4882a593Smuzhiyun *  Permission to use, copy, modify, distribute, and sell this software and
12*4882a593Smuzhiyun *  its documentation for any purpose is hereby granted without fee,
13*4882a593Smuzhiyun *  provided that the above copyright notice appear in all copies and that
14*4882a593Smuzhiyun *  both that copyright notice and this permission notice appear in
15*4882a593Smuzhiyun *  supporting documentation, and that the name of the authors not be used
16*4882a593Smuzhiyun *  in advertising or publicity pertaining to distribution of the software
17*4882a593Smuzhiyun *  without specific, written prior permission.  The authors makes no
18*4882a593Smuzhiyun *  representations about the suitability of this software for any purpose.
19*4882a593Smuzhiyun *  It is provided "as is" without express or implied warranty.
20*4882a593Smuzhiyun *
21*4882a593Smuzhiyun *  THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
22*4882a593Smuzhiyun *  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
23*4882a593Smuzhiyun *  EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24*4882a593Smuzhiyun *  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
25*4882a593Smuzhiyun *  USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26*4882a593Smuzhiyun *  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27*4882a593Smuzhiyun *  PERFORMANCE OF THIS SOFTWARE.
28*4882a593Smuzhiyun *
29*4882a593Smuzhiyun *  ========================================================================
30*4882a593Smuzhiyun *
31*4882a593Smuzhiyun * Language:     ANSI C
32*4882a593Smuzhiyun * Environment:  Any
33*4882a593Smuzhiyun * Developer:    Kendall Bennett
34*4882a593Smuzhiyun *
35*4882a593Smuzhiyun * Description:  Header file for instruction decoding logic.
36*4882a593Smuzhiyun *
37*4882a593Smuzhiyun ****************************************************************************/
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #ifndef __X86EMU_DECODE_H
40*4882a593Smuzhiyun #define __X86EMU_DECODE_H
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /*---------------------- Macros and type definitions ----------------------*/
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun /* Instruction Decoding Stuff */
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #define FETCH_DECODE_MODRM(mod,rh,rl)   fetch_decode_modrm(&mod,&rh,&rl)
47*4882a593Smuzhiyun #define DECODE_RM_BYTE_REGISTER(r)      decode_rm_byte_register(r)
48*4882a593Smuzhiyun #define DECODE_RM_WORD_REGISTER(r)      decode_rm_word_register(r)
49*4882a593Smuzhiyun #define DECODE_RM_LONG_REGISTER(r)      decode_rm_long_register(r)
50*4882a593Smuzhiyun #define DECODE_CLEAR_SEGOVR()           M.x86.mode &= ~SYSMODE_CLRMASK
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun /*-------------------------- Function Prototypes --------------------------*/
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #ifdef  __cplusplus
55*4882a593Smuzhiyun extern "C" {                        /* Use "C" linkage when in C++ mode */
56*4882a593Smuzhiyun #endif
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun void    x86emu_intr_raise (u8 type);
59*4882a593Smuzhiyun void    fetch_decode_modrm (int *mod,int *regh,int *regl);
60*4882a593Smuzhiyun u8      fetch_byte_imm (void);
61*4882a593Smuzhiyun u16     fetch_word_imm (void);
62*4882a593Smuzhiyun u32     fetch_long_imm (void);
63*4882a593Smuzhiyun u8      fetch_data_byte (uint offset);
64*4882a593Smuzhiyun u8      fetch_data_byte_abs (uint segment, uint offset);
65*4882a593Smuzhiyun u16     fetch_data_word (uint offset);
66*4882a593Smuzhiyun u16     fetch_data_word_abs (uint segment, uint offset);
67*4882a593Smuzhiyun u32     fetch_data_long (uint offset);
68*4882a593Smuzhiyun u32     fetch_data_long_abs (uint segment, uint offset);
69*4882a593Smuzhiyun void    store_data_byte (uint offset, u8 val);
70*4882a593Smuzhiyun void    store_data_byte_abs (uint segment, uint offset, u8 val);
71*4882a593Smuzhiyun void    store_data_word (uint offset, u16 val);
72*4882a593Smuzhiyun void    store_data_word_abs (uint segment, uint offset, u16 val);
73*4882a593Smuzhiyun void    store_data_long (uint offset, u32 val);
74*4882a593Smuzhiyun void    store_data_long_abs (uint segment, uint offset, u32 val);
75*4882a593Smuzhiyun u8*     decode_rm_byte_register(int reg);
76*4882a593Smuzhiyun u16*    decode_rm_word_register(int reg);
77*4882a593Smuzhiyun u32*    decode_rm_long_register(int reg);
78*4882a593Smuzhiyun u16*    decode_rm_seg_register(int reg);
79*4882a593Smuzhiyun unsigned decode_rm00_address(int rm);
80*4882a593Smuzhiyun unsigned decode_rm01_address(int rm);
81*4882a593Smuzhiyun unsigned decode_rm10_address(int rm);
82*4882a593Smuzhiyun unsigned decode_rmXX_address(int mod, int rm);
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun #ifdef  __cplusplus
85*4882a593Smuzhiyun }                                   /* End of "C" linkage for C++       */
86*4882a593Smuzhiyun #endif
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun #endif /* __X86EMU_DECODE_H */
89