VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SelProtModeCodeToRealMode.asm@ 60554

Last change on this file since 60554 was 60554, checked in by vboxsync, 9 years ago

bs3kit: far updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1; $Id: bs3-cmn-SelProtModeCodeToRealMode.asm 60554 2016-04-18 19:11:32Z vboxsync $
2;; @file
3; BS3Kit - Bs3SelProtModeCodeToRealMode.
4;
5
6;
7; Copyright (C) 2007-2016 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%include "bs3kit-template-header.mac"
28
29;
30; Make sure we can get at all the segments.
31;
32BS3_BEGIN_TEXT16
33BS3_BEGIN_X0TEXT16
34BS3_BEGIN_X1TEXT16
35TMPL_BEGIN_TEXT
36
37
38;;
39; @cproto BS3_CMN_PROTO(uint16_t, Bs3SelProtModeCodeToRealMode,(uint16_t uRealSel), false);
40; @uses ax (return register)
41;
42BS3_PROC_BEGIN_CMN Bs3SelProtModeCodeToRealMode, BS3_PBC_NEAR
43 BS3_CALL_CONV_PROLOG 1
44 push xBP
45 mov xBP, xSP
46
47 ; Load it and mask off the RPL.
48 mov ax, [xBP + xCB + cbCurRetAddr]
49 and ax, X86_SEL_MASK_OFF_RPL
50
51 ; We're allowed to use the real-mode segment value.
52 cmp ax, BS3TEXT16
53 je .bs3text16
54
55 ; Check for typical code segments.
56 cmp ax, BS3_SEL_R0_CS16
57 je .bs3text16
58 cmp ax, BS3_SEL_X0TEXT16_CS
59 je .bs3x0text16
60 cmp ax, BS3_SEL_X1TEXT16_CS
61 je .bs3x1text16
62
63 ; Check for less common BS3_SEL_R*_CS16_* values.
64 cmp ax, BS3_SEL_R0_FIRST
65 jb .panic
66 cmp ax, BS3_SEL_R3_FIRST + (1 << BS3_SEL_RING_SHIFT)
67 jae .panic
68
69 ; Since the relevant bits now are the lower 8 ones, we skip the
70 ; AND AX, BS3_SEL_RING_SHIFT
71 ; ADD AX, BS3_SEL_R0_FIRST
72 ; bits and compare AL with lower 8-bit of the BS3_SEL_R0_CS16* values.
73AssertCompile(BS3_SEL_RING_SHIFT == 8)
74 cmp al, BS3_SEL_R0_CS16 & 0xff
75 je .bs3text16
76 cmp al, BS3_SEL_R0_CS16_EO & 0xff
77 je .bs3text16
78 cmp ax, BS3_SEL_R0_CS16_CNF & 0xff
79 je .bs3text16
80 cmp ax, BS3_SEL_R0_CS16_CNF_EO & 0xff
81 je .bs3text16
82.panic:
83 extern BS3_CMN_NM(Bs3Panic)
84 call BS3_CMN_NM(Bs3Panic)
85 jmp .return
86
87.bs3x1text16:
88 mov ax, BS3_SEL_X1TEXT16_CS
89 jmp .return
90.bs3x0text16:
91 mov ax, BS3_SEL_X0TEXT16_CS
92 jmp .return
93.bs3text16:
94 mov ax, BS3TEXT16
95.return:
96 pop xBP
97 BS3_CALL_CONV_EPILOG 1
98 BS3_HYBRID_RET
99BS3_PROC_END_CMN Bs3SelProtModeCodeToRealMode
100
101;
102; We may be using the near code in some critical code paths, so don't
103; penalize it.
104;
105BS3_CMN_FAR_STUB Bs3SelProtModeCodeToRealMode, 2
106
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