1 | ; $Id: bs3-cmn-SelRealModeDataToProtFar16.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3SelRealModeDataToProtFar16.
|
---|
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 | BS3_BEGIN_DATA16 ; For real mode segment value.
|
---|
48 | BS3_BEGIN_SYSTEM16 ; Ditto.
|
---|
49 |
|
---|
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, Bs3SelRealModeDataToProtFar16,(uint32_t uFar1616));
|
---|
58 | ;
|
---|
59 | ; @uses Only return registers (ax:dx, eax, eax)
|
---|
60 | ; @remarks No 20h scratch area requirements.
|
---|
61 | ;
|
---|
62 | BS3_PROC_BEGIN_CMN Bs3SelRealModeDataToProtFar16, BS3_PBC_NEAR ; Far stub generated by the makefile/bs3kit.h.
|
---|
63 | push xBP
|
---|
64 | mov xBP, xSP
|
---|
65 |
|
---|
66 | ;
|
---|
67 | ; See if it's our default 16-bit data, stack or system data segment.
|
---|
68 | ;
|
---|
69 | %if TMPL_BITS == 16
|
---|
70 | mov ax, [xBP + xCB + cbCurRetAddr + 2]
|
---|
71 | %elif TMPL_BITS == 32
|
---|
72 | movzx eax, word [xBP + xCB + cbCurRetAddr + 2]
|
---|
73 | %else
|
---|
74 | mov eax, ecx
|
---|
75 | shr eax, 16
|
---|
76 | %endif
|
---|
77 | cmp ax, 0
|
---|
78 | jnz .not_stack
|
---|
79 | mov ax, BS3_SEL_R0_SS16
|
---|
80 |
|
---|
81 | .quick_return:
|
---|
82 | %if TMPL_BITS == 16
|
---|
83 | mov dx, ax
|
---|
84 | mov ax, [xBP + xCB + cbCurRetAddr]
|
---|
85 | %elif TMPL_BITS == 32
|
---|
86 | shl eax, 16
|
---|
87 | mov ax, word [xBP + xCB + cbCurRetAddr]
|
---|
88 | %else
|
---|
89 | shl eax, 16
|
---|
90 | mov ax, cx
|
---|
91 | %endif
|
---|
92 |
|
---|
93 | .return:
|
---|
94 | pop xBP
|
---|
95 | BS3_HYBRID_RET
|
---|
96 |
|
---|
97 | .not_stack:
|
---|
98 | cmp ax, BS3KIT_GRPNM_DATA16
|
---|
99 | jne .not_dgroup
|
---|
100 | mov ax, BS3_SEL_R0_DS16
|
---|
101 | jmp .quick_return
|
---|
102 |
|
---|
103 | .not_dgroup:
|
---|
104 | cmp ax, BS3SYSTEM16
|
---|
105 | jne .not_system16
|
---|
106 | mov ax, BS3_SEL_SYSTEM16
|
---|
107 | jmp .quick_return
|
---|
108 |
|
---|
109 | ;
|
---|
110 | ; Compute flat address and translate it to tiled.
|
---|
111 | ;
|
---|
112 | .not_system16:
|
---|
113 | %if TMPL_BITS == 16
|
---|
114 | push cx
|
---|
115 |
|
---|
116 | ; Calc flat address.
|
---|
117 | mov dx, ax
|
---|
118 | mov cl, 12
|
---|
119 | shr dx, cl
|
---|
120 | mov cl, 4
|
---|
121 | shl ax, cl
|
---|
122 | add ax, [xBP + xCB + cbCurRetAddr]
|
---|
123 | adc dx, 0
|
---|
124 |
|
---|
125 | ; Convert upper 16-bit to tiled selector.
|
---|
126 | mov cl, X86_SEL_SHIFT
|
---|
127 | shl dx, cl
|
---|
128 | add dx, BS3_SEL_TILED
|
---|
129 |
|
---|
130 | pop cx
|
---|
131 | %else
|
---|
132 | ; Calc flat address.
|
---|
133 | shl eax, 4
|
---|
134 | %if TMPL_BITS == 32
|
---|
135 | add ax, [xBP + xCB + cbCurRetAddr]
|
---|
136 | %else
|
---|
137 | add ax, cx
|
---|
138 | %endif
|
---|
139 | jnc .no_carry
|
---|
140 | add eax, 10000h
|
---|
141 | .no_carry:
|
---|
142 |
|
---|
143 | ; Convert upper 16-bit to tiled selector.
|
---|
144 | rol eax, 16
|
---|
145 | shl ax, X86_SEL_SHIFT
|
---|
146 | add ax, BS3_SEL_TILED
|
---|
147 | ror eax, 16
|
---|
148 | %endif
|
---|
149 | jmp .return
|
---|
150 | BS3_PROC_END_CMN Bs3SelRealModeDataToProtFar16
|
---|
151 |
|
---|