]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.S
Fixed issues compiling for Apple gcc on IA-32
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / X64 / CpuId.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 # CpuId.S
15 #
16 # Abstract:
17 #
18 # AsmCpuid function
19 #
20 # Notes:
21 #
22 #------------------------------------------------------------------------------
23
24 #include <EdkIIGlueBase.h>
25
26 #------------------------------------------------------------------------------
27 # VOID
28 # EFIAPI
29 # AsmCpuid (
30 # IN UINT32 RegisterInEax,
31 # OUT UINT32 *RegisterOutEax OPTIONAL,
32 # OUT UINT32 *RegisterOutEbx OPTIONAL,
33 # OUT UINT32 *RegisterOutEcx OPTIONAL,
34 # OUT UINT32 *RegisterOutEdx OPTIONAL
35 # )
36 #------------------------------------------------------------------------------
37 .globl ASM_PFX(AsmCpuid)
38 ASM_PFX(AsmCpuid):
39 push %rbx
40 mov %ecx, %eax
41 push %rax # save Index on stack
42 push %rdx
43 cpuid
44 test %r9, %r9
45 jz L1
46 mov %ecx, (%r9)
47 L1:
48 pop %rcx
49 jrcxz L2
50 mov %eax, (%rcx)
51 L2:
52 mov %r8, %rcx
53 jrcxz L3
54 mov %ebx, (%rcx)
55 L3:
56 mov 0x38(%rsp), %rcx
57 jrcxz L4
58 mov %edx, (%rcx)
59 L4:
60 pop %rax # restore Index to rax as return value
61 pop %rbx
62 ret