VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-SwitchTo32BitAndCallC.asm

Last change on this file was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1; $Id: bs3-mode-SwitchTo32BitAndCallC.asm 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; BS3Kit - bs3SwitchTo32BitAndCallC
4;
5
6;
7; Copyright (C) 2007-2024 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37;*********************************************************************************************************************************
38;* Header Files *
39;*********************************************************************************************************************************
40%include "bs3kit-template-header.mac"
41
42
43;*********************************************************************************************************************************
44;* External Symbols *
45;*********************************************************************************************************************************
46BS3_EXTERN_DATA16 g_bBs3CurrentMode
47TMPL_BEGIN_TEXT
48
49%ifdef BS3_STRICT
50BS3_EXTERN_CMN Bs3Panic
51%endif
52
53%if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
54BS3_EXTERN_CMN Bs3SelRealModeCodeToFlat
55%endif
56
57%if TMPL_MODE == BS3_MODE_RM
58extern NAME(Bs3SwitchToPE32_rm)
59extern NAME(Bs3SwitchToRM_pe32)
60%elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
61BS3_EXTERN_CMN Bs3SwitchTo32Bit
62 %if BS3_MODE_IS_16BIT_CODE_NO_V86(TMPL_MODE)
63extern _Bs3SwitchTo16Bit_c32
64 %elif BS3_MODE_IS_V86(TMPL_MODE)
65extern _Bs3SwitchTo16BitV86_c32
66 %elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
67extern _Bs3SwitchTo64_c32
68 %endif
69%endif
70
71
72
73;;
74; @cproto BS3_MODE_PROTO_STUB(int, Bs3SwitchTo32BitAndCallC,(PFNBS3FARADDRCONV fpfnCall, unsigned cbParams, ...));
75;
76BS3_PROC_BEGIN_MODE Bs3SwitchTo32BitAndCallC, BS3_PBC_HYBRID
77 BS3_CALL_CONV_PROLOG 4
78TONLY16 inc xBP
79 push xBP
80 mov xBP, xSP
81 push xSI
82
83 ;
84 ; Push the arguments first.
85 ;
86TONLY16 mov si, [xBP + xCB + cbCurRetAddr + sCB]
87TNOT16 mov esi, [xBP + xCB + cbCurRetAddr + sCB]
88%ifdef BS3_STRICT
89 test xSI, 3
90 jz .cbParams_ok
91 call Bs3Panic
92.cbParams_ok:
93 cmp byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], TMPL_MODE
94 je .mode_ok
95 call Bs3Panic
96.mode_ok:
97%endif
98 add xSI, sCB - 1 ; round it up to nearest push size / dword.
99 and xSI, ~(sCB - 1)
100 jz .done_pushing ; skip if zero
101.push_more:
102 push xPRE [xBP + xCB + cbCurRetAddr + sCB + xCB + xSI - xCB]
103 sub xSI, xCB
104 jnz .push_more
105 mov xSI, xAX ; restore xSI
106.done_pushing:
107
108 ;
109 ; Load fpfnCall into eax.
110 ;
111%if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
112 push sPRE [xBP + xCB + cbCurRetAddr]
113 BS3_CALL Bs3SelRealModeCodeToFlat, 1
114 add xSP, sCB
115 rol eax, 16
116 mov ax, dx
117 rol eax, 16
118%else
119 mov eax, [xBP + xCB + cbCurRetAddr]
120%endif
121
122 ;
123 ; Switch to 32-bit mode, if this is real mode pick PE32.
124 ;
125%if TMPL_MODE == BS3_MODE_RM
126 call NAME(Bs3SwitchToPE32_rm)
127 BS3_SET_BITS 32
128%elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
129 call Bs3SwitchTo32Bit
130 BS3_SET_BITS 32
131%endif
132
133 ;
134 ; Make the call.
135 ;
136 call eax
137
138 ;
139 ; Return, preserving xAX.
140 ;
141%if BS3_MODE_IS_RM_OR_V86(TMPL_MODE)
142 mov edx, eax
143 shr edx, 16
144%endif
145%if TMPL_MODE == BS3_MODE_RM
146 call NAME(Bs3SwitchToRM_pe32)
147%elif BS3_MODE_IS_16BIT_CODE_NO_V86(TMPL_MODE)
148 call _Bs3SwitchTo16Bit_c32
149%elif BS3_MODE_IS_V86(TMPL_MODE)
150 call _Bs3SwitchTo16BitV86_c32
151%elif !BS3_MODE_IS_32BIT_CODE(TMPL_MODE)
152 call _Bs3SwitchTo64_c32
153%endif
154 BS3_SET_BITS TMPL_BITS
155
156 ; Epilog.
157 lea xSP, [xBP - xCB]
158 pop xSI
159 pop xBP
160TONLY16 dec xBP
161 BS3_CALL_CONV_EPILOG 4
162 BS3_HYBRID_RET
163BS3_PROC_END_MODE Bs3SwitchTo32BitAndCallC
164
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