]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/CpuIA32Lib/EfiCpuVersion.c
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / CpuIA32Lib / EfiCpuVersion.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
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 Module Name:
15
16
17 EfiCpuVersion.c
18
19 Abstract:
20
21 Provide cpu version extract considering extended family & model ID.
22 --*/
23
24 #include <Library/CpuIA32.h>
25
26 /**
27 Extract CPU detail version infomation
28
29 @param FamilyId FamilyId, including ExtendedFamilyId
30 @param Model Model, including ExtendedModel
31 @param SteppingId SteppingId
32 @param Processor Processor
33
34 **/
35 VOID
36 EFIAPI
37 EfiCpuVersion (
38 IN OUT UINT16 *FamilyId, OPTIONAL
39 IN OUT UINT8 *Model, OPTIONAL
40 IN OUT UINT8 *SteppingId, OPTIONAL
41 IN OUT UINT8 *Processor OPTIONAL
42 )
43
44 {
45 EFI_CPUID_REGISTER Register;
46 UINT8 TempFamilyId;
47
48 EfiCpuid (EFI_CPUID_VERSION_INFO, &Register);
49
50 if (SteppingId != NULL) {
51 *SteppingId = (UINT8) (Register.RegEax & 0xF);
52 }
53
54 if (Processor != NULL) {
55 *Processor = (UINT8) ((Register.RegEax >> 12) & 0x3);
56 }
57
58 if (Model != NULL || FamilyId != NULL) {
59 TempFamilyId = (UINT8) ((Register.RegEax >> 8) & 0xF);
60
61 if (Model != NULL) {
62 *Model = (UINT8) ((Register.RegEax >> 4) & 0xF);
63 if (TempFamilyId == 0x6 || TempFamilyId == 0xF) {
64 *Model = (UINT8) (*Model | ((Register.RegEax >> 12) & 0xF0));
65 }
66 }
67
68 if (FamilyId != NULL) {
69 *FamilyId = TempFamilyId;
70 if (TempFamilyId == 0xF) {
71 *FamilyId = (UINT8 ) (*FamilyId + (UINT16) ((Register.RegEax >> 20) & 0xFF));
72 }
73 }
74 }
75 }