]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/CpuIA32Lib/IA32/CpuIA32.S
Vlv2TbltDevicePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / CpuIA32Lib / IA32 / CpuIA32.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 # CpuIA32.c
13 #
14 #Abstract:
15 #
16 #--*/
17
18 ##include "CpuIA32.h"
19 #include "EfiBind.h"
20
21 #---------------------------------------------------------------------------
22 .586p:
23 #.MODEL flat,C
24 .code:
25
26 #---------------------------------------------------------------------------
27
28 .globl ASM_PFX(EfiHalt)
29 .globl ASM_PFX(EfiWbinvd)
30 .globl ASM_PFX(EfiInvd)
31 .globl ASM_PFX(EfiCpuid)
32 .globl ASM_PFX(EfiReadMsr)
33 .globl ASM_PFX(EfiWriteMsr)
34 .globl ASM_PFX(EfiReadTsc)
35 .globl ASM_PFX(EfiDisableCache)
36 .globl ASM_PFX(EfiEnableCache)
37 .globl ASM_PFX(EfiGetEflags)
38 .globl ASM_PFX(EfiDisableInterrupts)
39 .globl ASM_PFX(EfiEnableInterrupts)
40 .globl ASM_PFX(EfiCpuidExt)
41
42
43 #VOID
44 #EfiHalt (
45 # VOID
46 #)
47 ASM_PFX(EfiHalt):
48 hlt
49 ret
50 #EfiHalt ENDP
51
52 #VOID
53 #EfiWbinvd (
54 # VOID
55 #)
56 ASM_PFX(EfiWbinvd):
57 wbinvd
58 ret
59 #EfiWbinvd ENDP
60
61 #VOID
62 #EfiInvd (
63 # VOID
64 #)
65 ASM_PFX(EfiInvd):
66 invd
67 ret
68 #EfiInvd ENDP
69
70 #VOID
71 #EfiCpuid (IN UINT32 RegisterInEax,
72 # OUT EFI_CPUID_REGISTER *Reg OPTIONAL)
73 ASM_PFX(EfiCpuid):
74 pushl %ebp
75 movl %esp, %ebp
76 pushl %ebx
77 pushl %esi
78 pushl %edi
79 pushal
80
81 movl 8(%ebp), %eax #RegisterInEax
82 cpuid
83 cmpl $0, 0xC(%ebp) # Reg
84 je L1
85 movl 0xC(%ebp), %edi # Reg
86
87 movl %eax, (%edi) # Reg->RegEax
88 movl %ebx, 4(%edi) # Reg->RegEbx
89 movl %ecx, 8(%edi) # Reg->RegEcx
90 movl %edx, 0xC(%edi) # Reg->RegEdx
91
92 L1:
93 popal
94 popl %edi
95 popl %esi
96 popl %ebx
97 popl %ebp
98
99 ret
100 #EfiCpuid ENDP
101
102
103 #UINT64
104 #EfiReadMsr (
105 # IN UINT32 Index
106 # );
107 ASM_PFX(EfiReadMsr):
108 movl 4(%esp), %ecx # Index
109 rdmsr
110 ret
111 #EfiReadMsr ENDP
112
113 #VOID
114 #EfiWriteMsr (
115 # IN UINT32 Index,
116 # IN UINT64 Value
117 # );
118 ASM_PFX(EfiWriteMsr):
119 movl 4(%esp), %ecx # Index
120 movl 8(%esp), %eax # DWORD PTR Value[0]
121 movl 0xC(%esp), %edx # DWORD PTR Value[4]
122 wrmsr
123 ret
124 #EfiWriteMsr ENDP
125
126 #UINT64
127 #EfiReadTsc (
128 # VOID
129 # )
130 ASM_PFX(EfiReadTsc):
131 rdtsc
132 ret
133 #EfiReadTsc ENDP
134
135 #VOID
136 #EfiDisableCache (
137 # VOID
138 #)
139 ASM_PFX(EfiDisableCache):
140 movl %cr0, %eax
141 bswapl %eax
142 andb $0x60, %al
143 cmpb $0x60, %al
144 je L2
145 movl %cr0, %eax
146 orl $0x60000000, %eax
147 movl %eax, %cr0
148 wbinvd
149 L2:
150 ret
151 #EfiDisableCache ENDP
152
153 #VOID
154 #EfiEnableCache (
155 # VOID
156 # )
157 ASM_PFX(EfiEnableCache):
158 wbinvd
159 movl %cr0, %eax
160 andl $0x9fffffff, %eax
161 movl %eax, %cr0
162 ret
163 #EfiEnableCache ENDP
164
165 #UINT32
166 #EfiGetEflags (
167 # VOID
168 # )
169 ASM_PFX(EfiGetEflags):
170 pushfl
171 popl %eax
172 ret
173 #EfiGetEflags ENDP
174
175 #VOID
176 #EfiDisableInterrupts (
177 # VOID
178 # )
179 ASM_PFX(EfiDisableInterrupts):
180 cli
181 ret
182 #EfiDisableInterrupts ENDP
183
184 #VOID
185 #EfiEnableInterrupts (
186 # VOID
187 # )
188 ASM_PFX(EfiEnableInterrupts):
189 sti
190 ret
191 #EfiEnableInterrupts ENDP
192
193 #VOID
194 #EfiCpuidExt (
195 # IN UINT32 RegisterInEax,
196 # IN UINT32 CacheLevel,
197 # OUT EFI_CPUID_REGISTER *Regs
198 # )
199 ASM_PFX(EfiCpuidExt):
200 push %ebx
201 push %edi
202 push %esi
203 pushal
204
205 movl 0x30(%esp), %eax # RegisterInEax
206 movl 0x34(%esp), %ecx # CacheLevel
207 cpuid
208 movl 0x38(%esp), %edi # DWORD PTR Regs
209
210 movl %eax, (%edi) # Reg->RegEax
211 movl %ebx, 4(%edi) # Reg->RegEbx
212 movl %ecx, 8(%edi) # Reg->RegEcx
213 movl %edx, 0xC(%edi) # Reg->RegEdx
214
215 popal
216 pop %esi
217 pop %edi
218 pop %ebx
219 ret
220 #EfiCpuidExt ENDP
221
222
223