VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/pmode.inc@ 104821

Last change on this file since 104821 was 98103, checked in by vboxsync, 22 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: 2.1 KB
Line 
1; $Id: pmode.inc 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; Enter and exit a minimal protected-mode environment.
4;
5
6;
7; Copyright (C) 2004-2023 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; SPDX-License-Identifier: GPL-3.0-only
26;
27
28;; Caveats: May only be called from the F000 segment (16-bit). Does not
29;; switch stacks. Must be run with disabled interrupts(!), any exceptions
30;; will cause a crash. On return from pmode_enter, DS contains a selector
31;; which can address the entire 4GB address space.
32
33public pmode_enter
34public pmode_exit
35public pmbios_gdt_desc
36public pmbios_gdt
37
38pmode_enter proc near
39
40 push cs
41 pop ds
42 .386p
43 lgdt fword ptr [pmbios_gdt_desc]
44 mov eax, cr0
45 or al, 1
46 mov cr0, eax
47; jmp far ptr 20h:really_enter_pm
48 db 0EAh
49 dw really_enter_pm
50 dw 20h
51really_enter_pm:
52 mov ax, 18h
53 mov ds, ax
54 ret
55
56pmode_enter endp
57
58
59pmode_exit proc near
60
61 mov ax, 40h ; Ensure RM limit/attributes
62 mov ds, ax ; (where base = selector << 4)
63
64 mov eax, cr0
65 and al, 0FEh
66 mov cr0, eax
67 SET_DEFAULT_CPU_286
68 jmp far ptr really_exit_pm
69really_exit_pm:
70 ret
71
72pmode_exit endp
73
74
75
76pmbios_gdt_desc:
77 dw 40h + 7 ; last selector plus 8 - 1
78 dw pmbios_gdt
79 dw 000Fh
80
81pmbios_gdt:
82 dw 0, 0, 0, 0
83 dw 0, 0, 0, 0
84 dw 0ffffh, 0, 9b00h, 00cfh ; 32-bit code (0x10)
85 dw 0ffffh, 0, 9300h, 00cfh ; 32-bit data (0x18)
86 dw 0ffffh, 0, 9b0fh, 0000h ; 16-bit code, base=0xf0000
87 dw 0ffffh, 0, 9300h, 0000h ; 16-bit data, base=0x0
88 dw 0, 0, 0, 0
89 dw 0, 0, 0, 0
90 dw 0ffffh, 400h, 9300h, 0000h ; 16-bit data, base=0x40
91
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