VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/os2/RTR0Os2DHQueryDOSVar.asm@ 96763

Last change on this file since 96763 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.0 KB
Line 
1; $Id: RTR0Os2DHQueryDOSVar.asm 96407 2022-08-22 17:43:14Z 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-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) 1999-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;*******************************************************************************
77extern KernThunkStackTo32
78extern KernThunkStackTo16
79extern NAME(g_fpfnDevHlp)
80
81
82;*******************************************************************************
83;* Defined Constants And Macros *
84;*******************************************************************************
85%define DevHlp_GetDOSVar 24h
86
87
88BEGINCODE
89
90;
91; Jump table used by RTR0Os2DHQueryDOSVar
92;
93DosVarJumpTab:
94 dd 0 ; 0 - Reserved
95 dd Load1600 ; 1 - GIS
96 dd Load1616 ; 2 - LIS
97 dd 0 ; 3 - Reserved
98 dd Load1616 ; 4 - VectorSDF
99 dd Load1616 ; 5 - VectorReboot
100 dd Load1616 ; 6 - VectorMSATS
101 dd AsIs ; 7 - YieldFlag (Resched)
102 dd AsIs ; 8 - TCYieldFlag (TCResched)
103 dd AsIs ; 9 - DOSTable
104 dd Load1616 ; a - VectorDEKKO
105 dd AsIs ; b - CodePgBuff
106 dd Load1616 ; c - VectorRIPL
107 dd AsIs ; d - InterruptLevel
108 dd AsIs ; e - DevClassTables
109 dd AsIs ; f - DMQS_Sel
110 dd AsIs ;10 - APMInfo
111 dd LoadWord ;11 - APM_Length (length of above structure)
112DosVarJumpTabEnd:
113%define DosVarJumpTabSize (DosVarJumpTabEnd - DosVarJumpTab) / 4
114
115;;
116; Unified DevHelp_GetDOSVar -> Far 16:16 pointer wrapper.
117;
118; @param iVar [ebp + 08h] Variable.
119; @param iMember [ebp + 0ch] Member.
120; @param pfp [ebp + 10h] Where to store the variable address (pointer to 16:16).
121;
122BEGINPROC_EXPORTED RTR0Os2DHQueryDOSVar
123 ; switch stack first.
124 call KernThunkStackTo16
125
126 ; normal prolog.
127 push ebp
128 mov ebp, esp
129 push dword [NAME(g_fpfnDevHlp)] ; ebp - 4
130 push ebx ; save ebx
131 push es ; save es
132
133 ; setup the devhelp call and switch to
134 mov eax, [ebp + 08h] ; iVar (8-bit)
135 mov ecx, [ebp + 0ch] ; iMember (16-bit)
136 mov dl, DevHlp_GetDOSVar
137
138 ; jump to the 16-bit code.
139 ;jmp far dword NAME(RTR0Os2DHQueryDOSVar_16) wrt CODE16
140 db 066h
141 db 0eah
142 dw NAME(RTR0Os2DHQueryDOSVar_16) wrt CODE16
143 dw CODE16
144BEGINCODE16
145GLOBALNAME RTR0Os2DHQueryDOSVar_16
146 call far [ss:ebp - 4]
147
148 ;jmp far dword NAME(RTR0Os2DHQueryDOSVar) wrt FLAT
149 db 066h
150 db 0eah
151 dd NAME(RTR0Os2DHQueryDOSVar_32) ;wrt FLAT
152 dw TEXT32 wrt FLAT
153BEGINCODE
154GLOBALNAME RTR0Os2DHQueryDOSVar_32
155 jc Error1
156
157 ;
158 ; Make ax:ebx contain the pointer and take action according
159 ; to the variable jump table.
160 ;
161 and ebx, 0000ffffh ; clean high part of ebx
162 movzx ecx, byte [ebp + 08] ; iVar
163 cmp ecx, DosVarJumpTabSize
164 jg Error2
165 jmp [DosVarJumpTab + ecx * 4]
166
167 ; Load Word at ax:ebx.
168LoadWord:
169 mov es, ax
170 movzx edx, word [es:ebx]
171 jmp StoreIt
172
173 ; Load selector at ax:ebx.
174Load1600:
175 mov es, ax
176 movzx edx, word [es:ebx]
177 shl edx, 16
178 jmp StoreIt
179
180 ; Load 16:16 ptr at ax:ebx.
181Load1616:
182 mov es, ax
183 mov edx, dword [es:ebx]
184 jmp StoreIt
185
186 ; Move ax:bx into edx.
187AsIs:
188 mov dx, ax
189 shl edx, 16
190 mov dx, bx
191 jmp StoreIt
192
193Error2:
194 mov eax, VERR_INVALID_PARAMETER
195 jmp Done
196
197Error1:
198 mov eax, VERR_GENERAL_FAILURE
199 jmp Done
200
201StoreIt:
202 mov ecx, [ebp + 10h]
203 mov [ecx], edx
204 xor eax, eax ; return success (VINF_SUCCESS == 0)
205
206Done:
207 pop es
208 pop ebx
209 leave
210
211 ; switch stack back and return.
212 push eax
213 call KernThunkStackTo32
214 pop eax
215 ret
216ENDPROC RTR0Os2DHQueryDOSVar
217
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette