Coding style cleanup
[platform/kernel/u-boot.git] / board / MAI / bios_emulator / scitech / src / pm / ntdrv / _pm.asm
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:    80386 Assembler, TASM 4.0 or NASM
25 ;* Environment: 32-bit Windows NT device driver
26 ;*
27 ;* Description: Low level assembly support for the PM library specific to
28 ;*              Windows NT device drivers.
29 ;*
30 ;****************************************************************************
31
32         IDEAL
33
34 include "scitech.mac"               ; Memory model macros
35
36 header      _pm                     ; Set up memory model
37
38 P586
39
40 begdataseg
41
42 ; Watcom C++ externals required to link when compiling floating point
43 ; C code. They are not actually used in the code because we compile with
44 ; inline floating point instructions, however the compiler still generates
45 ; the references in the object modules.
46
47 __8087      dd  0
48             PUBLIC  __8087
49 __imthread:
50 __fltused:
51 _fltused_   dd  0
52             PUBLIC  __imthread
53             PUBLIC  _fltused_
54             PUBLIC  __fltused
55
56 enddataseg
57
58 begcodeseg  _pm                 ; Start of code segment
59
60 ;----------------------------------------------------------------------------
61 ; void PM_segread(PMSREGS *sregs)
62 ;----------------------------------------------------------------------------
63 ; Read the current value of all segment registers
64 ;----------------------------------------------------------------------------
65 cprocstart  PM_segread
66
67         ARG     sregs:DPTR
68
69         enter_c
70
71         mov     ax,es
72         _les    _si,[sregs]
73         mov     [_ES _si],ax
74         mov     [_ES _si+2],cs
75         mov     [_ES _si+4],ss
76         mov     [_ES _si+6],ds
77         mov     [_ES _si+8],fs
78         mov     [_ES _si+10],gs
79
80         leave_c
81         ret
82
83 cprocend
84
85 ;----------------------------------------------------------------------------
86 ; int PM_int386x(int intno, PMREGS *in, PMREGS *out,PMSREGS *sregs)
87 ;----------------------------------------------------------------------------
88 ; Issues a software interrupt in protected mode. This routine has been
89 ; written to allow user programs to load CS and DS with different values
90 ; other than the default.
91 ;----------------------------------------------------------------------------
92 cprocstart  PM_int386x
93
94 ; Not used for NT device drivers
95
96         ret
97
98 cprocend
99
100 ;----------------------------------------------------------------------------
101 ; void PM_setBankA(int bank)
102 ;----------------------------------------------------------------------------
103 cprocstart      PM_setBankA
104
105 ; Not used for NT device drivers
106
107         ret
108
109 cprocend
110
111 ;----------------------------------------------------------------------------
112 ; void PM_setBankAB(int bank)
113 ;----------------------------------------------------------------------------
114 cprocstart      PM_setBankAB
115
116 ; Not used for NT device drivers
117
118         ret
119
120 cprocend
121
122 ;----------------------------------------------------------------------------
123 ; void PM_setCRTStart(int x,int y,int waitVRT)
124 ;----------------------------------------------------------------------------
125 cprocstart      PM_setCRTStart
126
127 ; Not used for NT device drivers
128
129         ret
130
131 cprocend
132
133 ; Macro to delay briefly to ensure that enough time has elapsed between
134 ; successive I/O accesses so that the device being accessed can respond
135 ; to both accesses even on a very fast PC.
136
137 ifdef   USE_NASM
138 %macro  DELAY 0
139         jmp     short $+2
140         jmp     short $+2
141         jmp     short $+2
142 %endmacro
143 %macro  IODELAYN 1
144 %rep    %1
145         DELAY
146 %endrep
147 %endmacro
148 else
149 macro   DELAY
150         jmp     short $+2
151         jmp     short $+2
152         jmp     short $+2
153 endm
154 macro   IODELAYN    N
155     rept    N
156         DELAY
157     endm
158 endm
159 endif
160
161 ;----------------------------------------------------------------------------
162 ; uchar _PM_readCMOS(int index)
163 ;----------------------------------------------------------------------------
164 ; Read the value of a specific CMOS register. We do this with both
165 ; normal interrupts and NMI disabled.
166 ;----------------------------------------------------------------------------
167 cprocstart  _PM_readCMOS
168
169         ARG     index:UINT
170
171         push    _bp
172         mov     _bp,_sp
173         pushfd
174         mov     al,[BYTE index]
175         or      al,80h              ; Add disable NMI flag
176         cli
177         out     70h,al
178         IODELAYN 5
179         in      al,71h
180         mov     ah,al
181         xor     al,al
182         IODELAYN 5
183         out     70h,al              ; Re-enable NMI
184         mov     al,ah               ; Return value in AL
185         popfd
186         pop     _bp
187         ret
188
189 cprocend
190
191 ;----------------------------------------------------------------------------
192 ; void _PM_writeCMOS(int index,uchar value)
193 ;----------------------------------------------------------------------------
194 ; Read the value of a specific CMOS register. We do this with both
195 ; normal interrupts and NMI disabled.
196 ;----------------------------------------------------------------------------
197 cprocstart  _PM_writeCMOS
198
199         ARG     index:UINT, value:UCHAR
200
201         push    _bp
202         mov     _bp,_sp
203         pushfd
204         mov     al,[BYTE index]
205         or      al,80h              ; Add disable NMI flag
206         cli
207         out     70h,al
208         IODELAYN 5
209         mov     al,[value]
210         out     71h,al
211         xor     al,al
212         IODELAYN 5
213         out     70h,al              ; Re-enable NMI
214         popfd
215         pop     _bp
216         ret
217
218 cprocend
219
220 ;----------------------------------------------------------------------------
221 ; double _ftol(double f)
222 ;----------------------------------------------------------------------------
223 ; Calls to __ftol are generated by the Borland C++ compiler for code
224 ; that needs to convert a floating point type to an integral type.
225 ;
226 ; Input: floating point number on the top of the '87.
227 ;
228 ; Output: a (signed or unsigned) long in EAX
229 ; All other registers preserved.
230 ;-----------------------------------------------------------------------
231 cprocstart  _ftol
232
233         LOCAL   temp1:WORD, temp2:QWORD = LocalSize
234
235         push    ebp
236         mov     ebp,esp
237         sub     esp,LocalSize
238
239         fstcw   [temp1]                 ; save the control word
240         fwait
241         mov     al,[BYTE temp1+1]
242         or      [BYTE temp1+1],0Ch      ; set rounding control to chop
243         fldcw   [temp1]
244         fistp   [temp2]                 ; convert to 64-bit integer
245         mov     [BYTE temp1+1],al
246         fldcw   [temp1]                 ; restore the control word
247         mov     eax,[DWORD temp2]       ; return LS 32 bits
248         mov     edx,[DWORD temp2+4]     ;        MS 32 bits
249
250         mov     esp,ebp
251         pop     ebp
252         ret
253
254 cprocend
255
256 ;----------------------------------------------------------------------------
257 ; _PM_getPDB - Return the Page Table Directory Base address
258 ;----------------------------------------------------------------------------
259 cprocstart  _PM_getPDB
260
261         mov     eax,cr3
262         and     eax,0FFFFF000h
263         ret
264
265 cprocend
266
267 ;----------------------------------------------------------------------------
268 ; Flush the Translation Lookaside buffer
269 ;----------------------------------------------------------------------------
270 cprocstart  PM_flushTLB
271
272         wbinvd                  ; Flush the CPU cache
273         mov     eax,cr3
274         mov     cr3,eax         ; Flush the TLB
275         ret
276
277 cprocend
278
279 endcodeseg  _pm
280
281         END                     ; End of module