1; 2; This file contains an 'Intel Sample Driver' and is 3; licensed for Intel CPUs and chipsets under the terms of your 4; license agreement with Intel or your vendor. This file may 5; be modified by the user, subject to additional terms of the 6; license agreement 7; 8; 9; Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved 10; 11 12; This program and the accompanying materials are licensed and made available under 13 14; the terms and conditions of the BSD License that accompanies this distribution. 15 16; The full text of the license may be found at 17 18; http://opensource.org/licenses/bsd-license.php. 19 20; 21 22; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 23 24; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 25 26; 27 28; 29 30;Module Name: 31; 32; CpuIA32.c 33; 34;Abstract: 35; 36;--*/ 37 38;#include "CpuIA32.h" 39 40;--------------------------------------------------------------------------- 41 .586p 42 .model flat,C 43 .code 44 45;--------------------------------------------------------------------------- 46;VOID 47;EfiHalt ( 48; VOID 49;) 50EfiHalt PROC C PUBLIC 51 hlt 52 ret 53EfiHalt ENDP 54 55;VOID 56;EfiWbinvd ( 57; VOID 58;) 59EfiWbinvd PROC C PUBLIC 60 wbinvd 61 ret 62EfiWbinvd ENDP 63 64;VOID 65;EfiInvd ( 66; VOID 67;) 68EfiInvd PROC C PUBLIC 69 invd 70 ret 71EfiInvd ENDP 72 73;VOID 74;EfiCpuid (IN UINT32 RegisterInEax, 75; OUT EFI_CPUID_REGISTER *Reg OPTIONAL) 76EfiCpuid PROC C PUBLIC 77 push ebp 78 mov ebp, esp 79 push ebx 80 push esi 81 push edi 82 pushad 83 84 mov eax, dword ptr[ebp + 8] ;egisterInEax 85 cpuid 86 cmp dword ptr[ebp + 0Ch], 0 ; Reg 87 je @F 88 mov edi,dword ptr [ebp+0Ch] ; Reg 89 90 mov dword ptr [edi],eax ; Reg->RegEax 91 mov dword ptr [edi+4],ebx ; Reg->RegEbx 92 mov dword ptr [edi+8],ecx ; Reg->RegEcx 93 mov dword ptr [edi+0Ch],edx ; Reg->RegEdx 94 95@@: 96 popad 97 pop edi 98 pop esi 99 pop ebx 100 pop ebp 101 102 ret 103EfiCpuid ENDP 104 105 106;UINT64 107;EfiReadMsr ( 108; IN UINT32 Index 109; ); 110EfiReadMsr PROC C PUBLIC 111 mov ecx, dword ptr [esp + 4]; Index 112 rdmsr 113 ret 114EfiReadMsr ENDP 115 116;VOID 117;EfiWriteMsr ( 118; IN UINT32 Index, 119; IN UINT64 Value 120; ); 121EfiWriteMsr PROC C PUBLIC 122 mov ecx, dword ptr [esp+4]; Index 123 mov eax, dword ptr [esp+8]; DWORD PTR Value[0] 124 mov edx, dword ptr [esp+0Ch]; DWORD PTR Value[4] 125 wrmsr 126 ret 127EfiWriteMsr ENDP 128 129;UINT64 130;EfiReadTsc ( 131; VOID 132; ) 133EfiReadTsc PROC C PUBLIC 134 rdtsc 135 ret 136EfiReadTsc ENDP 137 138;VOID 139;EfiDisableCache ( 140; VOID 141;) 142EfiDisableCache PROC C PUBLIC 143 mov eax, cr0 144 bswap eax 145 and al, 60h 146 cmp al, 60h 147 je @F 148 mov eax, cr0 149 or eax, 060000000h 150 mov cr0, eax 151 wbinvd 152@@: 153 ret 154EfiDisableCache ENDP 155 156;VOID 157;EfiEnableCache ( 158; VOID 159; ) 160EfiEnableCache PROC C PUBLIC 161 wbinvd 162 mov eax, cr0 163 and eax, 09fffffffh 164 mov cr0, eax 165 ret 166EfiEnableCache ENDP 167 168;UINT32 169;EfiGetEflags ( 170; VOID 171; ) 172EfiGetEflags PROC C PUBLIC 173 pushfd 174 pop eax 175 ret 176EfiGetEflags ENDP 177 178;VOID 179;EfiDisableInterrupts ( 180; VOID 181; ) 182EfiDisableInterrupts PROC C PUBLIC 183 cli 184 ret 185EfiDisableInterrupts ENDP 186 187;VOID 188;EfiEnableInterrupts ( 189; VOID 190; ) 191EfiEnableInterrupts PROC C PUBLIC 192 sti 193 ret 194EfiEnableInterrupts ENDP 195 196;VOID 197;EfiCpuidExt ( 198; IN UINT32 RegisterInEax, 199; IN UINT32 CacheLevel, 200; OUT EFI_CPUID_REGISTER *Regs 201; ) 202EfiCpuidExt PROC C PUBLIC USES ebx edi esi 203 pushad 204 205 mov eax, dword ptr [esp + 30h] ; RegisterInEax 206 mov ecx, dword ptr [esp + 34h] ; CacheLevel 207 cpuid 208 mov edi, dword ptr [esp + 38h] ; DWORD PTR Regs 209 210 mov dword ptr [edi], eax ; Reg->RegEax 211 mov dword ptr [edi + 4], ebx ; Reg->RegEbx 212 mov dword ptr [edi + 8], ecx ; Reg->RegEcx 213 mov dword ptr [edi + 0Ch], edx ; Reg->RegEdx 214 215 popad 216 ret 217EfiCpuidExt ENDP 218 219 END 220 221