1 ;****************************************************************************
3 ;* SciTech OS Portability Manager Library
5 ;* ========================================================================
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
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.
17 ;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 ;* The Initial Developer of the Original Code is SciTech Software, Inc.
20 ;* All Rights Reserved.
22 ;* ========================================================================
24 ;* Language: 80386 Assembler, TASM 4.0 or NASM
25 ;* Environment: 32-bit Windows NT device driver
27 ;* Description: Low level assembly support for the PM library specific to
28 ;* Windows NT device drivers.
30 ;****************************************************************************
34 include "scitech.mac" ; Memory model macros
36 header _pm ; Set up memory model
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.
58 begcodeseg _pm ; Start of code segment
60 ;----------------------------------------------------------------------------
61 ; void PM_segread(PMSREGS *sregs)
62 ;----------------------------------------------------------------------------
63 ; Read the current value of all segment registers
64 ;----------------------------------------------------------------------------
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 ;----------------------------------------------------------------------------
94 ; Not used for NT device drivers
100 ;----------------------------------------------------------------------------
101 ; void PM_setBankA(int bank)
102 ;----------------------------------------------------------------------------
103 cprocstart PM_setBankA
105 ; Not used for NT device drivers
111 ;----------------------------------------------------------------------------
112 ; void PM_setBankAB(int bank)
113 ;----------------------------------------------------------------------------
114 cprocstart PM_setBankAB
116 ; Not used for NT device drivers
122 ;----------------------------------------------------------------------------
123 ; void PM_setCRTStart(int x,int y,int waitVRT)
124 ;----------------------------------------------------------------------------
125 cprocstart PM_setCRTStart
127 ; Not used for NT device drivers
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.
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
175 or al,80h ; Add disable NMI flag
183 out 70h,al ; Re-enable NMI
184 mov al,ah ; Return value in AL
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
199 ARG index:UINT, value:UCHAR
205 or al,80h ; Add disable NMI flag
213 out 70h,al ; Re-enable NMI
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.
226 ; Input: floating point number on the top of the '87.
228 ; Output: a (signed or unsigned) long in EAX
229 ; All other registers preserved.
230 ;-----------------------------------------------------------------------
233 LOCAL temp1:WORD, temp2:QWORD = LocalSize
239 fstcw [temp1] ; save the control word
241 mov al,[BYTE temp1+1]
242 or [BYTE temp1+1],0Ch ; set rounding control to chop
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
256 ;----------------------------------------------------------------------------
257 ; _PM_getPDB - Return the Page Table Directory Base address
258 ;----------------------------------------------------------------------------
259 cprocstart _PM_getPDB
267 ;----------------------------------------------------------------------------
268 ; Flush the Translation Lookaside buffer
269 ;----------------------------------------------------------------------------
270 cprocstart PM_flushTLB
272 wbinvd ; Flush the CPU cache
274 mov cr3,eax ; Flush the TLB