VirtualBox

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

Last change on this file since 61533 was 60527, 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: 2.6 KB
Line 
1; $Id: bs3-cmn-SwitchToRingX.asm 60527 2016-04-18 09:11:04Z vboxsync $
2;; @file
3; BS3Kit - Bs3SwitchToRingX
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
30BS3_EXTERN_CMN Bs3Syscall
31%if TMPL_BITS == 16
32BS3_EXTERN_DATA16 g_bBs3CurrentMode
33%endif
34TMPL_BEGIN_TEXT
35
36
37;;
38; @cproto BS3_DECL(void) Bs3SwitchToRingX(uint8_t bRing);
39;
40; @param bRing The target ring (0..3).
41; @remarks Does not require 20h of parameter scratch space in 64-bit mode.
42;
43; @uses No GPRs.
44;
45BS3_PROC_BEGIN_CMN Bs3SwitchToRingX, BS3_PBC_HYBRID_SAFE
46 BS3_CALL_CONV_PROLOG 1
47 push xBP
48 mov xBP, xSP
49 push xAX
50
51%if TMPL_BITS == 16
52 ; Check the current mode.
53 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
54
55 ; If real mode: Nothing we can do, but we'll bitch if the request isn't for ring-0.
56 cmp al, BS3_MODE_RM
57 je .return_real_mode
58
59 ; If V8086 mode: Always do syscall and add a lock prefix to make sure it gets to the VMM.
60 test al, BS3_MODE_CODE_V86
61 jnz .just_do_it
62%endif
63
64 ; In protected mode: Check the CPL we're currently at skip syscall if ring-0 already.
65 mov ax, cs
66 and al, 3
67 cmp al, byte [xBP + xCB + cbCurRetAddr]
68 je .return
69
70.just_do_it:
71 mov xAX, BS3_SYSCALL_TO_RING0
72 add al, [xBP + xCB + cbCurRetAddr]
73 call Bs3Syscall
74
75%ifndef BS3_STRICT
76.return_real_mode:
77%endif
78.return:
79 pop xAX
80 pop xBP
81 BS3_CALL_CONV_EPILOG 1
82 BS3_HYBRID_RET
83
84%ifdef BS3_STRICT
85; In real mode, only ring-0 makes any sense.
86.return_real_mode:
87 cmp byte [xBP + xCB + cbCurRetAddr], 0
88 je .return
89 int3
90 jmp .return
91%endif
92BS3_PROC_END_CMN Bs3SwitchToRingX
93
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