1 | ; $Id: bs3-cmn-SelProtFar16DataToRealMode.asm 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3SelProtFar16DataToRealMode.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2020 Oracle Corporation
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
11 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | ; General Public License (GPL) as published by the Free Software
|
---|
13 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; The contents of this file may alternatively be used under the terms
|
---|
18 | ; of the Common Development and Distribution License Version 1.0
|
---|
19 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | ; CDDL are applicable instead of those of the GPL.
|
---|
22 | ;
|
---|
23 | ; You may elect to license modified versions of this file under the
|
---|
24 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | ;
|
---|
26 |
|
---|
27 |
|
---|
28 | ;*********************************************************************************************************************************
|
---|
29 | ;* Header Files *
|
---|
30 | ;*********************************************************************************************************************************
|
---|
31 | %include "bs3kit-template-header.mac"
|
---|
32 |
|
---|
33 |
|
---|
34 | ;*********************************************************************************************************************************
|
---|
35 | ;* External Symbols *
|
---|
36 | ;*********************************************************************************************************************************
|
---|
37 | BS3_BEGIN_DATA16 ; For real mode segment value.
|
---|
38 | BS3_BEGIN_SYSTEM16 ; Ditto.
|
---|
39 | TMPL_BEGIN_TEXT
|
---|
40 | BS3_EXTERN_CMN Bs3SelFar32ToFlat32NoClobber
|
---|
41 |
|
---|
42 | TMPL_BEGIN_TEXT
|
---|
43 | %if TMPL_BITS == 16
|
---|
44 | CPU 8086
|
---|
45 | %endif
|
---|
46 |
|
---|
47 |
|
---|
48 | ;;
|
---|
49 | ; @cproto BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelProtFar16DataToRealMode,(uint32_t uFar1616));
|
---|
50 | ;
|
---|
51 | ; @uses Only return registers (ax:dx, eax, eax)
|
---|
52 | ; @remarks No 20h scratch area requirements.
|
---|
53 | ;
|
---|
54 | BS3_PROC_BEGIN_CMN Bs3SelProtFar16DataToRealMode, BS3_PBC_NEAR ; Far stub generated by the makefile/bs3kit.h.
|
---|
55 | push xBP
|
---|
56 | mov xBP, xSP
|
---|
57 |
|
---|
58 | ;
|
---|
59 | ; See if it's our default 16-bit ring-0 data, stack or system data segment.
|
---|
60 | ;
|
---|
61 | %if TMPL_BITS == 16
|
---|
62 | mov ax, [xBP + xCB + cbCurRetAddr + 2]
|
---|
63 | %elif TMPL_BITS == 32
|
---|
64 | movzx eax, word [xBP + xCB + cbCurRetAddr + 2]
|
---|
65 | %else
|
---|
66 | mov eax, ecx
|
---|
67 | shr eax, 16
|
---|
68 | %endif
|
---|
69 | cmp ax, BS3_SEL_R0_SS16
|
---|
70 | jne .not_stack
|
---|
71 | mov ax, 0
|
---|
72 |
|
---|
73 | .quick_return:
|
---|
74 | %if TMPL_BITS == 16
|
---|
75 | mov dx, ax
|
---|
76 | mov ax, [xBP + xCB + cbCurRetAddr]
|
---|
77 | %elif TMPL_BITS == 32
|
---|
78 | shl eax, 16
|
---|
79 | mov ax, word [xBP + xCB + cbCurRetAddr]
|
---|
80 | %else
|
---|
81 | shl eax, 16
|
---|
82 | mov ax, cx
|
---|
83 | %endif
|
---|
84 |
|
---|
85 | .return:
|
---|
86 | pop xBP
|
---|
87 | BS3_HYBRID_RET
|
---|
88 |
|
---|
89 | .not_stack:
|
---|
90 | cmp ax, BS3_SEL_R0_DS16
|
---|
91 | jne .not_dgroup
|
---|
92 | mov ax, BS3KIT_GRPNM_DATA16
|
---|
93 | jmp .quick_return
|
---|
94 |
|
---|
95 | .not_dgroup:
|
---|
96 | cmp ax, BS3_SEL_SYSTEM16
|
---|
97 | jne .not_system16
|
---|
98 | mov ax, BS3SYSTEM16
|
---|
99 | jmp .quick_return
|
---|
100 |
|
---|
101 | ;
|
---|
102 | ; Call worker function to convert it to flat and the do tiled
|
---|
103 | ; calculation from that.
|
---|
104 | ;
|
---|
105 | .not_system16:
|
---|
106 | %if TMPL_BITS == 16
|
---|
107 | push word [xBP + xCB + cbCurRetAddr + 2]
|
---|
108 | xor ax, ax
|
---|
109 | push ax
|
---|
110 | push word [xBP + xCB + cbCurRetAddr]
|
---|
111 | call Bs3SelFar32ToFlat32NoClobber
|
---|
112 | add sp, 6
|
---|
113 |
|
---|
114 | ; Convert upper 16-bit of the flat address to a tiled selector.
|
---|
115 | push cx
|
---|
116 | mov cl, X86_SEL_SHIFT
|
---|
117 | shl dx, cl
|
---|
118 | add dx, BS3_SEL_TILED
|
---|
119 | pop cx
|
---|
120 | %else
|
---|
121 | %if TMPL_BITS == 32
|
---|
122 | push eax
|
---|
123 | movzx eax, word [xBP + xCB + cbCurRetAddr]
|
---|
124 | push eax
|
---|
125 | call Bs3SelFar32ToFlat32NoClobber
|
---|
126 | add esp, 8
|
---|
127 | %else
|
---|
128 | push xDX
|
---|
129 | push xCX
|
---|
130 |
|
---|
131 | mov edx, eax ; arg #2: selector
|
---|
132 | movzx ecx, cx ; arg #1: offset
|
---|
133 | call Bs3SelFar32ToFlat32NoClobber
|
---|
134 |
|
---|
135 | pop xDX
|
---|
136 | pop xCX
|
---|
137 | %endif
|
---|
138 |
|
---|
139 | ; Convert upper 16-bit to tiled selector.
|
---|
140 | rol eax, 16
|
---|
141 | shl ax, X86_SEL_SHIFT
|
---|
142 | add ax, BS3_SEL_TILED
|
---|
143 | ror eax, 16
|
---|
144 | %endif
|
---|
145 | jmp .return
|
---|
146 | BS3_PROC_END_CMN Bs3SelProtFar16DataToRealMode
|
---|
147 |
|
---|