Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#*****************************************************************************
|
||||
#*
|
||||
#* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
#* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#* This program and the accompanying materials
|
||||
#* are licensed and made available under the terms and conditions of the BSD License
|
||||
#* which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -51,4 +51,26 @@ ASM_PFX(AsmFxRestore):
|
||||
ret
|
||||
#AsmFxRestore ENDP
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# UINTN
|
||||
# AsmGetEflags (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(AsmGetEflags):
|
||||
pushfl
|
||||
pop %eax
|
||||
ret
|
||||
#AsmGetEflags ENDP
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# AsmSetEflags (
|
||||
# IN UINTN Eflags
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(AsmSetEflags):
|
||||
push 4(%esp)
|
||||
popfl
|
||||
ret
|
||||
#AsmSetEflags ENDP
|
||||
|
@@ -1,6 +1,6 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
;* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
;* This program and the accompanying materials
|
||||
;* are licensed and made available under the terms and conditions of the BSD License
|
||||
;* which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -48,4 +48,28 @@ AsmFxRestore PROC
|
||||
ret
|
||||
AsmFxRestore ENDP
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; UINTN
|
||||
; AsmGetEflags (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
AsmGetEflags PROC
|
||||
pushfd
|
||||
pop eax
|
||||
ret
|
||||
AsmGetEflags ENDP
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; AsmSetEflags (
|
||||
; IN UINTN Eflags
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
AsmSetEflags PROC
|
||||
push [esp + 4]
|
||||
popfd
|
||||
ret
|
||||
AsmSetEflags ENDP
|
||||
|
||||
END
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#*****************************************************************************
|
||||
#*
|
||||
#* Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
#* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#* This program and the accompanying materials
|
||||
#* are licensed and made available under the terms and conditions of the BSD License
|
||||
#* which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -72,6 +72,9 @@ ASM_PFX(Thunk16):
|
||||
push $0xd
|
||||
pop %ecx
|
||||
rep movsl %ds:(%esi),%es:(%edi) #; copy context to 16-bit stack
|
||||
#; copy eflags to stack frame
|
||||
mov -12(%esi), %eax
|
||||
mov %eax, -72(%edi)
|
||||
pop %ebx #; ebx <- 16-bit stack offset
|
||||
mov $L_Lable1,%eax
|
||||
stos %eax,%es:(%edi)
|
||||
@@ -140,20 +143,23 @@ ASM_PFX(RealMode):
|
||||
popw %es
|
||||
popw %fs
|
||||
popw %gs
|
||||
addw $4, %sp # skip EFlags
|
||||
testw $1, 14(%esp) #(_STK16 ptr [esp + 8]).ThunkFlags, 1
|
||||
sub 60, %esp
|
||||
popfw
|
||||
testw $1, 74(%esp) #(_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
|
||||
|
||||
jz 1f
|
||||
pushf
|
||||
pushf # push Flags when it's INT#
|
||||
1:
|
||||
pushw %cs
|
||||
# push @FarCallRet - _Code16Addr
|
||||
.byte 0x68 # push /iw
|
||||
.word FarCallRet - _Code16Addr
|
||||
jz 2f
|
||||
ljmp *6(%esp) #bugbug
|
||||
ljmp *66(%esp) #[esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
|
||||
2:
|
||||
ljmp *4(%esp) #bugbug
|
||||
ljmp *64(%esp) #[esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
|
||||
FarCallRet:
|
||||
add 60, %esp
|
||||
pushfl
|
||||
pushw %gs
|
||||
pushw %fs
|
||||
|
@@ -1,6 +1,6 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
;* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
;* This program and the accompanying materials
|
||||
;* are licensed and made available under the terms and conditions of the BSD License
|
||||
;* which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -55,6 +55,8 @@ _DATA ENDS
|
||||
|
||||
_TEXT SEGMENT FLAT "CODE" PARA
|
||||
|
||||
STACK_PARAM_SIZE EQU 16
|
||||
|
||||
IA32_REGS STRUC 4t
|
||||
_EDI DD ?
|
||||
_ESI DD ?
|
||||
@@ -99,6 +101,11 @@ __Thunk16 PROC USES ebp ebx esi edi ds es fs gs
|
||||
push sizeof (IA32_REGS) / 4
|
||||
pop ecx
|
||||
rep movsd ; copy context to 16-bit stack
|
||||
|
||||
; copy eflags to stack frame
|
||||
mov eax, [esi - sizeof(IA32_REGS)]._EFLAGS
|
||||
mov [edi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 4], eax
|
||||
|
||||
pop ebx ; ebx <- 16-bit stack offset
|
||||
mov eax, offset @F ; return offset
|
||||
stosd
|
||||
@@ -158,20 +165,22 @@ RealMode PROC
|
||||
pop es
|
||||
pop fs
|
||||
pop gs
|
||||
add sp, 4 ; skip EFlags
|
||||
test (_STK16 ptr [esp + 8]).ThunkFlags, 1
|
||||
sub esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4
|
||||
popfd
|
||||
test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
|
||||
jz @F
|
||||
pushf
|
||||
pushf ; push Flags when it's INT#
|
||||
@@:
|
||||
push cs
|
||||
; push @FarCallRet - _Code16Addr
|
||||
DB 68h ; push /iw
|
||||
DW @FarCallRet - _Code16Addr
|
||||
jz @F
|
||||
jmp fword ptr [esp + 6]
|
||||
jmp fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
|
||||
@@:
|
||||
jmp fword ptr [esp + 4]
|
||||
jmp fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
|
||||
@FarCallRet:
|
||||
add esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4
|
||||
pushfd
|
||||
push gs
|
||||
push fs
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -237,6 +237,13 @@ Returns:
|
||||
--*/
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
AsmThunk16SetUserStack (
|
||||
IN THUNK_CONTEXT *ThunkContext,
|
||||
IN VOID *Stack,
|
||||
IN UINTN StackSize
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
AsmThunk16Destroy (
|
||||
|
@@ -41,8 +41,30 @@ ASM_PFX(AsmFxSave):
|
||||
# IN CONST IA32_FX_BUFFER *Buffer
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
ASM_PFX(AsmFxRestore):
|
||||
fxrstor (%rcx)
|
||||
retq
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# UINTN
|
||||
# AsmGetEflags (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(AsmGetEflags):
|
||||
pushfq
|
||||
popq %rax
|
||||
ret
|
||||
#AsmGetEflags ENDP
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# AsmSetEflags (
|
||||
# IN UINTN Eflags
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(AsmSetEflags):
|
||||
pushq %rcx
|
||||
popfq
|
||||
ret
|
||||
#AsmSetEflags ENDP
|
||||
|
@@ -1,6 +1,6 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
;* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
;* This program and the accompanying materials
|
||||
;* are licensed and made available under the terms and conditions of the BSD License
|
||||
;* which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -43,4 +43,28 @@ AsmFxRestore PROC
|
||||
ret
|
||||
AsmFxRestore ENDP
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; UINTN
|
||||
; AsmGetEflags (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
AsmGetEflags PROC
|
||||
pushfq
|
||||
pop rax
|
||||
ret
|
||||
AsmGetEflags ENDP
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; AsmSetEflags (
|
||||
; IN UINTN Eflags
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
AsmSetEflags PROC
|
||||
push rcx
|
||||
popfq
|
||||
ret
|
||||
AsmSetEflags ENDP
|
||||
|
||||
END
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#*****************************************************************************
|
||||
#*
|
||||
#* Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
#* Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#* This program and the accompanying materials
|
||||
#* are licensed and made available under the terms and conditions of the BSD License
|
||||
#* which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -106,6 +106,9 @@ ASM_PFX(Thunk16):
|
||||
pushq $0xe #push sizeof (IA32_REGS) / 4
|
||||
pop %rcx
|
||||
rep movsl %ds:(%rsi),%es:(%rdi)
|
||||
#; copy eflags to stack frame
|
||||
mov -16(%rsi), %rax
|
||||
mov %rax, -80(%rsi)
|
||||
pop %rbx #rbx <- 16-bit stack offset
|
||||
lea Label,%eax #42 <_Thunk16+0x42>
|
||||
stos %eax,%es:(%rdi)
|
||||
@@ -183,27 +186,30 @@ ASM_PFX(RealMode):
|
||||
.byte 0x07 #pop es
|
||||
popq %fs
|
||||
popq %gs
|
||||
add $0x8,%esp #skip RFLAGS
|
||||
.byte 0x67 #test [esp + 0eh], 1
|
||||
sub 64, %esp
|
||||
.byte 0x66, 0x9d #popfd
|
||||
add $0x4,%esp #skip high part of RFLAGS
|
||||
.byte 0x67 #; test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
|
||||
.byte 0xf7
|
||||
.byte 0x44
|
||||
.byte 0x24
|
||||
.byte 0x0e
|
||||
.byte 0x4e
|
||||
.byte 0x01
|
||||
.byte 0x00
|
||||
jz 1f
|
||||
pushfq #pushf, actually
|
||||
pushfq #pushf, actually, when it's INT#
|
||||
1:
|
||||
.byte 0x0e #push cs
|
||||
.byte 0x68 #push /iw
|
||||
.word FarCallRet - _Code16Addr
|
||||
jz 2f
|
||||
.byte 0x66
|
||||
ljmp *6(%esp)
|
||||
ljmp *70(%esp)
|
||||
2:
|
||||
.byte 0x66
|
||||
ljmp *4(%esp)
|
||||
ljmp *68(%esp)
|
||||
FarCallRet:
|
||||
add 64, %esp
|
||||
.byte 0x66
|
||||
push $0x00 #push a dword of zero
|
||||
.byte 0x66
|
||||
|
@@ -1,6 +1,6 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
;* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
;* This program and the accompanying materials
|
||||
;* are licensed and made available under the terms and conditions of the BSD License
|
||||
;* which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -49,6 +49,8 @@ _16Gdtr LABEL FWORD
|
||||
|
||||
.code
|
||||
|
||||
STACK_PARAM_SIZE EQU 16
|
||||
|
||||
IA32_REGS STRUC 4t
|
||||
_EDI DD ?
|
||||
_ESI DD ?
|
||||
@@ -98,6 +100,11 @@ _Thunk16 PROC USES rbp rbx rsi rdi r12 r13 r14 r15
|
||||
push sizeof (IA32_REGS) / 4
|
||||
pop rcx
|
||||
rep movsd
|
||||
|
||||
; copy eflags to stack frame
|
||||
mov rax, (IA32_REGS ptr [rsi - sizeof(IA32_REGS)])._RFLAGS
|
||||
mov [rdi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 8], rax
|
||||
|
||||
pop rbx ; rbx <- 16-bit stack offset
|
||||
lea eax, @F ; return offset
|
||||
stosd
|
||||
@@ -165,22 +172,27 @@ RealMode PROC
|
||||
DB 7 ; pop es
|
||||
pop fs
|
||||
pop gs
|
||||
sub esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8
|
||||
|
||||
add esp, 8 ; skip RFLAGS
|
||||
DB 67h, 0f7h, 44h, 24h, 0eh, 1, 0 ; test [esp + 0eh], 1
|
||||
DB 66h, 9Dh ; popfd
|
||||
add esp, 4 ; skip high part of RFLAGS
|
||||
DB 67h, 0f7h, 44h, 24h ; test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
|
||||
DB (STACK_PARAM_SIZE + sizeof(IA32_REGS) + 6)
|
||||
DB 1, 0
|
||||
jz @F
|
||||
pushfq ; pushf, actually
|
||||
pushfq ; pushf, actually, when it's INT#
|
||||
@@:
|
||||
DB 0eh ; push cs
|
||||
DB 68h ; push /iw
|
||||
DW @FarCallRet - _Code16Addr
|
||||
jz @F
|
||||
DB 66h
|
||||
jmp fword ptr [esp + 6]
|
||||
jmp fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
|
||||
@@:
|
||||
DB 66h
|
||||
jmp fword ptr [esp + 4]
|
||||
jmp fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
|
||||
@FarCallRet:
|
||||
add esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8
|
||||
DB 66h
|
||||
push 0 ; push a dword of zero
|
||||
pushf ; pushfd, actually
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -53,6 +53,18 @@ AsmFxSave (
|
||||
OUT IA32_FX_BUFFER *Buffer
|
||||
);
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
AsmGetEflags (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
AsmSetEflags (
|
||||
IN UINTN Eflags
|
||||
);
|
||||
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
@@ -98,6 +110,7 @@ Returns:
|
||||
{
|
||||
IA32_FX_BUFFER *FpSavedState;
|
||||
UINT8 FpBuffer[sizeof (*FpSavedState) + 0x10];
|
||||
UINTN Eflags;
|
||||
|
||||
FpSavedState = (IA32_FX_BUFFER*)(((UINTN)FpBuffer + 0xf) & ~0xf);
|
||||
|
||||
@@ -110,6 +123,8 @@ Returns:
|
||||
AsmFxSave (FpSavedState);
|
||||
}
|
||||
|
||||
Eflags = AsmGetEflags ();
|
||||
|
||||
EfiCommonLibCopyMem (
|
||||
RegisterSet,
|
||||
_Thunk16 (
|
||||
@@ -120,6 +135,8 @@ Returns:
|
||||
sizeof (*RegisterSet)
|
||||
);
|
||||
|
||||
AsmSetEflags (Eflags);
|
||||
|
||||
if (ThunkFlags & THUNK_SAVE_FP_STATE) {
|
||||
AsmFxRestore (FpSavedState);
|
||||
}
|
||||
@@ -200,6 +217,67 @@ Returns:
|
||||
return ThunkContext;
|
||||
}
|
||||
|
||||
#pragma pack (1)
|
||||
|
||||
typedef struct {
|
||||
UINT32 EDI;
|
||||
UINT32 ESI;
|
||||
UINT32 EBP;
|
||||
UINT32 ESP;
|
||||
UINT32 EBX;
|
||||
UINT32 EDX;
|
||||
UINT32 ECX;
|
||||
UINT32 EAX;
|
||||
UINT16 DS;
|
||||
UINT16 ES;
|
||||
UINT16 FS;
|
||||
UINT16 GS;
|
||||
UINTN EFLAGS;
|
||||
UINT32 EIP;
|
||||
UINT16 CS;
|
||||
UINT16 SS;
|
||||
} IA32_REGS;
|
||||
|
||||
typedef struct {
|
||||
UINT16 Limit;
|
||||
UINT32 Base;
|
||||
} IA32_DESC;
|
||||
|
||||
typedef struct {
|
||||
UINT32 RetEip;
|
||||
UINT16 RetCs;
|
||||
UINT16 ThunkFlags;
|
||||
#ifdef EFI32
|
||||
UINT32 SavedEsp;
|
||||
UINT16 SavedSs;
|
||||
#endif
|
||||
IA32_DESC SavedGdtr;
|
||||
#ifdef EFIX64
|
||||
UINT16 Resvd1;
|
||||
#endif
|
||||
UINT32 SavedCr0;
|
||||
UINT32 SavedCr4;
|
||||
} _STK16;
|
||||
#pragma pack ()
|
||||
|
||||
#define STACK_PARAM_SIZE 16
|
||||
|
||||
BOOLEAN
|
||||
AsmThunk16SetUserStack (
|
||||
IN THUNK_CONTEXT *ThunkContext,
|
||||
IN VOID *Stack,
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
if (StackSize > STACK_PARAM_SIZE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
EfiCommonLibCopyMem ((VOID *)(UINTN)(ThunkContext->DefaultStack - sizeof(_STK16) - sizeof(IA32_REGS) - STACK_PARAM_SIZE), Stack, StackSize);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
AsmThunk16Destroy (
|
||||
@@ -253,12 +331,8 @@ Arguments:
|
||||
set on input, otherwise ignored.
|
||||
EFlages is ignored on input.
|
||||
On output, values of CS, EIP, SS and ESP should be ignored.
|
||||
ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and
|
||||
THUNK_USER_STACK.
|
||||
THUNK_SAVE_FP_STATE - FPU state would be saved/restored
|
||||
before/after calling real mode code.
|
||||
THUNK_USER_STACK - The stack specified by SS:ESP would be
|
||||
used instead of the default stack.
|
||||
ThunkFlags - THUNK_USER_STACK: The stack specified by SS:ESP would be
|
||||
used instead of the default stack.
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -298,12 +372,8 @@ Arguments:
|
||||
set on input, otherwise ignored.
|
||||
EFlages is ignored on input.
|
||||
On output, values of CS, EIP, SS and ESP should be ignored.
|
||||
ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and
|
||||
THUNK_USER_STACK.
|
||||
THUNK_SAVE_FP_STATE - FPU state would be saved/restored
|
||||
before/after calling real mode code.
|
||||
THUNK_USER_STACK - The stack specified by SS:ESP would be
|
||||
used instead of the default stack.
|
||||
ThunkFlags - THUNK_USER_STACK: The stack specified by SS:ESP would be
|
||||
used instead of the default stack.
|
||||
|
||||
Returns:
|
||||
|
||||
|
Reference in New Issue
Block a user