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 ;* ========================================================================
27 ;* Description: Assembler support routines for the Memory Type Range Register
28 ;* (MTRR) module for QNX.
30 ;****************************************************************************
34 include "scitech.mac" ; Memory model macros
36 header _mtrrqnx ; Set up memory model
38 begdataseg _mtrrqnx ; Start of code segment
41 %define R0_FLUSH_TLB 0
43 %define R0_RESTORE_CR4 2
45 %define R0_WRITE_MSR 4
60 enddataseg _mtrrqnx ; Start of code segment
62 begcodeseg _mtrrqnx ; Start of code segment
66 ;----------------------------------------------------------------------------
67 ; ulong _MTRR_disableInt(void);
68 ;----------------------------------------------------------------------------
69 ; Return processor interrupt status and disable interrupts.
70 ;----------------------------------------------------------------------------
71 cprocstart _MTRR_disableInt
73 pushfd ; Put flag word on stack
74 ; cli ; Disable interrupts!
75 pop eax ; deposit flag word in return register
80 ;----------------------------------------------------------------------------
81 ; void _MTRR_restoreInt(ulong ps);
82 ;----------------------------------------------------------------------------
83 ; Restore processor interrupt status.
84 ;----------------------------------------------------------------------------
85 cprocstart _MTRR_restoreInt
90 mov ebp,esp ; Set up stack frame
92 popfd ; Restore processor status (and interrupts)
98 ;----------------------------------------------------------------------------
99 ; uchar _MTRR_getCx86(uchar reg);
100 ;----------------------------------------------------------------------------
101 ; Read a Cyrix CPU indexed register
102 ;----------------------------------------------------------------------------
103 cprocstart _MTRR_getCx86
116 ;----------------------------------------------------------------------------
117 ; uchar _MTRR_setCx86(uchar reg,uchar val);
118 ;----------------------------------------------------------------------------
119 ; Write a Cyrix CPU indexed register
120 ;----------------------------------------------------------------------------
121 cprocstart _MTRR_setCx86
123 ARG reg:UCHAR, val:UCHAR
135 ;----------------------------------------------------------------------------
136 ; ulong _PM_ring0_isr(void);
137 ;----------------------------------------------------------------------------
138 ; Ring 0 clock interrupt handler that we use to execute the MTRR support
140 ;----------------------------------------------------------------------------
141 cprocnear _PM_ring0_isr
143 ;--------------------------------------------------------
144 ; void PM_flushTLB(void);
145 ;--------------------------------------------------------
147 cmp [DWORD _PM_R0_service],R0_FLUSH_TLB
149 wbinvd ; Flush the CPU cache
151 mov cr3,eax ; Flush the TLB
154 ;--------------------------------------------------------
155 ; ulong _MTRR_saveCR4(void);
156 ;--------------------------------------------------------
157 @@1: cmp [DWORD _PM_R0_service],R0_SAVE_CR4
160 ; Save value of CR4 and clear Page Global Enable (bit 7)
167 ; Disable and flush caches
175 ; Return value from CR4
180 ;--------------------------------------------------------
181 ; void _MTRR_restoreCR4(ulong cr4Val)
182 ;--------------------------------------------------------
183 @@2: cmp [DWORD _PM_R0_service],R0_RESTORE_CR4
193 ;--------------------------------------------------------
194 ; void _MTRR_readMSR(int reg, ulong FAR *eax, ulong FAR *edx);
195 ;--------------------------------------------------------
196 @@3: cmp [DWORD _PM_R0_service],R0_READ_MSR
205 ;--------------------------------------------------------
206 ; void _MTRR_writeMSR(int reg, ulong eax, ulong edx);
207 ;--------------------------------------------------------
208 @@4: cmp [DWORD _PM_R0_service],R0_WRITE_MSR
217 @@Exit: mov [DWORD _PM_R0_service],-1