1 | ; $Id: bs3-c16-SwitchFromV86To16BitAndCallC.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3SwitchFromV86To16BitAndCallC
|
---|
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 | %if TMPL_BITS != 16
|
---|
42 | %error "16-bit only"
|
---|
43 | %endif
|
---|
44 |
|
---|
45 |
|
---|
46 | ;*********************************************************************************************************************************
|
---|
47 | ;* External Symbols *
|
---|
48 | ;*********************************************************************************************************************************
|
---|
49 | %ifdef BS3_STRICT
|
---|
50 | BS3_EXTERN_DATA16 g_bBs3CurrentMode
|
---|
51 | TMPL_BEGIN_TEXT
|
---|
52 | BS3_EXTERN_CMN Bs3Panic
|
---|
53 | %endif
|
---|
54 | BS3_EXTERN_CMN Bs3SwitchTo16Bit
|
---|
55 | BS3_EXTERN_CMN Bs3SwitchTo16BitV86
|
---|
56 | BS3_EXTERN_CMN Bs3SelRealModeCodeToProtMode
|
---|
57 |
|
---|
58 |
|
---|
59 | ;;
|
---|
60 | ; @cproto BS3_CMN_PROTO_STUB(int, Bs3SwitchFromV86To16BitAndCallC,(FPFNBS3FAR fpfnCall, unsigned cbParams, ...));
|
---|
61 | ;
|
---|
62 | BS3_PROC_BEGIN_CMN Bs3SwitchFromV86To16BitAndCallC, BS3_PBC_HYBRID
|
---|
63 | inc bp
|
---|
64 | push bp
|
---|
65 | mov bp, sp
|
---|
66 |
|
---|
67 | ;
|
---|
68 | ; Push the arguments first.
|
---|
69 | ;
|
---|
70 | mov ax, si ; save si
|
---|
71 | mov si, [bp + 2 + cbCurRetAddr + 4]
|
---|
72 | %ifdef BS3_STRICT
|
---|
73 | test si, 1
|
---|
74 | jz .cbParams_ok
|
---|
75 | call Bs3Panic
|
---|
76 | .cbParams_ok:
|
---|
77 | test byte [g_bBs3CurrentMode], BS3_MODE_CODE_V86
|
---|
78 | jnz .mode_ok
|
---|
79 | call Bs3Panic
|
---|
80 | .mode_ok:
|
---|
81 | %endif
|
---|
82 |
|
---|
83 | .push_more:
|
---|
84 | push word [bp + 2 + cbCurRetAddr + 4 + 2 + si - 2]
|
---|
85 | sub si, 2
|
---|
86 | jnz .push_more
|
---|
87 | mov si, ax ; restore si
|
---|
88 |
|
---|
89 | ;
|
---|
90 | ; Convert the code segment to a 16-bit prot mode selector
|
---|
91 | ;
|
---|
92 | push word [bp + 2 + cbCurRetAddr + 2]
|
---|
93 | call Bs3SelRealModeCodeToProtMode
|
---|
94 | mov [bp + 2 + cbCurRetAddr + 2], ax
|
---|
95 | add sp, 2
|
---|
96 |
|
---|
97 | ;
|
---|
98 | ; Switch mode.
|
---|
99 | ;
|
---|
100 | call Bs3SwitchTo16Bit
|
---|
101 | call far [bp + 2 + cbCurRetAddr]
|
---|
102 | call Bs3SwitchTo16BitV86
|
---|
103 |
|
---|
104 | mov sp, bp
|
---|
105 | pop bp
|
---|
106 | dec bp
|
---|
107 | BS3_HYBRID_RET
|
---|
108 | BS3_PROC_END_CMN Bs3SwitchFromV86To16BitAndCallC
|
---|
109 |
|
---|