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