1 #*****************************************************************************
3 #* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
4 #* 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 #; copy eflags to stack frame
78 pop %ebx #; ebx <- 16-bit stack offset
92 mov %esi,0x6(%edi) #; save CR0
93 and $0x7ffffffe,%esi #; esi <- CR0 to set
95 mov %eax,0xa(%edi) #; save CR4
96 and $0xcf,%al #; clear PAE & PSE
97 mov %edx,%edi #; edi <- 16-bit stack segment
102 mov $(_16BitSsSel - NullSegSel),%dx
103 lgdtl _16Gdtr #bugbug mismatch.
105 .long L_16Bit #bugbug mismatch.
106 .word _16BitCsSel - NullSegSel
137 movw %di, %ss # set up stack
139 lidt %cs:_16Idtr - _Code16Addr #lidt fword ptr cs:[_16Idtr - _Code16Addr]
148 testw $1, 74(%esp) #(_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
151 pushf # push Flags when it's INT#
154 # push @FarCallRet - _Code16Addr
155 .byte 0x68 # push /iw
156 .word FarCallRet - _Code16Addr
158 ljmp *66(%esp) #[esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
160 ljmp *64(%esp) #[esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
170 .byte 0x66 # sizeof (IA32_REGS) = 13 * 4 = 52
171 lgdt 66(%esp) #lgdt (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedGdtr
175 movl %eax, %cr0 # restore CR0
181 .word 0x3ff #_16Idtr FWORD (1 SHL 10) - 1
186 _TEXT16SIZE = _TEXT16END - _Code16Addr