]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/ResetVector/Ia16/16RealTo32Flat.asm
OVMF ResetVector: Modify interface with SEC module
[mirror_edk2.git] / OvmfPkg / ResetVector / Ia16 / 16RealTo32Flat.asm
1 ;------------------------------------------------------------------------------
2 ; @file
3 ; Transition from 16 bit real mode into 32 bit flat protected mode
4 ;
5 ; Copyright (c) 2008 - 2009, Intel Corporation
6 ; All rights reserved. This program and the accompanying materials
7 ; are licensed and made available under the terms and conditions of the BSD License
8 ; which accompanies this distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php
10 ;
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 ;
14 ;------------------------------------------------------------------------------
15
16 %define SEC_DEFAULT_CR0 0x40000023
17 %define SEC_DEFAULT_CR4 0x640
18
19 BITS 16
20
21 ;
22 ; Modified: EAX, EBX
23 ;
24 TransitionFromReal16To32BitFlat:
25
26 debugShowPostCode POSTCODE_16BIT_MODE
27
28 cli
29
30 mov bx, 0xf000
31 mov ds, bx
32
33 mov bx, ADDR16_OF(gdtr)
34
35 o32 lgdt [bx]
36
37 mov eax, SEC_DEFAULT_CR0
38 mov cr0, eax
39
40 jmp LINEAR_CODE_SEL:dword ADDR_OF(jumpTo32BitAndLandHere)
41 BITS 32
42 jumpTo32BitAndLandHere:
43
44 mov eax, SEC_DEFAULT_CR4
45 mov cr4, eax
46
47 debugShowPostCode POSTCODE_32BIT_MODE
48
49 mov ax, LINEAR_SEL
50 mov ds, ax
51 mov es, ax
52 mov fs, ax
53 mov gs, ax
54 mov ss, ax
55
56 OneTimeCallRet TransitionFromReal16To32BitFlat
57
58 ALIGN 2
59
60 gdtr:
61 dw GDT_END - GDT_BASE - 1 ; GDT limit
62 dd ADDR_OF(GDT_BASE)
63
64 ALIGN 16
65
66 GDT_BASE:
67 ; null descriptor
68 NULL_SEL equ $-GDT_BASE
69 dw 0 ; limit 15:0
70 dw 0 ; base 15:0
71 db 0 ; base 23:16
72 db 0 ; type
73 db 0 ; limit 19:16, flags
74 db 0 ; base 31:24
75
76 ; linear data segment descriptor
77 LINEAR_SEL equ $-GDT_BASE
78 dw 0FFFFh ; limit 0xFFFFF
79 dw 0 ; base 0
80 db 0
81 db 092h ; present, ring 0, data, expand-up, writable
82 db 0CFh ; page-granular, 32-bit
83 db 0
84
85 ; linear code segment descriptor
86 LINEAR_CODE_SEL equ $-GDT_BASE
87 dw 0FFFFh ; limit 0xFFFFF
88 dw 0 ; base 0
89 db 0
90 db 09Ah ; present, ring 0, data, expand-up, writable
91 db 0CFh ; page-granular, 32-bit
92 db 0
93
94 ; system data segment descriptor
95 SYS_DATA_SEL equ $-GDT_BASE
96 dw 0FFFFh ; limit 0xFFFFF
97 dw 0 ; base 0
98 db 0
99 db 092h ; present, ring 0, data, expand-up, writable
100 db 0CFh ; page-granular, 32-bit
101 db 0
102
103 ; system code segment descriptor
104 SYS_CODE_SEL equ $-GDT_BASE
105 dw 0FFFFh ; limit 0xFFFFF
106 dw 0 ; base 0
107 db 0
108 db 09Ah ; present, ring 0, data, expand-up, writable
109 db 0CFh ; page-granular, 32-bit
110 db 0
111
112 ; spare segment descriptor
113 LINEAR_CODE64_SEL equ $-GDT_BASE
114 DW -1 ; LimitLow
115 DW 0 ; BaseLow
116 DB 0 ; BaseMid
117 DB 9bh
118 DB 0afh ; LimitHigh (CS.L=1, CS.D=0)
119 DB 0 ; BaseHigh
120
121 ; spare segment descriptor
122 SPARE4_SEL equ $-GDT_BASE
123 dw 0 ; limit 0xFFFFF
124 dw 0 ; base 0
125 db 0
126 db 0 ; present, ring 0, data, expand-up, writable
127 db 0 ; page-granular, 32-bit
128 db 0
129
130 ; spare segment descriptor
131 SPARE5_SEL equ $-GDT_BASE
132 dw 0 ; limit 0xFFFFF
133 dw 0 ; base 0
134 db 0
135 db 0 ; present, ring 0, data, expand-up, writable
136 db 0 ; page-granular, 32-bit
137 db 0
138
139 GDT_END:
140