VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelProtFar16DataToRealMode.asm

Last change on this file was 106061, checked in by vboxsync, 2 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: 4.9 KB
Line 
1; $Id: bs3-cmn-SelProtFar16DataToRealMode.asm 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; BS3Kit - Bs3SelProtFar16DataToRealMode.
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;*********************************************************************************************************************************
47BS3_BEGIN_DATA16 ; For real mode segment value.
48BS3_BEGIN_SYSTEM16 ; Ditto.
49TMPL_BEGIN_TEXT
50BS3_EXTERN_CMN Bs3SelFar32ToFlat32NoClobber
51
52TMPL_BEGIN_TEXT
53%if TMPL_BITS == 16
54CPU 8086
55%endif
56
57
58;;
59; @cproto BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelProtFar16DataToRealMode,(uint32_t uFar1616));
60;
61; @uses Only return registers (ax:dx, eax, eax)
62; @remarks No 20h scratch area requirements.
63;
64BS3_PROC_BEGIN_CMN Bs3SelProtFar16DataToRealMode, BS3_PBC_NEAR ; Far stub generated by the makefile/bs3kit.h.
65 push xBP
66 mov xBP, xSP
67
68 ;
69 ; See if it's our default 16-bit ring-0 data, stack or system data segment.
70 ;
71%if TMPL_BITS == 16
72 mov ax, [xBP + xCB + cbCurRetAddr + 2]
73%elif TMPL_BITS == 32
74 movzx eax, word [xBP + xCB + cbCurRetAddr + 2]
75%else
76 mov eax, ecx
77 shr eax, 16
78%endif
79 cmp ax, BS3_SEL_R0_SS16
80 jne .not_stack
81 mov ax, 0
82
83.quick_return:
84%if TMPL_BITS == 16
85 mov dx, ax
86 mov ax, [xBP + xCB + cbCurRetAddr]
87%elif TMPL_BITS == 32
88 shl eax, 16
89 mov ax, word [xBP + xCB + cbCurRetAddr]
90%else
91 shl eax, 16
92 mov ax, cx
93%endif
94
95.return:
96 pop xBP
97 BS3_HYBRID_RET
98
99.not_stack:
100 cmp ax, BS3_SEL_R0_DS16
101 jne .not_dgroup
102 mov ax, BS3KIT_GRPNM_DATA16
103 jmp .quick_return
104
105.not_dgroup:
106 cmp ax, BS3_SEL_SYSTEM16
107 jne .not_system16
108 mov ax, BS3SYSTEM16
109 jmp .quick_return
110
111 ;
112 ; Call worker function to convert it to flat and the do tiled
113 ; calculation from that.
114 ;
115.not_system16:
116%if TMPL_BITS == 16
117 push word [xBP + xCB + cbCurRetAddr + 2]
118 xor ax, ax
119 push ax
120 push word [xBP + xCB + cbCurRetAddr]
121 call Bs3SelFar32ToFlat32NoClobber
122 add sp, 6
123
124 ; Convert upper 16-bit of the flat address to a tiled selector.
125 push cx
126 mov cl, X86_SEL_SHIFT
127 shl dx, cl
128 add dx, BS3_SEL_TILED
129 pop cx
130%else
131 %if TMPL_BITS == 32
132 push eax
133 movzx eax, word [xBP + xCB + cbCurRetAddr]
134 push eax
135 call Bs3SelFar32ToFlat32NoClobber
136 add esp, 8
137 %else
138 push xDX
139 push xCX
140
141 mov edx, eax ; arg #2: selector
142 movzx ecx, cx ; arg #1: offset
143 call Bs3SelFar32ToFlat32NoClobber
144
145 pop xDX
146 pop xCX
147 %endif
148
149 ; Convert upper 16-bit to tiled selector.
150 rol eax, 16
151 shl ax, X86_SEL_SHIFT
152 add ax, BS3_SEL_TILED
153 ror eax, 16
154%endif
155 jmp .return
156BS3_PROC_END_CMN Bs3SelProtFar16DataToRealMode
157
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