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