]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Cpu / Pentium / CpuIA32Lib / IA32 / CpuIA32.c
CommitLineData
3eb9473e 1/*++\r
2\r
f57387d5
HT
3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 CpuIA32.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
20#include "CpuIA32.h"\r
21\r
22VOID\r
23EfiHalt (VOID)\r
24{\r
25 __asm {\r
26 hlt\r
27 }\r
28}\r
29\r
30VOID\r
31EfiWbinvd (VOID)\r
32{\r
33 __asm {\r
34 wbinvd\r
35 }\r
36}\r
37\r
38VOID\r
39EfiInvd (VOID)\r
40{\r
41 __asm {\r
42 invd\r
43 }\r
44}\r
45\r
46VOID\r
47EfiCpuid (IN UINT32 RegisterInEax,\r
48 OUT EFI_CPUID_REGISTER *Reg OPTIONAL)\r
49{\r
50 __asm {\r
51 pushad\r
52\r
53 mov eax, RegisterInEax\r
54 cpuid\r
55 cmp Reg, 0\r
56 je _Exit\r
57 mov edi, DWORD PTR Reg \r
58\r
59 mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax\r
60 mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx\r
61 mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx\r
62 mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx\r
63\r
64_Exit:\r
65 popad\r
66 }\r
67}\r
68\r
69UINT64\r
70EfiReadMsr (IN UINT32 Index)\r
71{\r
72 __asm {\r
73 mov ecx, Index\r
74 rdmsr\r
75 }\r
76}\r
77\r
78VOID\r
79EfiWriteMsr (\r
80 IN UINT32 Index,\r
81 IN UINT64 Value\r
82 )\r
83{\r
84 __asm {\r
85 mov ecx, Index\r
86 mov eax, DWORD PTR Value[0]\r
87 mov edx, DWORD PTR Value[4]\r
88 wrmsr \r
89 }\r
90}\r
91\r
92UINT64\r
93EfiReadTsc (VOID)\r
94{\r
95 __asm {\r
96 rdtsc\r
97 }\r
98}\r
99\r
100VOID\r
101EfiDisableCache (VOID)\r
102{\r
103 __asm {\r
104 mov eax, cr0\r
105 bswap eax\r
106 and al, 60h\r
107 cmp al, 60h\r
108 je Exit\r
3eb9473e 109 mov eax, cr0\r
110 or eax, 060000000h \r
111 mov cr0, eax\r
2c40a813 112 wbinvd\r
3eb9473e 113Exit:\r
114 }\r
115}\r
116\r
117VOID\r
118EfiEnableCache (VOID)\r
119{\r
120 __asm {\r
121 invd\r
122 mov eax, cr0\r
123 and eax, 09fffffffh \r
124 mov cr0, eax\r
125 }\r
126}\r
127\r
128UINT32\r
129EfiGetEflags (\r
130 VOID\r
131 )\r
132{\r
133 __asm {\r
134 pushfd\r
135 pop eax\r
136 }\r
137}\r
138\r
139VOID\r
140EfiDisableInterrupts (VOID)\r
141{\r
142 __asm {\r
143 cli\r
144 }\r
145}\r
146\r
147VOID\r
148EfiEnableInterrupts (\r
149 VOID\r
150 )\r
151{\r
152 __asm {\r
153 sti\r
154 }\r
155}\r
156\r
157VOID\r
158EfiCpuidExt (\r
159 IN UINT32 RegisterInEax,\r
160 IN UINT32 CacheLevel,\r
161 OUT EFI_CPUID_REGISTER *Regs \r
162 )\r
163{\r
164 __asm {\r
165 pushad\r
166\r
167 mov eax, RegisterInEax\r
168 mov ecx, CacheLevel\r
169 cpuid\r
170 mov edi, DWORD PTR Regs \r
171\r
172 mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax\r
173 mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx\r
174 mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx\r
175 mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx\r
176\r
177 popad\r
178 }\r
179}\r