From: bxing Date: Fri, 21 Jul 2006 08:47:38 +0000 (+0000) Subject: 1. Updated function headers in all assembly files. X-Git-Tag: edk2-stable201903~24805 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=3f566587aea64bb986866c7f69a6b82891bf59db 1. Updated function headers in all assembly files. 2. Split x86LowLevel.c into a bunch of C files to make images linked with BaseLib smaller. 3. Fixed a few minor bugs. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1066 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdePkg/Library/BaseLib/BaseLib.msa b/MdePkg/Library/BaseLib/BaseLib.msa index cb5359a14f..3f0224ba3b 100644 --- a/MdePkg/Library/BaseLib/BaseLib.msa +++ b/MdePkg/Library/BaseLib/BaseLib.msa @@ -83,8 +83,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. SwapBytes32.c SwapBytes64.c SwitchStack.c - x86LowLevel.c + x86DisablePaging32.c + x86DisablePaging64.c + x86EnablePaging32.c + x86EnablePaging64.c + x86FxRestore.c + x86FxSave.c + x86GetInterruptState.c + x86MemoryFence.c + x86Msr.c + x86ReadGdtr.c + x86ReadIdtr.c x86Thunk.c + x86WriteGdtr.c + x86WriteIdtr.c Unaligned.c Ia32/Non-existing.c Ia32/InternalSwitchStack.c @@ -107,7 +119,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Ia32/CpuIdEx.asm Ia32/ReadEflags.asm Ia32/ReadMsr64.asm - Ia32/WriteMsr32.asm Ia32/WriteMsr64.asm Ia32/ReadCr0.asm Ia32/ReadCr2.asm @@ -205,7 +216,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Ia32/CpuIdEx.S Ia32/ReadEflags.S Ia32/ReadMsr64.S - Ia32/WriteMsr32.S Ia32/WriteMsr64.S Ia32/ReadCr0.S Ia32/ReadCr2.S @@ -284,8 +294,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Ia32/CpuBreakpoint.S Ia32/CpuFlushTlb.S Ia32/Thunk16.S - x86LowLevel.c + x86DisablePaging32.c + x86DisablePaging64.c + x86EnablePaging32.c + x86EnablePaging64.c + x86FxRestore.c + x86FxSave.c + x86GetInterruptState.c + x86MemoryFence.c + x86Msr.c + x86ReadGdtr.c + x86ReadIdtr.c x86Thunk.c + x86WriteGdtr.c + x86WriteIdtr.c Unaligned.c Math64.c X64/Non-existing.c @@ -295,9 +317,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. X64/CpuId.asm X64/CpuIdEx.asm X64/ReadEflags.asm - X64/ReadMsr32.asm X64/ReadMsr64.asm - X64/WriteMsr32.asm X64/WriteMsr64.asm X64/ReadCr0.asm X64/ReadCr2.asm diff --git a/MdePkg/Library/BaseLib/Ia32/ARShiftU64.S b/MdePkg/Library/BaseLib/Ia32/ARShiftU64.S index 426ce5bd26..a41cfdb65c 100644 --- a/MdePkg/Library/BaseLib/Ia32/ARShiftU64.S +++ b/MdePkg/Library/BaseLib/Ia32/ARShiftU64.S @@ -19,21 +19,23 @@ # #------------------------------------------------------------------------------ - - - - .global _InternalMathARShiftU64 -_InternalMathARShiftU64: - movb 12(%esp),%cl - movl 8(%esp),%eax + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathARShiftU64 ( +# IN UINT64 Operand, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ +_InternalMathARShiftU64: + movb 12(%esp), %cl + movl 8(%esp), %eax cltd - testb $32,%cl + testb $32, %cl cmovz %eax, %edx cmovz 4(%esp), %eax - shrdl %cl,%edx,%eax - sar %cl,%edx + shrdl %cl, %edx, %eax + sar %cl, %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ARShiftU64.asm b/MdePkg/Library/BaseLib/Ia32/ARShiftU64.asm index 6b9cfa18a8..17f07bb66c 100644 --- a/MdePkg/Library/BaseLib/Ia32/ARShiftU64.asm +++ b/MdePkg/Library/BaseLib/Ia32/ARShiftU64.asm @@ -23,6 +23,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathARShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ InternalMathARShiftU64 PROC mov cl, [esp + 12] mov eax, [esp + 8] @@ -35,4 +43,4 @@ InternalMathARShiftU64 PROC ret InternalMathARShiftU64 ENDP - END \ No newline at end of file + END diff --git a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.S b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.S index 859369e50f..f88dc6846d 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.S +++ b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.S @@ -20,10 +20,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _CpuBreakpoint #------------------------------------------------------------------------------ # VOID @@ -32,10 +29,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _CpuBreakpoint -_CpuBreakpoint: +_CpuBreakpoint: int $3 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.S b/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.S index 1d85fa77da..c9d6194cdc 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.S +++ b/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.S @@ -20,9 +20,7 @@ # #------------------------------------------------------------------------------ - - - +.global _CpuFlushTlb #------------------------------------------------------------------------------ # VOID @@ -31,11 +29,7 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _CpuFlushTlb -_CpuFlushTlb: +_CpuFlushTlb: movl %cr3, %eax movl %eax, %cr3 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.asm b/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.asm index de87ad75e9..367412403e 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.asm +++ b/MdePkg/Library/BaseLib/Ia32/CpuFlushTlb.asm @@ -21,7 +21,7 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -31,10 +31,10 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_CpuFlushTlb PROC +CpuFlushTlb PROC mov eax, cr3 mov cr3, eax ret -_CpuFlushTlb ENDP +CpuFlushTlb ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/CpuId.S b/MdePkg/Library/BaseLib/Ia32/CpuId.S index c394de926d..592ade651a 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuId.S +++ b/MdePkg/Library/BaseLib/Ia32/CpuId.S @@ -21,6 +21,7 @@ # #------------------------------------------------------------------------------ +.globl _AsmCpuid #------------------------------------------------------------------------------ # VOID @@ -33,33 +34,30 @@ # OUT UINT32 *RegisterOutEdx OPTIONAL # ) #------------------------------------------------------------------------------ -.globl _AsmCpuid _AsmCpuid: - pushl %ebx - pushl %ebp + push %ebx + push %ebp movl %esp, %ebp movl 12(%ebp), %eax cpuid - pushl %ecx + push %ecx movl 16(%ebp), %ecx jecxz L1 movl %eax, (%ecx) -L1: +L1: movl 20(%ebp), %ecx jecxz L2 movl %ebx, (%ecx) -L2: +L2: movl 24(%ebp), %ecx jecxz L3 popl (%ecx) -L3: +L3: movl 28(%ebp), %ecx jecxz L4 movl %edx, (%ecx) -L4: +L4: movl 12(%ebp), %eax leave - popl %ebx + pop %ebx ret - - diff --git a/MdePkg/Library/BaseLib/Ia32/CpuId.asm b/MdePkg/Library/BaseLib/Ia32/CpuId.asm index 2c94e3a1ae..5c0eb1ffc8 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuId.asm +++ b/MdePkg/Library/BaseLib/Ia32/CpuId.asm @@ -34,7 +34,7 @@ ; OUT UINT32 *RegisterOutEbx OPTIONAL, ; OUT UINT32 *RegisterOutEcx OPTIONAL, ; OUT UINT32 *RegisterOutEdx OPTIONAL -; ) +; ); ;------------------------------------------------------------------------------ AsmCpuid PROC USES ebx push ebp diff --git a/MdePkg/Library/BaseLib/Ia32/CpuIdEx.S b/MdePkg/Library/BaseLib/Ia32/CpuIdEx.S index e5255fb1a3..ab66fe75b2 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuIdEx.S +++ b/MdePkg/Library/BaseLib/Ia32/CpuIdEx.S @@ -21,8 +21,8 @@ # #------------------------------------------------------------------------------ - .686: - .code: + .686: + .code: #------------------------------------------------------------------------------ # UINT32 @@ -39,28 +39,28 @@ .globl _AsmCpuidEx _AsmCpuidEx: push %ebx - pushl %ebp + push %ebp movl %esp, %ebp movl 12(%ebp), %eax movl 16(%ebp), %ecx cpuid - pushl %ecx + push %ecx movl 20(%ebp), %ecx jecxz L1 movl %eax, (%ecx) -L1: +L1: movl 24(%ebp), %ecx jecxz L2 movl %ebx, (%ecx) -L2: +L2: movl 28(%ebp), %ecx jecxz L3 popl (%ecx) -L3: +L3: movl 32(%ebp), %edx jecxz L4 movl %edx, (%ecx) -L4: +L4: movl 12(%ebp), %eax leave pop %ebx diff --git a/MdePkg/Library/BaseLib/Ia32/CpuPause.S b/MdePkg/Library/BaseLib/Ia32/CpuPause.S index ace2c6764a..7df74327e5 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuPause.S +++ b/MdePkg/Library/BaseLib/Ia32/CpuPause.S @@ -20,10 +20,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _CpuPause #------------------------------------------------------------------------------ # VOID @@ -32,10 +29,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _CpuPause -_CpuPause: +_CpuPause: pause ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/CpuPause.asm b/MdePkg/Library/BaseLib/Ia32/CpuPause.asm index 79a4f2f67b..4c7135fc9c 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuPause.asm +++ b/MdePkg/Library/BaseLib/Ia32/CpuPause.asm @@ -21,7 +21,7 @@ ;------------------------------------------------------------------------------ .686 - .model flat + .model flat,C .xmm .code @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_CpuPause PROC +CpuPause PROC pause ret -_CpuPause ENDP +CpuPause ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/CpuSleep.S b/MdePkg/Library/BaseLib/Ia32/CpuSleep.S index 9b7713128f..93106df0f7 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuSleep.S +++ b/MdePkg/Library/BaseLib/Ia32/CpuSleep.S @@ -20,9 +20,7 @@ # #------------------------------------------------------------------------------ - - - +.global _CpuSleep #------------------------------------------------------------------------------ # VOID @@ -31,10 +29,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _CpuSleep -_CpuSleep: +_CpuSleep: hlt ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/CpuSleep.asm b/MdePkg/Library/BaseLib/Ia32/CpuSleep.asm index 66fb90e903..8a779f7017 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuSleep.asm +++ b/MdePkg/Library/BaseLib/Ia32/CpuSleep.asm @@ -21,7 +21,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -31,9 +31,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_CpuSleep PROC +CpuSleep PROC hlt ret -_CpuSleep ENDP +CpuSleep ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.S b/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.S index cc9c95c30f..a222d7a700 100644 --- a/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.S +++ b/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _DisableInterrupts #------------------------------------------------------------------------------ # VOID @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _DisableInterrupts -_DisableInterrupts: +_DisableInterrupts: cli ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.asm b/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.asm index 74bdd0bd98..35209ff0d4 100644 --- a/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.asm +++ b/MdePkg/Library/BaseLib/Ia32/DisableInterrupts.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_DisableInterrupts PROC +DisableInterrupts PROC cli ret -_DisableInterrupts ENDP +DisableInterrupts ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/DisablePaging32.S b/MdePkg/Library/BaseLib/Ia32/DisablePaging32.S index b4e488ffe6..5ade180009 100644 --- a/MdePkg/Library/BaseLib/Ia32/DisablePaging32.S +++ b/MdePkg/Library/BaseLib/Ia32/DisablePaging32.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalX86DisablePaging32 #------------------------------------------------------------------------------ # VOID @@ -35,24 +33,20 @@ # IN VOID *NewStack # ); #------------------------------------------------------------------------------ -.global _InternalX86DisablePaging32 -_InternalX86DisablePaging32: - movl 4(%esp),%ebx - movl 8(%esp),%ecx - movl 12(%esp),%edx +_InternalX86DisablePaging32: + movl 4(%esp), %ebx + movl 8(%esp), %ecx + movl 12(%esp), %edx pushfl - popl %edi + pop %edi cli movl %cr0, %eax - btrl $31,%eax - movl 16(%esp),%esp + btrl $31, %eax + movl 16(%esp), %esp movl %eax, %cr0 - pushl %edi + push %edi popfl - pushl %edx - pushl %ecx + push %edx + push %ecx call *%ebx jmp . - - - diff --git a/MdePkg/Library/BaseLib/Ia32/DisablePaging32.asm b/MdePkg/Library/BaseLib/Ia32/DisablePaging32.asm index 04ae8cf514..d2949773b3 100644 --- a/MdePkg/Library/BaseLib/Ia32/DisablePaging32.asm +++ b/MdePkg/Library/BaseLib/Ia32/DisablePaging32.asm @@ -40,18 +40,18 @@ InternalX86DisablePaging32 PROC mov ecx, [esp + 8] mov edx, [esp + 12] pushfd - pop edi + pop edi ; save EFLAGS to edi cli mov eax, cr0 btr eax, 31 mov esp, [esp + 16] mov cr0, eax push edi - popfd + popfd ; restore EFLAGS from edi push edx push ecx call ebx - jmp $ + jmp $ ; EntryPoint() should not return InternalX86DisablePaging32 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x32.S b/MdePkg/Library/BaseLib/Ia32/DivU64x32.S index 89d754614a..0c7829f23e 100644 --- a/MdePkg/Library/BaseLib/Ia32/DivU64x32.S +++ b/MdePkg/Library/BaseLib/Ia32/DivU64x32.S @@ -19,17 +19,23 @@ # #------------------------------------------------------------------------------ - .386: - .code: - .global _InternalMathDivU64x32 + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathDivU64x32 ( +# IN UINT64 Dividend, +# IN UINT32 Divisor +# ); +#------------------------------------------------------------------------------ _InternalMathDivU64x32: - movl 8(%esp),%eax - movl 12(%esp),%ecx - xorl %edx,%edx + movl 8(%esp), %eax + movl 12(%esp), %ecx + xorl %edx, %edx divl %ecx - pushl %eax - movl 8(%esp),%eax + push %eax + movl 8(%esp), %eax divl %ecx - popl %edx + pop %edx ret diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x32.asm b/MdePkg/Library/BaseLib/Ia32/DivU64x32.asm index 1ad5474586..25ca074ad9 100644 --- a/MdePkg/Library/BaseLib/Ia32/DivU64x32.asm +++ b/MdePkg/Library/BaseLib/Ia32/DivU64x32.asm @@ -23,15 +23,23 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor +; ); +;------------------------------------------------------------------------------ InternalMathDivU64x32 PROC mov eax, [esp + 8] mov ecx, [esp + 12] xor edx, edx div ecx - push eax + push eax ; save quotient on stack mov eax, [esp + 8] div ecx - pop edx + pop edx ; restore high-order dword of the quotient ret InternalMathDivU64x32 ENDP diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.S b/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.S index 1f34f18255..41537b05ec 100644 --- a/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.S +++ b/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.S @@ -19,25 +19,28 @@ # #------------------------------------------------------------------------------ - - - - .global _InternalMathDivRemU64x32 -_InternalMathDivRemU64x32: - movl 12(%esp),%ecx - movl 8(%esp),%eax - xorl %edx,%edx + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathDivRemU64x32 ( +# IN UINT64 Dividend, +# IN UINT32 Divisor, +# OUT UINT32 *Remainder +# ); +#------------------------------------------------------------------------------ +_InternalMathDivRemU64x32: + movl 12(%esp), %ecx + movl 8(%esp), %eax + xorl %edx, %edx divl %ecx - pushl %eax - movl 8(%esp),%eax + push %eax + movl 8(%esp), %eax divl %ecx - movl 20(%esp),%ecx + movl 20(%esp), %ecx jecxz L1 - movl %edx,(%ecx) -L1: - popl %edx + movl %edx, (%ecx) +L1: + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.asm b/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.asm index f1c6c1f4ac..a836e22d0d 100644 --- a/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.asm +++ b/MdePkg/Library/BaseLib/Ia32/DivU64x32Remainder.asm @@ -23,6 +23,15 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivRemU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor, +; OUT UINT32 *Remainder +; ); +;------------------------------------------------------------------------------ InternalMathDivRemU64x32 PROC mov ecx, [esp + 12] mov eax, [esp + 8] @@ -32,7 +41,7 @@ InternalMathDivRemU64x32 PROC mov eax, [esp + 8] div ecx mov ecx, [esp + 20] - jecxz @F + jecxz @F ; abandon remainder if Remainder == NULL mov [ecx], edx @@: pop edx diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.S b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.S index df1e6ad495..90ccc56a70 100644 --- a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.S +++ b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.S @@ -20,69 +20,70 @@ # #------------------------------------------------------------------------------ +.global _InternalMathDivRemU64x32, _InternalMathDivRemU64x64 - - - -.extern _InternalMathDivRemU64x32 - -.global _InternalMathDivRemU64x64 -_InternalMathDivRemU64x64: - movl 16(%esp),%ecx - testl %ecx,%ecx - jnz _DivRemU64x64 - movl 20(%esp),%ecx +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathDivRemU64x64 ( +# IN UINT64 Dividend, +# IN UINT64 Divisor, +# OUT UINT64 *Remainder OPTIONAL +# ); +#------------------------------------------------------------------------------ +_InternalMathDivRemU64x64: + movl 16(%esp), %ecx + testl %ecx, %ecx + jnz Hard + movl 20(%esp), %ecx jecxz L1 - and $0,4(%ecx) - movl %ecx,16(%esp) -L1: + and $0, 4(%ecx) + movl %ecx, 16(%esp) +L1: jmp _InternalMathDivRemU64x32 - - -.global _DivRemU64x64 -_DivRemU64x64: - push %ebx - push %esi - push %edi +Hard: + push %ebx + push %esi + push %edi mov 20(%esp), %edx mov 16(%esp), %eax - movl %edx,%edi - movl %eax,%esi + movl %edx, %edi + movl %eax, %esi mov 24(%esp), %ebx -L2: +L2: shrl %edx - rcrl $1,%eax - shrdl $1,%ecx,%ebx + rcrl $1, %eax + shrdl $1, %ecx, %ebx shrl %ecx jnz L2 divl %ebx - movl %eax,%ebx - movl 28(%esp),%ecx + movl %eax, %ebx + movl 28(%esp), %ecx mull 24(%esp) - imull %ebx,%ecx - addl %ecx,%edx + imull %ebx, %ecx + addl %ecx, %edx mov 32(%esp), %ecx jc TooLarge - cmpl %edx,%edi + cmpl %edx, %edi ja Correct jb TooLarge - cmpl %eax,%esi + cmpl %eax, %esi jae Correct -TooLarge: +TooLarge: decl %ebx jecxz Return sub 24(%esp), %eax sbb 28(%esp), %edx -Correct: +Correct: jecxz Return - subl %eax,%esi - sbbl %edx,%edi - movl %esi,(%ecx) - movl %edi,4(%ecx) -Return: - movl %ebx,%eax - xorl %edx,%edx - push %edi - push %esi - push %ebx + subl %eax, %esi + sbbl %edx, %edi + movl %esi, (%ecx) + movl %edi, 4(%ecx) +Return: + movl %ebx, %eax + xorl %edx, %edx + pop %edi + pop %esi + pop %ebx ret diff --git a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm index 261211b946..61a53d1e3a 100644 --- a/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm +++ b/MdePkg/Library/BaseLib/Ia32/DivU64x64Remainder.asm @@ -26,10 +26,19 @@ EXTERN InternalMathDivRemU64x32:PROC +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivRemU64x64 ( +; IN UINT64 Dividend, +; IN UINT64 Divisor, +; OUT UINT64 *Remainder OPTIONAL +; ); +;------------------------------------------------------------------------------ InternalMathDivRemU64x64 PROC mov ecx, [esp + 16] test ecx, ecx - jnz _@DivRemU64x64 + jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32 mov ecx, [esp + 20] jecxz @F and dword ptr [ecx + 4], 0 @@ -40,10 +49,10 @@ InternalMathDivRemU64x64 ENDP _@DivRemU64x64 PROC USES ebx esi edi mov edx, dword ptr [esp + 20] - mov eax, dword ptr [esp + 16] + mov eax, dword ptr [esp + 16] ; edx:eax <- dividend mov edi, edx - mov esi, eax - mov ebx, dword ptr [esp + 24] + mov esi, eax ; edi:esi <- dividend + mov ebx, dword ptr [esp + 24] ; ecx:ebx <- divisor @@: shr edx, 1 rcr eax, 1 @@ -51,31 +60,31 @@ _@DivRemU64x64 PROC USES ebx esi edi shr ecx, 1 jnz @B div ebx - mov ebx, eax + mov ebx, eax ; ebx <- quotient mov ecx, [esp + 28] mul dword ptr [esp + 24] imul ecx, ebx add edx, ecx mov ecx, dword ptr [esp + 32] - jc @TooLarge - cmp edi, edx + jc @TooLarge ; product > 2^64 + cmp edi, edx ; compare high 32 bits ja @Correct - jb @TooLarge + jb @TooLarge ; product > dividend cmp esi, eax - jae @Correct + jae @Correct ; product <= dividend @TooLarge: - dec ebx - jecxz @Return + dec ebx ; adjust quotient by -1 + jecxz @Return ; return if Remainder == NULL sub eax, dword ptr [esp + 24] sbb edx, dword ptr [esp + 28] @Correct: jecxz @Return sub esi, eax - sbb edi, edx + sbb edi, edx ; edi:esi <- remainder mov [ecx], esi mov [ecx + 4], edi @Return: - mov eax, ebx + mov eax, ebx ; eax <- quotient xor edx, edx ret _@DivRemU64x64 ENDP diff --git a/MdePkg/Library/BaseLib/Ia32/EnableDisableInterrupts.S b/MdePkg/Library/BaseLib/Ia32/EnableDisableInterrupts.S index 80362a95b2..c082561f66 100644 --- a/MdePkg/Library/BaseLib/Ia32/EnableDisableInterrupts.S +++ b/MdePkg/Library/BaseLib/Ia32/EnableDisableInterrupts.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _EnableDisableInterrupts #------------------------------------------------------------------------------ # VOID @@ -32,11 +30,7 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _EnableDisableInterrupts -_EnableDisableInterrupts: +_EnableDisableInterrupts: sti cli ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/EnableInterrupts.S b/MdePkg/Library/BaseLib/Ia32/EnableInterrupts.S index 74413d83b6..075b85e260 100644 --- a/MdePkg/Library/BaseLib/Ia32/EnableInterrupts.S +++ b/MdePkg/Library/BaseLib/Ia32/EnableInterrupts.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _EnableInterrupts #------------------------------------------------------------------------------ # VOID @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _EnableInterrupts -_EnableInterrupts: +_EnableInterrupts: sti ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/EnablePaging32.S b/MdePkg/Library/BaseLib/Ia32/EnablePaging32.S index 7c97a502da..7335e628f9 100644 --- a/MdePkg/Library/BaseLib/Ia32/EnablePaging32.S +++ b/MdePkg/Library/BaseLib/Ia32/EnablePaging32.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalX86EnablePaging32 #------------------------------------------------------------------------------ # VOID @@ -35,24 +33,20 @@ # IN VOID *NewStack # ); #------------------------------------------------------------------------------ -.global _InternalX86EnablePaging32 -_InternalX86EnablePaging32: - movl 4(%esp),%ebx - movl 8(%esp),%ecx - movl 12(%esp),%edx +_InternalX86EnablePaging32: + movl 4(%esp), %ebx + movl 8(%esp), %ecx + movl 12(%esp), %edx pushfl - popl %edi + pop %edi cli movl %cr0, %eax - btsl $31,%eax - movl 16(%esp),%esp + btsl $31, %eax + movl 16(%esp), %esp movl %eax, %cr0 - pushl %edi + push %edi popfl - pushl %edx - pushl %ecx + push %edx + push %ecx call *%ebx jmp . - - - diff --git a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.S b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.S index 3758479980..61525b8403 100644 --- a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.S +++ b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - #.MODEL flat - +.global _InternalX86EnablePaging64 #------------------------------------------------------------------------------ # VOID @@ -36,7 +34,6 @@ # IN UINT64 NewStack # ); #------------------------------------------------------------------------------ -.global _InternalX86EnablePaging64 _InternalX86EnablePaging64: cli movl $LongStart, (%esp) @@ -52,13 +49,13 @@ _InternalX86EnablePaging64: movl %eax, %cr0 # enable paging lret LongStart: # long mode starts here - .byte 0x67,0x48 + .byte 0x67, 0x48 movl (%esp), %ebx # mov rbx, [esp] - .byte 0x67,0x48 + .byte 0x67, 0x48 movl 8(%esp), %ecx # mov rcx, [esp + 8] - .byte 0x67,0x48 + .byte 0x67, 0x48 movl 0x10(%esp), %edx # mov rdx, [esp + 10h] - .byte 0x67,0x48 + .byte 0x67, 0x48 movl 0x18(%esp), %esp # mov rsp, [esp + 18h] .byte 0x48 addl $0x-20, %esp # add rsp, -20h diff --git a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm index 6c9b0ea76b..354d1fe603 100644 --- a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm +++ b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm @@ -25,9 +25,20 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86EnablePaging64 ( +; IN UINT16 Cs, +; IN UINT64 EntryPoint, +; IN UINT64 Context1, OPTIONAL +; IN UINT64 Context2, OPTIONAL +; IN UINT64 NewStack +; ); +;------------------------------------------------------------------------------ InternalX86EnablePaging64 PROC cli - mov [esp], @F ; offset for far retf + mov [esp], @F ; offset for far retf, seg is the 1st arg mov eax, cr4 or al, (1 SHL 5) mov cr4, eax ; enable PAE diff --git a/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.S b/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.S index c14bd11d68..a1c62755f4 100644 --- a/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.S +++ b/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmFlushCacheLine #------------------------------------------------------------------------------ # VOID @@ -33,11 +30,7 @@ # IN VOID *LinearAddress # ); #------------------------------------------------------------------------------ -.global _AsmFlushCacheLine -_AsmFlushCacheLine: - movl 4(%esp),%eax +_AsmFlushCacheLine: + movl 4(%esp), %eax clflush (%eax) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.asm b/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.asm index c1e6466d04..f4ad87de7b 100644 --- a/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.asm +++ b/MdePkg/Library/BaseLib/Ia32/FlushCacheLine.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586P - .model flat + .model flat,C .xmm .code @@ -33,10 +33,10 @@ ; IN VOID *LinearAddress ; ); ;------------------------------------------------------------------------------ -_AsmFlushCacheLine PROC +AsmFlushCacheLine PROC mov eax, [esp + 4] clflush [eax] ret -_AsmFlushCacheLine ENDP +AsmFlushCacheLine ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/FxRestore.S b/MdePkg/Library/BaseLib/Ia32/FxRestore.S index cc840de464..fa1922308f 100644 --- a/MdePkg/Library/BaseLib/Ia32/FxRestore.S +++ b/MdePkg/Library/BaseLib/Ia32/FxRestore.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _InternalX86FxRestore #------------------------------------------------------------------------------ # VOID @@ -33,11 +30,7 @@ # IN CONST IA32_FX_BUFFER *Buffer # ); #------------------------------------------------------------------------------ -.global _InternalX86FxRestore -_InternalX86FxRestore: - movl 4(%esp),%eax +_InternalX86FxRestore: + movl 4(%esp), %eax fxrstor (%eax) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/FxRestore.asm b/MdePkg/Library/BaseLib/Ia32/FxRestore.asm index e9e37d1384..9bcc6ac885 100644 --- a/MdePkg/Library/BaseLib/Ia32/FxRestore.asm +++ b/MdePkg/Library/BaseLib/Ia32/FxRestore.asm @@ -21,7 +21,7 @@ ; ;------------------------------------------------------------------------------ - .586P + .586 .model flat,C .xmm .code diff --git a/MdePkg/Library/BaseLib/Ia32/FxSave.S b/MdePkg/Library/BaseLib/Ia32/FxSave.S index a558816e1d..7bca947cea 100644 --- a/MdePkg/Library/BaseLib/Ia32/FxSave.S +++ b/MdePkg/Library/BaseLib/Ia32/FxSave.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _InternalX86FxSave #------------------------------------------------------------------------------ # VOID @@ -33,11 +30,7 @@ # OUT IA32_FX_BUFFER *Buffer # ); #------------------------------------------------------------------------------ -.global _InternalX86FxSave -_InternalX86FxSave: - movl 4(%esp),%eax +_InternalX86FxSave: + movl 4(%esp), %eax fxsave (%eax) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/FxSave.asm b/MdePkg/Library/BaseLib/Ia32/FxSave.asm index 22496c5e57..7d5ea45ffb 100644 --- a/MdePkg/Library/BaseLib/Ia32/FxSave.asm +++ b/MdePkg/Library/BaseLib/Ia32/FxSave.asm @@ -21,7 +21,7 @@ ; ;------------------------------------------------------------------------------ - .586P + .586 .model flat,C .xmm .code diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.S b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.S index b53ca0fb93..ec0eec1928 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.S +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalSyncCompareExchange32 #------------------------------------------------------------------------------ # UINT32 @@ -34,13 +32,10 @@ # IN UINT32 ExchangeValue # ); #------------------------------------------------------------------------------ -.global _InternalSyncCompareExchange32 -_InternalSyncCompareExchange32: - movl 4(%esp),%ecx - movl 8(%esp),%eax - movl 12(%esp),%edx - lock cmpxchgl %edx,(%ecx) +_InternalSyncCompareExchange32: + movl 4(%esp), %ecx + movl 8(%esp), %eax + movl 12(%esp), %edx + lock + cmpxchgl %edx, (%ecx) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm index c8c20fbc92..47d959fa6a 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm @@ -28,7 +28,7 @@ ;------------------------------------------------------------------------------ ; UINT32 ; EFIAPI -; InterlockedCompareExchange32 ( +; InternalSyncCompareExchange32 ( ; IN UINT32 *Value, ; IN UINT32 CompareValue, ; IN UINT32 ExchangeValue diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.S b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.S index 383503fbfe..5c964b9e62 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.S +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalSyncCompareExchange64 #------------------------------------------------------------------------------ # UINT64 @@ -34,20 +32,16 @@ # IN UINT64 ExchangeValue # ); #------------------------------------------------------------------------------ -.global _InternalSyncCompareExchange64 _InternalSyncCompareExchange64: push %esi push %ebx - movl 12(%esp),%esi - movl 16(%esp),%eax - movl 20(%esp),%edx - movl 24(%esp),%ebx - movl 28(%esp),%ecx - lock + movl 12(%esp), %esi + movl 16(%esp), %eax + movl 20(%esp), %edx + movl 24(%esp), %ebx + movl 28(%esp), %ecx + lock cmpxchg8b (%esi) pop %ebx pop %esi ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm index cded9206b8..18311e77d3 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm @@ -28,7 +28,7 @@ ;------------------------------------------------------------------------------ ; UINT64 ; EFIAPI -; InterlockedCompareExchange64 ( +; InternalSyncCompareExchange64 ( ; IN UINT64 *Value, ; IN UINT64 CompareValue, ; IN UINT64 ExchangeValue diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.S b/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.S index 4256b60ee9..72765031d2 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.S +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalSyncDecrement #------------------------------------------------------------------------------ # UINT32 @@ -32,13 +30,9 @@ # IN UINT32 *Value # ); #------------------------------------------------------------------------------ -.global _InternalSyncDecrement -_InternalSyncDecrement: - movl 4(%esp),%eax - lock - decl (%eax) - movl (%eax),%eax +_InternalSyncDecrement: + movl 4(%esp), %eax + lock + decl (%eax) + movl (%eax), %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.asm b/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.asm index d8495405c0..082429e520 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.asm +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedDecrement.asm @@ -28,7 +28,7 @@ ;------------------------------------------------------------------------------ ; UINT32 ; EFIAPI -; InterlockedDecrement ( +; InternalSyncDecrement ( ; IN UINT32 *Value ; ); ;------------------------------------------------------------------------------ diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.S b/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.S index 02cb33b29b..69f604cac5 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.S +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalSyncIncrement #------------------------------------------------------------------------------ # UINT32 @@ -32,13 +30,9 @@ # IN UINT32 *Value # ); #------------------------------------------------------------------------------ -.global _InternalSyncIncrement -_InternalSyncIncrement: - movl 4(%esp),%eax - lock - incl (%eax) - movl (%eax),%eax +_InternalSyncIncrement: + movl 4(%esp), %eax + lock + incl (%eax) + movl (%eax), %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.asm b/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.asm index a7bfb6fccd..ea27e666ca 100644 --- a/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.asm +++ b/MdePkg/Library/BaseLib/Ia32/InterlockedIncrement.asm @@ -28,7 +28,7 @@ ;------------------------------------------------------------------------------ ; UINT32 ; EFIAPI -; InterlockedIncrement ( +; InternalSyncIncrement ( ; IN UINT32 *Value ; ); ;------------------------------------------------------------------------------ diff --git a/MdePkg/Library/BaseLib/Ia32/Invd.S b/MdePkg/Library/BaseLib/Ia32/Invd.S index 6d6c8d46cd..f87aa08a6c 100644 --- a/MdePkg/Library/BaseLib/Ia32/Invd.S +++ b/MdePkg/Library/BaseLib/Ia32/Invd.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmInvd #------------------------------------------------------------------------------ # VOID @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmInvd -_AsmInvd: +_AsmInvd: invd ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/LRotU64.S b/MdePkg/Library/BaseLib/Ia32/LRotU64.S index 54cdfadcc8..a9f72d8505 100644 --- a/MdePkg/Library/BaseLib/Ia32/LRotU64.S +++ b/MdePkg/Library/BaseLib/Ia32/LRotU64.S @@ -19,26 +19,28 @@ # #------------------------------------------------------------------------------ - - - - .global _InternalMathLRotU64 + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathLRotU64 ( +# IN UINT64 Operand, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ _InternalMathLRotU64: push %ebx - movb 16(%esp),%cl - movl 12(%esp),%edx - movl 8(%esp),%eax - shldl %cl,%edx,%ebx - shldl %cl,%eax,%edx - rorl %cl,%ebx - shldl %cl,%ebx,%eax - testb $32,%cl + movb 16(%esp), %cl + movl 12(%esp), %edx + movl 8(%esp), %eax + shldl %cl, %edx, %ebx + shldl %cl, %eax, %edx + rorl %cl, %ebx + shldl %cl, %ebx, %eax + testb $32, %cl cmovnz %eax, %ecx - cmovnz %edx, %eax + cmovnz %edx, %eax cmovnz %ecx, %edx pop %ebx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/LRotU64.asm b/MdePkg/Library/BaseLib/Ia32/LRotU64.asm index 1d5562a799..a6437d868f 100644 --- a/MdePkg/Library/BaseLib/Ia32/LRotU64.asm +++ b/MdePkg/Library/BaseLib/Ia32/LRotU64.asm @@ -23,6 +23,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathLRotU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ InternalMathLRotU64 PROC USES ebx mov cl, [esp + 16] mov edx, [esp + 12] @@ -31,7 +39,7 @@ InternalMathLRotU64 PROC USES ebx shld edx, eax, cl ror ebx, cl shld eax, ebx, cl - test cl, 32 + test cl, 32 ; Count >= 32? cmovnz ecx, eax cmovnz eax, edx cmovnz edx, ecx diff --git a/MdePkg/Library/BaseLib/Ia32/LShiftU64.S b/MdePkg/Library/BaseLib/Ia32/LShiftU64.S index 4aa17c637d..6912b86fc3 100644 --- a/MdePkg/Library/BaseLib/Ia32/LShiftU64.S +++ b/MdePkg/Library/BaseLib/Ia32/LShiftU64.S @@ -19,11 +19,16 @@ # #------------------------------------------------------------------------------ - .686: - #.MODEL flat,C - .code: - .global _InternalMathLShiftU64 + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathLShiftU64 ( +# IN UINT64 Operand, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ _InternalMathLShiftU64: movb 12(%esp), %cl xorl %eax, %eax @@ -31,6 +36,6 @@ _InternalMathLShiftU64: testb $32, %cl cmovz %edx, %eax cmovz 0x8(%esp), %edx - shld %cl,%eax,%edx + shld %cl, %eax, %edx shl %cl, %eax ret diff --git a/MdePkg/Library/BaseLib/Ia32/LShiftU64.asm b/MdePkg/Library/BaseLib/Ia32/LShiftU64.asm index 9ce946ddd1..6c3d9a4ee6 100644 --- a/MdePkg/Library/BaseLib/Ia32/LShiftU64.asm +++ b/MdePkg/Library/BaseLib/Ia32/LShiftU64.asm @@ -23,11 +23,19 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathLShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ InternalMathLShiftU64 PROC mov cl, [esp + 12] xor eax, eax mov edx, [esp + 4] - test cl, 32 + test cl, 32 ; Count >= 32? cmovz eax, edx cmovz edx, [esp + 8] shld edx, eax, cl diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.S b/MdePkg/Library/BaseLib/Ia32/LongJump.S index 5fa1521226..fa17dddff9 100644 --- a/MdePkg/Library/BaseLib/Ia32/LongJump.S +++ b/MdePkg/Library/BaseLib/Ia32/LongJump.S @@ -19,20 +19,23 @@ # #------------------------------------------------------------------------------ - .386: - .code: +.global _InternalLongJump -.globl _InternalLongJump +#------------------------------------------------------------------------------ +# VOID +# EFIAPI +# InternalLongJump ( +# IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, +# IN UINTN Value +# ); +#------------------------------------------------------------------------------ _InternalLongJump: - popl %eax - popl %edx - popl %eax + pop %eax + pop %edx + pop %eax movl (%edx), %ebx movl 4(%edx), %esi movl 8(%edx), %edi movl 12(%edx), %ebp movl 16(%edx), %esp jmp *20(%edx) -#InternalLongJump ENDP - - diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.asm b/MdePkg/Library/BaseLib/Ia32/LongJump.asm index b419215237..a634c4599c 100644 --- a/MdePkg/Library/BaseLib/Ia32/LongJump.asm +++ b/MdePkg/Library/BaseLib/Ia32/LongJump.asm @@ -23,10 +23,18 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalLongJump ( +; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ InternalLongJump PROC - pop eax - pop edx - pop eax + pop eax ; skip return address + pop edx ; edx <- JumpBuffer + pop eax ; eax <- Value mov ebx, [edx] mov esi, [edx + 4] mov edi, [edx + 8] diff --git a/MdePkg/Library/BaseLib/Ia32/ModU64x32.S b/MdePkg/Library/BaseLib/Ia32/ModU64x32.S index a8e9574b2d..f2d6cfddf7 100644 --- a/MdePkg/Library/BaseLib/Ia32/ModU64x32.S +++ b/MdePkg/Library/BaseLib/Ia32/ModU64x32.S @@ -19,20 +19,22 @@ # #------------------------------------------------------------------------------ - - - - .global _InternalMathModU64x32 -_InternalMathModU64x32: - movl 8(%esp),%eax - movl 12(%esp),%ecx - xorl %edx,%edx + +#------------------------------------------------------------------------------ +# UINT32 +# EFIAPI +# InternalMathModU64x32 ( +# IN UINT64 Dividend, +# IN UINT32 Divisor +# ); +#------------------------------------------------------------------------------ +_InternalMathModU64x32: + movl 8(%esp), %eax + movl 12(%esp), %ecx + xorl %edx, %edx divl %ecx - movl 4(%esp),%eax + movl 4(%esp), %eax divl %ecx - movl %edx,%eax + movl %edx, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ModU64x32.asm b/MdePkg/Library/BaseLib/Ia32/ModU64x32.asm index 62481ce98a..9e5f9aeda9 100644 --- a/MdePkg/Library/BaseLib/Ia32/ModU64x32.asm +++ b/MdePkg/Library/BaseLib/Ia32/ModU64x32.asm @@ -23,6 +23,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalMathModU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor +; ); +;------------------------------------------------------------------------------ InternalMathModU64x32 PROC mov eax, [esp + 8] mov ecx, [esp + 12] diff --git a/MdePkg/Library/BaseLib/Ia32/Monitor.S b/MdePkg/Library/BaseLib/Ia32/Monitor.S index 8da0e341ed..371e1839fc 100644 --- a/MdePkg/Library/BaseLib/Ia32/Monitor.S +++ b/MdePkg/Library/BaseLib/Ia32/Monitor.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmMonitor #------------------------------------------------------------------------------ # UINT64 @@ -34,13 +32,9 @@ # IN UINTN Edx # ); #------------------------------------------------------------------------------ -.global _AsmMonitor -_AsmMonitor: - movl 4(%esp),%eax - movl 8(%esp),%ecx - movl 12(%esp),%edx - monitor %eax,%ecx,%edx +_AsmMonitor: + movl 4(%esp), %eax + movl 8(%esp), %ecx + movl 12(%esp), %edx + monitor %eax, %ecx, %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/Monitor.asm b/MdePkg/Library/BaseLib/Ia32/Monitor.asm index 5d92d26673..174bd7665f 100644 --- a/MdePkg/Library/BaseLib/Ia32/Monitor.asm +++ b/MdePkg/Library/BaseLib/Ia32/Monitor.asm @@ -22,11 +22,11 @@ ;------------------------------------------------------------------------------ .686 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; UINT64 +; UINTN ; EFIAPI ; AsmMonitor ( ; IN UINTN Eax, @@ -34,12 +34,12 @@ ; IN UINTN Edx ; ); ;------------------------------------------------------------------------------ -_AsmMonitor PROC +AsmMonitor PROC mov eax, [esp + 4] mov ecx, [esp + 8] mov edx, [esp + 12] - DB 0fh, 1, 0c8h + DB 0fh, 1, 0c8h ; monitor ret -_AsmMonitor ENDP +AsmMonitor ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/MultU64x32.S b/MdePkg/Library/BaseLib/Ia32/MultU64x32.S index 572a312de8..0b01733076 100644 --- a/MdePkg/Library/BaseLib/Ia32/MultU64x32.S +++ b/MdePkg/Library/BaseLib/Ia32/MultU64x32.S @@ -19,14 +19,23 @@ # #------------------------------------------------------------------------------ - .386: - .code: + .386: + .code: .global _InternalMathMultU64x32 + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathMultU64x32 ( +# IN UINT64 Multiplicand, +# IN UINT32 Multiplier +# ); +#------------------------------------------------------------------------------ _InternalMathMultU64x32: - movl 12(%esp),%ecx - movl %ecx,%eax - imull 8(%esp),%ecx - mull 0x4(%esp) - addl %ecx,%edx + movl 12(%esp), %ecx + movl %ecx, %eax + imull 8(%esp), %ecx + mull 0x4(%esp) + addl %ecx, %edx ret diff --git a/MdePkg/Library/BaseLib/Ia32/MultU64x32.asm b/MdePkg/Library/BaseLib/Ia32/MultU64x32.asm index e2806e3082..9c9ef06996 100644 --- a/MdePkg/Library/BaseLib/Ia32/MultU64x32.asm +++ b/MdePkg/Library/BaseLib/Ia32/MultU64x32.asm @@ -23,10 +23,18 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathMultU64x32 ( +; IN UINT64 Multiplicand, +; IN UINT32 Multiplier +; ); +;------------------------------------------------------------------------------ InternalMathMultU64x32 PROC mov ecx, [esp + 12] mov eax, ecx - imul ecx, [esp + 8] + imul ecx, [esp + 8] ; overflow not detectable mul dword ptr [esp + 4] add edx, ecx ret diff --git a/MdePkg/Library/BaseLib/Ia32/MultU64x64.S b/MdePkg/Library/BaseLib/Ia32/MultU64x64.S index 641b0d652c..f2e55ad6cc 100644 --- a/MdePkg/Library/BaseLib/Ia32/MultU64x64.S +++ b/MdePkg/Library/BaseLib/Ia32/MultU64x64.S @@ -19,24 +19,26 @@ # #------------------------------------------------------------------------------ - - - - .global _InternalMathMultU64x64 -_InternalMathMultU64x64: + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathMultU64x64 ( +# IN UINT64 Multiplicand, +# IN UINT64 Multiplier +# ); +#------------------------------------------------------------------------------ +_InternalMathMultU64x64: push %ebx - movl 8(%esp),%ebx - movl 16(%esp),%edx - movl %ebx,%ecx - movl %edx,%eax - imull 20(%esp),%ebx - imull 12(%esp),%edx - addl %edx,%ebx + movl 8(%esp), %ebx + movl 16(%esp), %edx + movl %ebx, %ecx + movl %edx, %eax + imull 20(%esp), %ebx + imull 12(%esp), %edx + addl %edx, %ebx mull %ecx - addl %ebx,%edx + addl %ebx, %edx pop %ebx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/MultU64x64.asm b/MdePkg/Library/BaseLib/Ia32/MultU64x64.asm index 24c6a7daa3..377aa51972 100644 --- a/MdePkg/Library/BaseLib/Ia32/MultU64x64.asm +++ b/MdePkg/Library/BaseLib/Ia32/MultU64x64.asm @@ -23,6 +23,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathMultU64x64 ( +; IN UINT64 Multiplicand, +; IN UINT64 Multiplier +; ); +;------------------------------------------------------------------------------ InternalMathMultU64x64 PROC USES ebx mov ebx, [esp + 8] mov edx, [esp + 16] diff --git a/MdePkg/Library/BaseLib/Ia32/Mwait.S b/MdePkg/Library/BaseLib/Ia32/Mwait.S index 7e04453352..1aad7cb357 100644 --- a/MdePkg/Library/BaseLib/Ia32/Mwait.S +++ b/MdePkg/Library/BaseLib/Ia32/Mwait.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmMwait #------------------------------------------------------------------------------ # UINT64 @@ -33,12 +31,8 @@ # IN UINTN Ecx # ); #------------------------------------------------------------------------------ -.global _AsmMwait -_AsmMwait: - movl 4(%esp),%eax - movl 8(%esp),%ecx - mwait %eax,%ecx +_AsmMwait: + movl 4(%esp), %eax + movl 8(%esp), %ecx + mwait %eax, %ecx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/Mwait.asm b/MdePkg/Library/BaseLib/Ia32/Mwait.asm index 91d505b4e2..3e5f48c280 100644 --- a/MdePkg/Library/BaseLib/Ia32/Mwait.asm +++ b/MdePkg/Library/BaseLib/Ia32/Mwait.asm @@ -22,22 +22,22 @@ ;------------------------------------------------------------------------------ .686 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; UINT64 +; UINTN ; EFIAPI ; AsmMwait ( ; IN UINTN Eax, ; IN UINTN Ecx ; ); ;------------------------------------------------------------------------------ -_AsmMwait PROC +AsmMwait PROC mov eax, [esp + 4] mov ecx, [esp + 8] - DB 0fh, 1, 0c9h + DB 0fh, 1, 0c9h ; mwait ret -_AsmMwait ENDP +AsmMwait ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/RRotU64.S b/MdePkg/Library/BaseLib/Ia32/RRotU64.S index 2d4f42fe36..4b89a4eaa7 100644 --- a/MdePkg/Library/BaseLib/Ia32/RRotU64.S +++ b/MdePkg/Library/BaseLib/Ia32/RRotU64.S @@ -19,26 +19,28 @@ # #------------------------------------------------------------------------------ - - - - .global _InternalMathRRotU64 + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathRRotU64 ( +# IN UINT64 Operand, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ _InternalMathRRotU64: push %ebx - movb 16(%esp),%cl - movl 8(%esp),%eax - movl 12(%esp),%edx - shrdl %cl,%eax,%ebx - shrdl %cl,%edx,%eax - roll %cl,%ebx - shrdl %cl,%ebx,%edx - testb $32,%cl + movb 16(%esp), %cl + movl 8(%esp), %eax + movl 12(%esp), %edx + shrdl %cl, %eax, %ebx + shrdl %cl, %edx, %eax + roll %cl, %ebx + shrdl %cl, %ebx, %edx + testb $32, %cl cmovnz %eax, %ecx cmovnz %edx, %eax cmovnz %ecx, %edx pop %ebx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/RRotU64.asm b/MdePkg/Library/BaseLib/Ia32/RRotU64.asm index 062e201e8d..4c58878ace 100644 --- a/MdePkg/Library/BaseLib/Ia32/RRotU64.asm +++ b/MdePkg/Library/BaseLib/Ia32/RRotU64.asm @@ -23,6 +23,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathRRotU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ InternalMathRRotU64 PROC USES ebx mov cl, [esp + 16] mov eax, [esp + 8] @@ -31,7 +39,7 @@ InternalMathRRotU64 PROC USES ebx shrd eax, edx, cl rol ebx, cl shrd edx, ebx, cl - test cl, 32 + test cl, 32 ; Count >= 32? cmovnz ecx, eax cmovnz eax, edx cmovnz edx, ecx diff --git a/MdePkg/Library/BaseLib/Ia32/RShiftU64.S b/MdePkg/Library/BaseLib/Ia32/RShiftU64.S index f6c28dee96..3aea31b7ef 100644 --- a/MdePkg/Library/BaseLib/Ia32/RShiftU64.S +++ b/MdePkg/Library/BaseLib/Ia32/RShiftU64.S @@ -19,17 +19,26 @@ # #------------------------------------------------------------------------------ - .686: - .code: + .686: + .code: .global _InternalMathRShiftU64 + +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathRShiftU64 ( +# IN UINT64 Operand, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ _InternalMathRShiftU64: - movb 12(%esp),%cl - xorl %edx,%edx - movl 8(%esp),%eax - testb $32,%cl + movb 12(%esp), %cl + xorl %edx, %edx + movl 8(%esp), %eax + testb $32, %cl cmovz %eax, %edx cmovz 0x4(%esp), %eax - shrdl %cl,%edx,%eax - shr %cl,%edx + shrdl %cl, %edx, %eax + shr %cl, %edx ret diff --git a/MdePkg/Library/BaseLib/Ia32/RShiftU64.asm b/MdePkg/Library/BaseLib/Ia32/RShiftU64.asm index effbc55e1c..793a8f988f 100644 --- a/MdePkg/Library/BaseLib/Ia32/RShiftU64.asm +++ b/MdePkg/Library/BaseLib/Ia32/RShiftU64.asm @@ -23,6 +23,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathRShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ InternalMathRShiftU64 PROC mov cl, [esp + 12] xor edx, edx @@ -35,4 +43,4 @@ InternalMathRShiftU64 PROC ret InternalMathRShiftU64 ENDP - END \ No newline at end of file + END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr0.S b/MdePkg/Library/BaseLib/Ia32/ReadCr0.S index 3108b71eeb..4ebb51cab1 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr0.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr0.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadCr0 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadCr0 -_AsmReadCr0: +_AsmReadCr0: movl %cr0, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr0.asm b/MdePkg/Library/BaseLib/Ia32/ReadCr0.asm index 579cee2377..a8fe4a7e89 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr0.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr0.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadCr0 PROC +AsmReadCr0 PROC mov eax, cr0 ret -_AsmReadCr0 ENDP +AsmReadCr0 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr2.S b/MdePkg/Library/BaseLib/Ia32/ReadCr2.S index 3ce287a252..3080ae9aaf 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr2.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr2.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadCr2 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadCr2 -_AsmReadCr2: +_AsmReadCr2: movl %cr2, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr2.asm b/MdePkg/Library/BaseLib/Ia32/ReadCr2.asm index 3e4a926abd..a6a9b8c08f 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr2.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr2.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadCr2 PROC +AsmReadCr2 PROC mov eax, cr2 ret -_AsmReadCr2 ENDP +AsmReadCr2 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr3.S b/MdePkg/Library/BaseLib/Ia32/ReadCr3.S index 2bd63c725a..b714801b0a 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr3.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr3.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadCr3 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadCr3 -_AsmReadCr3: +_AsmReadCr3: movl %cr3, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr3.asm b/MdePkg/Library/BaseLib/Ia32/ReadCr3.asm index c24ded8051..97b9ee4b99 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr3.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr3.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadCr3 PROC +AsmReadCr3 PROC mov eax, cr3 ret -_AsmReadCr3 ENDP +AsmReadCr3 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr4.S b/MdePkg/Library/BaseLib/Ia32/ReadCr4.S index 4d746d807b..212976119a 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr4.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr4.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadCr4 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadCr4 -_AsmReadCr4: +_AsmReadCr4: movl %cr4, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCr4.asm b/MdePkg/Library/BaseLib/Ia32/ReadCr4.asm index 258f37a97f..a454903387 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCr4.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadCr4.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadCr4 PROC +AsmReadCr4 PROC mov eax, cr4 ret -_AsmReadCr4 ENDP +AsmReadCr4 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCs.S b/MdePkg/Library/BaseLib/Ia32/ReadCs.S index 66bf4b9eeb..97d76066b0 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCs.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadCs.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadCs #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadCs -_AsmReadCs: - movw %cs,%ax +_AsmReadCs: + movl %cs, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadCs.asm b/MdePkg/Library/BaseLib/Ia32/ReadCs.asm index 5972d66754..68497e21fe 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadCs.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadCs.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadCs PROC - mov ax, cs +AsmReadCs PROC + mov eax, cs ret -_AsmReadCs ENDP +AsmReadCs ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr0.S b/MdePkg/Library/BaseLib/Ia32/ReadDr0.S index 00c521b51d..8ad15ea5c1 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr0.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr0.S @@ -21,8 +21,7 @@ # #------------------------------------------------------------------------------ - - +.global _AsmReadDr0 #------------------------------------------------------------------------------ # UINTN @@ -31,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr0 -_AsmReadDr0: +_AsmReadDr0: movl %dr0, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr0.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr0.asm index 4da1dd8d0d..8792ce40b9 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr0.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr0.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr0 PROC +AsmReadDr0 PROC mov eax, dr0 ret -_AsmReadDr0 ENDP +AsmReadDr0 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr1.S b/MdePkg/Library/BaseLib/Ia32/ReadDr1.S index 81d0e54919..e1d7dab497 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr1.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr1.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadDr1 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr1 -_AsmReadDr1: +_AsmReadDr1: movl %dr1, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr1.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr1.asm index 8724dd228b..e924407d57 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr1.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr1.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr1 PROC +AsmReadDr1 PROC mov eax, dr1 ret -_AsmReadDr1 ENDP +AsmReadDr1 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr2.S b/MdePkg/Library/BaseLib/Ia32/ReadDr2.S index 296fff699e..1c0ea04a8b 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr2.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr2.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadDr2 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr2 -_AsmReadDr2: +_AsmReadDr2: movl %dr2, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr2.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr2.asm index 9122d42545..bbbef7e2fa 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr2.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr2.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr2 PROC +AsmReadDr2 PROC mov eax, dr2 ret -_AsmReadDr2 ENDP +AsmReadDr2 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr3.S b/MdePkg/Library/BaseLib/Ia32/ReadDr3.S index e99391de81..705c5c649a 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr3.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr3.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadDr3 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr3 -_AsmReadDr3: +_AsmReadDr3: movl %dr3, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr3.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr3.asm index 7c1ee9826d..af2e7a2689 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr3.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr3.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr3 PROC +AsmReadDr3 PROC mov eax, dr3 ret -_AsmReadDr3 ENDP +AsmReadDr3 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr4.S b/MdePkg/Library/BaseLib/Ia32/ReadDr4.S index 7bff6766a4..4e7d3d1c1e 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr4.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr4.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadDr4 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr4 -_AsmReadDr4: +_AsmReadDr4: movl %dr4, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr4.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr4.asm index 01724555d2..d1fffe4ec0 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr4.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr4.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr4 PROC +AsmReadDr4 PROC DB 0fh, 21h, 0e0h ret -_AsmReadDr4 ENDP +AsmReadDr4 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr5.S b/MdePkg/Library/BaseLib/Ia32/ReadDr5.S index df409e3304..09ae3857f2 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr5.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr5.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadDr5 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr5 -_AsmReadDr5: +_AsmReadDr5: movl %dr5, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr5.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr5.asm index a95527e44c..bba8b602ba 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr5.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr5.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr5 PROC +AsmReadDr5 PROC DB 0fh, 21h, 0e8h ret -_AsmReadDr5 ENDP +AsmReadDr5 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr6.S b/MdePkg/Library/BaseLib/Ia32/ReadDr6.S index bdadd80672..c514a7680f 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr6.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr6.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadDr6 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr6 -_AsmReadDr6: +_AsmReadDr6: movl %dr6, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr6.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr6.asm index b2d9a3d252..479414b3e6 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr6.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr6.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr6 PROC +AsmReadDr6 PROC mov eax, dr6 ret -_AsmReadDr6 ENDP +AsmReadDr6 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr7.S b/MdePkg/Library/BaseLib/Ia32/ReadDr7.S index cf213caac9..638daea15d 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr7.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr7.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadDr7 #------------------------------------------------------------------------------ # UINTN @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDr7 -_AsmReadDr7: +_AsmReadDr7: movl %dr7, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr7.asm b/MdePkg/Library/BaseLib/Ia32/ReadDr7.asm index 23924b1184..7dee98121c 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDr7.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDr7.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDr7 PROC +AsmReadDr7 PROC mov eax, dr7 ret -_AsmReadDr7 ENDP +AsmReadDr7 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDs.S b/MdePkg/Library/BaseLib/Ia32/ReadDs.S index ca1e37937a..7364c70994 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDs.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadDs.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadEflags #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadDs -_AsmReadDs: - movw %ds,%ax +_AsmReadDs: + movl %ds, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDs.asm b/MdePkg/Library/BaseLib/Ia32/ReadDs.asm index 6992766e58..b8edcb6996 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadDs.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadDs.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadDs PROC - mov ax, ds +AsmReadDs PROC + mov eax, ds ret -_AsmReadDs ENDP +AsmReadDs ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadEflags.S b/MdePkg/Library/BaseLib/Ia32/ReadEflags.S index a70a209ffb..3e40756fc4 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadEflags.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadEflags.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadEflags #------------------------------------------------------------------------------ # UINTN @@ -32,11 +30,7 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadEflags -_AsmReadEflags: +_AsmReadEflags: pushfl - popl %eax + pop %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadEflags.asm b/MdePkg/Library/BaseLib/Ia32/ReadEflags.asm index 365b1dee87..32d55b35b9 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadEflags.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadEflags.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,10 +32,10 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadEflags PROC +AsmReadEflags PROC pushfd pop eax ret -_AsmReadEflags ENDP +AsmReadEflags ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadEs.S b/MdePkg/Library/BaseLib/Ia32/ReadEs.S index 69727b5afc..87a5bacf64 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadEs.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadEs.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadEs #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadEs -_AsmReadEs: - movw %es,%ax +_AsmReadEs: + movl %es, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadEs.asm b/MdePkg/Library/BaseLib/Ia32/ReadEs.asm index 0ced46aa62..48f141748e 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadEs.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadEs.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadEs PROC - mov ax, es +AsmReadEs PROC + mov eax, es ret -_AsmReadEs ENDP +AsmReadEs ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadFs.S b/MdePkg/Library/BaseLib/Ia32/ReadFs.S index 7f4fdfa77c..3bf19f23ed 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadFs.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadFs.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadFs #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadFs -_AsmReadFs: - movw %fs,%ax +_AsmReadFs: + movl %fs, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadFs.asm b/MdePkg/Library/BaseLib/Ia32/ReadFs.asm index f1790c6e9e..ae87107599 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadFs.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadFs.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadFs PROC - mov ax, fs +AsmReadFs PROC + mov eax, fs ret -_AsmReadFs ENDP +AsmReadFs ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadGdtr.S b/MdePkg/Library/BaseLib/Ia32/ReadGdtr.S index ebfe800e68..ec1504601e 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadGdtr.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadGdtr.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalX86ReadGdtr #------------------------------------------------------------------------------ # VOID @@ -32,11 +30,7 @@ # OUT IA32_DESCRIPTOR *Gdtr # ); #------------------------------------------------------------------------------ -.global _InternalX86ReadGdtr -_InternalX86ReadGdtr: - movl 4(%esp),%eax +_InternalX86ReadGdtr: + movl 4(%esp), %eax sgdt (%eax) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadGs.S b/MdePkg/Library/BaseLib/Ia32/ReadGs.S index 0d88a60a52..8e0a9d279b 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadGs.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadGs.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadGs #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadGs -_AsmReadGs: - movw %gs,%ax +_AsmReadGs: + movl %gs, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadGs.asm b/MdePkg/Library/BaseLib/Ia32/ReadGs.asm index 1de0ebfc88..93313b8998 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadGs.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadGs.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadGs PROC - mov ax, gs +AsmReadGs PROC + mov eax, gs ret -_AsmReadGs ENDP +AsmReadGs ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadIdtr.S b/MdePkg/Library/BaseLib/Ia32/ReadIdtr.S index 052c745534..cafc0ac45b 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadIdtr.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadIdtr.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _InternalX86ReadIdtr #------------------------------------------------------------------------------ # VOID @@ -32,11 +30,7 @@ # OUT IA32_DESCRIPTOR *Idtr # ); #------------------------------------------------------------------------------ -.global _InternalX86ReadIdtr -_InternalX86ReadIdtr: - movl 4(%esp),%eax +_InternalX86ReadIdtr: + movl 4(%esp), %eax sidt (%eax) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadIdtr.asm b/MdePkg/Library/BaseLib/Ia32/ReadIdtr.asm index 95158be903..dc7d473507 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadIdtr.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadIdtr.asm @@ -25,10 +25,17 @@ .model flat,C .code -InternalX86ReadIdtr PROC +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadIdtr ( +; OUT IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadIdtr PROC mov eax, [esp + 4] sidt fword ptr [eax] ret -InternalX86ReadIdtr ENDP +InternalX86ReadIdtr ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadLdtr.S b/MdePkg/Library/BaseLib/Ia32/ReadLdtr.S index aea1d9265c..39c35582bc 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadLdtr.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadLdtr.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadLdtr #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadLdtr -_AsmReadLdtr: +_AsmReadLdtr: sldt %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadLdtr.asm b/MdePkg/Library/BaseLib/Ia32/ReadLdtr.asm index a859a0e553..449b7cfe99 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadLdtr.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadLdtr.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadLdtr PROC +AsmReadLdtr PROC sldt ax ret -_AsmReadLdtr ENDP +AsmReadLdtr ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm0.S b/MdePkg/Library/BaseLib/Ia32/ReadMm0.S index dd6b846836..380b2f2806 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm0.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm0.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm0 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm0 -_AsmReadMm0: - pushl %eax - pushl %eax - movq %mm0,(%esp) - popl %eax - popl %edx +_AsmReadMm0: + push %eax + push %eax + movq %mm0, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm0.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm0.asm index c45895b2a8..e43c45fab4 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm0.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm0.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm0 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm0 PROC +AsmReadMm0 PROC push eax push eax movq [esp], mm0 pop eax pop edx ret -_AsmReadMm0 ENDP +AsmReadMm0 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm1.S b/MdePkg/Library/BaseLib/Ia32/ReadMm1.S index cbaafff0f3..a893ff7c38 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm1.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm1.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm1 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm1 -_AsmReadMm1: - pushl %eax - pushl %eax - movq %mm1,(%esp) - popl %eax - popl %edx +_AsmReadMm1: + push %eax + push %eax + movq %mm1, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm1.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm1.asm index ea748cbd7e..9f92a44aa0 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm1.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm1.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm1 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm1 PROC +AsmReadMm1 PROC push eax push eax movq [esp], mm1 pop eax pop edx ret -_AsmReadMm1 ENDP +AsmReadMm1 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm2.S b/MdePkg/Library/BaseLib/Ia32/ReadMm2.S index 22a5d71ebc..9dbc9e2180 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm2.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm2.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm2 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm2 -_AsmReadMm2: - pushl %eax - pushl %eax - movq %mm2,(%esp) - popl %eax - popl %edx +_AsmReadMm2: + push %eax + push %eax + movq %mm2, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm2.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm2.asm index ab16c513f3..38e4cb0047 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm2.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm2.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm2 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm2 PROC +AsmReadMm2 PROC push eax push eax movq [esp], mm2 pop eax pop edx ret -_AsmReadMm2 ENDP +AsmReadMm2 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm3.S b/MdePkg/Library/BaseLib/Ia32/ReadMm3.S index dae267af7a..04d57078bb 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm3.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm3.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm3 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm3 -_AsmReadMm3: - pushl %eax - pushl %eax - movq %mm3,(%esp) - popl %eax - popl %edx +_AsmReadMm3: + push %eax + push %eax + movq %mm3, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm3.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm3.asm index 3c4bf34492..e646762bf3 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm3.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm3.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm3 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm3 PROC +AsmReadMm3 PROC push eax push eax movq [esp], mm3 pop eax pop edx ret -_AsmReadMm3 ENDP +AsmReadMm3 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm4.S b/MdePkg/Library/BaseLib/Ia32/ReadMm4.S index 0ae1afcedd..4bd812230b 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm4.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm4.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm4 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm4 -_AsmReadMm4: - pushl %eax - pushl %eax - movq %mm4,(%esp) - popl %eax - popl %edx +_AsmReadMm4: + push %eax + push %eax + movq %mm4, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm4.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm4.asm index 4c2beb885b..8da079d82c 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm4.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm4.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm4 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm4 PROC +AsmReadMm4 PROC push eax push eax movq [esp], mm4 pop eax pop edx ret -_AsmReadMm4 ENDP +AsmReadMm4 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm5.S b/MdePkg/Library/BaseLib/Ia32/ReadMm5.S index 2fad14a7e0..d2b0498f08 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm5.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm5.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm5 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm5 -_AsmReadMm5: - pushl %eax - pushl %eax - movq %mm5,(%esp) - popl %eax - popl %edx +_AsmReadMm5: + push %eax + push %eax + movq %mm5, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm5.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm5.asm index 66e38265c6..9d6b4746a6 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm5.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm5.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm5 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm5 PROC +AsmReadMm5 PROC push eax push eax movq [esp], mm5 pop eax pop edx ret -_AsmReadMm5 ENDP +AsmReadMm5 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm6.S b/MdePkg/Library/BaseLib/Ia32/ReadMm6.S index 22cddfa486..875295fb32 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm6.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm6.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm6 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm6 -_AsmReadMm6: - pushl %eax - pushl %eax - movq %mm6,(%esp) - popl %eax - popl %edx +_AsmReadMm6: + push %eax + push %eax + movq %mm6, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm6.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm6.asm index 69d9e13f6b..95c73f601b 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm6.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm6.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm6 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm6 PROC +AsmReadMm6 PROC push eax push eax movq [esp], mm6 pop eax pop edx ret -_AsmReadMm6 ENDP +AsmReadMm6 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm7.S b/MdePkg/Library/BaseLib/Ia32/ReadMm7.S index fb485a00c9..fb12a655ef 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm7.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm7.S @@ -21,10 +21,7 @@ # #------------------------------------------------------------------------------ - - - - +.global _AsmReadMm7 #------------------------------------------------------------------------------ # UINTN @@ -33,14 +30,10 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadMm7 -_AsmReadMm7: - pushl %eax - pushl %eax - movq %mm7,(%esp) - popl %eax - popl %edx +_AsmReadMm7: + push %eax + push %eax + movq %mm7, (%esp) + pop %eax + pop %edx ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMm7.asm b/MdePkg/Library/BaseLib/Ia32/ReadMm7.asm index a8788cbf7a..0bd3b9b61f 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMm7.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMm7.asm @@ -21,25 +21,25 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm7 ( ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadMm7 PROC +AsmReadMm7 PROC push eax push eax movq [esp], mm7 pop eax pop edx ret -_AsmReadMm7 ENDP +AsmReadMm7 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMsr64.S b/MdePkg/Library/BaseLib/Ia32/ReadMsr64.S index 6a2c9c6688..be3c44e9d0 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMsr64.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadMsr64.S @@ -21,37 +21,16 @@ # #------------------------------------------------------------------------------ - - - - -#------------------------------------------------------------------------------ -# UINT32 -# EFIAPI -# AsmReadMsr32 ( -# IN UINT32 Index -# ); -#------------------------------------------------------------------------------ -.global _AsmReadMsr32 -_AsmReadMsr32: - # - # AsmReadMsr32 shares the same implementation with AsmReadMsr64 and thus no - # code inside this function - # - +.global _AsmReadMsr64 #------------------------------------------------------------------------------ # UINT64 # EFIAPI # AsmReadMsr64 ( -# IN UINT64 Index +# IN UINT32 Index # ); #------------------------------------------------------------------------------ -.global _AsmReadMsr64 -_AsmReadMsr64: - movl 4(%esp),%ecx +_AsmReadMsr64: + movl 4(%esp), %ecx rdmsr ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadMsr64.asm b/MdePkg/Library/BaseLib/Ia32/ReadMsr64.asm index 6c9fe00033..9a3e11ccca 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadMsr64.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadMsr64.asm @@ -21,24 +21,10 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat + .586p + .model flat,C .code -;------------------------------------------------------------------------------ -; UINT32 -; EFIAPI -; AsmReadMsr32 ( -; IN UINT32 Index -; ); -;------------------------------------------------------------------------------ -_AsmReadMsr32 PROC - ; - ; AsmReadMsr32 shares the same implementation with AsmReadMsr64 and thus no - ; code inside this function - ; -_AsmReadMsr32 ENDP - ;------------------------------------------------------------------------------ ; UINT64 ; EFIAPI @@ -46,10 +32,10 @@ _AsmReadMsr32 ENDP ; IN UINT64 Index ; ); ;------------------------------------------------------------------------------ -_AsmReadMsr64 PROC +AsmReadMsr64 PROC mov ecx, [esp + 4] rdmsr ret -_AsmReadMsr64 ENDP +AsmReadMsr64 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadPmc.S b/MdePkg/Library/BaseLib/Ia32/ReadPmc.S index 868e85c23d..a6c4e6ef00 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadPmc.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadPmc.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadPmc #------------------------------------------------------------------------------ # UINT64 @@ -32,11 +30,7 @@ # IN UINT32 PmcIndex # ); #------------------------------------------------------------------------------ -.global _AsmReadPmc -_AsmReadPmc: - movl 4(%esp),%ecx +_AsmReadPmc: + movl 4(%esp), %ecx rdpmc ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadPmc.asm b/MdePkg/Library/BaseLib/Ia32/ReadPmc.asm index 1fe598158d..17156d4652 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadPmc.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadPmc.asm @@ -21,8 +21,8 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat + .586p + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,10 +32,10 @@ ; IN UINT32 PmcIndex ; ); ;------------------------------------------------------------------------------ -_AsmReadPmc PROC +AsmReadPmc PROC mov ecx, [esp + 4] rdpmc ret -_AsmReadPmc ENDP +AsmReadPmc ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadSs.S b/MdePkg/Library/BaseLib/Ia32/ReadSs.S index 7db65c1490..f0a6fe8c65 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadSs.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadSs.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadSs #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadSs -_AsmReadSs: - movw %ss,%ax +_AsmReadSs: + movl %ss, %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadSs.asm b/MdePkg/Library/BaseLib/Ia32/ReadSs.asm index 6d0cd9f2a0..414353755f 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadSs.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadSs.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadSs PROC - mov ax, ss +AsmReadSs PROC + mov eax, ss ret -_AsmReadSs ENDP +AsmReadSs ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadTr.S b/MdePkg/Library/BaseLib/Ia32/ReadTr.S index 8c31e9d9fa..92e0ce630c 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadTr.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadTr.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadTr #------------------------------------------------------------------------------ # UINT16 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadTr -_AsmReadTr: +_AsmReadTr: str %eax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadTr.asm b/MdePkg/Library/BaseLib/Ia32/ReadTr.asm index d77ee89123..4f4e64b186 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadTr.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadTr.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .386 - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadTr PROC +AsmReadTr PROC str ax ret -_AsmReadTr ENDP +AsmReadTr ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/ReadTsc.S b/MdePkg/Library/BaseLib/Ia32/ReadTsc.S index e7981c05b0..c615ac7b83 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadTsc.S +++ b/MdePkg/Library/BaseLib/Ia32/ReadTsc.S @@ -21,9 +21,7 @@ # #------------------------------------------------------------------------------ - - - +.global _AsmReadTsc #------------------------------------------------------------------------------ # UINT64 @@ -32,10 +30,6 @@ # VOID # ); #------------------------------------------------------------------------------ -.global _AsmReadTsc -_AsmReadTsc: +_AsmReadTsc: rdtsc ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/ReadTsc.asm b/MdePkg/Library/BaseLib/Ia32/ReadTsc.asm index ea3c164ecd..fff38292ef 100644 --- a/MdePkg/Library/BaseLib/Ia32/ReadTsc.asm +++ b/MdePkg/Library/BaseLib/Ia32/ReadTsc.asm @@ -21,8 +21,8 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat + .586p + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmReadTsc PROC +AsmReadTsc PROC rdtsc ret -_AsmReadTsc ENDP +AsmReadTsc ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.S b/MdePkg/Library/BaseLib/Ia32/SetJump.S index 05acc4ab26..c600b7f0a8 100644 --- a/MdePkg/Library/BaseLib/Ia32/SetJump.S +++ b/MdePkg/Library/BaseLib/Ia32/SetJump.S @@ -19,25 +19,26 @@ # #------------------------------------------------------------------------------ - - - - .global _SetJump, _InternalAssertJumpBuffer -_SetJump: + +#------------------------------------------------------------------------------ +# UINTN +# EFIAPI +# SetJump ( +# OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer +# ); +#------------------------------------------------------------------------------ +_SetJump: pushl 0x4(%esp) call _InternalAssertJumpBuffer - popl %ecx - popl %ecx - movl (%esp),%edx - movl %ebx,(%edx) - movl %esi,4(%edx) - movl %edi,8(%edx) - movl %ebp,12(%edx) - movl %esp,16(%edx) - movl %ecx,20(%edx) - xorl %eax,%eax + pop %ecx + pop %ecx + movl (%esp), %edx + movl %ebx, (%edx) + movl %esi, 4(%edx) + movl %edi, 8(%edx) + movl %ebp, 12(%edx) + movl %esp, 16(%edx) + movl %ecx, 20(%edx) + xorl %eax, %eax jmp *%ecx - - - diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.asm b/MdePkg/Library/BaseLib/Ia32/SetJump.asm index 7d8579c9b9..4d745e29ac 100644 --- a/MdePkg/Library/BaseLib/Ia32/SetJump.asm +++ b/MdePkg/Library/BaseLib/Ia32/SetJump.asm @@ -25,6 +25,13 @@ InternalAssertJumpBuffer PROTO C +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; SetJump ( +; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer +; ); +;------------------------------------------------------------------------------ SetJump PROC push [esp + 4] call InternalAssertJumpBuffer diff --git a/MdePkg/Library/BaseLib/Ia32/SwapBytes64.S b/MdePkg/Library/BaseLib/Ia32/SwapBytes64.S index 01af949afa..f7633428bd 100644 --- a/MdePkg/Library/BaseLib/Ia32/SwapBytes64.S +++ b/MdePkg/Library/BaseLib/Ia32/SwapBytes64.S @@ -22,13 +22,17 @@ #------------------------------------------------------------------------------ +#------------------------------------------------------------------------------ +# UINT64 +# EFIAPI +# InternalMathSwapBytes64 ( +# IN UINT64 Operand +# ); +#------------------------------------------------------------------------------ .global _InternalMathSwapBytes64 _InternalMathSwapBytes64: - movl 8(%esp), %eax movl 4(%esp), %edx bswapl %eax bswapl %edx ret - - diff --git a/MdePkg/Library/BaseLib/Ia32/SwapBytes64.asm b/MdePkg/Library/BaseLib/Ia32/SwapBytes64.asm index 72e366bd4d..186d094eee 100644 --- a/MdePkg/Library/BaseLib/Ia32/SwapBytes64.asm +++ b/MdePkg/Library/BaseLib/Ia32/SwapBytes64.asm @@ -21,10 +21,17 @@ ; ;------------------------------------------------------------------------------ - .586P + .586 .model flat,C .code +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathSwapBytes64 ( +; IN UINT64 Operand +; ); +;------------------------------------------------------------------------------ InternalMathSwapBytes64 PROC mov eax, [esp + 8] mov edx, [esp + 4] diff --git a/MdePkg/Library/BaseLib/Ia32/Thunk16.S b/MdePkg/Library/BaseLib/Ia32/Thunk16.S index 97b49f5a38..aad6bbe26b 100644 --- a/MdePkg/Library/BaseLib/Ia32/Thunk16.S +++ b/MdePkg/Library/BaseLib/Ia32/Thunk16.S @@ -19,16 +19,10 @@ # #------------------------------------------------------------------------------ -.global _m16Start, _m16Size, _mThunk16Attr, _m16GdtrBase, _m16Gdt, _m16GdtrBase, _mTransition +.global _m16Start, _m16Size, _mThunk16Attr, _m16Gdt, _m16GdtrBase, _mTransition .global _InternalAsmThunk16 -#THUNK_ATTRIBUTE_BIG_REAL_MODE EQU 1 -#THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 EQU 2 -#THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL EQU 4 - - .code: - -_m16Start: +_m16Start: SavedGdt: .space 6 @@ -37,7 +31,7 @@ _BackFromUserCode: push %cs .byte 0x66 call @Base1 # push eip -@Base1: +@Base1: pushfw # pushfd actually cli # disable interrupts push %gs @@ -45,37 +39,37 @@ _BackFromUserCode: push %es push %ds pushaw # pushad actually - .byte 0x66,0xba # mov edx, imm32 + .byte 0x66, 0xba # mov edx, imm32 _ThunkAttr: .space 4 testb $THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15, %dl jz @1 movl $0x15cd2401, %eax # mov ax, 2401h & int 15h cli # disable interrupts jnc @2 -@1: +@1: testb $THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL, %dl jz @2 inb $0x92, %al orb $2, %al outb %al, $0x92 # deactivate A20M# -@2: +@2: movl %ss, %eax .byte 0x67, 0x66, 0x8d, 0x6c, 0x24, 0x34, 0x66 - mov %ebp,0xffffffd8(%esi) - mov 0xfffffff8(%esi),%ebx + mov %ebp, 0xffffffd8(%esi) + mov 0xfffffff8(%esi), %ebx shlw $4, %ax # shl eax, 4 addw %ax, %bp # add ebp, eax - .byte 0x66,0xb8 # mov eax, imm32 + .byte 0x66, 0xb8 # mov eax, imm32 SavedCr4: .space 4 movl %eax, %cr4 - lgdtw %cs:0xfffffff2(%edi) - .byte 0x66,0xb8 # mov eax, imm32 + lgdtw %cs:0xfffffff2(%edi) + .byte 0x66, 0xb8 # mov eax, imm32 SavedCr0: .space 4 movl %eax, %cr0 .byte 0xb8 # mov ax, imm16 SavedSs: .space 2 movl %eax, %ss - .byte 0x66,0xbc # mov esp, imm32 + .byte 0x66, 0xbc # mov esp, imm32 SavedEsp: .space 4 .byte 0x66 lret # return to protected mode @@ -100,23 +94,23 @@ _ToUserCode: xchgw %bx, %sp # set up 16-bit stack pointer .byte 0x66 call @Base # push eip -@Base: +@Base: popw %bp # ebp <- offset @Base addr16 pushl 36(%si) .byte 0x36 - lea 0xc(%esi),%eax - pushl %eax + lea 0xc(%esi), %eax + push %eax lret -@RealMode: - mov %edx,%cs:0xffffffc5(%esi) - mov %bx,%cs:0xffffffcb(%esi) +@RealMode: + mov %edx, %cs:0xffffffc5(%esi) + mov %bx, %cs:0xffffffcb(%esi) lidtw %cs:0xffffffd7(%esi) popaw # popad actually - popl %ds - popl %es - popl %fs - popl %gs + pop %ds + pop %es + pop %fs + pop %gs popfw # popfd lretw # transfer control to user code @@ -152,41 +146,41 @@ _InternalAsmThunk16: push %fs push %gs movl 36(%esp), %esi # esi <- RegSet - movzwl 0x32(%esi),%edx - mov 0xc(%esi),%edi - add $0xffffffc8,%edi + movzwl 0x32(%esi), %edx + mov 0xc(%esi), %edi + add $0xffffffc8, %edi movl %edi, %ebx # ebx <- stack offset - imul $0x10,%edx,%eax + imul $0x10, %edx, %eax push $0xd addl %eax, %edi # edi <- linear address of 16-bit stack - popl %ecx + pop %ecx rep movsl # copy RegSet movl 40(%esp), %eax # eax <- address of transition code movl %edx, %esi # esi <- 16-bit stack segment - lea 0x5e(%eax),%edx + lea 0x5e(%eax), %edx movl %eax, %ecx andl $0xf, %ecx shll $12, %eax - lea 0x6(%ecx),%ecx + lea 0x6(%ecx), %ecx movw %cx, %ax stosl # [edi] <- return address of user code - sgdtl 0xffffffa2(%edx) + sgdtl 0xffffffa2(%edx) sidtl 0x24(%esp) movl %cr0, %eax movl %eax, (%edx) # save CR0 in SavedCr0 andl $0x7ffffffe, %eax # clear PE, PG bits movl %cr4, %ebp - mov %ebp,0xfffffff1(%edx) + mov %ebp, 0xfffffff1(%edx) andl $0x300, %ebp # clear all but PCE and OSFXSR bits pushl $0x10 - popl %ecx # ecx <- selector for data segments + pop %ecx # ecx <- selector for data segments lgdtl 0x20(%edx) pushfl lcall *0x14(%edx) popfl lidtl 0x24(%esp) - lea 0xffffffcc(%ebp),%eax + lea 0xffffffcc(%ebp), %eax pop %gs pop %fs pop %es @@ -197,11 +191,10 @@ _InternalAsmThunk16: pop %ebp ret - .const: + .const: _m16Size: .word _InternalAsmThunk16 - _m16Start _mThunk16Attr: .word _ThunkAttr - _m16Start _m16Gdt: .word _NullSegDesc - _m16Start _m16GdtrBase: .word _16GdtrBase - _m16Start _mTransition: .word _EntryPoint - _m16Start - diff --git a/MdePkg/Library/BaseLib/Ia32/Thunk16.asm b/MdePkg/Library/BaseLib/Ia32/Thunk16.asm index 9fba03ac05..5e35799127 100644 --- a/MdePkg/Library/BaseLib/Ia32/Thunk16.asm +++ b/MdePkg/Library/BaseLib/Ia32/Thunk16.asm @@ -29,6 +29,10 @@ EXTERNDEF C m16Gdt:WORD EXTERNDEF C m16GdtrBase:WORD EXTERNDEF C mTransition:WORD +; +; Here is the layout of the real mode stack. _ToUserCode() is responsible for +; loading all these registers from real mode stack. +; IA32_REGS STRUC 4t _EDI DD ? _ESI DD ? @@ -50,6 +54,9 @@ IA32_REGS ENDS .const +; +; These are global constant to convey information to C code. +; m16Size DW InternalAsmThunk16 - m16Start mThunk16Attr DW _ThunkAttr - m16Start m16Gdt DW _NullSegDesc - m16Start @@ -63,7 +70,10 @@ m16Start LABEL BYTE SavedGdt LABEL FWORD DW ? DD ? - +;------------------------------------------------------------------------------ +; _BackFromUserCode() takes control in real mode after 'retf' has been executed +; by user code. It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ _BackFromUserCode PROC push ss push cs @@ -122,6 +132,10 @@ _16Gdtr LABEL FWORD DW GdtEnd - _NullSegDesc - 1 _16GdtrBase DD _NullSegDesc +;------------------------------------------------------------------------------ +; _ToUserCode() takes control in real mode before passing control to user code. +; It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ _ToUserCode PROC mov edx, ss mov ss, ecx ; set new segment selectors @@ -174,11 +188,14 @@ _16DsDesc LABEL QWORD DB 0 GdtEnd LABEL QWORD -; -; @param RegSet Pointer to a IA32_DWORD_REGS structure -; @param Transition Pointer to the transition code -; @return The address of the 16-bit stack after returning from user code -; +;------------------------------------------------------------------------------ +; IA32_REGISTER_SET * +; EFIAPI +; InternalAsmThunk16 ( +; IN IA32_REGISTER_SET *RegisterSet, +; IN OUT VOID *Transition +; ); +;------------------------------------------------------------------------------ InternalAsmThunk16 PROC USES ebp ebx esi edi ds es fs gs mov esi, [esp + 36] ; esi <- RegSet movzx edx, (IA32_REGS ptr [esi])._SS diff --git a/MdePkg/Library/BaseLib/Ia32/Wbinvd.S b/MdePkg/Library/BaseLib/Ia32/Wbinvd.S index e9f6c0ce6b..7a4b8ccedc 100644 --- a/MdePkg/Library/BaseLib/Ia32/Wbinvd.S +++ b/MdePkg/Library/BaseLib/Ia32/Wbinvd.S @@ -21,10 +21,6 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # VOID # EFIAPI @@ -33,9 +29,6 @@ # ); #------------------------------------------------------------------------------ .global _AsmWbinvd -_AsmWbinvd: +_AsmWbinvd: wbinvd ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/Wbinvd.asm b/MdePkg/Library/BaseLib/Ia32/Wbinvd.asm index 07258fb9e9..1230c89c20 100644 --- a/MdePkg/Library/BaseLib/Ia32/Wbinvd.asm +++ b/MdePkg/Library/BaseLib/Ia32/Wbinvd.asm @@ -22,7 +22,7 @@ ;------------------------------------------------------------------------------ .486p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ @@ -32,9 +32,9 @@ ; VOID ; ); ;------------------------------------------------------------------------------ -_AsmWbinvd PROC +AsmWbinvd PROC wbinvd ret -_AsmWbinvd ENDP +AsmWbinvd ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr0.S b/MdePkg/Library/BaseLib/Ia32/WriteCr0.S index 6e3ad50765..192ed4fa57 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr0.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr0.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # UINTN # EFIAPI # AsmWriteCr0 ( -# VOID +# IN UINTN Cr0 # ); #------------------------------------------------------------------------------ .global _AsmWriteCr0 -_AsmWriteCr0: - movl 4(%esp),%eax +_AsmWriteCr0: + movl 4(%esp), %eax movl %eax, %cr0 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr0.asm b/MdePkg/Library/BaseLib/Ia32/WriteCr0.asm index d64d621cd5..5eab67f819 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr0.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr0.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmWriteCr0 ( -; VOID +; UINTN Cr0 ; ); ;------------------------------------------------------------------------------ -_AsmWriteCr0 PROC +AsmWriteCr0 PROC mov eax, [esp + 4] mov cr0, eax ret -_AsmWriteCr0 ENDP +AsmWriteCr0 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr2.S b/MdePkg/Library/BaseLib/Ia32/WriteCr2.S index cf45e01a24..223dbb973c 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr2.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr2.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # UINTN # EFIAPI # AsmWriteCr2 ( -# VOID +# IN UINTN Cr2 # ); #------------------------------------------------------------------------------ .global _AsmWriteCr2 -_AsmWriteCr2: - movl 4(%esp),%eax +_AsmWriteCr2: + movl 4(%esp), %eax movl %eax, %cr2 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr2.asm b/MdePkg/Library/BaseLib/Ia32/WriteCr2.asm index 7ab5b0f64f..0df84412bf 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr2.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr2.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmWriteCr2 ( -; VOID +; UINTN Cr2 ; ); ;------------------------------------------------------------------------------ -_AsmWriteCr2 PROC +AsmWriteCr2 PROC mov eax, [esp + 4] mov cr2, eax ret -_AsmWriteCr2 ENDP +AsmWriteCr2 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr3.S b/MdePkg/Library/BaseLib/Ia32/WriteCr3.S index 1c55581905..3a12755092 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr3.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr3.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # UINTN # EFIAPI # AsmWriteCr3 ( -# VOID +# IN UINTN Cr3 # ); #------------------------------------------------------------------------------ .global _AsmWriteCr3 -_AsmWriteCr3: - movl 4(%esp),%eax +_AsmWriteCr3: + movl 4(%esp), %eax movl %eax, %cr3 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr3.asm b/MdePkg/Library/BaseLib/Ia32/WriteCr3.asm index 9753de1abe..32b05fdf35 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr3.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr3.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .386p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmWriteCr3 ( -; VOID +; UINTN Cr3 ; ); ;------------------------------------------------------------------------------ -_AsmWriteCr3 PROC +AsmWriteCr3 PROC mov eax, [esp + 4] mov cr3, eax ret -_AsmWriteCr3 ENDP +AsmWriteCr3 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr4.S b/MdePkg/Library/BaseLib/Ia32/WriteCr4.S index fbe48c1cd0..4b65a26f71 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr4.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr4.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # UINTN # EFIAPI # AsmWriteCr4 ( -# VOID +# IN UINTN Cr4 # ); #------------------------------------------------------------------------------ .global _AsmWriteCr4 -_AsmWriteCr4: - movl 4(%esp),%eax +_AsmWriteCr4: + movl 4(%esp), %eax movl %eax, %cr4 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteCr4.asm b/MdePkg/Library/BaseLib/Ia32/WriteCr4.asm index 60bfe78cb6..4ed7f61030 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteCr4.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteCr4.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI ; AsmWriteCr4 ( -; VOID +; UINTN Cr4 ; ); ;------------------------------------------------------------------------------ -_AsmWriteCr4 PROC +AsmWriteCr4 PROC mov eax, [esp + 4] mov cr4, eax ret -_AsmWriteCr4 ENDP +AsmWriteCr4 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr0.S b/MdePkg/Library/BaseLib/Ia32/WriteDr0.S index a5a84de6b4..9faa5a5694 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr0.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr0.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr0 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr0 -_AsmWriteDr0: - movl 4(%esp),%eax +_AsmWriteDr0: + movl 4(%esp), %eax movl %eax, %dr0 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr0.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr0.asm index 3dab544c49..1bd39d50e4 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr0.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr0.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr0 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr0 PROC +AsmWriteDr0 PROC mov eax, [esp + 4] mov dr0, eax ret -_AsmWriteDr0 ENDP +AsmWriteDr0 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr1.S b/MdePkg/Library/BaseLib/Ia32/WriteDr1.S index 66fc2c7cf3..1038cf78e2 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr1.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr1.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr1 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr1 -_AsmWriteDr1: - movl 4(%esp),%eax +_AsmWriteDr1: + movl 4(%esp), %eax movl %eax, %dr1 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr1.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr1.asm index 5898206c53..542125ba55 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr1.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr1.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr1 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr1 PROC +AsmWriteDr1 PROC mov eax, [esp + 4] mov dr1, eax ret -_AsmWriteDr1 ENDP +AsmWriteDr1 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr2.S b/MdePkg/Library/BaseLib/Ia32/WriteDr2.S index 7b3f780510..4afee11456 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr2.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr2.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr2 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr2 -_AsmWriteDr2: - movl 4(%esp),%eax +_AsmWriteDr2: + movl 4(%esp), %eax movl %eax, %dr2 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr2.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr2.asm index 3ed25fc8ef..7638babc73 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr2.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr2.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr2 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr2 PROC +AsmWriteDr2 PROC mov eax, [esp + 4] mov dr2, eax ret -_AsmWriteDr2 ENDP +AsmWriteDr2 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr3.S b/MdePkg/Library/BaseLib/Ia32/WriteDr3.S index 34d3e4f0cb..3d46fc1a80 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr3.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr3.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr3 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr3 -_AsmWriteDr3: - movl 4(%esp),%eax +_AsmWriteDr3: + movl 4(%esp), %eax movl %eax, %dr3 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr3.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr3.asm index c1dbc826b3..69a17b4ad3 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr3.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr3.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr3 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr3 PROC +AsmWriteDr3 PROC mov eax, [esp + 4] mov dr3, eax ret -_AsmWriteDr3 ENDP +AsmWriteDr3 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr4.S b/MdePkg/Library/BaseLib/Ia32/WriteDr4.S index 20ddbd2903..3c375545bd 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr4.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr4.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr4 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr4 -_AsmWriteDr4: - movl 4(%esp),%eax +_AsmWriteDr4: + movl 4(%esp), %eax movl %eax, %dr4 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr4.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr4.asm index 2c82512acc..ca9a839f70 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr4.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr4.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr4 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr4 PROC +AsmWriteDr4 PROC mov eax, [esp + 4] DB 0fh, 23h, 0e0h ret -_AsmWriteDr4 ENDP +AsmWriteDr4 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr5.S b/MdePkg/Library/BaseLib/Ia32/WriteDr5.S index 057928a327..4ab45d1bd7 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr5.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr5.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr5 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr5 -_AsmWriteDr5: - movl 4(%esp),%eax +_AsmWriteDr5: + movl 4(%esp), %eax movl %eax, %dr5 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr5.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr5.asm index dc074244a1..c6def6820c 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr5.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr5.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr5 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr5 PROC +AsmWriteDr5 PROC mov eax, [esp + 4] DB 0fh, 23h, 0e8h ret -_AsmWriteDr5 ENDP +AsmWriteDr5 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr6.S b/MdePkg/Library/BaseLib/Ia32/WriteDr6.S index 7d7726be64..be3156aba5 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr6.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr6.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr6 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr6 -_AsmWriteDr6: - movl 4(%esp),%eax +_AsmWriteDr6: + movl 4(%esp), %eax movl %eax, %dr6 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr6.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr6.asm index e307e827dd..4e5acf58b0 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr6.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr6.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr6 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr6 PROC +AsmWriteDr6 PROC mov eax, [esp + 4] mov dr6, eax ret -_AsmWriteDr6 ENDP +AsmWriteDr6 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr7.S b/MdePkg/Library/BaseLib/Ia32/WriteDr7.S index a96f445632..d38fd98131 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr7.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr7.S @@ -21,22 +21,15 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ -# VOID +# UINTN # EFIAPI # AsmWriteDr7 ( # IN UINTN Value # ); #------------------------------------------------------------------------------ .global _AsmWriteDr7 -_AsmWriteDr7: - movl 4(%esp),%eax +_AsmWriteDr7: + movl 4(%esp), %eax movl %eax, %dr7 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr7.asm b/MdePkg/Library/BaseLib/Ia32/WriteDr7.asm index 55dbdc9c52..10e83d6fe7 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteDr7.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteDr7.asm @@ -22,20 +22,20 @@ ;------------------------------------------------------------------------------ .586p - .model flat + .model flat,C .code ;------------------------------------------------------------------------------ -; VOID +; UINTN ; EFIAPI ; AsmWriteDr7 ( ; IN UINTN Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteDr7 PROC +AsmWriteDr7 PROC mov eax, [esp + 4] mov dr7, eax ret -_AsmWriteDr7 ENDP +AsmWriteDr7 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteGdtr.S b/MdePkg/Library/BaseLib/Ia32/WriteGdtr.S index 50600717bf..f8f700f528 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteGdtr.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteGdtr.S @@ -21,10 +21,6 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # VOID # EFIAPI @@ -33,10 +29,7 @@ # ); #------------------------------------------------------------------------------ .global _InternalX86WriteGdtr -_InternalX86WriteGdtr: - movl 4(%esp),%eax +_InternalX86WriteGdtr: + movl 4(%esp), %eax lgdt (%eax) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteGdtr.asm b/MdePkg/Library/BaseLib/Ia32/WriteGdtr.asm index a317e75388..f1c7a92e3b 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteGdtr.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteGdtr.asm @@ -21,10 +21,17 @@ ; ;------------------------------------------------------------------------------ - .686P + .386p .model flat,C .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteGdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ InternalX86WriteGdtr PROC mov eax, [esp + 4] lgdt fword ptr [eax] diff --git a/MdePkg/Library/BaseLib/Ia32/WriteIdtr.S b/MdePkg/Library/BaseLib/Ia32/WriteIdtr.S index 3e6da5c1c5..fc5e6cd42e 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteIdtr.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteIdtr.S @@ -21,10 +21,6 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # VOID # EFIAPI @@ -33,10 +29,7 @@ # ); #------------------------------------------------------------------------------ .global _InternalX86WriteIdtr -_InternalX86WriteIdtr: - movl 4(%esp),%eax +_InternalX86WriteIdtr: + movl 4(%esp), %eax lidt (%eax) ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteIdtr.asm b/MdePkg/Library/BaseLib/Ia32/WriteIdtr.asm index d4b3b51a04..65fca407f2 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteIdtr.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteIdtr.asm @@ -21,10 +21,17 @@ ; ;------------------------------------------------------------------------------ - .686P + .386p .model flat,C .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteIdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ InternalX86WriteIdtr PROC mov eax, [esp + 4] lidt fword ptr [eax] diff --git a/MdePkg/Library/BaseLib/Ia32/WriteLdtr.S b/MdePkg/Library/BaseLib/Ia32/WriteLdtr.S index 3797bd547d..2be1e9dfb0 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteLdtr.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteLdtr.S @@ -21,10 +21,6 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # VOID # EFIAPI @@ -33,10 +29,7 @@ # ); #------------------------------------------------------------------------------ .global _AsmWriteLdtr -_AsmWriteLdtr: - movl 4(%esp),%eax +_AsmWriteLdtr: + movl 4(%esp), %eax lldtw %ax ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm0.S b/MdePkg/Library/BaseLib/Ia32/WriteMm0.S index c4444219a9..a3dca7d7d9 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm0.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm0.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm0 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm0 -_AsmWriteMm0: - movq 4(%esp),%mm0 +_AsmWriteMm0: + movq 4(%esp), %mm0 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm0.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm0.asm index e924dbdb61..15912f6c4a 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm0.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm0.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm0 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm0 PROC +AsmWriteMm0 PROC movq mm0, [esp + 4] ret -_AsmWriteMm0 ENDP +AsmWriteMm0 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm1.S b/MdePkg/Library/BaseLib/Ia32/WriteMm1.S index e3a492f9ec..62ef07d1bc 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm1.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm1.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm1 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm1 -_AsmWriteMm1: - movq 4(%esp),%mm1 +_AsmWriteMm1: + movq 4(%esp), %mm1 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm1.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm1.asm index 1f1d8ce8dc..097e760e8c 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm1.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm1.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm1 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm1 PROC +AsmWriteMm1 PROC movq mm1, [esp + 4] ret -_AsmWriteMm1 ENDP +AsmWriteMm1 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm2.S b/MdePkg/Library/BaseLib/Ia32/WriteMm2.S index eaebb37636..b43d455d0a 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm2.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm2.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm2 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm2 -_AsmWriteMm2: - movq 4(%esp),%mm2 +_AsmWriteMm2: + movq 4(%esp), %mm2 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm2.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm2.asm index a18417a0d1..fea7081d28 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm2.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm2.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm2 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm2 PROC +AsmWriteMm2 PROC movq mm2, [esp + 4] ret -_AsmWriteMm2 ENDP +AsmWriteMm2 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm3.S b/MdePkg/Library/BaseLib/Ia32/WriteMm3.S index a514091732..ffc5c35a9f 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm3.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm3.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm3 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm3 -_AsmWriteMm3: - movq 4(%esp),%mm3 +_AsmWriteMm3: + movq 4(%esp), %mm3 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm3.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm3.asm index 7aad49f77f..1af24908f7 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm3.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm3.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm3 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm3 PROC +AsmWriteMm3 PROC movq mm3, [esp + 4] ret -_AsmWriteMm3 ENDP +AsmWriteMm3 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm4.S b/MdePkg/Library/BaseLib/Ia32/WriteMm4.S index 6d4a6cdce1..01fde70ebc 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm4.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm4.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm4 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm4 -_AsmWriteMm4: - movq 4(%esp),%mm4 +_AsmWriteMm4: + movq 4(%esp), %mm4 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm4.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm4.asm index 8be9c4beb8..2cf9da095c 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm4.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm4.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm4 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm4 PROC +AsmWriteMm4 PROC movq mm4, [esp + 4] ret -_AsmWriteMm4 ENDP +AsmWriteMm4 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm5.S b/MdePkg/Library/BaseLib/Ia32/WriteMm5.S index 15d433271f..9effef0758 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm5.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm5.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm5 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm5 -_AsmWriteMm5: - movq 4(%esp),%mm5 +_AsmWriteMm5: + movq 4(%esp), %mm5 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm5.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm5.asm index bc501b397c..9c9882ef10 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm5.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm5.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm5 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm5 PROC +AsmWriteMm5 PROC movq mm5, [esp + 4] ret -_AsmWriteMm5 ENDP +AsmWriteMm5 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm6.S b/MdePkg/Library/BaseLib/Ia32/WriteMm6.S index 6b1361e7a3..c1ecd9ea0e 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm6.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm6.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm6 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm6 -_AsmWriteMm6: - movq 4(%esp),%mm6 +_AsmWriteMm6: + movq 4(%esp), %mm6 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm6.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm6.asm index 4a6445cb63..5e0cfad563 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm6.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm6.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm6 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm6 PROC +AsmWriteMm6 PROC movq mm6, [esp + 4] ret -_AsmWriteMm6 ENDP +AsmWriteMm6 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm7.S b/MdePkg/Library/BaseLib/Ia32/WriteMm7.S index d702fbb242..c7cb0880b4 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm7.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm7.S @@ -21,22 +21,14 @@ # #------------------------------------------------------------------------------ - - - - - #------------------------------------------------------------------------------ -# UINT64 +# VOID # EFIAPI # AsmWriteMm7 ( # IN UINT64 Value # ); #------------------------------------------------------------------------------ .global _AsmWriteMm7 -_AsmWriteMm7: - movq 4(%esp),%mm7 +_AsmWriteMm7: + movq 4(%esp), %mm7 ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMm7.asm b/MdePkg/Library/BaseLib/Ia32/WriteMm7.asm index 3bc73fed27..faaa23bfd2 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMm7.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMm7.asm @@ -21,21 +21,21 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat - .xmm + .586 + .model flat,C + .mmx .code ;------------------------------------------------------------------------------ -; UINT64 +; VOID ; EFIAPI ; AsmWriteMm7 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMm7 PROC +AsmWriteMm7 PROC movq mm7, [esp + 4] ret -_AsmWriteMm7 ENDP +AsmWriteMm7 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMsr32.S b/MdePkg/Library/BaseLib/Ia32/WriteMsr32.S deleted file mode 100644 index 450b3b7b9f..0000000000 --- a/MdePkg/Library/BaseLib/Ia32/WriteMsr32.S +++ /dev/null @@ -1,45 +0,0 @@ -#------------------------------------------------------------------------------ -# -# 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: -# -# WriteMsr32.Asm -# -# Abstract: -# -# AsmWriteMsr32 function -# -# Notes: -# -#------------------------------------------------------------------------------ - - - - - -#------------------------------------------------------------------------------ -# UINT32 -# EFIAPI -# AsmWriteMsr32 ( -# IN UINT32 Index, -# IN UINT32 Value -# ); -#------------------------------------------------------------------------------ -.global _AsmWriteMsr32 -_AsmWriteMsr32: - movl 8(%esp),%eax - xorl %edx,%edx - movl 4(%esp),%ecx - wrmsr - ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMsr32.asm b/MdePkg/Library/BaseLib/Ia32/WriteMsr32.asm deleted file mode 100644 index ba14514c93..0000000000 --- a/MdePkg/Library/BaseLib/Ia32/WriteMsr32.asm +++ /dev/null @@ -1,44 +0,0 @@ -;------------------------------------------------------------------------------ -; -; 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: -; -; WriteMsr32.Asm -; -; Abstract: -; -; AsmWriteMsr32 function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .586P - .model flat - .code - -;------------------------------------------------------------------------------ -; UINT32 -; EFIAPI -; AsmWriteMsr32 ( -; IN UINT32 Index, -; IN UINT32 Value -; ); -;------------------------------------------------------------------------------ -_AsmWriteMsr32 PROC - mov eax, [esp + 8] - xor edx, edx - mov ecx, [esp + 4] - wrmsr - ret -_AsmWriteMsr32 ENDP - - END diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMsr64.S b/MdePkg/Library/BaseLib/Ia32/WriteMsr64.S index 802aad7803..8af2147554 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMsr64.S +++ b/MdePkg/Library/BaseLib/Ia32/WriteMsr64.S @@ -21,10 +21,6 @@ # #------------------------------------------------------------------------------ - - - - #------------------------------------------------------------------------------ # UINT64 # EFIAPI @@ -34,12 +30,9 @@ # ); #------------------------------------------------------------------------------ .global _AsmWriteMsr64 -_AsmWriteMsr64: - movl 12(%esp),%edx - movl 8(%esp),%eax - movl 4(%esp),%ecx +_AsmWriteMsr64: + movl 12(%esp), %edx + movl 8(%esp), %eax + movl 4(%esp), %ecx wrmsr ret - - - diff --git a/MdePkg/Library/BaseLib/Ia32/WriteMsr64.asm b/MdePkg/Library/BaseLib/Ia32/WriteMsr64.asm index 5afc074291..14edba60c1 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteMsr64.asm +++ b/MdePkg/Library/BaseLib/Ia32/WriteMsr64.asm @@ -21,8 +21,8 @@ ; ;------------------------------------------------------------------------------ - .586P - .model flat + .586p + .model flat,C .code ;------------------------------------------------------------------------------ @@ -33,12 +33,12 @@ ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ -_AsmWriteMsr64 PROC +AsmWriteMsr64 PROC mov edx, [esp + 12] mov eax, [esp + 8] mov ecx, [esp + 4] wrmsr ret -_AsmWriteMsr64 ENDP +AsmWriteMsr64 ENDP END diff --git a/MdePkg/Library/BaseLib/SetJump.c b/MdePkg/Library/BaseLib/SetJump.c index 8bac97ab47..f03479ae81 100644 --- a/MdePkg/Library/BaseLib/SetJump.c +++ b/MdePkg/Library/BaseLib/SetJump.c @@ -26,6 +26,7 @@ **/ VOID +EFIAPI InternalAssertJumpBuffer ( IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer ) diff --git a/MdePkg/Library/BaseLib/X64/DisablePaging64.asm b/MdePkg/Library/BaseLib/X64/DisablePaging64.asm index 7b1e1b8bd2..2609c941aa 100644 --- a/MdePkg/Library/BaseLib/X64/DisablePaging64.asm +++ b/MdePkg/Library/BaseLib/X64/DisablePaging64.asm @@ -23,6 +23,17 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86DisablePaging64 ( +; IN UINT16 Cs, +; IN UINT32 EntryPoint, +; IN UINT32 Context1, OPTIONAL +; IN UINT32 Context2, OPTIONAL +; IN UINT32 NewStack +; ); +;------------------------------------------------------------------------------ InternalX86DisablePaging64 PROC cli shl rcx, 32 diff --git a/MdePkg/Library/BaseLib/X64/FxRestore.asm b/MdePkg/Library/BaseLib/X64/FxRestore.asm index 8acfc2f00f..7e7037e9e6 100644 --- a/MdePkg/Library/BaseLib/X64/FxRestore.asm +++ b/MdePkg/Library/BaseLib/X64/FxRestore.asm @@ -23,6 +23,13 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxRestore ( +; IN CONST IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ InternalX86FxRestore PROC fxrstor [rcx] ret diff --git a/MdePkg/Library/BaseLib/X64/FxSave.asm b/MdePkg/Library/BaseLib/X64/FxSave.asm index cacb1f5283..ea19cd1648 100644 --- a/MdePkg/Library/BaseLib/X64/FxSave.asm +++ b/MdePkg/Library/BaseLib/X64/FxSave.asm @@ -23,6 +23,13 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxSave ( +; OUT IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ InternalX86FxSave PROC fxsave [rcx] ret diff --git a/MdePkg/Library/BaseLib/X64/LongJump.asm b/MdePkg/Library/BaseLib/X64/LongJump.asm index fb6378d030..6ef5f964e0 100644 --- a/MdePkg/Library/BaseLib/X64/LongJump.asm +++ b/MdePkg/Library/BaseLib/X64/LongJump.asm @@ -21,6 +21,14 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalLongJump ( +; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ InternalLongJump PROC mov rbx, [rcx] mov rsp, [rcx + 8] diff --git a/MdePkg/Library/BaseLib/X64/ReadCs.asm b/MdePkg/Library/BaseLib/X64/ReadCs.asm index 126149a47c..642ce5b169 100644 --- a/MdePkg/Library/BaseLib/X64/ReadCs.asm +++ b/MdePkg/Library/BaseLib/X64/ReadCs.asm @@ -31,7 +31,7 @@ ; ); ;------------------------------------------------------------------------------ AsmReadCs PROC - mov ax, cs + mov eax, cs ret AsmReadCs ENDP diff --git a/MdePkg/Library/BaseLib/X64/ReadDs.asm b/MdePkg/Library/BaseLib/X64/ReadDs.asm index bdcddb65d8..6f2629872b 100644 --- a/MdePkg/Library/BaseLib/X64/ReadDs.asm +++ b/MdePkg/Library/BaseLib/X64/ReadDs.asm @@ -31,9 +31,8 @@ ; ); ;------------------------------------------------------------------------------ AsmReadDs PROC - mov ax, ds + mov eax, ds ret AsmReadDs ENDP END - diff --git a/MdePkg/Library/BaseLib/X64/ReadEs.asm b/MdePkg/Library/BaseLib/X64/ReadEs.asm index 40384bcd71..d5fe84d73f 100644 --- a/MdePkg/Library/BaseLib/X64/ReadEs.asm +++ b/MdePkg/Library/BaseLib/X64/ReadEs.asm @@ -31,7 +31,7 @@ ; ); ;------------------------------------------------------------------------------ AsmReadEs PROC - mov ax, es + mov eax, es ret AsmReadEs ENDP diff --git a/MdePkg/Library/BaseLib/X64/ReadFs.asm b/MdePkg/Library/BaseLib/X64/ReadFs.asm index b63e474023..d44ee545af 100644 --- a/MdePkg/Library/BaseLib/X64/ReadFs.asm +++ b/MdePkg/Library/BaseLib/X64/ReadFs.asm @@ -31,7 +31,7 @@ ; ); ;------------------------------------------------------------------------------ AsmReadFs PROC - mov ax, fs + mov eax, fs ret AsmReadFs ENDP diff --git a/MdePkg/Library/BaseLib/X64/ReadGdtr.asm b/MdePkg/Library/BaseLib/X64/ReadGdtr.asm index 2d40599a8b..0bc2949b54 100644 --- a/MdePkg/Library/BaseLib/X64/ReadGdtr.asm +++ b/MdePkg/Library/BaseLib/X64/ReadGdtr.asm @@ -23,6 +23,13 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadGdtr ( +; OUT IA32_DESCRIPTOR *Gdtr +; ); +;------------------------------------------------------------------------------ InternalX86ReadGdtr PROC sgdt fword ptr [rcx] ret diff --git a/MdePkg/Library/BaseLib/X64/ReadGs.asm b/MdePkg/Library/BaseLib/X64/ReadGs.asm index 02d140e670..bc5de7691b 100644 --- a/MdePkg/Library/BaseLib/X64/ReadGs.asm +++ b/MdePkg/Library/BaseLib/X64/ReadGs.asm @@ -31,7 +31,7 @@ ; ); ;------------------------------------------------------------------------------ AsmReadGs PROC - mov ax, gs + mov eax, gs ret AsmReadGs ENDP diff --git a/MdePkg/Library/BaseLib/X64/ReadIdtr.asm b/MdePkg/Library/BaseLib/X64/ReadIdtr.asm index 260f697178..db684f3671 100644 --- a/MdePkg/Library/BaseLib/X64/ReadIdtr.asm +++ b/MdePkg/Library/BaseLib/X64/ReadIdtr.asm @@ -23,6 +23,13 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadIdtr ( +; OUT IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ InternalX86ReadIdtr PROC sidt fword ptr [rcx] ret diff --git a/MdePkg/Library/BaseLib/X64/ReadMm0.asm b/MdePkg/Library/BaseLib/X64/ReadMm0.asm index 1239bcacd6..a81d208298 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm0.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm0.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm0 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMm1.asm b/MdePkg/Library/BaseLib/X64/ReadMm1.asm index b42bd7f63f..5da8c4f9e5 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm1.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm1.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm1 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMm2.asm b/MdePkg/Library/BaseLib/X64/ReadMm2.asm index b10782e403..3b2b1e3af3 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm2.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm2.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm2 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMm3.asm b/MdePkg/Library/BaseLib/X64/ReadMm3.asm index 15a96475bd..6283c30285 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm3.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm3.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm3 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMm4.asm b/MdePkg/Library/BaseLib/X64/ReadMm4.asm index 73f528342e..a65f130283 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm4.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm4.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm4 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMm5.asm b/MdePkg/Library/BaseLib/X64/ReadMm5.asm index a487889480..5295c38ae0 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm5.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm5.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm5 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMm6.asm b/MdePkg/Library/BaseLib/X64/ReadMm6.asm index 56f81bf7b1..acdc99b888 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm6.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm6.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm6 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMm7.asm b/MdePkg/Library/BaseLib/X64/ReadMm7.asm index e3ad6bb658..7a1b4e6111 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMm7.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMm7.asm @@ -24,7 +24,7 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; UINT64 ; EFIAPI ; AsmReadMm7 ( ; VOID diff --git a/MdePkg/Library/BaseLib/X64/ReadMsr32.asm b/MdePkg/Library/BaseLib/X64/ReadMsr32.asm deleted file mode 100644 index 271eabbeae..0000000000 --- a/MdePkg/Library/BaseLib/X64/ReadMsr32.asm +++ /dev/null @@ -1,38 +0,0 @@ -;------------------------------------------------------------------------------ -; -; 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: -; -; ReadMsr32.Asm -; -; Abstract: -; -; AsmReadMsr32 function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; UINT32 -; EFIAPI -; AsmReadMsr32 ( -; IN UINT32 Index -; ); -;------------------------------------------------------------------------------ -AsmReadMsr32 PROC - rdmsr - ret -AsmReadMsr32 ENDP - - END diff --git a/MdePkg/Library/BaseLib/X64/ReadMsr64.asm b/MdePkg/Library/BaseLib/X64/ReadMsr64.asm index 4444c18676..580c0761a4 100644 --- a/MdePkg/Library/BaseLib/X64/ReadMsr64.asm +++ b/MdePkg/Library/BaseLib/X64/ReadMsr64.asm @@ -31,9 +31,9 @@ ; ); ;------------------------------------------------------------------------------ AsmReadMsr64 PROC - rdmsr - shl rax, 20h - shrd rax, rdx, 20h + rdmsr ; edx & eax are zero extended + shl rdx, 20h + or rax, rdx ret AsmReadMsr64 ENDP diff --git a/MdePkg/Library/BaseLib/X64/ReadPmc.asm b/MdePkg/Library/BaseLib/X64/ReadPmc.asm index b5004d6f34..5ca60fa85f 100644 --- a/MdePkg/Library/BaseLib/X64/ReadPmc.asm +++ b/MdePkg/Library/BaseLib/X64/ReadPmc.asm @@ -32,11 +32,8 @@ ;------------------------------------------------------------------------------ AsmReadPmc PROC rdpmc - shl ecx, 1 - jnc @F - shl rax, 20h - shrd rax, rdx, 20h -@@: + shl rdx, 20h + or rax, rdx ret AsmReadPmc ENDP diff --git a/MdePkg/Library/BaseLib/X64/ReadSs.asm b/MdePkg/Library/BaseLib/X64/ReadSs.asm index 4aa480d71b..2c2be564ac 100644 --- a/MdePkg/Library/BaseLib/X64/ReadSs.asm +++ b/MdePkg/Library/BaseLib/X64/ReadSs.asm @@ -31,7 +31,7 @@ ; ); ;------------------------------------------------------------------------------ AsmReadSs PROC - mov ax, ss + mov eax, ss ret AsmReadSs ENDP diff --git a/MdePkg/Library/BaseLib/X64/ReadTsc.asm b/MdePkg/Library/BaseLib/X64/ReadTsc.asm index 25fa2cc5d8..7c45eebd54 100644 --- a/MdePkg/Library/BaseLib/X64/ReadTsc.asm +++ b/MdePkg/Library/BaseLib/X64/ReadTsc.asm @@ -32,8 +32,8 @@ ;------------------------------------------------------------------------------ AsmReadTsc PROC rdtsc - shl rax, 20h - shrd rax, rdx, 20h + shl rdx, 20h + or rax, rdx ret AsmReadTsc ENDP diff --git a/MdePkg/Library/BaseLib/X64/SetJump.asm b/MdePkg/Library/BaseLib/X64/SetJump.asm index 148b0cb65e..2ed581ea9d 100644 --- a/MdePkg/Library/BaseLib/X64/SetJump.asm +++ b/MdePkg/Library/BaseLib/X64/SetJump.asm @@ -23,6 +23,13 @@ EXTERNDEF InternalAssertJumpBuffer:PROC +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; SetJump ( +; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer +; ); +;------------------------------------------------------------------------------ SetJump PROC push rcx add rsp, -20h diff --git a/MdePkg/Library/BaseLib/X64/Thunk16.asm b/MdePkg/Library/BaseLib/X64/Thunk16.asm index b120434efb..2c35c72a57 100644 --- a/MdePkg/Library/BaseLib/X64/Thunk16.asm +++ b/MdePkg/Library/BaseLib/X64/Thunk16.asm @@ -61,6 +61,10 @@ SavedGdt LABEL FWORD DW ? DQ ? +;------------------------------------------------------------------------------ +; _BackFromUserCode() takes control in real mode after 'retf' has been executed +; by user code. It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ _BackFromUserCode PROC DB 16h ; push ss DB 0eh ; push cs @@ -125,6 +129,10 @@ _16Gdtr LABEL FWORD _16GdtrBase DQ _NullSegDesc _16Idtr FWORD (1 SHL 10) - 1 +;------------------------------------------------------------------------------ +; _ToUserCode() takes control in real mode before passing control to user code. +; It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ _ToUserCode PROC mov edi, ss mov ss, edx ; set new segment selectors @@ -184,11 +192,14 @@ _16DsDesc LABEL QWORD DB 0 GdtEnd LABEL QWORD -; -; @param RegSet Pointer to a IA32_DWORD_REGS structure -; @param Transition Pointer to the transition code -; @return The address of the 16-bit stack after returning from user code -; +;------------------------------------------------------------------------------ +; IA32_REGISTER_SET * +; EFIAPI +; InternalAsmThunk16 ( +; IN IA32_REGISTER_SET *RegisterSet, +; IN OUT VOID *Transition +; ); +;------------------------------------------------------------------------------ InternalAsmThunk16 PROC USES rbp rbx rsi rdi mov r10d, ds mov r11d, es diff --git a/MdePkg/Library/BaseLib/X64/WriteCr0.asm b/MdePkg/Library/BaseLib/X64/WriteCr0.asm index defc7e7c96..caf1904d2e 100644 --- a/MdePkg/Library/BaseLib/X64/WriteCr0.asm +++ b/MdePkg/Library/BaseLib/X64/WriteCr0.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteCr0 ( -; VOID +; UINTN Cr0 ; ); ;------------------------------------------------------------------------------ AsmWriteCr0 PROC mov cr0, rcx + mov rax, rcx ret AsmWriteCr0 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteCr2.asm b/MdePkg/Library/BaseLib/X64/WriteCr2.asm index ebe6f89d62..ee5b546262 100644 --- a/MdePkg/Library/BaseLib/X64/WriteCr2.asm +++ b/MdePkg/Library/BaseLib/X64/WriteCr2.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteCr2 ( -; VOID +; UINTN Cr2 ; ); ;------------------------------------------------------------------------------ AsmWriteCr2 PROC mov cr2, rcx + mov rax, rcx ret AsmWriteCr2 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteCr3.asm b/MdePkg/Library/BaseLib/X64/WriteCr3.asm index 5715dea9b7..e63229820e 100644 --- a/MdePkg/Library/BaseLib/X64/WriteCr3.asm +++ b/MdePkg/Library/BaseLib/X64/WriteCr3.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteCr3 ( -; VOID +; UINTN Cr3 ; ); ;------------------------------------------------------------------------------ AsmWriteCr3 PROC mov cr3, rcx + mov rax, rcx ret AsmWriteCr3 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteCr4.asm b/MdePkg/Library/BaseLib/X64/WriteCr4.asm index 210744e16f..3e79fe23e4 100644 --- a/MdePkg/Library/BaseLib/X64/WriteCr4.asm +++ b/MdePkg/Library/BaseLib/X64/WriteCr4.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteCr4 ( -; VOID +; UINTN Cr4 ; ); ;------------------------------------------------------------------------------ AsmWriteCr4 PROC mov cr4, rcx + mov rax, rcx ret AsmWriteCr4 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr0.asm b/MdePkg/Library/BaseLib/X64/WriteDr0.asm index 2515a20404..a1131fead9 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr0.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr0.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteDr0 ( -; VOID +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr0 PROC mov dr0, rcx + mov rax, rcx ret AsmWriteDr0 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr1.asm b/MdePkg/Library/BaseLib/X64/WriteDr1.asm index 89f36ac3f9..366edb6ef8 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr1.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr1.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteDr1 ( -; VOID +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr1 PROC mov dr1, rcx + mov rax, rcx ret AsmWriteDr1 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr2.asm b/MdePkg/Library/BaseLib/X64/WriteDr2.asm index 820977c2e4..bde8e3d929 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr2.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr2.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteDr2 ( -; VOID +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr2 PROC mov dr2, rcx + mov rax, rcx ret AsmWriteDr2 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr3.asm b/MdePkg/Library/BaseLib/X64/WriteDr3.asm index 51c1407277..65180a27d5 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr3.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr3.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteDr3 ( -; VOID +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr3 PROC mov dr3, rcx + mov rax, rcx ret AsmWriteDr3 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr4.asm b/MdePkg/Library/BaseLib/X64/WriteDr4.asm index 12b643825b..ad618f1089 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr4.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr4.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteDr4 ( -; VOID +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr4 PROC DB 0fh, 23h, 0e1h + mov rax, rcx ret AsmWriteDr4 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr5.asm b/MdePkg/Library/BaseLib/X64/WriteDr5.asm index 6d454d5267..91eeef20e3 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr5.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr5.asm @@ -26,12 +26,13 @@ ;------------------------------------------------------------------------------ ; UINTN ; EFIAPI -; AsmWriteDr5 ( -; VOID +; AsmWriteDr6 ( +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr5 PROC DB 0fh, 23h, 0e9h + mov rax, rcx ret AsmWriteDr5 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr6.asm b/MdePkg/Library/BaseLib/X64/WriteDr6.asm index b7b9f2509d..f1ddae8bfc 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr6.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr6.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteDr6 ( -; VOID +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr6 PROC mov dr6, rcx + mov rax, rcx ret AsmWriteDr6 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteDr7.asm b/MdePkg/Library/BaseLib/X64/WriteDr7.asm index de2237b6e4..6a0cbfa6ff 100644 --- a/MdePkg/Library/BaseLib/X64/WriteDr7.asm +++ b/MdePkg/Library/BaseLib/X64/WriteDr7.asm @@ -27,11 +27,12 @@ ; UINTN ; EFIAPI ; AsmWriteDr7 ( -; VOID +; IN UINTN Value ; ); ;------------------------------------------------------------------------------ AsmWriteDr7 PROC mov dr7, rcx + mov rax, rcx ret AsmWriteDr7 ENDP diff --git a/MdePkg/Library/BaseLib/X64/WriteGdtr.asm b/MdePkg/Library/BaseLib/X64/WriteGdtr.asm index 1757e3dea4..fa99a499e7 100644 --- a/MdePkg/Library/BaseLib/X64/WriteGdtr.asm +++ b/MdePkg/Library/BaseLib/X64/WriteGdtr.asm @@ -23,6 +23,13 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteGdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ InternalX86WriteGdtr PROC lgdt fword ptr [rcx] ret diff --git a/MdePkg/Library/BaseLib/X64/WriteIdtr.asm b/MdePkg/Library/BaseLib/X64/WriteIdtr.asm index 09fcb9e457..2f6c081ab6 100644 --- a/MdePkg/Library/BaseLib/X64/WriteIdtr.asm +++ b/MdePkg/Library/BaseLib/X64/WriteIdtr.asm @@ -23,6 +23,13 @@ .code +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteIdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ InternalX86WriteIdtr PROC lidt fword ptr [rcx] ret diff --git a/MdePkg/Library/BaseLib/X64/WriteMm0.asm b/MdePkg/Library/BaseLib/X64/WriteMm0.asm index bb9a576125..0ad65e366d 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm0.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm0.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm0 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm0 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMm1.asm b/MdePkg/Library/BaseLib/X64/WriteMm1.asm index 1bab3bcd8e..66425a43c2 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm1.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm1.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm1 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm1 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMm2.asm b/MdePkg/Library/BaseLib/X64/WriteMm2.asm index 97e8a6a676..bd0f0a0e1a 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm2.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm2.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm2 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm2 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMm3.asm b/MdePkg/Library/BaseLib/X64/WriteMm3.asm index d55e19a406..fa36ea64bb 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm3.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm3.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm3 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm3 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMm4.asm b/MdePkg/Library/BaseLib/X64/WriteMm4.asm index 2a69b93bcc..d9bc46e16c 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm4.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm4.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm4 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm4 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMm5.asm b/MdePkg/Library/BaseLib/X64/WriteMm5.asm index c4d798bcbd..f268bea8ec 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm5.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm5.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm5 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm5 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMm6.asm b/MdePkg/Library/BaseLib/X64/WriteMm6.asm index c0164f66da..cb32ea6dc3 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm6.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm6.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm6 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm6 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMm7.asm b/MdePkg/Library/BaseLib/X64/WriteMm7.asm index 20768e2b78..f5713823bb 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMm7.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMm7.asm @@ -24,10 +24,10 @@ .code ;------------------------------------------------------------------------------ -; UINTN +; VOID ; EFIAPI ; AsmWriteMm7 ( -; VOID +; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm7 PROC diff --git a/MdePkg/Library/BaseLib/X64/WriteMsr32.asm b/MdePkg/Library/BaseLib/X64/WriteMsr32.asm deleted file mode 100644 index 0a74403624..0000000000 --- a/MdePkg/Library/BaseLib/X64/WriteMsr32.asm +++ /dev/null @@ -1,41 +0,0 @@ -;------------------------------------------------------------------------------ -; -; 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: -; -; WriteMsr32.Asm -; -; Abstract: -; -; AsmWriteMsr32 function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; UINT32 -; EFIAPI -; AsmWriteMsr32 ( -; IN UINT32 Index, -; IN UINT32 Value -; ); -;------------------------------------------------------------------------------ -AsmWriteMsr32 PROC - mov eax, edx - xor edx, edx - wrmsr - ret -AsmWriteMsr32 ENDP - - END diff --git a/MdePkg/Library/BaseLib/X64/WriteMsr64.asm b/MdePkg/Library/BaseLib/X64/WriteMsr64.asm index 3337f45891..6b8066f922 100644 --- a/MdePkg/Library/BaseLib/X64/WriteMsr64.asm +++ b/MdePkg/Library/BaseLib/X64/WriteMsr64.asm @@ -32,11 +32,9 @@ ; ); ;------------------------------------------------------------------------------ AsmWriteMsr64 PROC - push rdx - mov eax, edx + mov rax, rdx shr rdx, 20h wrmsr - pop rax ret AsmWriteMsr64 ENDP diff --git a/MdePkg/Library/BaseLib/x86DisablePaging32.c b/MdePkg/Library/BaseLib/x86DisablePaging32.c new file mode 100644 index 0000000000..417a7794bb --- /dev/null +++ b/MdePkg/Library/BaseLib/x86DisablePaging32.c @@ -0,0 +1,65 @@ +/** @file + IA-32/x64 AsmDisablePaging32() + + 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: x86DisablePaging32.c + +**/ + +#include "BaseLibInternals.h" + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + If the current execution mode is not 32-bit paged mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL); + ASSERT (NewStack != NULL); + InternalX86DisablePaging32 (EntryPoint, Context1, Context2, NewStack); +} diff --git a/MdePkg/Library/BaseLib/x86DisablePaging64.c b/MdePkg/Library/BaseLib/x86DisablePaging64.c new file mode 100644 index 0000000000..18496522ca --- /dev/null +++ b/MdePkg/Library/BaseLib/x86DisablePaging64.c @@ -0,0 +1,62 @@ +/** @file + IA-32/x64 AsmDisablePaging64() + + 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: x86DisablePaging64.c + +**/ + +#include "BaseLibInternals.h" + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + If the current execution mode is not 64-bit paged mode, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging64 ( + IN UINT16 Cs, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ) +{ + ASSERT (EntryPoint != 0); + ASSERT (NewStack != 0); + InternalX86DisablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); +} diff --git a/MdePkg/Library/BaseLib/x86EnablePaging32.c b/MdePkg/Library/BaseLib/x86EnablePaging32.c new file mode 100644 index 0000000000..f186146940 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86EnablePaging32.c @@ -0,0 +1,68 @@ +/** @file + IA-32/x64 AsmEnablePaging32() + + 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: x86EnablePaging32.c + +**/ + +#include "BaseLibInternals.h" + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL); + ASSERT (NewStack != NULL); + InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack); +} diff --git a/MdePkg/Library/BaseLib/x86EnablePaging64.c b/MdePkg/Library/BaseLib/x86EnablePaging64.c new file mode 100644 index 0000000000..424568d0f7 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86EnablePaging64.c @@ -0,0 +1,64 @@ +/** @file + IA-32/x64 AsmEnablePaging64() + + 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: x86EnablePaging64.c + +**/ + +#include "BaseLibInternals.h" + +/** + Enables the 64-bit paging mode on the CPU. + + Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode with flat + descriptors. This function is only available on IA-32. After the 64-bit + paging mode is enabled, control is transferred to the function specified by + EntryPoint using the new stack specified by NewStack and passing in the + parameters specified by Context1 and Context2. Context1 and Context2 are + optional and may be 0. The function EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode with flat + descriptors, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for long mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is enabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is enabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is enabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging64 ( + IN UINT16 Cs, + IN UINT64 EntryPoint, + IN UINT64 Context1, OPTIONAL + IN UINT64 Context2, OPTIONAL + IN UINT64 NewStack + ) +{ + ASSERT (EntryPoint != 0); + ASSERT (NewStack != 0); + InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); +} diff --git a/MdePkg/Library/BaseLib/x86FxRestore.c b/MdePkg/Library/BaseLib/x86FxRestore.c new file mode 100644 index 0000000000..70a0c24025 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86FxRestore.c @@ -0,0 +1,48 @@ +/** @file + IA-32/x64 AsmFxRestore() + + 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: x86FxRestore.c + +**/ + +#include "BaseLibInternals.h" + +/** + Restores the current floating point/SSE/SSE2 context from a buffer. + + Restores the current floating point/SSE/SSE2 state from the buffer specified + by Buffer. Buffer must be aligned on a 16-byte boundary. This function is + only available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + If Buffer was not saved with AsmFxSave(), then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ) +{ + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & 0xf) == 0); + + // + // Check the flag recorded by AsmFxSave() + // + ASSERT (*(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) == 0xAA5555AA); + + InternalX86FxRestore (Buffer); +} diff --git a/MdePkg/Library/BaseLib/x86FxSave.c b/MdePkg/Library/BaseLib/x86FxSave.c new file mode 100644 index 0000000000..18c329195c --- /dev/null +++ b/MdePkg/Library/BaseLib/x86FxSave.c @@ -0,0 +1,47 @@ +/** @file + IA-32/x64 AsmFxSave() + + 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: x86FxSave.c + +**/ + +#include "BaseLibInternals.h" + +/** + Save the current floating point/SSE/SSE2 context to a buffer. + + Saves the current floating point/SSE/SSE2 state to the buffer specified by + Buffer. Buffer must be aligned on a 16-byte boundary. This function is only + available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxSave ( + OUT IA32_FX_BUFFER *Buffer + ) +{ + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & 0xf) == 0); + + InternalX86FxSave (Buffer); + + // + // Mark one flag at end of Buffer, it will be check by AsmFxRestor() + // + *(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA; +} diff --git a/MdePkg/Library/BaseLib/x86GetInterruptState.c b/MdePkg/Library/BaseLib/x86GetInterruptState.c new file mode 100644 index 0000000000..2e06efbc83 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86GetInterruptState.c @@ -0,0 +1,39 @@ +/** @file + IA-32/x64 GetInterruptState() + + 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: x86GetInterruptState.c + +**/ + +/** + Retrieves the current CPU interrupt state. + + Retrieves the current CPU interrupt state. Returns TRUE is interrupts are + currently enabled. Otherwise returns FALSE. + + @retval TRUE CPU interrupts are enabled. + @retval FALSE CPU interrupts are disabled. + +**/ +BOOLEAN +EFIAPI +GetInterruptState ( + VOID + ) +{ + IA32_EFLAGS32 EFlags; + + EFlags.UintN = AsmReadEflags (); + return (BOOLEAN)(EFlags.Bits.IF == 1); +} + + diff --git a/MdePkg/Library/BaseLib/x86LowLevel.c b/MdePkg/Library/BaseLib/x86LowLevel.c deleted file mode 100644 index 28193044bc..0000000000 --- a/MdePkg/Library/BaseLib/x86LowLevel.c +++ /dev/null @@ -1,992 +0,0 @@ -/** @file - IA-32/x64 specific functions. - - 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: x86LowLevel.c - -**/ - -#include "BaseLibInternals.h" - -// -// Bit-wise MSR operations -// - -/** - Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and - writes the result back to the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR - between the lower 32-bits of the read result and the value specified by - OrData, and writes the result to the 64-bit MSR specified by Index. The lower - 32-bits of the value written to the MSR is returned. No parameter checking is - performed on Index or OrData, and some of these may cause CPU exceptions. The - caller must either guarantee that Index and OrData are valid, or the caller - must establish proper exception handlers. This function is only available on - IA-32 and X64. - - @param Index The 32-bit MSR index to write. - @param OrData The value to OR with the read value from the MSR. - - @return The lower 32-bit value written to the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrOr32 ( - IN UINT32 Index, - IN UINT32 OrData - ) -{ - return (UINT32)AsmMsrOr64 (Index, OrData); -} - -/** - Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes - the result back to the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND between the - lower 32-bits of the read result and the value specified by AndData, and - writes the result to the 64-bit MSR specified by Index. The lower 32-bits of - the value written to the MSR is returned. No parameter checking is performed - on Index or AndData, and some of these may cause CPU exceptions. The caller - must either guarantee that Index and AndData are valid, or the caller must - establish proper exception handlers. This function is only available on IA-32 - and X64. - - @param Index The 32-bit MSR index to write. - @param AndData The value to AND with the read value from the MSR. - - @return The lower 32-bit value written to the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrAnd32 ( - IN UINT32 Index, - IN UINT32 AndData - ) -{ - return (UINT32)AsmMsrAnd64 (Index, AndData); -} - -/** - Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR - on the lower 32-bits, and writes the result back to the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND between the - lower 32-bits of the read result and the value specified by AndData - preserving the upper 32-bits, performs a bitwise inclusive OR between the - result of the AND operation and the value specified by OrData, and writes the - result to the 64-bit MSR specified by Address. The lower 32-bits of the value - written to the MSR is returned. No parameter checking is performed on Index, - AndData, or OrData, and some of these may cause CPU exceptions. The caller - must either guarantee that Index, AndData, and OrData are valid, or the - caller must establish proper exception handlers. This function is only - available on IA-32 and X64. - - @param Index The 32-bit MSR index to write. - @param AndData The value to AND with the read value from the MSR. - @param OrData The value to OR with the result of the AND operation. - - @return The lower 32-bit value written to the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrAndThenOr32 ( - IN UINT32 Index, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData); -} - -/** - Reads a bit field of an MSR. - - Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is - specified by the StartBit and the EndBit. The value of the bit field is - returned. The caller must either guarantee that Index is valid, or the caller - must set up exception handlers to catch the exceptions. This function is only - available on IA-32 and X64. - - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - - @return The bit field read from the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrBitFieldRead32 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit); -} - -/** - Writes a bit field to an MSR. - - Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit - field is specified by the StartBit and the EndBit. All other bits in the - destination MSR are preserved. The lower 32-bits of the MSR written is - returned. Extra left bits in Value are stripped. The caller must either - guarantee that Index and the data written is valid, or the caller must set up - exception handlers to catch the exceptions. This function is only available - on IA-32 and X64. - - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param Value New value of the bit field. - - @return The lower 32-bit of the value written to the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrBitFieldWrite32 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 Value - ) -{ - ASSERT (EndBit < sizeof (Value) * 8); - ASSERT (StartBit <= EndBit); - return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value); -} - -/** - Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the - result back to the bit field in the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR - between the read result and the value specified by OrData, and writes the - result to the 64-bit MSR specified by Index. The lower 32-bits of the value - written to the MSR are returned. Extra left bits in OrData are stripped. The - caller must either guarantee that Index and the data written is valid, or - the caller must set up exception handlers to catch the exceptions. This - function is only available on IA-32 and X64. - - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param OrData The value to OR with the read value from the MSR. - - @return The lower 32-bit of the value written to the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrBitFieldOr32 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 OrData - ) -{ - ASSERT (EndBit < sizeof (OrData) * 8); - ASSERT (StartBit <= EndBit); - return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData); -} - -/** - Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the - result back to the bit field in the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND between the - read result and the value specified by AndData, and writes the result to the - 64-bit MSR specified by Index. The lower 32-bits of the value written to the - MSR are returned. Extra left bits in AndData are stripped. The caller must - either guarantee that Index and the data written is valid, or the caller must - set up exception handlers to catch the exceptions. This function is only - available on IA-32 and X64. - - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with the read value from the MSR. - - @return The lower 32-bit of the value written to the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrBitFieldAnd32 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData - ) -{ - ASSERT (EndBit < sizeof (AndData) * 8); - ASSERT (StartBit <= EndBit); - return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData); -} - -/** - Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a - bitwise inclusive OR, and writes the result back to the bit field in the - 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a - bitwise inclusive OR between the read result and the value specified by - AndData, and writes the result to the 64-bit MSR specified by Index. The - lower 32-bits of the value written to the MSR are returned. Extra left bits - in both AndData and OrData are stripped. The caller must either guarantee - that Index and the data written is valid, or the caller must set up exception - handlers to catch the exceptions. This function is only available on IA-32 - and X64. - - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with the read value from the MSR. - @param OrData The value to OR with the result of the AND operation. - - @return The lower 32-bit of the value written to the MSR. - -**/ -UINT32 -EFIAPI -AsmMsrBitFieldAndThenOr32 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - ASSERT (EndBit < sizeof (AndData) * 8); - ASSERT (StartBit <= EndBit); - return (UINT32)AsmMsrBitFieldAndThenOr64 ( - Index, - StartBit, - EndBit, - AndData, - OrData - ); -} - -/** - Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result - back to the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR - between the read result and the value specified by OrData, and writes the - result to the 64-bit MSR specified by Index. The value written to the MSR is - returned. No parameter checking is performed on Index or OrData, and some of - these may cause CPU exceptions. The caller must either guarantee that Index - and OrData are valid, or the caller must establish proper exception handlers. - This function is only available on IA-32 and X64. - - @param Index The 32-bit MSR index to write. - @param OrData The value to OR with the read value from the MSR. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrOr64 ( - IN UINT32 Index, - IN UINT64 OrData - ) -{ - return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData); -} - -/** - Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the - 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND between the - read result and the value specified by OrData, and writes the result to the - 64-bit MSR specified by Index. The value written to the MSR is returned. No - parameter checking is performed on Index or OrData, and some of these may - cause CPU exceptions. The caller must either guarantee that Index and OrData - are valid, or the caller must establish proper exception handlers. This - function is only available on IA-32 and X64. - - @param Index The 32-bit MSR index to write. - @param AndData The value to AND with the read value from the MSR. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrAnd64 ( - IN UINT32 Index, - IN UINT64 AndData - ) -{ - return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData); -} - -/** - Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive - OR, and writes the result back to the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND between read - result and the value specified by AndData, performs a bitwise inclusive OR - between the result of the AND operation and the value specified by OrData, - and writes the result to the 64-bit MSR specified by Index. The value written - to the MSR is returned. No parameter checking is performed on Index, AndData, - or OrData, and some of these may cause CPU exceptions. The caller must either - guarantee that Index, AndData, and OrData are valid, or the caller must - establish proper exception handlers. This function is only available on IA-32 - and X64. - - @param Index The 32-bit MSR index to write. - @param AndData The value to AND with the read value from the MSR. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrAndThenOr64 ( - IN UINT32 Index, - IN UINT64 AndData, - IN UINT64 OrData - ) -{ - return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData); -} - -/** - Reads a bit field of an MSR. - - Reads the bit field in the 64-bit MSR. The bit field is specified by the - StartBit and the EndBit. The value of the bit field is returned. The caller - must either guarantee that Index is valid, or the caller must set up - exception handlers to catch the exceptions. This function is only available - on IA-32 and X64. - - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrBitFieldRead64 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit); -} - -/** - Writes a bit field to an MSR. - - Writes Value to a bit field in a 64-bit MSR. The bit field is specified by - the StartBit and the EndBit. All other bits in the destination MSR are - preserved. The MSR written is returned. Extra left bits in Value are - stripped. The caller must either guarantee that Index and the data written is - valid, or the caller must set up exception handlers to catch the exceptions. - This function is only available on IA-32 and X64. - - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param Value New value of the bit field. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrBitFieldWrite64 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 Value - ) -{ - return AsmWriteMsr64 ( - Index, - BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value) - ); -} - -/** - Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and - writes the result back to the bit field in the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR - between the read result and the value specified by OrData, and writes the - result to the 64-bit MSR specified by Index. The value written to the MSR is - returned. Extra left bits in OrData are stripped. The caller must either - guarantee that Index and the data written is valid, or the caller must set up - exception handlers to catch the exceptions. This function is only available - on IA-32 and X64. - - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param OrData The value to OR with the read value from the bit field. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrBitFieldOr64 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 OrData - ) -{ - return AsmWriteMsr64 ( - Index, - BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData) - ); -} - -/** - Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the - result back to the bit field in the 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND between the - read result and the value specified by AndData, and writes the result to the - 64-bit MSR specified by Index. The value written to the MSR is returned. - Extra left bits in AndData are stripped. The caller must either guarantee - that Index and the data written is valid, or the caller must set up exception - handlers to catch the exceptions. This function is only available on IA-32 - and X64. - - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param AndData The value to AND with the read value from the bit field. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrBitFieldAnd64 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 AndData - ) -{ - return AsmWriteMsr64 ( - Index, - BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData) - ); -} - -/** - Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a - bitwise inclusive OR, and writes the result back to the bit field in the - 64-bit MSR. - - Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by - a bitwise inclusive OR between the read result and the value specified by - AndData, and writes the result to the 64-bit MSR specified by Index. The - value written to the MSR is returned. Extra left bits in both AndData and - OrData are stripped. The caller must either guarantee that Index and the data - written is valid, or the caller must set up exception handlers to catch the - exceptions. This function is only available on IA-32 and X64. - - If StartBit is greater than 63, then ASSERT(). - If EndBit is greater than 63, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Index The 32-bit MSR index to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..63. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..63. - @param AndData The value to AND with the read value from the bit field. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the MSR. - -**/ -UINT64 -EFIAPI -AsmMsrBitFieldAndThenOr64 ( - IN UINT32 Index, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT64 AndData, - IN UINT64 OrData - ) -{ - return AsmWriteMsr64 ( - Index, - BitFieldAndThenOr64 ( - AsmReadMsr64 (Index), - StartBit, - EndBit, - AndData, - OrData - ) - ); -} - -// -// Base Library CPU Functions -// - -/** - Retrieves the current CPU interrupt state. - - Retrieves the current CPU interrupt state. Returns TRUE is interrupts are - currently enabled. Otherwise returns FALSE. - - @retval TRUE CPU interrupts are enabled. - @retval FALSE CPU interrupts are disabled. - -**/ -BOOLEAN -EFIAPI -GetInterruptState ( - VOID - ) -{ - IA32_EFLAGS32 EFlags; - - EFlags.UintN = AsmReadEflags (); - return (BOOLEAN)(EFlags.Bits.IF == 1); -} - -// -// Ia32 and x64 specific functions -// - -/** - Reads the current Global Descriptor Table Register(GDTR) descriptor. - - Reads and returns the current GDTR descriptor and returns it in Gdtr. This - function is only available on IA-32 and X64. - - If Gdtr is NULL, then ASSERT(). - - @param Gdtr Pointer to a GDTR descriptor. - -**/ -VOID -EFIAPI -AsmReadGdtr ( - OUT IA32_DESCRIPTOR *Gdtr - ) -{ - ASSERT (Gdtr != NULL); - InternalX86ReadGdtr (Gdtr); -} - -/** - Writes the current Global Descriptor Table Register (GDTR) descriptor. - - Writes and the current GDTR descriptor specified by Gdtr. This function is - only available on IA-32 and X64. - - If Gdtr is NULL, then ASSERT(). - - @param Gdtr Pointer to a GDTR descriptor. - -**/ -VOID -EFIAPI -AsmWriteGdtr ( - IN CONST IA32_DESCRIPTOR *Gdtr - ) -{ - ASSERT (Gdtr != NULL); - InternalX86WriteGdtr (Gdtr); -} - -/** - Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. - - Reads and returns the current IDTR descriptor and returns it in Idtr. This - function is only available on IA-32 and X64. - - If Idtr is NULL, then ASSERT(). - - @param Idtr Pointer to a IDTR descriptor. - -**/ -VOID -EFIAPI -AsmReadIdtr ( - OUT IA32_DESCRIPTOR *Idtr - ) -{ - ASSERT (Idtr != NULL); - InternalX86ReadIdtr (Idtr); -} - -/** - Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. - - Writes the current IDTR descriptor and returns it in Idtr. This function is - only available on IA-32 and X64. - - If Idtr is NULL, then ASSERT(). - - @param Idtr Pointer to a IDTR descriptor. - -**/ -VOID -EFIAPI -AsmWriteIdtr ( - IN CONST IA32_DESCRIPTOR *Idtr - ) -{ - ASSERT (Idtr != NULL); - InternalX86WriteIdtr (Idtr); -} - -/** - Save the current floating point/SSE/SSE2 context to a buffer. - - Saves the current floating point/SSE/SSE2 state to the buffer specified by - Buffer. Buffer must be aligned on a 16-byte boundary. This function is only - available on IA-32 and X64. - - If Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 16-byte boundary, then ASSERT(). - - @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. - -**/ -VOID -EFIAPI -AsmFxSave ( - OUT IA32_FX_BUFFER *Buffer - ) -{ - ASSERT (Buffer != NULL); - ASSERT (((UINTN)Buffer & 0xf) == 0); - - InternalX86FxSave (Buffer); - - // - // Mark one flag at end of Buffer, it will be check by AsmFxRestor() - // - *(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA; -} - -/** - Restores the current floating point/SSE/SSE2 context from a buffer. - - Restores the current floating point/SSE/SSE2 state from the buffer specified - by Buffer. Buffer must be aligned on a 16-byte boundary. This function is - only available on IA-32 and X64. - - If Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 16-byte boundary, then ASSERT(). - If Buffer was not saved with AsmFxSave(), then ASSERT(). - - @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. - -**/ -VOID -EFIAPI -AsmFxRestore ( - IN CONST IA32_FX_BUFFER *Buffer - ) -{ - ASSERT (Buffer != NULL); - ASSERT (((UINTN)Buffer & 0xf) == 0); - - // - // Check the flag recorded by AsmFxSave() - // - ASSERT (*(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) == 0xAA5555AA); - - InternalX86FxRestore (Buffer); -} - -/** - Enables the 32-bit paging mode on the CPU. - - Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables - must be properly initialized prior to calling this service. This function - assumes the current execution mode is 32-bit protected mode. This function is - only available on IA-32. After the 32-bit paging mode is enabled, control is - transferred to the function specified by EntryPoint using the new stack - specified by NewStack and passing in the parameters specified by Context1 and - Context2. Context1 and Context2 are optional and may be NULL. The function - EntryPoint must never return. - - If the current execution mode is not 32-bit protected mode, then ASSERT(). - If EntryPoint is NULL, then ASSERT(). - If NewStack is NULL, then ASSERT(). - - There are a number of constraints that must be followed before calling this - function: - 1) Interrupts must be disabled. - 2) The caller must be in 32-bit protected mode with flat descriptors. This - means all descriptors must have a base of 0 and a limit of 4GB. - 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat - descriptors. - 4) CR3 must point to valid page tables that will be used once the transition - is complete, and those page tables must guarantee that the pages for this - function and the stack are identity mapped. - - @param EntryPoint A pointer to function to call with the new stack after - paging is enabled. - @param Context1 A pointer to the context to pass into the EntryPoint - function as the first parameter after paging is enabled. - @param Context2 A pointer to the context to pass into the EntryPoint - function as the second parameter after paging is enabled. - @param NewStack A pointer to the new stack to use for the EntryPoint - function after paging is enabled. - -**/ -VOID -EFIAPI -AsmEnablePaging32 ( - IN SWITCH_STACK_ENTRY_POINT EntryPoint, - IN VOID *Context1, OPTIONAL - IN VOID *Context2, OPTIONAL - IN VOID *NewStack - ) -{ - ASSERT (EntryPoint != NULL); - ASSERT (NewStack != NULL); - InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack); -} - -/** - Disables the 32-bit paging mode on the CPU. - - Disables the 32-bit paging mode on the CPU and returns to 32-bit protected - mode. This function assumes the current execution mode is 32-paged protected - mode. This function is only available on IA-32. After the 32-bit paging mode - is disabled, control is transferred to the function specified by EntryPoint - using the new stack specified by NewStack and passing in the parameters - specified by Context1 and Context2. Context1 and Context2 are optional and - may be NULL. The function EntryPoint must never return. - - If the current execution mode is not 32-bit paged mode, then ASSERT(). - If EntryPoint is NULL, then ASSERT(). - If NewStack is NULL, then ASSERT(). - - There are a number of constraints that must be followed before calling this - function: - 1) Interrupts must be disabled. - 2) The caller must be in 32-bit paged mode. - 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. - 4) CR3 must point to valid page tables that guarantee that the pages for - this function and the stack are identity mapped. - - @param EntryPoint A pointer to function to call with the new stack after - paging is disabled. - @param Context1 A pointer to the context to pass into the EntryPoint - function as the first parameter after paging is disabled. - @param Context2 A pointer to the context to pass into the EntryPoint - function as the second parameter after paging is - disabled. - @param NewStack A pointer to the new stack to use for the EntryPoint - function after paging is disabled. - -**/ -VOID -EFIAPI -AsmDisablePaging32 ( - IN SWITCH_STACK_ENTRY_POINT EntryPoint, - IN VOID *Context1, OPTIONAL - IN VOID *Context2, OPTIONAL - IN VOID *NewStack - ) -{ - ASSERT (EntryPoint != NULL); - ASSERT (NewStack != NULL); - InternalX86DisablePaging32 (EntryPoint, Context1, Context2, NewStack); -} - -/** - Enables the 64-bit paging mode on the CPU. - - Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables - must be properly initialized prior to calling this service. This function - assumes the current execution mode is 32-bit protected mode with flat - descriptors. This function is only available on IA-32. After the 64-bit - paging mode is enabled, control is transferred to the function specified by - EntryPoint using the new stack specified by NewStack and passing in the - parameters specified by Context1 and Context2. Context1 and Context2 are - optional and may be 0. The function EntryPoint must never return. - - If the current execution mode is not 32-bit protected mode with flat - descriptors, then ASSERT(). - If EntryPoint is 0, then ASSERT(). - If NewStack is 0, then ASSERT(). - - @param Cs The 16-bit selector to load in the CS before EntryPoint - is called. The descriptor in the GDT that this selector - references must be setup for long mode. - @param EntryPoint The 64-bit virtual address of the function to call with - the new stack after paging is enabled. - @param Context1 The 64-bit virtual address of the context to pass into - the EntryPoint function as the first parameter after - paging is enabled. - @param Context2 The 64-bit virtual address of the context to pass into - the EntryPoint function as the second parameter after - paging is enabled. - @param NewStack The 64-bit virtual address of the new stack to use for - the EntryPoint function after paging is enabled. - -**/ -VOID -EFIAPI -AsmEnablePaging64 ( - IN UINT16 Cs, - IN UINT64 EntryPoint, - IN UINT64 Context1, OPTIONAL - IN UINT64 Context2, OPTIONAL - IN UINT64 NewStack - ) -{ - ASSERT (EntryPoint != 0); - ASSERT (NewStack != 0); - InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); -} - -/** - Disables the 64-bit paging mode on the CPU. - - Disables the 64-bit paging mode on the CPU and returns to 32-bit protected - mode. This function assumes the current execution mode is 64-paging mode. - This function is only available on X64. After the 64-bit paging mode is - disabled, control is transferred to the function specified by EntryPoint - using the new stack specified by NewStack and passing in the parameters - specified by Context1 and Context2. Context1 and Context2 are optional and - may be 0. The function EntryPoint must never return. - - If the current execution mode is not 64-bit paged mode, then ASSERT(). - If EntryPoint is 0, then ASSERT(). - If NewStack is 0, then ASSERT(). - - @param Cs The 16-bit selector to load in the CS before EntryPoint - is called. The descriptor in the GDT that this selector - references must be setup for 32-bit protected mode. - @param EntryPoint The 64-bit virtual address of the function to call with - the new stack after paging is disabled. - @param Context1 The 64-bit virtual address of the context to pass into - the EntryPoint function as the first parameter after - paging is disabled. - @param Context2 The 64-bit virtual address of the context to pass into - the EntryPoint function as the second parameter after - paging is disabled. - @param NewStack The 64-bit virtual address of the new stack to use for - the EntryPoint function after paging is disabled. - -**/ -VOID -EFIAPI -AsmDisablePaging64 ( - IN UINT16 Cs, - IN UINT32 EntryPoint, - IN UINT32 Context1, OPTIONAL - IN UINT32 Context2, OPTIONAL - IN UINT32 NewStack - ) -{ - ASSERT (EntryPoint != 0); - ASSERT (NewStack != 0); - InternalX86DisablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); -} - -// -// x86 version of MemoryFence() -// - -/** - Used to serialize load and store operations. - - All loads and stores that proceed calls to this function are guaranteed to be - globally visible when this function returns. - -**/ -VOID -EFIAPI -MemoryFence ( - VOID - ) -{ - return; -} diff --git a/MdePkg/Library/BaseLib/x86MemoryFence.c b/MdePkg/Library/BaseLib/x86MemoryFence.c new file mode 100644 index 0000000000..96b1bf26c5 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86MemoryFence.c @@ -0,0 +1,31 @@ +/** @file + IA-32/x64 MemoryFence(). + + 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: x86MemoryFence.c + +**/ + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ) +{ + return; +} diff --git a/MdePkg/Library/BaseLib/x86Msr.c b/MdePkg/Library/BaseLib/x86Msr.c new file mode 100644 index 0000000000..aa8e25b83a --- /dev/null +++ b/MdePkg/Library/BaseLib/x86Msr.c @@ -0,0 +1,649 @@ +/** @file + IA-32/x64 MSR functions. + + 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: x86Msr.c + +**/ + +/** + Returns the lower 32-bits of a Machine Specific Register(MSR). + + Reads and returns the lower 32-bits of the MSR specified by Index. + No parameter checking is performed on Index, and some Index values may cause + CPU exceptions. The caller must either guarantee that Index is valid, or the + caller must set up exception handlers to catch the exceptions. This function + is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to read. + + @return The lower 32 bits of the MSR identified by Index. + +**/ +UINT32 +EFIAPI +AsmReadMsr32 ( + IN UINT32 Index + ) +{ + return (UINT32)AsmReadMsr64 (Index); +} + +/** + Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR). + + Writes the 32-bit value specified by Value to the MSR specified by Index. The + upper 32-bits of the MSR write are set to zero. The 32-bit value written to + the MSR is returned. No parameter checking is performed on Index or Value, + and some of these may cause CPU exceptions. The caller must either guarantee + that Index and Value are valid, or the caller must establish proper exception + handlers. This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param Value The 32-bit value to write to the MSR. + + @return Value + +**/ +UINT32 +EFIAPI +AsmWriteMsr32 ( + IN UINT32 Index, + IN UINT32 Value + ) +{ + return (UINT32)AsmWriteMsr64 (Index, Value); +} + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and + writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the lower 32-bits of the read result and the value specified by + OrData, and writes the result to the 64-bit MSR specified by Index. The lower + 32-bits of the value written to the MSR is returned. No parameter checking is + performed on Index or OrData, and some of these may cause CPU exceptions. The + caller must either guarantee that Index and OrData are valid, or the caller + must establish proper exception handlers. This function is only available on + IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrOr32 ( + IN UINT32 Index, + IN UINT32 OrData + ) +{ + return (UINT32)AsmMsrOr64 (Index, OrData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes + the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData, and + writes the result to the 64-bit MSR specified by Index. The lower 32-bits of + the value written to the MSR is returned. No parameter checking is performed + on Index or AndData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index and AndData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAnd32 ( + IN UINT32 Index, + IN UINT32 AndData + ) +{ + return (UINT32)AsmMsrAnd64 (Index, AndData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR + on the lower 32-bits, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData + preserving the upper 32-bits, performs a bitwise inclusive OR between the + result of the AND operation and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Address. The lower 32-bits of the value + written to the MSR is returned. No parameter checking is performed on Index, + AndData, or OrData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index, AndData, and OrData are valid, or the + caller must establish proper exception handlers. This function is only + available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAndThenOr32 ( + IN UINT32 Index, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData); +} + +/** + Reads a bit field of an MSR. + + Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. The caller must either guarantee that Index is valid, or the caller + must set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read from the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldRead32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit); +} + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination MSR are preserved. The lower 32-bits of the MSR written is + returned. Extra left bits in Value are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldWrite32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT (EndBit < sizeof (Value) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The lower 32-bits of the value + written to the MSR are returned. Extra left bits in OrData are stripped. The + caller must either guarantee that Index and the data written is valid, or + the caller must set up exception handlers to catch the exceptions. This + function is only available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (OrData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The lower 32-bits of the value written to the + MSR are returned. Extra left bits in AndData are stripped. The caller must + either guarantee that Index and the data written is valid, or the caller must + set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAnd32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT (EndBit < sizeof (AndData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a + bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + lower 32-bits of the value written to the MSR are returned. Extra left bits + in both AndData and OrData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAndThenOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (AndData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldAndThenOr64 ( + Index, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result + back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. No parameter checking is performed on Index or OrData, and some of + these may cause CPU exceptions. The caller must either guarantee that Index + and OrData are valid, or the caller must establish proper exception handlers. + This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrOr64 ( + IN UINT32 Index, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by OrData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. No + parameter checking is performed on Index or OrData, and some of these may + cause CPU exceptions. The caller must either guarantee that Index and OrData + are valid, or the caller must establish proper exception handlers. This + function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAnd64 ( + IN UINT32 Index, + IN UINT64 AndData + ) +{ + return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive + OR, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between read + result and the value specified by AndData, performs a bitwise inclusive OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit MSR specified by Index. The value written + to the MSR is returned. No parameter checking is performed on Index, AndData, + or OrData, and some of these may cause CPU exceptions. The caller must either + guarantee that Index, AndData, and OrData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAndThenOr64 ( + IN UINT32 Index, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData); +} + +/** + Reads a bit field of an MSR. + + Reads the bit field in the 64-bit MSR. The bit field is specified by the + StartBit and the EndBit. The value of the bit field is returned. The caller + must either guarantee that Index is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldRead64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit); +} + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in a 64-bit MSR. The bit field is specified by + the StartBit and the EndBit. All other bits in the destination MSR are + preserved. The MSR written is returned. Extra left bits in Value are + stripped. The caller must either guarantee that Index and the data written is + valid, or the caller must set up exception handlers to catch the exceptions. + This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldWrite64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and + writes the result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. Extra left bits in OrData are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. + Extra left bits in AndData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAnd64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by + a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + value written to the MSR is returned. Extra left bits in both AndData and + OrData are stripped. The caller must either guarantee that Index and the data + written is valid, or the caller must set up exception handlers to catch the + exceptions. This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAndThenOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldAndThenOr64 ( + AsmReadMsr64 (Index), + StartBit, + EndBit, + AndData, + OrData + ) + ); +} diff --git a/MdePkg/Library/BaseLib/x86ReadGdtr.c b/MdePkg/Library/BaseLib/x86ReadGdtr.c new file mode 100644 index 0000000000..20d41c0217 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86ReadGdtr.c @@ -0,0 +1,38 @@ +/** @file + IA-32/x64 AsmReadGdtr() + + 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: x86ReadGdtr.c + +**/ + +#include "BaseLibInternals.h" + +/** + Reads the current Global Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current GDTR descriptor and returns it in Gdtr. This + function is only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadGdtr ( + OUT IA32_DESCRIPTOR *Gdtr + ) +{ + ASSERT (Gdtr != NULL); + InternalX86ReadGdtr (Gdtr); +} diff --git a/MdePkg/Library/BaseLib/x86ReadIdtr.c b/MdePkg/Library/BaseLib/x86ReadIdtr.c new file mode 100644 index 0000000000..f902b0c11b --- /dev/null +++ b/MdePkg/Library/BaseLib/x86ReadIdtr.c @@ -0,0 +1,38 @@ +/** @file + IA-32/x64 AsmReadIdtr() + + 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: x86ReadIdtr.c + +**/ + +#include "BaseLibInternals.h" + +/** + Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current IDTR descriptor and returns it in Idtr. This + function is only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadIdtr ( + OUT IA32_DESCRIPTOR *Idtr + ) +{ + ASSERT (Idtr != NULL); + InternalX86ReadIdtr (Idtr); +} diff --git a/MdePkg/Library/BaseLib/x86Thunk.c b/MdePkg/Library/BaseLib/x86Thunk.c index 9e69255181..c74962afc7 100644 --- a/MdePkg/Library/BaseLib/x86Thunk.c +++ b/MdePkg/Library/BaseLib/x86Thunk.c @@ -58,6 +58,7 @@ extern CONST UINT16 mTransition; **/ IA32_REGISTER_SET * +EFIAPI InternalAsmThunk16 ( IN IA32_REGISTER_SET *RegisterSet, IN OUT VOID *Transition diff --git a/MdePkg/Library/BaseLib/x86WriteGdtr.c b/MdePkg/Library/BaseLib/x86WriteGdtr.c new file mode 100644 index 0000000000..c3df563d57 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86WriteGdtr.c @@ -0,0 +1,38 @@ +/** @file + IA-32/x64 AsmWriteGdtr() + + 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: x86GetInterruptState.c + +**/ + +#include "BaseLibInternals.h" + +/** + Writes the current Global Descriptor Table Register (GDTR) descriptor. + + Writes and the current GDTR descriptor specified by Gdtr. This function is + only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteGdtr ( + IN CONST IA32_DESCRIPTOR *Gdtr + ) +{ + ASSERT (Gdtr != NULL); + InternalX86WriteGdtr (Gdtr); +} diff --git a/MdePkg/Library/BaseLib/x86WriteIdtr.c b/MdePkg/Library/BaseLib/x86WriteIdtr.c new file mode 100644 index 0000000000..cfe6758584 --- /dev/null +++ b/MdePkg/Library/BaseLib/x86WriteIdtr.c @@ -0,0 +1,38 @@ +/** @file + IA-32/x64 AsmWriteIdtr() + + 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: x86WriteIdtr.c + +**/ + +#include "BaseLibInternals.h" + +/** + Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Writes the current IDTR descriptor and returns it in Idtr. This function is + only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteIdtr ( + IN CONST IA32_DESCRIPTOR *Idtr + ) +{ + ASSERT (Idtr != NULL); + InternalX86WriteIdtr (Idtr); +}