1 | ; $Id: RTR0Os2DHQueryDOSVar.asm 77120 2019-02-01 15:08:46Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; IPRT - DevHelp_GetDOSVar, Ring-0 Driver, OS/2.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Contributed by knut st. osmundsen.
|
---|
8 | ;
|
---|
9 | ; Copyright (C) 2007-2019 Oracle Corporation
|
---|
10 | ;
|
---|
11 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
13 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | ; General Public License (GPL) as published by the Free Software
|
---|
15 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | ;
|
---|
19 | ; The contents of this file may alternatively be used under the terms
|
---|
20 | ; of the Common Development and Distribution License Version 1.0
|
---|
21 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
22 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
23 | ; CDDL are applicable instead of those of the GPL.
|
---|
24 | ;
|
---|
25 | ; You may elect to license modified versions of this file under the
|
---|
26 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
27 | ;
|
---|
28 | ; --------------------------------------------------------------------
|
---|
29 | ;
|
---|
30 | ; This code is based on:
|
---|
31 | ;
|
---|
32 | ; Copyright (c) 1999-2007 knut st. osmundsen <[email protected]>
|
---|
33 | ;
|
---|
34 | ; Permission is hereby granted, free of charge, to any person
|
---|
35 | ; obtaining a copy of this software and associated documentation
|
---|
36 | ; files (the "Software"), to deal in the Software without
|
---|
37 | ; restriction, including without limitation the rights to use,
|
---|
38 | ; copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
39 | ; copies of the Software, and to permit persons to whom the
|
---|
40 | ; Software is furnished to do so, subject to the following
|
---|
41 | ; conditions:
|
---|
42 | ;
|
---|
43 | ; The above copyright notice and this permission notice shall be
|
---|
44 | ; included in all copies or substantial portions of the Software.
|
---|
45 | ;
|
---|
46 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
47 | ; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
48 | ; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
49 | ; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
50 | ; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
51 | ; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
52 | ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
53 | ; OTHER DEALINGS IN THE SOFTWARE.
|
---|
54 | ;
|
---|
55 |
|
---|
56 |
|
---|
57 | ;*******************************************************************************
|
---|
58 | ;* Header Files *
|
---|
59 | ;*******************************************************************************
|
---|
60 | %define RT_INCL_16BIT_SEGMENTS
|
---|
61 | %include "iprt/asmdefs.mac"
|
---|
62 | %include "iprt/err.mac"
|
---|
63 |
|
---|
64 |
|
---|
65 | ;*******************************************************************************
|
---|
66 | ;* External Symbols *
|
---|
67 | ;*******************************************************************************
|
---|
68 | extern KernThunkStackTo32
|
---|
69 | extern KernThunkStackTo16
|
---|
70 | extern NAME(g_fpfnDevHlp)
|
---|
71 |
|
---|
72 |
|
---|
73 | ;*******************************************************************************
|
---|
74 | ;* Defined Constants And Macros *
|
---|
75 | ;*******************************************************************************
|
---|
76 | %define DevHlp_GetDOSVar 24h
|
---|
77 |
|
---|
78 |
|
---|
79 | BEGINCODE
|
---|
80 |
|
---|
81 | ;
|
---|
82 | ; Jump table used by RTR0Os2DHQueryDOSVar
|
---|
83 | ;
|
---|
84 | DosVarJumpTab:
|
---|
85 | dd 0 ; 0 - Reserved
|
---|
86 | dd Load1600 ; 1 - GIS
|
---|
87 | dd Load1616 ; 2 - LIS
|
---|
88 | dd 0 ; 3 - Reserved
|
---|
89 | dd Load1616 ; 4 - VectorSDF
|
---|
90 | dd Load1616 ; 5 - VectorReboot
|
---|
91 | dd Load1616 ; 6 - VectorMSATS
|
---|
92 | dd AsIs ; 7 - YieldFlag (Resched)
|
---|
93 | dd AsIs ; 8 - TCYieldFlag (TCResched)
|
---|
94 | dd AsIs ; 9 - DOSTable
|
---|
95 | dd Load1616 ; a - VectorDEKKO
|
---|
96 | dd AsIs ; b - CodePgBuff
|
---|
97 | dd Load1616 ; c - VectorRIPL
|
---|
98 | dd AsIs ; d - InterruptLevel
|
---|
99 | dd AsIs ; e - DevClassTables
|
---|
100 | dd AsIs ; f - DMQS_Sel
|
---|
101 | dd AsIs ;10 - APMInfo
|
---|
102 | dd LoadWord ;11 - APM_Length (length of above structure)
|
---|
103 | DosVarJumpTabEnd:
|
---|
104 | %define DosVarJumpTabSize (DosVarJumpTabEnd - DosVarJumpTab) / 4
|
---|
105 |
|
---|
106 | ;;
|
---|
107 | ; Unified DevHelp_GetDOSVar -> Far 16:16 pointer wrapper.
|
---|
108 | ;
|
---|
109 | ; @param iVar [ebp + 08h] Variable.
|
---|
110 | ; @param iMember [ebp + 0ch] Member.
|
---|
111 | ; @param pfp [ebp + 10h] Where to store the variable address (pointer to 16:16).
|
---|
112 | ;
|
---|
113 | BEGINPROC_EXPORTED RTR0Os2DHQueryDOSVar
|
---|
114 | ; switch stack first.
|
---|
115 | call KernThunkStackTo16
|
---|
116 |
|
---|
117 | ; normal prolog.
|
---|
118 | push ebp
|
---|
119 | mov ebp, esp
|
---|
120 | push dword [NAME(g_fpfnDevHlp)] ; ebp - 4
|
---|
121 | push ebx ; save ebx
|
---|
122 | push es ; save es
|
---|
123 |
|
---|
124 | ; setup the devhelp call and switch to
|
---|
125 | mov eax, [ebp + 08h] ; iVar (8-bit)
|
---|
126 | mov ecx, [ebp + 0ch] ; iMember (16-bit)
|
---|
127 | mov dl, DevHlp_GetDOSVar
|
---|
128 |
|
---|
129 | ; jump to the 16-bit code.
|
---|
130 | ;jmp far dword NAME(RTR0Os2DHQueryDOSVar_16) wrt CODE16
|
---|
131 | db 066h
|
---|
132 | db 0eah
|
---|
133 | dw NAME(RTR0Os2DHQueryDOSVar_16) wrt CODE16
|
---|
134 | dw CODE16
|
---|
135 | BEGINCODE16
|
---|
136 | GLOBALNAME RTR0Os2DHQueryDOSVar_16
|
---|
137 | call far [ss:ebp - 4]
|
---|
138 |
|
---|
139 | ;jmp far dword NAME(RTR0Os2DHQueryDOSVar) wrt FLAT
|
---|
140 | db 066h
|
---|
141 | db 0eah
|
---|
142 | dd NAME(RTR0Os2DHQueryDOSVar_32) ;wrt FLAT
|
---|
143 | dw TEXT32 wrt FLAT
|
---|
144 | BEGINCODE
|
---|
145 | GLOBALNAME RTR0Os2DHQueryDOSVar_32
|
---|
146 | jc Error1
|
---|
147 |
|
---|
148 | ;
|
---|
149 | ; Make ax:ebx contain the pointer and take action according
|
---|
150 | ; to the variable jump table.
|
---|
151 | ;
|
---|
152 | and ebx, 0000ffffh ; clean high part of ebx
|
---|
153 | movzx ecx, byte [ebp + 08] ; iVar
|
---|
154 | cmp ecx, DosVarJumpTabSize
|
---|
155 | jg Error2
|
---|
156 | jmp [DosVarJumpTab + ecx * 4]
|
---|
157 |
|
---|
158 | ; Load Word at ax:ebx.
|
---|
159 | LoadWord:
|
---|
160 | mov es, ax
|
---|
161 | movzx edx, word [es:ebx]
|
---|
162 | jmp StoreIt
|
---|
163 |
|
---|
164 | ; Load selector at ax:ebx.
|
---|
165 | Load1600:
|
---|
166 | mov es, ax
|
---|
167 | movzx edx, word [es:ebx]
|
---|
168 | shl edx, 16
|
---|
169 | jmp StoreIt
|
---|
170 |
|
---|
171 | ; Load 16:16 ptr at ax:ebx.
|
---|
172 | Load1616:
|
---|
173 | mov es, ax
|
---|
174 | mov edx, dword [es:ebx]
|
---|
175 | jmp StoreIt
|
---|
176 |
|
---|
177 | ; Move ax:bx into edx.
|
---|
178 | AsIs:
|
---|
179 | mov dx, ax
|
---|
180 | shl edx, 16
|
---|
181 | mov dx, bx
|
---|
182 | jmp StoreIt
|
---|
183 |
|
---|
184 | Error2:
|
---|
185 | mov eax, VERR_INVALID_PARAMETER
|
---|
186 | jmp Done
|
---|
187 |
|
---|
188 | Error1:
|
---|
189 | mov eax, VERR_GENERAL_FAILURE
|
---|
190 | jmp Done
|
---|
191 |
|
---|
192 | StoreIt:
|
---|
193 | mov ecx, [ebp + 10h]
|
---|
194 | mov [ecx], edx
|
---|
195 | xor eax, eax ; return success (VINF_SUCCESS == 0)
|
---|
196 |
|
---|
197 | Done:
|
---|
198 | pop es
|
---|
199 | pop ebx
|
---|
200 | leave
|
---|
201 |
|
---|
202 | ; switch stack back and return.
|
---|
203 | push eax
|
---|
204 | call KernThunkStackTo32
|
---|
205 | pop eax
|
---|
206 | ret
|
---|
207 | ENDPROC RTR0Os2DHQueryDOSVar
|
---|
208 |
|
---|