xref: /OK3568_Linux_fs/u-boot/drivers/bios_emulator/include/biosemu.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /****************************************************************************
2*4882a593Smuzhiyun *
3*4882a593Smuzhiyun *                        BIOS emulator and interface
4*4882a593Smuzhiyun *                      to Realmode X86 Emulator Library
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun *               Copyright (C) 1996-1999 SciTech Software, Inc.
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun *  ========================================================================
9*4882a593Smuzhiyun *
10*4882a593Smuzhiyun *  Permission to use, copy, modify, distribute, and sell this software and
11*4882a593Smuzhiyun *  its documentation for any purpose is hereby granted without fee,
12*4882a593Smuzhiyun *  provided that the above copyright notice appear in all copies and that
13*4882a593Smuzhiyun *  both that copyright notice and this permission notice appear in
14*4882a593Smuzhiyun *  supporting documentation, and that the name of the authors not be used
15*4882a593Smuzhiyun *  in advertising or publicity pertaining to distribution of the software
16*4882a593Smuzhiyun *  without specific, written prior permission.  The authors makes no
17*4882a593Smuzhiyun *  representations about the suitability of this software for any purpose.
18*4882a593Smuzhiyun *  It is provided "as is" without express or implied warranty.
19*4882a593Smuzhiyun *
20*4882a593Smuzhiyun *  THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
21*4882a593Smuzhiyun *  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
22*4882a593Smuzhiyun *  EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
23*4882a593Smuzhiyun *  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
24*4882a593Smuzhiyun *  USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25*4882a593Smuzhiyun *  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26*4882a593Smuzhiyun *  PERFORMANCE OF THIS SOFTWARE.
27*4882a593Smuzhiyun *
28*4882a593Smuzhiyun *  ========================================================================
29*4882a593Smuzhiyun *
30*4882a593Smuzhiyun * Language:     ANSI C
31*4882a593Smuzhiyun * Environment:  Any
32*4882a593Smuzhiyun * Developer:    Kendall Bennett
33*4882a593Smuzhiyun *
34*4882a593Smuzhiyun * Description:  Header file for the real mode x86 BIOS emulator, which is
35*4882a593Smuzhiyun *               used to warmboot any number of VGA compatible PCI/AGP
36*4882a593Smuzhiyun *               controllers under any OS, on any processor family that
37*4882a593Smuzhiyun *               supports PCI. We also allow the user application to call
38*4882a593Smuzhiyun *               real mode BIOS functions and Int 10h functions (including
39*4882a593Smuzhiyun *               the VESA BIOS).
40*4882a593Smuzhiyun *
41*4882a593Smuzhiyun ****************************************************************************/
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #ifndef __BIOSEMU_H
44*4882a593Smuzhiyun #define __BIOSEMU_H
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #include <bios_emul.h>
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun #ifdef __KERNEL__
49*4882a593Smuzhiyun #include "x86emu.h"
50*4882a593Smuzhiyun #else
51*4882a593Smuzhiyun #include "x86emu.h"
52*4882a593Smuzhiyun #include "pmapi.h"
53*4882a593Smuzhiyun #include "pcilib.h"
54*4882a593Smuzhiyun #endif
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun /*---------------------- Macros and type definitions ----------------------*/
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun #pragma pack(1)
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #define CRT_C   24		/* 24  CRT Controller Registers             */
61*4882a593Smuzhiyun #define ATT_C   21		/* 21  Attribute Controller Registers       */
62*4882a593Smuzhiyun #define GRA_C   9		/* 9   Graphics Controller Registers        */
63*4882a593Smuzhiyun #define SEQ_C   5		/* 5   Sequencer Registers                  */
64*4882a593Smuzhiyun #define PAL_C   768		/* 768 Palette Registers                    */
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /****************************************************************************
67*4882a593Smuzhiyun REMARKS:
68*4882a593Smuzhiyun Data structure used to describe the details for the BIOS emulator system
69*4882a593Smuzhiyun environment as used by the X86 emulator library.
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun HEADER:
72*4882a593Smuzhiyun biosemu.h
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun MEMBERS:
75*4882a593Smuzhiyun vgaInfo         - VGA BIOS information structure
76*4882a593Smuzhiyun biosmem_base    - Base of the BIOS image
77*4882a593Smuzhiyun biosmem_limit   - Limit of the BIOS image
78*4882a593Smuzhiyun busmem_base     - Base of the VGA bus memory
79*4882a593Smuzhiyun timer           - Timer used to emulate PC timer ports
80*4882a593Smuzhiyun timer0          - Latched value for timer 0
81*4882a593Smuzhiyun timer0Latched   - true if timer 0 value was just latched
82*4882a593Smuzhiyun timer2          - Current value for timer 2
83*4882a593Smuzhiyun emulateVGA      - true to emulate VGA I/O and memory accesses
84*4882a593Smuzhiyun ****************************************************************************/
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun typedef struct {
87*4882a593Smuzhiyun 	BE_VGAInfo vgaInfo;
88*4882a593Smuzhiyun 	ulong biosmem_base;
89*4882a593Smuzhiyun 	ulong biosmem_limit;
90*4882a593Smuzhiyun 	ulong busmem_base;
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun 	u32 timer0;
93*4882a593Smuzhiyun 	int timer0Latched;
94*4882a593Smuzhiyun 	u32 timer1;
95*4882a593Smuzhiyun 	int timer1Latched;
96*4882a593Smuzhiyun 	u32 timer2;
97*4882a593Smuzhiyun 	int timer2Latched;
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun 	int emulateVGA;
100*4882a593Smuzhiyun 	u8 emu61;
101*4882a593Smuzhiyun 	u8 emu70;
102*4882a593Smuzhiyun 	int flipFlop3C0;
103*4882a593Smuzhiyun 	u32 configAddress;
104*4882a593Smuzhiyun 	u8 emu3C0;
105*4882a593Smuzhiyun 	u8 emu3C1[ATT_C];
106*4882a593Smuzhiyun 	u8 emu3C2;
107*4882a593Smuzhiyun 	u8 emu3C4;
108*4882a593Smuzhiyun 	u8 emu3C5[SEQ_C];
109*4882a593Smuzhiyun 	u8 emu3C6;
110*4882a593Smuzhiyun 	uint emu3C7;
111*4882a593Smuzhiyun 	uint emu3C8;
112*4882a593Smuzhiyun 	u8 emu3C9[PAL_C];
113*4882a593Smuzhiyun 	u8 emu3CE;
114*4882a593Smuzhiyun 	u8 emu3CF[GRA_C];
115*4882a593Smuzhiyun 	u8 emu3D4;
116*4882a593Smuzhiyun 	u8 emu3D5[CRT_C];
117*4882a593Smuzhiyun 	u8 emu3DA;
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun } BE_sysEnv;
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun #ifdef __KERNEL__
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun /* Define some types when compiling for the Linux kernel that normally
124*4882a593Smuzhiyun  * come from the SciTech PM library.
125*4882a593Smuzhiyun  */
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun /****************************************************************************
128*4882a593Smuzhiyun REMARKS:
129*4882a593Smuzhiyun Structure describing the 32-bit extended x86 CPU registers
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun HEADER:
132*4882a593Smuzhiyun pmapi.h
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun MEMBERS:
135*4882a593Smuzhiyun eax     - Value of the EAX register
136*4882a593Smuzhiyun ebx     - Value of the EBX register
137*4882a593Smuzhiyun ecx     - Value of the ECX register
138*4882a593Smuzhiyun edx     - Value of the EDX register
139*4882a593Smuzhiyun esi     - Value of the ESI register
140*4882a593Smuzhiyun edi     - Value of the EDI register
141*4882a593Smuzhiyun cflag   - Value of the carry flag
142*4882a593Smuzhiyun ****************************************************************************/
143*4882a593Smuzhiyun typedef struct {
144*4882a593Smuzhiyun 	u32 eax;
145*4882a593Smuzhiyun 	u32 ebx;
146*4882a593Smuzhiyun 	u32 ecx;
147*4882a593Smuzhiyun 	u32 edx;
148*4882a593Smuzhiyun 	u32 esi;
149*4882a593Smuzhiyun 	u32 edi;
150*4882a593Smuzhiyun 	u32 cflag;
151*4882a593Smuzhiyun } RMDWORDREGS;
152*4882a593Smuzhiyun 
153*4882a593Smuzhiyun /****************************************************************************
154*4882a593Smuzhiyun REMARKS:
155*4882a593Smuzhiyun Structure describing the 16-bit x86 CPU registers
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun HEADER:
158*4882a593Smuzhiyun pmapi.h
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun MEMBERS:
161*4882a593Smuzhiyun ax      - Value of the AX register
162*4882a593Smuzhiyun bx      - Value of the BX register
163*4882a593Smuzhiyun cx      - Value of the CX register
164*4882a593Smuzhiyun dx      - Value of the DX register
165*4882a593Smuzhiyun si      - Value of the SI register
166*4882a593Smuzhiyun di      - Value of the DI register
167*4882a593Smuzhiyun cflag   - Value of the carry flag
168*4882a593Smuzhiyun ****************************************************************************/
169*4882a593Smuzhiyun #ifdef __BIG_ENDIAN__
170*4882a593Smuzhiyun typedef struct {
171*4882a593Smuzhiyun 	u16 ax_hi, ax;
172*4882a593Smuzhiyun 	u16 bx_hi, bx;
173*4882a593Smuzhiyun 	u16 cx_hi, cx;
174*4882a593Smuzhiyun 	u16 dx_hi, dx;
175*4882a593Smuzhiyun 	u16 si_hi, si;
176*4882a593Smuzhiyun 	u16 di_hi, di;
177*4882a593Smuzhiyun 	u16 cflag_hi, cflag;
178*4882a593Smuzhiyun } RMWORDREGS;
179*4882a593Smuzhiyun #else
180*4882a593Smuzhiyun typedef struct {
181*4882a593Smuzhiyun 	u16 ax, ax_hi;
182*4882a593Smuzhiyun 	u16 bx, bx_hi;
183*4882a593Smuzhiyun 	u16 cx, cx_hi;
184*4882a593Smuzhiyun 	u16 dx, dx_hi;
185*4882a593Smuzhiyun 	u16 si, si_hi;
186*4882a593Smuzhiyun 	u16 di, di_hi;
187*4882a593Smuzhiyun 	u16 cflag, cflag_hi;
188*4882a593Smuzhiyun } RMWORDREGS;
189*4882a593Smuzhiyun #endif
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun /****************************************************************************
192*4882a593Smuzhiyun REMARKS:
193*4882a593Smuzhiyun Structure describing the 8-bit x86 CPU registers
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun HEADER:
196*4882a593Smuzhiyun pmapi.h
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun MEMBERS:
199*4882a593Smuzhiyun al      - Value of the AL register
200*4882a593Smuzhiyun ah      - Value of the AH register
201*4882a593Smuzhiyun bl      - Value of the BL register
202*4882a593Smuzhiyun bh      - Value of the BH register
203*4882a593Smuzhiyun cl      - Value of the CL register
204*4882a593Smuzhiyun ch      - Value of the CH register
205*4882a593Smuzhiyun dl      - Value of the DL register
206*4882a593Smuzhiyun dh      - Value of the DH register
207*4882a593Smuzhiyun ****************************************************************************/
208*4882a593Smuzhiyun #ifdef __BIG_ENDIAN__
209*4882a593Smuzhiyun typedef struct {
210*4882a593Smuzhiyun 	u16 ax_hi;
211*4882a593Smuzhiyun 	u8 ah, al;
212*4882a593Smuzhiyun 	u16 bx_hi;
213*4882a593Smuzhiyun 	u8 bh, bl;
214*4882a593Smuzhiyun 	u16 cx_hi;
215*4882a593Smuzhiyun 	u8 ch, cl;
216*4882a593Smuzhiyun 	u16 dx_hi;
217*4882a593Smuzhiyun 	u8 dh, dl;
218*4882a593Smuzhiyun } RMBYTEREGS;
219*4882a593Smuzhiyun #else
220*4882a593Smuzhiyun typedef struct {
221*4882a593Smuzhiyun 	u8 al;
222*4882a593Smuzhiyun 	u8 ah;
223*4882a593Smuzhiyun 	u16 ax_hi;
224*4882a593Smuzhiyun 	u8 bl;
225*4882a593Smuzhiyun 	u8 bh;
226*4882a593Smuzhiyun 	u16 bx_hi;
227*4882a593Smuzhiyun 	u8 cl;
228*4882a593Smuzhiyun 	u8 ch;
229*4882a593Smuzhiyun 	u16 cx_hi;
230*4882a593Smuzhiyun 	u8 dl;
231*4882a593Smuzhiyun 	u8 dh;
232*4882a593Smuzhiyun 	u16 dx_hi;
233*4882a593Smuzhiyun } RMBYTEREGS;
234*4882a593Smuzhiyun #endif
235*4882a593Smuzhiyun 
236*4882a593Smuzhiyun /****************************************************************************
237*4882a593Smuzhiyun REMARKS:
238*4882a593Smuzhiyun Structure describing all the x86 CPU registers
239*4882a593Smuzhiyun 
240*4882a593Smuzhiyun HEADER:
241*4882a593Smuzhiyun pmapi.h
242*4882a593Smuzhiyun 
243*4882a593Smuzhiyun MEMBERS:
244*4882a593Smuzhiyun e   - Member to access registers as 32-bit values
245*4882a593Smuzhiyun x   - Member to access registers as 16-bit values
246*4882a593Smuzhiyun h   - Member to access registers as 8-bit values
247*4882a593Smuzhiyun ****************************************************************************/
248*4882a593Smuzhiyun typedef union {
249*4882a593Smuzhiyun 	RMDWORDREGS e;
250*4882a593Smuzhiyun 	RMWORDREGS x;
251*4882a593Smuzhiyun 	RMBYTEREGS h;
252*4882a593Smuzhiyun } RMREGS;
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun /****************************************************************************
255*4882a593Smuzhiyun REMARKS:
256*4882a593Smuzhiyun Structure describing all the x86 segment registers
257*4882a593Smuzhiyun 
258*4882a593Smuzhiyun HEADER:
259*4882a593Smuzhiyun pmapi.h
260*4882a593Smuzhiyun 
261*4882a593Smuzhiyun MEMBERS:
262*4882a593Smuzhiyun es  - ES segment register
263*4882a593Smuzhiyun cs  - CS segment register
264*4882a593Smuzhiyun ss  - SS segment register
265*4882a593Smuzhiyun ds  - DS segment register
266*4882a593Smuzhiyun fs  - FS segment register
267*4882a593Smuzhiyun gs  - GS segment register
268*4882a593Smuzhiyun ****************************************************************************/
269*4882a593Smuzhiyun typedef struct {
270*4882a593Smuzhiyun 	u16 es;
271*4882a593Smuzhiyun 	u16 cs;
272*4882a593Smuzhiyun 	u16 ss;
273*4882a593Smuzhiyun 	u16 ds;
274*4882a593Smuzhiyun 	u16 fs;
275*4882a593Smuzhiyun 	u16 gs;
276*4882a593Smuzhiyun } RMSREGS;
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun #endif				/* __KERNEL__ */
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun #ifndef __KERNEL__
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun /****************************************************************************
283*4882a593Smuzhiyun REMARKS:
284*4882a593Smuzhiyun Structure defining all the BIOS Emulator API functions as exported from
285*4882a593Smuzhiyun the Binary Portable DLL.
286*4882a593Smuzhiyun {secret}
287*4882a593Smuzhiyun ****************************************************************************/
288*4882a593Smuzhiyun typedef struct {
289*4882a593Smuzhiyun 	ulong dwSize;
290*4882a593Smuzhiyun 	 ibool(PMAPIP BE_init) (u32 debugFlags, int memSize, BE_VGAInfo * info);
291*4882a593Smuzhiyun 	void (PMAPIP BE_setVGA) (BE_VGAInfo * info);
292*4882a593Smuzhiyun 	void (PMAPIP BE_getVGA) (BE_VGAInfo * info);
293*4882a593Smuzhiyun 	void *(PMAPIP BE_mapRealPointer) (uint r_seg, uint r_off);
294*4882a593Smuzhiyun 	void *(PMAPIP BE_getVESABuf) (uint * len, uint * rseg, uint * roff);
295*4882a593Smuzhiyun 	void (PMAPIP BE_callRealMode) (uint seg, uint off, RMREGS * regs,
296*4882a593Smuzhiyun 				       RMSREGS * sregs);
297*4882a593Smuzhiyun 	int (PMAPIP BE_int86) (int intno, RMREGS * in, RMREGS * out);
298*4882a593Smuzhiyun 	int (PMAPIP BE_int86x) (int intno, RMREGS * in, RMREGS * out,
299*4882a593Smuzhiyun 				RMSREGS * sregs);
300*4882a593Smuzhiyun 	void *reserved1;
301*4882a593Smuzhiyun 	void (PMAPIP BE_exit) (void);
302*4882a593Smuzhiyun } BE_exports;
303*4882a593Smuzhiyun 
304*4882a593Smuzhiyun /****************************************************************************
305*4882a593Smuzhiyun REMARKS:
306*4882a593Smuzhiyun Function pointer type for the Binary Portable DLL initialisation entry point.
307*4882a593Smuzhiyun {secret}
308*4882a593Smuzhiyun ****************************************************************************/
309*4882a593Smuzhiyun typedef BE_exports *(PMAPIP BE_initLibrary_t) (PM_imports * PMImp);
310*4882a593Smuzhiyun #endif
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun #pragma pack()
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun /*---------------------------- Global variables ---------------------------*/
315*4882a593Smuzhiyun 
316*4882a593Smuzhiyun #ifdef  __cplusplus
317*4882a593Smuzhiyun extern "C" {			/* Use "C" linkage when in C++ mode */
318*4882a593Smuzhiyun #endif
319*4882a593Smuzhiyun 
320*4882a593Smuzhiyun /* {secret} Global BIOS emulator system environment */
321*4882a593Smuzhiyun 	extern BE_sysEnv _BE_env;
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun /*-------------------------- Function Prototypes --------------------------*/
324*4882a593Smuzhiyun 
325*4882a593Smuzhiyun /* BIOS emulator library entry points */
326*4882a593Smuzhiyun 	int X86API BE_init(u32 debugFlags, int memSize, BE_VGAInfo * info,
327*4882a593Smuzhiyun 			   int shared);
328*4882a593Smuzhiyun 	void X86API BE_setVGA(BE_VGAInfo * info);
329*4882a593Smuzhiyun 	void X86API BE_getVGA(BE_VGAInfo * info);
330*4882a593Smuzhiyun 	void X86API BE_setDebugFlags(u32 debugFlags);
331*4882a593Smuzhiyun 	void *X86API BE_mapRealPointer(uint r_seg, uint r_off);
332*4882a593Smuzhiyun 	void *X86API BE_getVESABuf(uint * len, uint * rseg, uint * roff);
333*4882a593Smuzhiyun 	void X86API BE_callRealMode(uint seg, uint off, RMREGS * regs,
334*4882a593Smuzhiyun 				    RMSREGS * sregs);
335*4882a593Smuzhiyun 	int X86API BE_int86(int intno, RMREGS * in, RMREGS * out);
336*4882a593Smuzhiyun 	int X86API BE_int86x(int intno, RMREGS * in, RMREGS * out,
337*4882a593Smuzhiyun 			     RMSREGS * sregs);
338*4882a593Smuzhiyun 	void X86API BE_exit(void);
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun #ifdef  __cplusplus
341*4882a593Smuzhiyun }				/* End of "C" linkage for C++       */
342*4882a593Smuzhiyun #endif
343*4882a593Smuzhiyun #endif				/* __BIOSEMU_H */
344