diff options
Diffstat (limited to 'MdePkg/Library')
-rw-r--r-- | MdePkg/Library/BaseLib/BaseLib.msa | 1 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/Ia32/Thunk16.asm | 8 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/Ipf/CpuFlushTlb.s | 38 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/Ipf/PalCallStatic.s | 47 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/X64/Thunk16.asm | 7 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/x86Thunk.c | 4 |
6 files changed, 100 insertions, 5 deletions
diff --git a/MdePkg/Library/BaseLib/BaseLib.msa b/MdePkg/Library/BaseLib/BaseLib.msa index 7719c3af01..0bba18d0bc 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 89d4f679b6..454b8905bc 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 0afd87e88b..608830496c 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 0000000000..7fa68e15f6 --- /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 15aaa80090..3121867ebb 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 d4e37ae59e..9e69255181 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;
}
|