VirtualBox

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

Last change on this file since 77922 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

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