+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-VOID\r
-EfiHalt (VOID)\r
-{\r
- __asm {\r
- hlt\r
- }\r
-}\r
-\r
-VOID\r
-EfiWbinvd (VOID)\r
-{\r
- __asm {\r
- wbinvd\r
- }\r
-}\r
-\r
-VOID\r
-EfiInvd (VOID)\r
-{\r
- __asm {\r
- invd\r
- }\r
-}\r
-\r
-VOID\r
-EfiCpuid (IN UINT32 RegisterInEax,\r
- OUT EFI_CPUID_REGISTER *Reg OPTIONAL)\r
-{\r
- __asm {\r
- pushad\r
-\r
- mov eax, RegisterInEax\r
- cpuid\r
- cmp Reg, 0\r
- je _Exit\r
- mov edi, DWORD PTR Reg \r
-\r
- mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax\r
- mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx\r
- mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx\r
- mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx\r
-\r
-_Exit:\r
- popad\r
- }\r
-}\r
-\r
-UINT64\r
-EfiReadMsr (IN UINT32 Index)\r
-{\r
- __asm {\r
- mov ecx, Index\r
- rdmsr\r
- }\r
-}\r
-\r
-VOID\r
-EfiWriteMsr (\r
- IN UINT32 Index,\r
- IN UINT64 Value\r
- )\r
-{\r
- __asm {\r
- mov ecx, Index\r
- mov eax, DWORD PTR Value[0]\r
- mov edx, DWORD PTR Value[4]\r
- wrmsr \r
- }\r
-}\r
-\r
-UINT64\r
-EfiReadTsc (VOID)\r
-{\r
- __asm {\r
- rdtsc\r
- }\r
-}\r
-\r
-VOID\r
-EfiDisableCache (VOID)\r
-{\r
- __asm {\r
- mov eax, cr0\r
- bswap eax\r
- and al, 60h\r
- cmp al, 60h\r
- je Exit\r
- mov eax, cr0\r
- or eax, 060000000h \r
- mov cr0, eax\r
- wbinvd\r
-Exit:\r
- }\r
-}\r
-\r
-VOID\r
-EfiEnableCache (VOID)\r
-{\r
- __asm {\r
- wbinvd\r
- mov eax, cr0\r
- and eax, 09fffffffh \r
- mov cr0, eax\r
- }\r
-}\r
-\r
-UINT32\r
-EfiGetEflags (\r
- VOID\r
- )\r
-{\r
- __asm {\r
- pushfd\r
- pop eax\r
- }\r
-}\r
-\r
-VOID\r
-EfiDisableInterrupts (VOID)\r
-{\r
- __asm {\r
- cli\r
- }\r
-}\r
-\r
-VOID\r
-EfiEnableInterrupts (\r
- VOID\r
- )\r
-{\r
- __asm {\r
- sti\r
- }\r
-}\r
-\r
-VOID\r
-EfiCpuidExt (\r
- IN UINT32 RegisterInEax,\r
- IN UINT32 CacheLevel,\r
- OUT EFI_CPUID_REGISTER *Regs \r
- )\r
-{\r
- __asm {\r
- pushad\r
-\r
- mov eax, RegisterInEax\r
- mov ecx, CacheLevel\r
- cpuid\r
- mov edi, DWORD PTR Regs \r
-\r
- mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax\r
- mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx\r
- mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx\r
- mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx\r
-\r
- popad\r
- }\r
-}\r