VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 3 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.6 KB
Line 
1; $Id: bs3-cmn-SelFlatDataToProtFar16.asm 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; BS3Kit - Bs3SelFlatDataToProtFar16.
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
48BS3_EXTERN_CMN Bs3Panic
49%endif
50
51TMPL_BEGIN_TEXT
52%if TMPL_BITS == 16
53CPU 8086
54%endif
55
56
57;;
58; @cproto BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelFlatDataToProtFar16,(uint32_t uFlatAddr));
59;
60; @uses Only return registers (ax:dx, eax, eax)
61; @remarks No 20h scratch area requirements.
62;
63BS3_PROC_BEGIN_CMN Bs3SelFlatDataToProtFar16, BS3_PBC_NEAR ; Far stub generated by the makefile/bs3kit.h.
64 push xBP
65 mov xBP, xSP
66
67 ;
68 ; Check if we can use the protected mode stack or data selector.
69 ; The latter ensures the usability of this function for setting SS.
70 ;
71%if TMPL_BITS == 16
72 mov ax, [xBP + xCB + cbCurRetAddr]
73 mov dx, [xBP + xCB + cbCurRetAddr + 2]
74 test dx, dx
75 jnz .not_stack
76 mov dx, BS3_SEL_R0_SS16
77%else
78TNOT64 mov eax, [xBP + xCB + cbCurRetAddr]
79TONLY64 mov eax, ecx
80 test eax, 0ffff0000h
81 jnz .not_stack
82 or eax, BS3_SEL_R0_SS16 << 16
83%endif
84 jmp .return
85
86.not_stack:
87%if TMPL_BITS == 16
88 sub ax, BS3_ADDR_BS3DATA16 & 0xffff
89 sbb dx, BS3_ADDR_BS3DATA16 >> 16
90 jnz .do_tiled
91 mov dx, BS3_SEL_R0_DS16
92%else
93 sub eax, BS3_ADDR_BS3DATA16
94 test eax, 0ffff0000h
95 jnz .do_tiled
96 or eax, BS3_SEL_R0_DS16 << 16
97%endif
98 jmp .return
99
100 ;
101 ; Just translate the address to tiled.
102 ;
103.do_tiled:
104%if TMPL_BITS == 16
105 ; Convert upper 16-bit to a tiled selector.
106 mov ax, cx ; save cx
107 mov dx, [xBP + xCB + cbCurRetAddr + 2]
108 %ifdef BS3_STRICT
109 cmp dx, BS3_SEL_TILED_AREA_SIZE >> 16
110 jb .address_ok
111 call Bs3Panic
112.address_ok:
113 %endif
114 mov cl, X86_SEL_SHIFT
115 shl dx, cl
116 add dx, BS3_SEL_TILED
117 mov cx, ax ; restore cx
118
119 ; Load segment offset and return.
120 mov ax, [xBP + xCB + cbCurRetAddr]
121
122%else
123 ; Convert upper 16-bit to tiled selector.
124TNOT64 mov eax, [xBP + xCB + cbCurRetAddr]
125TONLY64 mov rax, rcx
126 %ifdef BS3_STRICT
127 cmp xAX, BS3_SEL_TILED_AREA_SIZE
128 jb .address_ok
129 call Bs3Panic
130.address_ok:
131 %endif
132 ror eax, 16
133 shl ax, X86_SEL_SHIFT
134 add ax, BS3_SEL_TILED
135 rol eax, 16
136%endif
137
138.return:
139 pop xBP
140 BS3_HYBRID_RET
141BS3_PROC_END_CMN Bs3SelFlatDataToProtFar16
142
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