1 | ; $Id: bs3-cmn-SelFlatDataToRealMode.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3SelFlatDataToRealMode
|
---|
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 | ;*********************************************************************************************************************************
|
---|
39 | ;* Header Files *
|
---|
40 | ;*********************************************************************************************************************************
|
---|
41 | %include "bs3kit-template-header.mac"
|
---|
42 |
|
---|
43 |
|
---|
44 | ;*********************************************************************************************************************************
|
---|
45 | ;* External Symbols *
|
---|
46 | ;*********************************************************************************************************************************
|
---|
47 | %ifdef BS3_STRICT
|
---|
48 | BS3_EXTERN_CMN Bs3Panic
|
---|
49 | %endif
|
---|
50 | TMPL_BEGIN_TEXT
|
---|
51 | %if TMPL_BITS == 16
|
---|
52 | CPU 8086
|
---|
53 | %endif
|
---|
54 |
|
---|
55 |
|
---|
56 | ;;
|
---|
57 | ; @cproto BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelFlatDataToRealMode,(uint32_t uFlatAddr));
|
---|
58 | ;
|
---|
59 | ; @uses Only return registers (ax:dx, eax, eax)
|
---|
60 | ; @remarks No 20h scratch area requirements.
|
---|
61 | ;
|
---|
62 | BS3_PROC_BEGIN_CMN Bs3SelFlatDataToRealMode, BS3_PBC_NEAR ; Far stub generated by the makefile/bs3kit.h.
|
---|
63 | push xBP
|
---|
64 | mov xBP, xSP
|
---|
65 |
|
---|
66 | ;
|
---|
67 | ; Take the simplest approach possible (64KB tiled).
|
---|
68 | ;
|
---|
69 | %if TMPL_BITS == 16
|
---|
70 | mov ax, cx ; save cx
|
---|
71 | mov dx, [xBP + xCB + cbCurRetAddr + 2]
|
---|
72 | %ifdef BS3_STRICT
|
---|
73 | cmp dx, _1M >> 16
|
---|
74 | jb .address_ok
|
---|
75 | call Bs3Panic
|
---|
76 | .address_ok:
|
---|
77 | %endif
|
---|
78 | mov cl, 12
|
---|
79 | shl dx, cl
|
---|
80 | mov ax, cx ; restore cx
|
---|
81 |
|
---|
82 | mov ax, [xBP + xCB + cbCurRetAddr]
|
---|
83 |
|
---|
84 | %else
|
---|
85 | %if TMPL_BITS == 32
|
---|
86 | mov eax, [xBP + xCB + cbCurRetAddr]
|
---|
87 | %else
|
---|
88 | mov rax, rcx
|
---|
89 | %endif
|
---|
90 | %ifdef BS3_STRICT
|
---|
91 | cmp xAX, _1M
|
---|
92 | jb .address_ok
|
---|
93 | call Bs3Panic
|
---|
94 | .address_ok:
|
---|
95 | %endif
|
---|
96 | ror eax, 16
|
---|
97 | shl ax, 12
|
---|
98 | rol eax, 16
|
---|
99 | %endif
|
---|
100 |
|
---|
101 | pop xBP
|
---|
102 | BS3_HYBRID_RET
|
---|
103 | BS3_PROC_END_CMN Bs3SelFlatDataToRealMode
|
---|
104 |
|
---|