]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Inline ASM in .c file is specific to MS tool-chain. Other tool-chain (such as Intel...
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 21 Jul 2008 14:01:55 +0000 (14:01 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 21 Jul 2008 14:01:55 +0000 (14:01 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5540 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm [new file with mode: 0644]

diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm
new file mode 100644 (file)
index 0000000..e9c9f54
--- /dev/null
@@ -0,0 +1,202 @@
+;/*++\r
+;\r
+;Copyright (c) 2006, Intel Corporation                                                         \r
+;All rights reserved. This program and the accompanying materials                          \r
+;are licensed and made available under the terms and conditions of the BSD License         \r
+;which accompanies this distribution.  The full text of the license may be found at        \r
+;http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                          \r
+;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+;\r
+;Module Name:\r
+;\r
+;  CpuIA32.c\r
+;\r
+;Abstract:\r
+;\r
+;--*/\r
+\r
+;#include "CpuIA32.h"\r
+\r
+;---------------------------------------------------------------------------\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;---------------------------------------------------------------------------\r
+;VOID\r
+;EfiHalt (\r
+;  VOID\r
+;)\r
+EfiHalt PROC C PUBLIC\r
+    hlt\r
+    ret\r
+EfiHalt ENDP    \r
+\r
+;VOID\r
+;EfiWbinvd (\r
+;  VOID\r
+;)\r
+EfiWbinvd PROC C PUBLIC\r
+    wbinvd\r
+    ret\r
+EfiWbinvd ENDP\r
+\r
+;VOID\r
+;EfiInvd (\r
+; VOID\r
+;)\r
+EfiInvd PROC C PUBLIC\r
+    invd\r
+    ret\r
+EfiInvd ENDP\r
+\r
+;VOID\r
+;EfiCpuid (IN UINT32 RegisterInEax,\r
+;          OUT EFI_CPUID_REGISTER *Reg OPTIONAL)\r
+EfiCpuid PROC C PUBLIC\r
+    push ebp\r
+    mov  ebp, esp\r
+    push ebx\r
+    push esi\r
+    push edi\r
+    pushad\r
+\r
+    mov    eax, dword ptr[ebp + 8] ;egisterInEax\r
+    cpuid\r
+    cmp    dword ptr[ebp + 0Ch], 0 ; Reg\r
+    je     @F\r
+    mov         edi,dword ptr [ebp+0Ch] ; Reg \r
+\r
+    mov         dword ptr [edi],eax ; Reg->RegEax\r
+    mov         dword ptr [edi+4],ebx ; Reg->RegEbx\r
+    mov         dword ptr [edi+8],ecx ; Reg->RegEcx\r
+    mov         dword ptr [edi+0Ch],edx ; Reg->RegEdx\r
+\r
+@@:\r
+    popad\r
+    pop         edi\r
+    pop         esi\r
+    pop         ebx\r
+    pop         ebp\r
+    \r
+    ret\r
+EfiCpuid ENDP\r
+\r
+\r
+;UINT64\r
+;EfiReadMsr (\r
+;  IN UINT32 Index\r
+;  );\r
+EfiReadMsr PROC C PUBLIC\r
+    mov    ecx, dword ptr [esp + 4]; Index\r
+    rdmsr\r
+    ret\r
+EfiReadMsr ENDP\r
+\r
+;VOID\r
+;EfiWriteMsr (\r
+;  IN   UINT32  Index,\r
+;  IN   UINT64  Value\r
+;  );\r
+EfiWriteMsr PROC C PUBLIC\r
+    mov    ecx, dword ptr [esp+4]; Index\r
+    mov    eax, dword ptr [esp+8]; DWORD PTR Value[0]\r
+    mov    edx, dword ptr [esp+0Ch]; DWORD PTR Value[4]\r
+    wrmsr            \r
+    ret\r
+EfiWriteMsr  ENDP\r
+\r
+;UINT64\r
+;EfiReadTsc (\r
+;  VOID\r
+;  )\r
+EfiReadTsc PROC C PUBLIC\r
+    rdtsc\r
+    ret\r
+EfiReadTsc  ENDP\r
+\r
+;VOID\r
+;EfiDisableCache (\r
+;  VOID\r
+;)\r
+EfiDisableCache PROC C PUBLIC\r
+    mov   eax, cr0\r
+    bswap eax\r
+    and   al, 60h\r
+    cmp   al, 60h\r
+    je    @F\r
+    mov   eax, cr0\r
+    or    eax, 060000000h     \r
+    mov   cr0, eax\r
+    wbinvd\r
+@@:\r
+    ret\r
+EfiDisableCache  ENDP\r
+\r
+;VOID\r
+;EfiEnableCache (\r
+;  VOID\r
+;  )\r
+EfiEnableCache PROC C PUBLIC\r
+    invd\r
+    mov   eax, cr0\r
+    and   eax, 09fffffffh         \r
+    mov   cr0, eax\r
+    ret\r
+EfiEnableCache  ENDP\r
+\r
+;UINT32\r
+;EfiGetEflags (\r
+;  VOID\r
+;  )\r
+EfiGetEflags PROC C PUBLIC\r
+    pushfd\r
+    pop  eax\r
+    ret\r
+EfiGetEflags  ENDP\r
+\r
+;VOID\r
+;EfiDisableInterrupts (\r
+;  VOID\r
+;  )\r
+EfiDisableInterrupts PROC C PUBLIC\r
+    cli\r
+    ret\r
+EfiDisableInterrupts  ENDP\r
+\r
+;VOID\r
+;EfiEnableInterrupts (\r
+;  VOID\r
+;  )\r
+EfiEnableInterrupts  PROC C PUBLIC\r
+    sti\r
+    ret\r
+EfiEnableInterrupts   ENDP\r
+\r
+;VOID\r
+;EfiCpuidExt (\r
+;  IN   UINT32              RegisterInEax,\r
+;  IN   UINT32              CacheLevel,\r
+;  OUT  EFI_CPUID_REGISTER  *Regs              \r
+;  )\r
+EfiCpuidExt PROC C PUBLIC USES ebx edi esi\r
+    pushad\r
+\r
+    mov    eax, dword ptr [esp + 30h] ; RegisterInEax\r
+    mov    ecx, dword ptr [esp + 34h] ; CacheLevel\r
+    cpuid\r
+    mov    edi, dword ptr [esp + 38h] ; DWORD PTR Regs \r
+\r
+    mov    dword ptr [edi], eax        ; Reg->RegEax\r
+    mov    dword ptr [edi + 4], ebx    ; Reg->RegEbx\r
+    mov    dword ptr [edi + 8], ecx    ; Reg->RegEcx\r
+    mov    dword ptr [edi + 0Ch], edx   ; Reg->RegEdx\r
+\r
+    popad\r
+    ret\r
+EfiCpuidExt  ENDP\r
+\r
+       END\r
+       \r