]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/CpuIA32Lib/IA32/CpuIA32.S
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / CpuIA32Lib / IA32 / CpuIA32.S
1 #
2 #
3 # Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
4 #
5 # This program and the accompanying materials are licensed and made available under
6 # the terms and conditions of the BSD License that accompanies this distribution.
7 # The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php.
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #
14 #
15 #Module Name:
16 #
17 # CpuIA32.c
18 #
19 #Abstract:
20 #
21 #--*/
22
23 ##include "CpuIA32.h"
24 #include "EfiBind.h"
25
26 #---------------------------------------------------------------------------
27 .586p:
28 #.MODEL flat,C
29 .code:
30
31 #---------------------------------------------------------------------------
32
33 .globl ASM_PFX(EfiHalt)
34 .globl ASM_PFX(EfiWbinvd)
35 .globl ASM_PFX(EfiInvd)
36 .globl ASM_PFX(EfiCpuid)
37 .globl ASM_PFX(EfiReadMsr)
38 .globl ASM_PFX(EfiWriteMsr)
39 .globl ASM_PFX(EfiReadTsc)
40 .globl ASM_PFX(EfiDisableCache)
41 .globl ASM_PFX(EfiEnableCache)
42 .globl ASM_PFX(EfiGetEflags)
43 .globl ASM_PFX(EfiDisableInterrupts)
44 .globl ASM_PFX(EfiEnableInterrupts)
45 .globl ASM_PFX(EfiCpuidExt)
46
47
48 #VOID
49 #EfiHalt (
50 # VOID
51 #)
52 ASM_PFX(EfiHalt):
53 hlt
54 ret
55 #EfiHalt ENDP
56
57 #VOID
58 #EfiWbinvd (
59 # VOID
60 #)
61 ASM_PFX(EfiWbinvd):
62 wbinvd
63 ret
64 #EfiWbinvd ENDP
65
66 #VOID
67 #EfiInvd (
68 # VOID
69 #)
70 ASM_PFX(EfiInvd):
71 invd
72 ret
73 #EfiInvd ENDP
74
75 #VOID
76 #EfiCpuid (IN UINT32 RegisterInEax,
77 # OUT EFI_CPUID_REGISTER *Reg OPTIONAL)
78 ASM_PFX(EfiCpuid):
79 pushl %ebp
80 movl %esp, %ebp
81 pushl %ebx
82 pushl %esi
83 pushl %edi
84 pushal
85
86 movl 8(%ebp), %eax #RegisterInEax
87 cpuid
88 cmpl $0, 0xC(%ebp) # Reg
89 je L1
90 movl 0xC(%ebp), %edi # Reg
91
92 movl %eax, (%edi) # Reg->RegEax
93 movl %ebx, 4(%edi) # Reg->RegEbx
94 movl %ecx, 8(%edi) # Reg->RegEcx
95 movl %edx, 0xC(%edi) # Reg->RegEdx
96
97 L1:
98 popal
99 popl %edi
100 popl %esi
101 popl %ebx
102 popl %ebp
103
104 ret
105 #EfiCpuid ENDP
106
107
108 #UINT64
109 #EfiReadMsr (
110 # IN UINT32 Index
111 # );
112 ASM_PFX(EfiReadMsr):
113 movl 4(%esp), %ecx # Index
114 rdmsr
115 ret
116 #EfiReadMsr ENDP
117
118 #VOID
119 #EfiWriteMsr (
120 # IN UINT32 Index,
121 # IN UINT64 Value
122 # );
123 ASM_PFX(EfiWriteMsr):
124 movl 4(%esp), %ecx # Index
125 movl 8(%esp), %eax # DWORD PTR Value[0]
126 movl 0xC(%esp), %edx # DWORD PTR Value[4]
127 wrmsr
128 ret
129 #EfiWriteMsr ENDP
130
131 #UINT64
132 #EfiReadTsc (
133 # VOID
134 # )
135 ASM_PFX(EfiReadTsc):
136 rdtsc
137 ret
138 #EfiReadTsc ENDP
139
140 #VOID
141 #EfiDisableCache (
142 # VOID
143 #)
144 ASM_PFX(EfiDisableCache):
145 movl %cr0, %eax
146 bswapl %eax
147 andb $0x60, %al
148 cmpb $0x60, %al
149 je L2
150 movl %cr0, %eax
151 orl $0x60000000, %eax
152 movl %eax, %cr0
153 wbinvd
154 L2:
155 ret
156 #EfiDisableCache ENDP
157
158 #VOID
159 #EfiEnableCache (
160 # VOID
161 # )
162 ASM_PFX(EfiEnableCache):
163 wbinvd
164 movl %cr0, %eax
165 andl $0x9fffffff, %eax
166 movl %eax, %cr0
167 ret
168 #EfiEnableCache ENDP
169
170 #UINT32
171 #EfiGetEflags (
172 # VOID
173 # )
174 ASM_PFX(EfiGetEflags):
175 pushfl
176 popl %eax
177 ret
178 #EfiGetEflags ENDP
179
180 #VOID
181 #EfiDisableInterrupts (
182 # VOID
183 # )
184 ASM_PFX(EfiDisableInterrupts):
185 cli
186 ret
187 #EfiDisableInterrupts ENDP
188
189 #VOID
190 #EfiEnableInterrupts (
191 # VOID
192 # )
193 ASM_PFX(EfiEnableInterrupts):
194 sti
195 ret
196 #EfiEnableInterrupts ENDP
197
198 #VOID
199 #EfiCpuidExt (
200 # IN UINT32 RegisterInEax,
201 # IN UINT32 CacheLevel,
202 # OUT EFI_CPUID_REGISTER *Regs
203 # )
204 ASM_PFX(EfiCpuidExt):
205 push %ebx
206 push %edi
207 push %esi
208 pushal
209
210 movl 0x30(%esp), %eax # RegisterInEax
211 movl 0x34(%esp), %ecx # CacheLevel
212 cpuid
213 movl 0x38(%esp), %edi # DWORD PTR Regs
214
215 movl %eax, (%edi) # Reg->RegEax
216 movl %ebx, 4(%edi) # Reg->RegEbx
217 movl %ecx, 8(%edi) # Reg->RegEcx
218 movl %edx, 0xC(%edi) # Reg->RegEdx
219
220 popal
221 pop %esi
222 pop %edi
223 pop %ebx
224 ret
225 #EfiCpuidExt ENDP
226
227
228