1 | ; $Id: timerA-r0drv-os2.asm 96407 2022-08-22 17:43:14Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; IPRT - DevHelp_VMGlobalToProcess, Ring-0 Driver, OS/2.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Contributed by knut st. osmundsen.
|
---|
8 | ;
|
---|
9 | ; Copyright (C) 2007-2022 Oracle and/or its affiliates.
|
---|
10 | ;
|
---|
11 | ; This file is part of VirtualBox base platform packages, as
|
---|
12 | ; available from https://www.virtualbox.org.
|
---|
13 | ;
|
---|
14 | ; This program is free software; you can redistribute it and/or
|
---|
15 | ; modify it under the terms of the GNU General Public License
|
---|
16 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
17 | ; License.
|
---|
18 | ;
|
---|
19 | ; This program is distributed in the hope that it will be useful, but
|
---|
20 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | ; General Public License for more details.
|
---|
23 | ;
|
---|
24 | ; You should have received a copy of the GNU General Public License
|
---|
25 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | ;
|
---|
27 | ; The contents of this file may alternatively be used under the terms
|
---|
28 | ; of the Common Development and Distribution License Version 1.0
|
---|
29 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
30 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
31 | ; CDDL are applicable instead of those of the GPL.
|
---|
32 | ;
|
---|
33 | ; You may elect to license modified versions of this file under the
|
---|
34 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
35 | ;
|
---|
36 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
37 | ; --------------------------------------------------------------------
|
---|
38 | ;
|
---|
39 | ; This code is based on:
|
---|
40 | ;
|
---|
41 | ; Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
42 | ;
|
---|
43 | ; Permission is hereby granted, free of charge, to any person
|
---|
44 | ; obtaining a copy of this software and associated documentation
|
---|
45 | ; files (the "Software"), to deal in the Software without
|
---|
46 | ; restriction, including without limitation the rights to use,
|
---|
47 | ; copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
48 | ; copies of the Software, and to permit persons to whom the
|
---|
49 | ; Software is furnished to do so, subject to the following
|
---|
50 | ; conditions:
|
---|
51 | ;
|
---|
52 | ; The above copyright notice and this permission notice shall be
|
---|
53 | ; included in all copies or substantial portions of the Software.
|
---|
54 | ;
|
---|
55 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
56 | ; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
57 | ; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
58 | ; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
59 | ; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
60 | ; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
61 | ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
62 | ; OTHER DEALINGS IN THE SOFTWARE.
|
---|
63 | ;
|
---|
64 |
|
---|
65 |
|
---|
66 | ;*******************************************************************************
|
---|
67 | ;* Header Files *
|
---|
68 | ;*******************************************************************************
|
---|
69 | %define RT_INCL_16BIT_SEGMENTS
|
---|
70 | %include "iprt/asmdefs.mac"
|
---|
71 | %include "iprt/err.mac"
|
---|
72 |
|
---|
73 |
|
---|
74 | ;*******************************************************************************
|
---|
75 | ;* External Symbols *
|
---|
76 | ;*******************************************************************************
|
---|
77 | extern KernThunkStackTo32
|
---|
78 | extern KernThunkStackTo16
|
---|
79 | extern NAME(rtTimerOs2Tick)
|
---|
80 | extern NAME(RTErrConvertFromOS2)
|
---|
81 | BEGINDATA16
|
---|
82 | extern NAME(g_fpfnDevHlp)
|
---|
83 |
|
---|
84 |
|
---|
85 | ;*******************************************************************************
|
---|
86 | ;* Defined Constants And Macros *
|
---|
87 | ;*******************************************************************************
|
---|
88 | %define DevHlp_SetTimer 01dh
|
---|
89 | %define DevHlp_ResetTimer 01eh
|
---|
90 |
|
---|
91 |
|
---|
92 | BEGINCODE
|
---|
93 |
|
---|
94 | ;;
|
---|
95 | ; Arms the our OS/2 timer.
|
---|
96 | ;
|
---|
97 | ; @returns IPRT status code.
|
---|
98 | ;
|
---|
99 | BEGINPROC_EXPORTED rtTimerOs2Arm
|
---|
100 | call KernThunkStackTo16
|
---|
101 | push ebp
|
---|
102 | mov ebp, esp
|
---|
103 |
|
---|
104 | ; jump to the 16-bit code.
|
---|
105 | ;jmp far dword NAME(rtTimerOs2Arm_16) wrt CODE16
|
---|
106 | db 066h
|
---|
107 | db 0eah
|
---|
108 | dw NAME(rtTimerOs2Arm_16) wrt CODE16
|
---|
109 | dw CODE16
|
---|
110 | BEGINCODE16
|
---|
111 | GLOBALNAME rtTimerOs2Arm_16
|
---|
112 |
|
---|
113 | ; setup and do the call
|
---|
114 | push ds
|
---|
115 | push es
|
---|
116 | mov dx, DATA16
|
---|
117 | mov ds, dx
|
---|
118 | mov es, dx
|
---|
119 |
|
---|
120 | mov ax, NAME(rtTimerOs2TickAsm) wrt CODE16
|
---|
121 | mov dl, DevHlp_SetTimer
|
---|
122 | call far [NAME(g_fpfnDevHlp)]
|
---|
123 |
|
---|
124 | pop es
|
---|
125 | pop ds
|
---|
126 |
|
---|
127 | ;jmp far dword NAME(rtTimerOs2Arm_32) wrt FLAT
|
---|
128 | db 066h
|
---|
129 | db 0eah
|
---|
130 | dd NAME(rtTimerOs2Arm_32) ;wrt FLAT
|
---|
131 | dw TEXT32 wrt FLAT
|
---|
132 | BEGINCODE
|
---|
133 | GLOBALNAME rtTimerOs2Arm_32
|
---|
134 | jc .error
|
---|
135 | xor eax, eax
|
---|
136 | .done:
|
---|
137 |
|
---|
138 | leave
|
---|
139 | push eax
|
---|
140 | call KernThunkStackTo32
|
---|
141 | pop eax
|
---|
142 | ret
|
---|
143 |
|
---|
144 | ; convert the error code.
|
---|
145 | .error:
|
---|
146 | and eax, 0ffffh
|
---|
147 | call NAME(RTErrConvertFromOS2)
|
---|
148 | jmp .done
|
---|
149 | ENDPROC rtTimerOs2Arm
|
---|
150 |
|
---|
151 |
|
---|
152 | ;;
|
---|
153 | ; Dearms the our OS/2 timer.
|
---|
154 | ;
|
---|
155 | ; @returns IPRT status code.
|
---|
156 | ;
|
---|
157 | BEGINPROC_EXPORTED rtTimerOs2Dearm
|
---|
158 | call KernThunkStackTo16
|
---|
159 | push ebp
|
---|
160 | mov ebp, esp
|
---|
161 |
|
---|
162 | ; jump to the 16-bit code.
|
---|
163 | ;jmp far dword NAME(rtTimerOs2Dearm_16) wrt CODE16
|
---|
164 | db 066h
|
---|
165 | db 0eah
|
---|
166 | dw NAME(rtTimerOs2Dearm_16) wrt CODE16
|
---|
167 | dw CODE16
|
---|
168 | BEGINCODE16
|
---|
169 | GLOBALNAME rtTimerOs2Dearm_16
|
---|
170 |
|
---|
171 | ; setup and do the call
|
---|
172 | push ds
|
---|
173 | push es
|
---|
174 | mov dx, DATA16
|
---|
175 | mov ds, dx
|
---|
176 | mov es, dx
|
---|
177 |
|
---|
178 | mov ax, NAME(rtTimerOs2TickAsm) wrt CODE16
|
---|
179 | mov dl, DevHlp_ResetTimer
|
---|
180 | call far [NAME(g_fpfnDevHlp)]
|
---|
181 |
|
---|
182 | pop es
|
---|
183 | pop ds
|
---|
184 |
|
---|
185 | ;jmp far dword NAME(rtTimerOs2Dearm_32) wrt FLAT
|
---|
186 | db 066h
|
---|
187 | db 0eah
|
---|
188 | dd NAME(rtTimerOs2Dearm_32) ;wrt FLAT
|
---|
189 | dw TEXT32 wrt FLAT
|
---|
190 | BEGINCODE
|
---|
191 | GLOBALNAME rtTimerOs2Dearm_32
|
---|
192 | jc .error
|
---|
193 | xor eax, eax
|
---|
194 | .done:
|
---|
195 |
|
---|
196 | ; epilogue
|
---|
197 | leave
|
---|
198 | push eax
|
---|
199 | call KernThunkStackTo32
|
---|
200 | pop eax
|
---|
201 | ret
|
---|
202 |
|
---|
203 | ; convert the error code.
|
---|
204 | .error:
|
---|
205 | and eax, 0ffffh
|
---|
206 | call NAME(RTErrConvertFromOS2)
|
---|
207 | jmp .done
|
---|
208 | ENDPROC rtTimerOs2Dearm
|
---|
209 |
|
---|
210 |
|
---|
211 | BEGINCODE16
|
---|
212 |
|
---|
213 | ;;
|
---|
214 | ; OS/2 timer tick callback.
|
---|
215 | ;
|
---|
216 | BEGINPROC rtTimerOs2TickAsm
|
---|
217 | push ds
|
---|
218 | push es
|
---|
219 | push ecx
|
---|
220 | push edx
|
---|
221 | push eax
|
---|
222 |
|
---|
223 | mov ax, DATA32 wrt FLAT
|
---|
224 | mov ds, ax
|
---|
225 | mov es, ax
|
---|
226 |
|
---|
227 | ;jmp far dword NAME(rtTimerOs2TickAsm_32) wrt FLAT
|
---|
228 | db 066h
|
---|
229 | db 0eah
|
---|
230 | dd NAME(rtTimerOs2TickAsm_32) ;wrt FLAT
|
---|
231 | dw TEXT32 wrt FLAT
|
---|
232 | BEGINCODE
|
---|
233 | GLOBALNAME rtTimerOs2TickAsm_32
|
---|
234 | call KernThunkStackTo32
|
---|
235 | call NAME(rtTimerOs2Tick)
|
---|
236 | call KernThunkStackTo16
|
---|
237 |
|
---|
238 | ;jmp far dword NAME(rtTimerOs2TickAsm_16) wrt CODE16
|
---|
239 | db 066h
|
---|
240 | db 0eah
|
---|
241 | dw NAME(rtTimerOs2TickAsm_16) wrt CODE16
|
---|
242 | dw CODE16
|
---|
243 | BEGINCODE16
|
---|
244 | GLOBALNAME rtTimerOs2TickAsm_16
|
---|
245 |
|
---|
246 | pop eax
|
---|
247 | pop edx
|
---|
248 | pop ecx
|
---|
249 | pop es
|
---|
250 | pop ds
|
---|
251 | retf
|
---|
252 | ENDPROC rtTimerOs2TickAsm
|
---|