summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-24 05:33:03 +0000
committerbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-24 05:33:03 +0000
commit18c319ae39f741101ccf0b076bb749e05344d443 (patch)
tree2ff98855267f75d38c3235c911c15db2ecd0dd4a /MdePkg
parent4df60ea54fd2ee5bf97586f453165ab3533a1aec (diff)
downloadedk2-18c319ae39f741101ccf0b076bb749e05344d443.zip
edk2-18c319ae39f741101ccf0b076bb749e05344d443.tar.gz
edk2-18c319ae39f741101ccf0b076bb749e05344d443.tar.bz2
1. Updated CpuFlushTlb() according to IA-64 programmer's guide
2. Updated Thunk code to preserve EFLAGS/RFLAGS across real mode code invocation 3. Updated comments in x86Thunk.c git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@248 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/BaseLib/BaseLib.msa1
-rw-r--r--MdePkg/Library/BaseLib/Ia32/Thunk16.asm8
-rw-r--r--MdePkg/Library/BaseLib/Ipf/CpuFlushTlb.s38
-rw-r--r--MdePkg/Library/BaseLib/Ipf/PalCallStatic.s47
-rw-r--r--MdePkg/Library/BaseLib/X64/Thunk16.asm7
-rw-r--r--MdePkg/Library/BaseLib/x86Thunk.c4
6 files changed, 100 insertions, 5 deletions
diff --git a/MdePkg/Library/BaseLib/BaseLib.msa b/MdePkg/Library/BaseLib/BaseLib.msa
index 7719c3a..0bba18d 100644
--- a/MdePkg/Library/BaseLib/BaseLib.msa
+++ b/MdePkg/Library/BaseLib/BaseLib.msa
@@ -265,6 +265,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
</Arch>
<Arch ArchType="IPF">
<Filename>Math64.c</Filename>
+ <Filename>Ipf/PalCallStatic.s</Filename>
<Filename>Ipf/setjmp.s</Filename>
<Filename>Ipf/SwitchStack.s</Filename>
<Filename>Ipf/Unaligned.c</Filename>
diff --git a/MdePkg/Library/BaseLib/Ia32/Thunk16.asm b/MdePkg/Library/BaseLib/Ia32/Thunk16.asm
index 89d4f67..454b890 100644
--- a/MdePkg/Library/BaseLib/Ia32/Thunk16.asm
+++ b/MdePkg/Library/BaseLib/Ia32/Thunk16.asm
@@ -141,6 +141,12 @@ _ToUserCode PROC
call @Base ; push eip
@Base:
pop bp ; ebp <- offset @Base
+ DB 67h ; address size override
+ push [esp + sizeof (IA32_REGS) + 2]
+ lea eax, [esi + (offset @RealMode - offset @Base)]
+ push eax
+ retf
+@RealMode:
mov cs:[esi + (offset SavedSs - offset @Base)], edx
mov cs:[esi + (offset SavedEsp - offset @Base)], bx
DB 66h
@@ -208,7 +214,9 @@ InternalAsmThunk16 PROC USES ebp ebx esi edi ds es fs gs
push 10h
pop ecx ; ecx <- selector for data segments
lgdt fword ptr [edx + (offset _16Gdtr - offset SavedCr0)]
+ pushfd
call fword ptr [edx + (offset _EntryPoint - offset SavedCr0)]
+ popfd
lidt fword ptr [esp + 36] ; restore protected mode IDTR
lea eax, [ebp - sizeof (IA32_REGS)]
ret
diff --git a/MdePkg/Library/BaseLib/Ipf/CpuFlushTlb.s b/MdePkg/Library/BaseLib/Ipf/CpuFlushTlb.s
index 0afd87e..6088304 100644
--- a/MdePkg/Library/BaseLib/Ipf/CpuFlushTlb.s
+++ b/MdePkg/Library/BaseLib/Ipf/CpuFlushTlb.s
@@ -17,13 +17,41 @@
.auto
.text
+.global PalCallStatic
+.type PalCallStatic, @function
+
.proc CpuFlushTlb
.type CpuFlushTlb, @function
CpuFlushTlb::
- mov r8 = ip
- mov r9 = -1
- dep.z r10 = -1, 61, 3
- and r8 = r8, r10
- ptc.l r8, r9
+ alloc loc0 = ar.pfs, 0, 2, 5, 0
+ mov out0 = 0
+ mov out1 = 6
+ mov out2 = 0
+ mov out3 = 0
+ mov out4 = 0
+ mov loc1 = b0
+ br.call.sptk b0 = PalCallStatic
+ rsm 1 << 14 // Disable interrupts
+ mov ar.pfs = loc0
+ extr.u r14 = r10, 32, 32 // r14 <- count1
+ extr.u r15 = r11, 32, 32 // r15 <- stride1
+ extr.u r10 = r10, 0, 32 // r10 <- count2
+ mov loc0 = psr
+ extr.u r11 = r11, 0, 32 // r11 <- stride2
+ br.cond.sptk LoopPredicate
+LoopOuter:
+ mov ar.lc = r10 // LC <- count2
+ mov ar.ec = r0 // EC <- 0
+Loop:
+ ptc.e r9
+ add r9 = r11, r9 // r9 += stride2
+ br.ctop.sptk Loop
+ add r9 = r15, r9 // r9 += stride1
+LoopPredicate:
+ cmp.ne p6, p7 = r0, r14 // count1 == 0?
+ add r14 = -1, r14
+(p6) br.cond.sptk LoopOuter
+ mov psr.l = loc0
+ mov b0 = loc1
br.ret.sptk.many b0
.endp
diff --git a/MdePkg/Library/BaseLib/Ipf/PalCallStatic.s b/MdePkg/Library/BaseLib/Ipf/PalCallStatic.s
new file mode 100644
index 0000000..7fa68e1
--- /dev/null
+++ b/MdePkg/Library/BaseLib/Ipf/PalCallStatic.s
@@ -0,0 +1,47 @@
+/// @file
+/// Contains an implementation of CallPalProcStatic on Itanium-based
+/// architecture.
+///
+/// Copyright (c) 2006, Intel Corporation
+/// All rights reserved. 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
+/// http://opensource.org/licenses/bsd-license.php
+///
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+///
+/// Module Name: PalCallStatic.s
+///
+///
+
+.auto
+.text
+
+.proc PalCallStatic
+.type PalCallStatic, @function
+.regstk 5, 0, 0, 0
+PalCallStatic::
+ cmp.ne p6, p7 = r0, in0
+ mov r31 = in4
+ mov r8 = ip
+(p6) mov in0 = ar.k5
+ add r8 = (PalProcReturn - PalCallStatic), r8
+ mov in4 = b0
+ mov r30 = in3
+ mov r29 = in2
+ mov b7 = in0
+ mov in3 = psr
+ rsm 1 << 14 // Disable interrupts
+ mov r28 = in1
+ mov in0 = 256
+ mov b0 = r8
+ br.cond.sptk b7
+PalProcReturn:
+ mov psr.l = in3
+ cmp.eq p6, p7 = in0, in1 // in1 == PAL_COPY_PAL?
+(p6) cmp.eq p6, p7 = r0, r8 // Status == Success?
+(p6) mov ar.k5 = in2
+ mov b0 = in4
+ br.ret.sptk.many b0
+.endp PalCallStatic
diff --git a/MdePkg/Library/BaseLib/X64/Thunk16.asm b/MdePkg/Library/BaseLib/X64/Thunk16.asm
index 15aaa80..3121867 100644
--- a/MdePkg/Library/BaseLib/X64/Thunk16.asm
+++ b/MdePkg/Library/BaseLib/X64/Thunk16.asm
@@ -149,6 +149,11 @@ _ToUserCode PROC
call @Base ; push eip
@Base:
pop bp ; ebp <- offset @Base
+ push [esp + sizeof (IA32_REGS) + 2]
+ lea eax, [rsi + (offset @RealMode - offset @Base)]
+ push rax
+ retf
+@RealMode:
DB 2eh ; cs:
mov [rsi + (offset SavedSs - offset @Base)], edi
DB 2eh ; cs:
@@ -222,7 +227,9 @@ InternalAsmThunk16 PROC USES rbp rbx rsi rdi
push 10h
pop rdx ; rdx <- selector for data segments
lgdt fword ptr [rcx + (offset _16Gdtr - offset SavedCr4)]
+ pushfq
call fword ptr [rcx + (offset _EntryPoint - offset SavedCr4)]
+ popfq
lidt fword ptr [rsp + 38h] ; restore protected mode IDTR
lea eax, [rbp - sizeof (IA32_REGS)]
pop gs
diff --git a/MdePkg/Library/BaseLib/x86Thunk.c b/MdePkg/Library/BaseLib/x86Thunk.c
index d4e37ae..9e69255 100644
--- a/MdePkg/Library/BaseLib/x86Thunk.c
+++ b/MdePkg/Library/BaseLib/x86Thunk.c
@@ -95,6 +95,10 @@ AsmGetThunk16Properties (
ASSERT (ExtraStackSize != NULL);
*RealModeBufferSize = m16Size;
+
+ //
+ // Extra 4 bytes for return address, and another 4 bytes for mode transition
+ //
*ExtraStackSize = sizeof (IA32_DWORD_REGS) + 8;
}