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