Import upstream u-boot 1.1.4
[u-boot.git] / board / MAI / bios_emulator / scitech / src / pm / ntdrv / int86.c
1 /****************************************************************************
2 *
3 *                   SciTech OS Portability Manager Library
4 *
5 *  ========================================================================
6 *
7 *    The contents of this file are subject to the SciTech MGL Public
8 *    License Version 1.0 (the "License"); you may not use this file
9 *    except in compliance with the License. You may obtain a copy of
10 *    the License at http://www.scitechsoft.com/mgl-license.txt
11 *
12 *    Software distributed under the License is distributed on an
13 *    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 *    implied. See the License for the specific language governing
15 *    rights and limitations under the License.
16 *
17 *    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18 *
19 *    The Initial Developer of the Original Code is SciTech Software, Inc.
20 *    All Rights Reserved.
21 *
22 *  ========================================================================
23 *
24 * Language:     ANSI C
25 * Environment:  32-bit Windows NT device drivers.
26 *
27 * Description:  Implementation for the real mode software interrupt
28 *               handling functions.
29 *
30 ****************************************************************************/
31
32 #include "pmapi.h"
33 #include "drvlib/os/os.h"
34 #include "sdd/sddhelp.h"
35 #include "mtrr.h"
36 #include "oshdr.h"
37
38 /*----------------------------- Implementation ----------------------------*/
39
40 /****************************************************************************
41 REMARKS:
42 We do have limited BIOS access under Windows NT device drivers.
43 ****************************************************************************/
44 ibool PMAPI PM_haveBIOSAccess(void)
45 {
46     /* Return false unless we have full buffer passing! */
47     return false;
48 }
49
50 /****************************************************************************
51 PARAMETERS:
52 len     - Place to store the length of the buffer
53 rseg    - Place to store the real mode segment of the buffer
54 roff    - Place to store the real mode offset of the buffer
55
56 REMARKS:
57 This function returns the address and length of the global VESA transfer
58 buffer that is used for communicating with the VESA BIOS functions from
59 Win16 and Win32 programs under Windows.
60 ****************************************************************************/
61 void * PMAPI PM_getVESABuf(
62     uint *len,
63     uint *rseg,
64     uint *roff)
65 {
66     /* No buffers supported under Windows NT (Windows XP has them however if */
67     /* we ever decide to support this!) */
68     return NULL;
69 }
70
71 /****************************************************************************
72 REMARKS:
73 Issue a protected mode software interrupt.
74 ****************************************************************************/
75 int PMAPI PM_int386(
76     int intno,
77     PMREGS *in,
78     PMREGS *out)
79 {
80     PMSREGS sregs;
81     PM_segread(&sregs);
82     return PM_int386x(intno,in,out,&sregs);
83 }
84
85 /****************************************************************************
86 REMARKS:
87 Map a real mode pointer to a protected mode pointer.
88 ****************************************************************************/
89 void * PMAPI PM_mapRealPointer(
90     uint r_seg,
91     uint r_off)
92 {
93     /* Not used for Windows NT drivers! */
94     return NULL;
95 }
96
97 /****************************************************************************
98 REMARKS:
99 Allocate a block of real mode memory
100 ****************************************************************************/
101 void * PMAPI PM_allocRealSeg(
102     uint size,
103     uint *r_seg,
104     uint *r_off)
105 {
106     /* Not supported in NT drivers */
107     (void)size;
108     (void)r_seg;
109     (void)r_off;
110     return NULL;
111 }
112
113 /****************************************************************************
114 REMARKS:
115 Free a block of real mode memory.
116 ****************************************************************************/
117 void PMAPI PM_freeRealSeg(
118     void *mem)
119 {
120     /* Not supported in NT drivers */
121     (void)mem;
122 }
123
124 /****************************************************************************
125 REMARKS:
126 Issue a real mode interrupt (parameters in DPMI compatible structure)
127 ****************************************************************************/
128 void PMAPI DPMI_int86(
129     int intno,
130     DPMI_regs *regs)
131 {
132     /* Not used in NT drivers */
133 }
134
135 /****************************************************************************
136 REMARKS:
137 Call a V86 real mode function with the specified register values
138 loaded before the call. The call returns with a far ret.
139 ****************************************************************************/
140 void PMAPI PM_callRealMode(
141     uint seg,
142     uint off,
143     RMREGS *regs,
144     RMSREGS *sregs)
145 {
146     /* TODO!! */
147 #if 0
148     CLIENT_STRUCT saveRegs;
149
150     /* Bail if we do not have BIOS access (ie: the VxD was dynamically
151      * loaded, and not statically loaded.
152      */
153     if (!_PM_haveBIOS)
154         return;
155
156     TRACE("SDDHELP: Entering PM_callRealMode()\n");
157     Begin_Nest_V86_Exec();
158     LoadV86Registers(&saveRegs,regs,sregs);
159     Simulate_Far_Call(seg, off);
160     Resume_Exec();
161     ReadV86Registers(&saveRegs,regs,sregs);
162     End_Nest_Exec();
163     TRACE("SDDHELP: Exiting PM_callRealMode()\n");
164 #endif
165 }
166
167 /****************************************************************************
168 REMARKS:
169 Issue a V86 real mode interrupt with the specified register values
170 loaded before the interrupt.
171 ****************************************************************************/
172 int PMAPI PM_int86(
173     int intno,
174     RMREGS *in,
175     RMREGS *out)
176 {
177     /* TODO!! */
178 #if 0
179     RMSREGS         sregs = {0};
180     CLIENT_STRUCT   saveRegs;
181     ushort          oldDisable;
182
183     /* Disable pass-up to our VxD handler so we directly call BIOS */
184     TRACE("SDDHELP: Entering PM_int86()\n");
185     if (disableTSRFlag) {
186         oldDisable = *disableTSRFlag;
187         *disableTSRFlag = 0;
188         }
189     Begin_Nest_V86_Exec();
190     LoadV86Registers(&saveRegs,in,&sregs);
191     Exec_Int(intno);
192     ReadV86Registers(&saveRegs,out,&sregs);
193     End_Nest_Exec();
194
195     /* Re-enable pass-up to our VxD handler if previously enabled */
196     if (disableTSRFlag)
197         *disableTSRFlag = oldDisable;
198
199     TRACE("SDDHELP: Exiting PM_int86()\n");
200 #else
201     *out = *in;
202 #endif
203     return out->x.ax;
204 }
205
206 /****************************************************************************
207 REMARKS:
208 Issue a V86 real mode interrupt with the specified register values
209 loaded before the interrupt.
210 ****************************************************************************/
211 int PMAPI PM_int86x(
212     int intno,
213     RMREGS *in,
214     RMREGS *out,
215     RMSREGS *sregs)
216 {
217     /* TODO!! */
218 #if 0
219     CLIENT_STRUCT   saveRegs;
220     ushort          oldDisable;
221
222     /* Bail if we do not have BIOS access (ie: the VxD was dynamically
223      * loaded, and not statically loaded.
224      */
225     if (!_PM_haveBIOS) {
226         *out = *in;
227         return out->x.ax;
228         }
229
230     /* Disable pass-up to our VxD handler so we directly call BIOS */
231     TRACE("SDDHELP: Entering PM_int86x()\n");
232     if (disableTSRFlag) {
233         oldDisable = *disableTSRFlag;
234         *disableTSRFlag = 0;
235         }
236     Begin_Nest_V86_Exec();
237     LoadV86Registers(&saveRegs,in,sregs);
238     Exec_Int(intno);
239     ReadV86Registers(&saveRegs,out,sregs);
240     End_Nest_Exec();
241
242     /* Re-enable pass-up to our VxD handler if previously enabled */
243     if (disableTSRFlag)
244         *disableTSRFlag = oldDisable;
245
246     TRACE("SDDHELP: Exiting PM_int86x()\n");
247 #else
248     *out = *in;
249 #endif
250     return out->x.ax;
251 }