1 | ; $Id: bs3-mode-PagingGetRootForPP32.asm 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3PagingGetRootForPP32
|
---|
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 | %include "bs3kit-template-header.mac"
|
---|
28 |
|
---|
29 |
|
---|
30 | %ifdef TMPL_RM
|
---|
31 | extern TMPL_NM(Bs3SwitchToPE16)
|
---|
32 | extern NAME(Bs3SwitchToRM_pe16)
|
---|
33 | %elifdef TMPL_CMN_V86
|
---|
34 | extern TMPL_NM(Bs3SwitchToRing0)
|
---|
35 | extern TMPL_NM(Bs3SwitchTo16BitV86)
|
---|
36 | %endif
|
---|
37 |
|
---|
38 | BS3_EXTERN_CMN Bs3PagingInitRootForPP
|
---|
39 |
|
---|
40 | BS3_EXTERN_DATA16 g_PhysPagingRootPP
|
---|
41 | TMPL_BEGIN_TEXT
|
---|
42 |
|
---|
43 |
|
---|
44 | ;;
|
---|
45 | ; @cproto BS3_DECL(uint32_t) Bs3PagingGetRootForPP32(void)
|
---|
46 | ;
|
---|
47 | ; @returns eax
|
---|
48 | ;
|
---|
49 | ; @uses ax
|
---|
50 | ;
|
---|
51 | ; @remarks returns value in EAX, not dx:ax!
|
---|
52 | ;
|
---|
53 | BS3_PROC_BEGIN_MODE Bs3PagingGetRootForPP32, BS3_PBC_NEAR ; Internal function, no far variant necessary.
|
---|
54 | mov eax, [BS3_DATA16_WRT(g_PhysPagingRootPP)]
|
---|
55 | cmp eax, 0ffffffffh
|
---|
56 | je .init_root
|
---|
57 | %ifdef BS3_STRICT
|
---|
58 | .return:
|
---|
59 | cmp eax, 1000h
|
---|
60 | jnb .cr3_ok_low
|
---|
61 | hlt
|
---|
62 | .cr3_ok_low:
|
---|
63 | cmp eax, 16*_1M
|
---|
64 | jb .cr3_ok_high
|
---|
65 | hlt
|
---|
66 | .cr3_ok_high:
|
---|
67 | %endif
|
---|
68 | ret
|
---|
69 |
|
---|
70 | .init_root:
|
---|
71 | push xBP
|
---|
72 | mov xBP, xSP
|
---|
73 | BONLY16 push es
|
---|
74 | push sDX
|
---|
75 | push sCX
|
---|
76 | push sBX
|
---|
77 | %if TMPL_BITS == 64
|
---|
78 | push r8
|
---|
79 | push r9
|
---|
80 | push r10
|
---|
81 | push r11
|
---|
82 | %endif
|
---|
83 |
|
---|
84 | %ifdef TMPL_RM
|
---|
85 | ;
|
---|
86 | ; We don't want to be restricted to real mode addressing, so
|
---|
87 | ; temporarily switch to 16-bit protected mode.
|
---|
88 | ;
|
---|
89 | call TMPL_NM(Bs3SwitchToPE16)
|
---|
90 | call Bs3PagingInitRootForPP
|
---|
91 | call NAME(Bs3SwitchToRM_pe16)
|
---|
92 |
|
---|
93 | %elifdef TMPL_CMN_V86
|
---|
94 | ;
|
---|
95 | ; V8086 mode uses real mode addressing too. Unlikly that we'll
|
---|
96 | ; ever end up here though.
|
---|
97 | ;
|
---|
98 | call TMPL_NM(Bs3SwitchToRing0)
|
---|
99 | call Bs3PagingInitRootForPP
|
---|
100 | call TMPL_NM(Bs3SwitchTo16BitV86)
|
---|
101 | %else
|
---|
102 | ;
|
---|
103 | ; Not a problematic addressing mode.
|
---|
104 | ;
|
---|
105 | BONLY64 sub rsp, 20h
|
---|
106 | BS3_CALL Bs3PagingInitRootForPP, 0
|
---|
107 | BONLY64 add rsp, 20h
|
---|
108 | %endif
|
---|
109 |
|
---|
110 | ;
|
---|
111 | ; Load the value and return.
|
---|
112 | ;
|
---|
113 | mov eax, [BS3_DATA16_WRT(g_PhysPagingRootPP)]
|
---|
114 |
|
---|
115 | %if TMPL_BITS == 64
|
---|
116 | pop r11
|
---|
117 | pop r10
|
---|
118 | pop r9
|
---|
119 | pop r8
|
---|
120 | %endif
|
---|
121 | pop sBX
|
---|
122 | pop sCX
|
---|
123 | pop sDX
|
---|
124 | BONLY16 pop es
|
---|
125 | leave
|
---|
126 | %ifdef BS3_STRICT
|
---|
127 | jmp .return
|
---|
128 | %else
|
---|
129 | ret
|
---|
130 | %endif
|
---|
131 | BS3_PROC_END_MODE Bs3PagingGetRootForPP32
|
---|
132 |
|
---|