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