]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/Library/CpuIA32Lib/IA32/CpuIA32.S
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / CpuIA32Lib / IA32 / CpuIA32.S
CommitLineData
3cbfba02
DW
1#\r
2#\r
3# Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved\r
4# \r\r
5# This program and the accompanying materials are licensed and made available under\r\r
6# the terms and conditions of the BSD License that accompanies this distribution. \r\r
7# The full text of the license may be found at \r\r
8# http://opensource.org/licenses/bsd-license.php. \r\r
9# \r\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r
12# \r\r
13#\r
14#\r
15#Module Name:\r
16#\r
17# CpuIA32.c\r
18#\r
19#Abstract:\r
20#\r
21#--*/\r
22\r
23##include "CpuIA32.h"\r
24#include "EfiBind.h"\r
25\r
26#---------------------------------------------------------------------------\r
27 .586p:\r
28 #.MODEL flat,C\r
29 .code:\r
30\r
31#---------------------------------------------------------------------------\r
32\r
33.globl ASM_PFX(EfiHalt)\r
34.globl ASM_PFX(EfiWbinvd)\r
35.globl ASM_PFX(EfiInvd)\r
36.globl ASM_PFX(EfiCpuid)\r
37.globl ASM_PFX(EfiReadMsr)\r
38.globl ASM_PFX(EfiWriteMsr)\r
39.globl ASM_PFX(EfiReadTsc)\r
40.globl ASM_PFX(EfiDisableCache)\r
41.globl ASM_PFX(EfiEnableCache)\r
42.globl ASM_PFX(EfiGetEflags)\r
43.globl ASM_PFX(EfiDisableInterrupts)\r
44.globl ASM_PFX(EfiEnableInterrupts)\r
45.globl ASM_PFX(EfiCpuidExt)\r
46\r
47\r
48#VOID\r
49#EfiHalt (\r
50# VOID\r
51#)\r
52ASM_PFX(EfiHalt):\r
53 hlt\r
54 ret\r
55#EfiHalt ENDP\r
56\r
57#VOID\r
58#EfiWbinvd (\r
59# VOID\r
60#)\r
61ASM_PFX(EfiWbinvd):\r
62 wbinvd\r
63 ret\r
64#EfiWbinvd ENDP\r
65\r
66#VOID\r
67#EfiInvd (\r
68# VOID\r
69#)\r
70ASM_PFX(EfiInvd):\r
71 invd\r
72 ret\r
73#EfiInvd ENDP\r
74\r
75#VOID\r
76#EfiCpuid (IN UINT32 RegisterInEax,\r
77# OUT EFI_CPUID_REGISTER *Reg OPTIONAL)\r
78ASM_PFX(EfiCpuid):\r
79 pushl %ebp\r
80 movl %esp, %ebp\r
81 pushl %ebx\r
82 pushl %esi\r
83 pushl %edi\r
84 pushal\r
85\r
86 movl 8(%ebp), %eax #RegisterInEax\r
87 cpuid\r
88 cmpl $0, 0xC(%ebp) # Reg\r
89 je L1\r
90 movl 0xC(%ebp), %edi # Reg\r
91\r
92 movl %eax, (%edi) # Reg->RegEax\r
93 movl %ebx, 4(%edi) # Reg->RegEbx\r
94 movl %ecx, 8(%edi) # Reg->RegEcx\r
95 movl %edx, 0xC(%edi) # Reg->RegEdx\r
96\r
97L1:\r
98 popal\r
99 popl %edi\r
100 popl %esi\r
101 popl %ebx\r
102 popl %ebp\r
103\r
104 ret\r
105#EfiCpuid ENDP\r
106\r
107\r
108#UINT64\r
109#EfiReadMsr (\r
110# IN UINT32 Index\r
111# );\r
112ASM_PFX(EfiReadMsr):\r
113 movl 4(%esp), %ecx # Index\r
114 rdmsr\r
115 ret\r
116#EfiReadMsr ENDP\r
117\r
118#VOID\r
119#EfiWriteMsr (\r
120# IN UINT32 Index,\r
121# IN UINT64 Value\r
122# );\r
123ASM_PFX(EfiWriteMsr):\r
124 movl 4(%esp), %ecx # Index\r
125 movl 8(%esp), %eax # DWORD PTR Value[0]\r
126 movl 0xC(%esp), %edx # DWORD PTR Value[4]\r
127 wrmsr\r
128 ret\r
129#EfiWriteMsr ENDP\r
130\r
131#UINT64\r
132#EfiReadTsc (\r
133# VOID\r
134# )\r
135ASM_PFX(EfiReadTsc):\r
136 rdtsc\r
137 ret\r
138#EfiReadTsc ENDP\r
139\r
140#VOID\r
141#EfiDisableCache (\r
142# VOID\r
143#)\r
144ASM_PFX(EfiDisableCache):\r
145 movl %cr0, %eax\r
146 bswapl %eax\r
147 andb $0x60, %al\r
148 cmpb $0x60, %al\r
149 je L2\r
150 movl %cr0, %eax\r
151 orl $0x60000000, %eax\r
152 movl %eax, %cr0\r
153 wbinvd\r
154L2:\r
155 ret\r
156#EfiDisableCache ENDP\r
157\r
158#VOID\r
159#EfiEnableCache (\r
160# VOID\r
161# )\r
162ASM_PFX(EfiEnableCache):\r
163 wbinvd\r
164 movl %cr0, %eax\r
165 andl $0x9fffffff, %eax\r
166 movl %eax, %cr0\r
167 ret\r
168#EfiEnableCache ENDP\r
169\r
170#UINT32\r
171#EfiGetEflags (\r
172# VOID\r
173# )\r
174ASM_PFX(EfiGetEflags):\r
175 pushfl\r
176 popl %eax\r
177 ret\r
178#EfiGetEflags ENDP\r
179\r
180#VOID\r
181#EfiDisableInterrupts (\r
182# VOID\r
183# )\r
184ASM_PFX(EfiDisableInterrupts):\r
185 cli\r
186 ret\r
187#EfiDisableInterrupts ENDP\r
188\r
189#VOID\r
190#EfiEnableInterrupts (\r
191# VOID\r
192# )\r
193ASM_PFX(EfiEnableInterrupts):\r
194 sti\r
195 ret\r
196#EfiEnableInterrupts ENDP\r
197\r
198#VOID\r
199#EfiCpuidExt (\r
200# IN UINT32 RegisterInEax,\r
201# IN UINT32 CacheLevel,\r
202# OUT EFI_CPUID_REGISTER *Regs\r
203# )\r
204ASM_PFX(EfiCpuidExt):\r
205 push %ebx\r
206 push %edi\r
207 push %esi\r
208 pushal\r
209\r
210 movl 0x30(%esp), %eax # RegisterInEax\r
211 movl 0x34(%esp), %ecx # CacheLevel\r
212 cpuid\r
213 movl 0x38(%esp), %edi # DWORD PTR Regs\r
214\r
215 movl %eax, (%edi) # Reg->RegEax\r
216 movl %ebx, 4(%edi) # Reg->RegEbx\r
217 movl %ecx, 8(%edi) # Reg->RegEcx\r
218 movl %edx, 0xC(%edi) # Reg->RegEdx\r
219\r
220 popal\r
221 pop %esi\r
222 pop %edi\r
223 pop %ebx\r
224 ret\r
225#EfiCpuidExt ENDP\r
226\r
227\r
228\r