1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2008, Intel Corporation
4 ; All rights reserved. This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 ; Transition from 16 bit real mode into 32 bit flat protected mode
20 ;------------------------------------------------------------------------------
22 %define SEC_DEFAULT_CR0 0x40000023
23 %define SEC_DEFAULT_CR4 0x640
38 mov bx, ADDR16_OF(gdtr)
42 mov eax, SEC_DEFAULT_CR0
49 jmp LINEAR_CODE_SEL:dword ADDR_OF(jumpTo32BitAndLandHere)
51 jumpTo32BitAndLandHere:
53 mov eax, SEC_DEFAULT_CR4
67 jmp TransitionFrom16RealTo32FlatComplete
72 dw GDT_END - GDT_BASE - 1 ; GDT limit
79 NULL_SEL equ $-GDT_BASE
84 db 0 ; limit 19:16, flags
87 ; linear data segment descriptor
88 LINEAR_SEL equ $-GDT_BASE
89 dw 0FFFFh ; limit 0xFFFFF
92 db 092h ; present, ring 0, data, expand-up, writable
93 db 0CFh ; page-granular, 32-bit
96 ; linear code segment descriptor
97 LINEAR_CODE_SEL equ $-GDT_BASE
98 dw 0FFFFh ; limit 0xFFFFF
101 db 09Ah ; present, ring 0, data, expand-up, writable
102 db 0CFh ; page-granular, 32-bit
105 ; system data segment descriptor
106 SYS_DATA_SEL equ $-GDT_BASE
107 dw 0FFFFh ; limit 0xFFFFF
110 db 092h ; present, ring 0, data, expand-up, writable
111 db 0CFh ; page-granular, 32-bit
114 ; system code segment descriptor
115 SYS_CODE_SEL equ $-GDT_BASE
116 dw 0FFFFh ; limit 0xFFFFF
119 db 09Ah ; present, ring 0, data, expand-up, writable
120 db 0CFh ; page-granular, 32-bit
123 ; spare segment descriptor
124 LINEAR_CODE64_SEL equ $-GDT_BASE
129 DB 0afh ; LimitHigh (CS.L=1, CS.D=0)
132 ; spare segment descriptor
133 SPARE4_SEL equ $-GDT_BASE
137 db 0 ; present, ring 0, data, expand-up, writable
138 db 0 ; page-granular, 32-bit
141 ; spare segment descriptor
142 SPARE5_SEL equ $-GDT_BASE
146 db 0 ; present, ring 0, data, expand-up, writable
147 db 0 ; page-granular, 32-bit