]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/Library/CpuIA32Lib/X64/Cpu.S
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / CpuIA32Lib / X64 / Cpu.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#* Cpu.asm\r
18#*\r
19#* Abstract:\r
20#*\r
21#------------------------------------------------------------------------------\r
22##include <EfiBind.h>\r
23\r
24.globl ASM_PFX(EfiHalt)\r
25.globl ASM_PFX(EfiWbinvd)\r
26.globl ASM_PFX(EfiInvd)\r
27.globl ASM_PFX(EfiCpuid)\r
28.globl ASM_PFX(EfiReadTsc)\r
29.globl ASM_PFX(EfiDisableCache)\r
30.globl ASM_PFX(EfiEnableCache)\r
31.globl ASM_PFX(EfiReadMsr)\r
32.globl ASM_PFX(EfiWriteMsr)\r
33.globl ASM_PFX(EfiGetEflags)\r
34.globl ASM_PFX(EfiDisableInterrupts)\r
35.globl ASM_PFX(EfiEnableInterrupts)\r
36.globl ASM_PFX(EfiCpuidExt)\r
37\r
38.text\r
39\r
40\r
41#------------------------------------------------------------------------------\r
42# VOID\r
43# EfiHalt (\r
44# VOID\r
45# )\r
46#------------------------------------------------------------------------------\r
47ASM_PFX(EfiHalt):\r
48 hlt\r
49 retq\r
50\r
51\r
52#------------------------------------------------------------------------------\r
53# VOID\r
54# EfiWbinvd (\r
55# VOID\r
56# )\r
57#------------------------------------------------------------------------------\r
58ASM_PFX(EfiWbinvd):\r
59 wbinvd\r
60 retq\r
61\r
62\r
63#------------------------------------------------------------------------------\r
64# VOID\r
65# EfiInvd (\r
66# VOID\r
67# )\r
68#------------------------------------------------------------------------------\r
69ASM_PFX(EfiInvd):\r
70 invd\r
71 retq\r
72\r
73#------------------------------------------------------------------------------\r
74# VOID\r
75# EfiCpuid (\r
76# IN UINT32 RegisterInEax, // rcx\r
77# OUT EFI_CPUID_REGISTER *Reg OPTIONAL // rdx\r
78# )\r
79#------------------------------------------------------------------------------\r
80ASM_PFX(EfiCpuid):\r
81 push %rbx\r
82 mov %rdx,%r8\r
83 mov %rcx,%rax\r
84 cpuid\r
85 cmp $0x0,%r8\r
86 je _Exit\r
87 mov %eax,(%r8)\r
88 mov %ebx,0x4(%r8)\r
89 mov %ecx,0x8(%r8)\r
90 mov %edx,0xc(%r8)\r
91_Exit:\r
92 pop %rbx\r
93 retq\r
94\r
95#------------------------------------------------------------------------------\r
96# UINT64\r
97# EfiReadMsr (\r
98# IN UINT32 Index, // rcx\r
99# )\r
100#------------------------------------------------------------------------------\r
101ASM_PFX(EfiReadMsr):\r
102 rdmsr\r
103 shl $0x20,%rdx\r
104 or %rdx,%rax\r
105 retq\r
106\r
107#------------------------------------------------------------------------------\r
108# VOID\r
109# EfiWriteMsr (\r
110# IN UINT32 Index, // rcx\r
111# IN UINT64 Value // rdx\r
112# )\r
113#------------------------------------------------------------------------------\r
114ASM_PFX(EfiWriteMsr):\r
115 mov %rdx,%rax\r
116 sar $0x20,%rdx\r
117 wrmsr\r
118 retq\r
119\r
120#------------------------------------------------------------------------------\r
121# UINT64\r
122# EfiReadTsc (\r
123# VOID\r
124# );\r
125#------------------------------------------------------------------------------\r
126ASM_PFX(EfiReadTsc):\r
127 rdtsc\r
128 shl $0x20,%rax\r
129 shrd $0x20,%rdx,%rax\r
130 retq\r
131\r
132#------------------------------------------------------------------------------\r
133# VOID\r
134# EfiDisableCache (\r
135# VOID\r
136# );\r
137#------------------------------------------------------------------------------\r
138ASM_PFX(EfiDisableCache):\r
139# added a check to see if cache is already disabled. If it is, then skip.\r
140 mov %cr0,%rax\r
141 and $0x60000000,%rax\r
142 cmp $0x0,%rax\r
143 jne 1f\r
144 mov %cr0,%rax\r
145 or $0x60000000,%rax\r
146 mov %rax,%cr0\r
147 wbinvd\r
1481:\r
149 retq\r
150\r
151#------------------------------------------------------------------------------\r
152# VOID\r
153# EfiEnableCache (\r
154# VOID\r
155# );\r
156#------------------------------------------------------------------------------\r
157ASM_PFX(EfiEnableCache):\r
158 wbinvd\r
159 mov %cr0,%rax\r
160 and $0xffffffff9fffffff,%rax\r
161 mov %rax,%cr0\r
162 retq\r
163\r
164#------------------------------------------------------------------------------\r
165# UINTN\r
166# EfiGetEflags (\r
167# VOID\r
168# );\r
169#------------------------------------------------------------------------------\r
170ASM_PFX(EfiGetEflags):\r
171 pushfq\r
172 pop %rax\r
173 retq\r
174\r
175#------------------------------------------------------------------------------\r
176# VOID\r
177# EfiDisableInterrupts (\r
178# VOID\r
179# );\r
180#------------------------------------------------------------------------------\r
181ASM_PFX(EfiDisableInterrupts):\r
182 cli\r
183 ret\r
184\r
185#------------------------------------------------------------------------------\r
186# VOID\r
187# EfiEnableInterrupts (\r
188# VOID\r
189# );\r
190#------------------------------------------------------------------------------\r
191ASM_PFX(EfiEnableInterrupts):\r
192 sti\r
193 ret\r
194#------------------------------------------------------------------------------\r
195# VOID\r
196# EfiCpuidExt (\r
197# IN UINT32 RegisterInEax,\r
198# IN UINT32 CacheLevel,\r
199# OUT EFI_CPUID_REGISTER *Regs\r
200# )\r
201#------------------------------------------------------------------------------\r
202ASM_PFX(EfiCpuidExt):\r
203 push %rbx\r
204 mov %rcx,%rax\r
205 mov %rdx,%rcx\r
206 cpuid\r
207 mov %eax,(%r8)\r
208 mov %ebx,0x4(%r8)\r
209 mov %ecx,0x8(%r8)\r
210 mov %edx,0xc(%r8)\r
211 pop %rbx\r
212 retq\r