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