]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c
UefiCpuPkg: Clean up source files
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCommonFeaturesLib / Ppin.c
1 /** @file
2 Protected Processor Inventory Number(PPIN) feature.
3
4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. 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 #include "CpuCommonFeatures.h"
16
17 /**
18 Detects if Protected Processor Inventory Number feature supported on current
19 processor.
20
21 @param[in] ProcessorNumber The index of the CPU executing this function.
22 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
23 structure for the CPU executing this function.
24 @param[in] ConfigData A pointer to the configuration buffer returned
25 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
26 CPU_FEATURE_GET_CONFIG_DATA was not provided in
27 RegisterCpuFeature().
28
29 @retval TRUE Protected Processor Inventory Number feature is supported.
30 @retval FALSE Protected Processor Inventory Number feature is not supported.
31
32 @note This service could be called by BSP/APs.
33 **/
34 BOOLEAN
35 EFIAPI
36 PpinSupport (
37 IN UINTN ProcessorNumber,
38 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
39 IN VOID *ConfigData OPTIONAL
40 )
41 {
42 MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER PlatformInfo;
43
44 if ((CpuInfo->DisplayFamily == 0x06) &&
45 ((CpuInfo->DisplayModel == 0x3E) || // Xeon E5 V2
46 (CpuInfo->DisplayModel == 0x56) || // Xeon Processor D Product
47 (CpuInfo->DisplayModel == 0x4F) || // Xeon E5 v4, E7 v4
48 (CpuInfo->DisplayModel == 0x55) || // Xeon Processor Scalable
49 (CpuInfo->DisplayModel == 0x57) || // Xeon Phi processor 3200, 5200, 7200 series.
50 (CpuInfo->DisplayModel == 0x85) // Future Xeon phi processor
51 )) {
52 //
53 // Check whether platform support this feature.
54 //
55 PlatformInfo.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1);
56 return (PlatformInfo.Bits.PPIN_CAP != 0);
57 }
58
59 return FALSE;
60 }
61
62 /**
63 Initializes Protected Processor Inventory Number feature to specific state.
64
65 @param[in] ProcessorNumber The index of the CPU executing this function.
66 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
67 structure for the CPU executing this function.
68 @param[in] ConfigData A pointer to the configuration buffer returned
69 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
70 CPU_FEATURE_GET_CONFIG_DATA was not provided in
71 RegisterCpuFeature().
72 @param[in] State If TRUE, then the Protected Processor Inventory
73 Number feature must be enabled.
74 If FALSE, then the Protected Processor Inventory
75 Number feature must be disabled.
76
77 @retval RETURN_SUCCESS Protected Processor Inventory Number feature is
78 initialized.
79 @retval RETURN_DEVICE_ERROR Device can't change state because it has been
80 locked.
81
82 **/
83 RETURN_STATUS
84 EFIAPI
85 PpinInitialize (
86 IN UINTN ProcessorNumber,
87 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
88 IN VOID *ConfigData, OPTIONAL
89 IN BOOLEAN State
90 )
91 {
92 MSR_IVY_BRIDGE_PPIN_CTL_REGISTER MsrPpinCtrl;
93
94 //
95 // Check whether device already lock this register.
96 // If already locked, just base on the request state and
97 // the current state to return the status.
98 //
99 MsrPpinCtrl.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN_CTL);
100 if (MsrPpinCtrl.Bits.LockOut != 0) {
101 return MsrPpinCtrl.Bits.Enable_PPIN == State ? RETURN_SUCCESS : RETURN_DEVICE_ERROR;
102 }
103
104 CPU_REGISTER_TABLE_WRITE_FIELD (
105 ProcessorNumber,
106 Msr,
107 MSR_IVY_BRIDGE_PPIN_CTL,
108 MSR_IVY_BRIDGE_PPIN_CTL_REGISTER,
109 Bits.Enable_PPIN,
110 (State) ? 1 : 0
111 );
112
113 return RETURN_SUCCESS;
114 }