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
This commit is contained in:
bxing 2006-05-24 05:33:03 +00:00
parent 4df60ea54f
commit 18c319ae39
6 changed files with 100 additions and 5 deletions

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}