1 ;------------------------------------------------------------------------------
3 ; Transition from 16 bit real mode into 32 bit flat protected mode
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
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.
14 ;------------------------------------------------------------------------------
16 %define SEC_DEFAULT_CR0 0x40000023
17 %define SEC_DEFAULT_CR4 0x640
24 TransitionFromReal16To32BitFlat:
26 debugShowPostCode POSTCODE_16BIT_MODE
33 mov bx, ADDR16_OF(gdtr)
37 mov eax, SEC_DEFAULT_CR0
40 jmp LINEAR_CODE_SEL:dword ADDR_OF(jumpTo32BitAndLandHere)
42 jumpTo32BitAndLandHere:
44 mov eax, SEC_DEFAULT_CR4
47 debugShowPostCode POSTCODE_32BIT_MODE
56 OneTimeCallRet TransitionFromReal16To32BitFlat
61 dw GDT_END - GDT_BASE - 1 ; GDT limit
68 NULL_SEL equ $-GDT_BASE
73 db 0 ; limit 19:16, flags
76 ; linear data segment descriptor
77 LINEAR_SEL equ $-GDT_BASE
78 dw 0FFFFh ; limit 0xFFFFF
81 db 092h ; present, ring 0, data, expand-up, writable
82 db 0CFh ; page-granular, 32-bit
85 ; linear code segment descriptor
86 LINEAR_CODE_SEL equ $-GDT_BASE
87 dw 0FFFFh ; limit 0xFFFFF
90 db 09Ah ; present, ring 0, data, expand-up, writable
91 db 0CFh ; page-granular, 32-bit
94 ; system data segment descriptor
95 SYS_DATA_SEL equ $-GDT_BASE
96 dw 0FFFFh ; limit 0xFFFFF
99 db 092h ; present, ring 0, data, expand-up, writable
100 db 0CFh ; page-granular, 32-bit
103 ; system code segment descriptor
104 SYS_CODE_SEL equ $-GDT_BASE
105 dw 0FFFFh ; limit 0xFFFFF
108 db 09Ah ; present, ring 0, data, expand-up, writable
109 db 0CFh ; page-granular, 32-bit
112 ; spare segment descriptor
113 LINEAR_CODE64_SEL equ $-GDT_BASE
118 DB 0afh ; LimitHigh (CS.L=1, CS.D=0)
121 ; spare segment descriptor
122 SPARE4_SEL equ $-GDT_BASE
126 db 0 ; present, ring 0, data, expand-up, writable
127 db 0 ; page-granular, 32-bit
130 ; spare segment descriptor
131 SPARE5_SEL equ $-GDT_BASE
135 db 0 ; present, ring 0, data, expand-up, writable
136 db 0 ; page-granular, 32-bit