1 #*****************************************************************************
3 #* Copyright (c) 2006 - 2009, 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.
20 #*****************************************************************************
25 .globl ASM_PFX(mCode16Size)
28 mCode16Size: .long _TEXT16SIZE
38 .byte 0x8f # 16-bit segment
45 .byte 0x8f # 16-bit segment
49 .word _16Gdtr - NullSegSel - 1
66 movzwl 0x32(%esi),%edx
69 push %edi #; save stack offset
70 imul $0x10,%edx,%eax #; eax <- edx*16
71 add %eax,%edi #; edi <- linear address of 16-bit stack
74 rep movsl %ds:(%esi),%es:(%edi) #; copy context to 16-bit stack
75 pop %ebx #; ebx <- 16-bit stack offset
89 mov %esi,0x6(%edi) #; save CR0
90 and $0x7ffffffe,%esi #; esi <- CR0 to set
92 mov %eax,0xa(%edi) #; save CR4
93 and $0xcf,%al #; clear PAE & PSE
94 mov %edx,%edi #; edi <- 16-bit stack segment
99 mov $(_16BitSsSel - NullSegSel),%dx
100 lgdtl _16Gdtr #bugbug mismatch.
102 .long L_16Bit #bugbug mismatch.
103 .word _16BitCsSel - NullSegSel
134 movw %di, %ss # set up stack
136 lidt %cs:_16Idtr - _Code16Addr #lidt fword ptr cs:[_16Idtr - _Code16Addr]
143 addw $4, %sp # skip EFlags
144 testw $1, 14(%esp) #(_STK16 ptr [esp + 8]).ThunkFlags, 1
149 # push @FarCallRet - _Code16Addr
150 .byte 0x68 # push /iw
151 .word FarCallRet - _Code16Addr
153 ljmp *6(%esp) #bugbug
155 ljmp *4(%esp) #bugbug
164 .byte 0x66 # sizeof (IA32_REGS) = 13 * 4 = 52
165 lgdt 66(%esp) #lgdt (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedGdtr
169 movl %eax, %cr0 # restore CR0
175 .word 0x3ff #_16Idtr FWORD (1 SHL 10) - 1
180 _TEXT16SIZE = _TEXT16END - _Code16Addr