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