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