]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c
MdeModulePkg: Fix potential memory leaks in DxeHttpLib.
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCommonFeaturesLib / X2Apic.c
CommitLineData
80c4b236
JF
1/** @file\r
2 X2Apic feature.\r
3\r
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "CpuCommonFeatures.h"\r
16\r
17/**\r
18 Detects if X2Apci feature supported on current processor.\r
19\r
20 Detect if X2Apci has been already enabled.\r
21\r
22 @param[in] ProcessorNumber The index of the CPU executing this function.\r
23 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
24 structure for the CPU executing this function.\r
25 @param[in] ConfigData A pointer to the configuration buffer returned\r
26 by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r
27 CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
28 RegisterCpuFeature().\r
29\r
30 @retval TRUE X2Apci feature is supported.\r
31 @retval FALSE X2Apci feature is not supported.\r
32\r
33 @note This service could be called by BSP/APs.\r
34**/\r
35BOOLEAN\r
36EFIAPI\r
37X2ApicSupport (\r
38 IN UINTN ProcessorNumber,\r
39 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r
40 IN VOID *ConfigData OPTIONAL\r
41 )\r
42{\r
43 return (GetApicMode () == LOCAL_APIC_MODE_X2APIC);\r
44}\r
45\r
46/**\r
47 Initializes X2Apci feature to specific state.\r
48\r
49 @param[in] ProcessorNumber The index of the CPU executing this function.\r
50 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
51 structure for the CPU executing this function.\r
52 @param[in] ConfigData A pointer to the configuration buffer returned\r
53 by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r
54 CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
55 RegisterCpuFeature().\r
56 @param[in] State If TRUE, then the X2Apci feature must be enabled.\r
57 If FALSE, then the X2Apci feature must be disabled.\r
58\r
59 @retval RETURN_SUCCESS X2Apci feature is initialized.\r
60\r
61 @note This service could be called by BSP only.\r
62**/\r
63RETURN_STATUS\r
64EFIAPI\r
65X2ApicInitialize (\r
66 IN UINTN ProcessorNumber,\r
67 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r
68 IN VOID *ConfigData, OPTIONAL\r
69 IN BOOLEAN State\r
70 )\r
71{\r
72 PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD (\r
73 ProcessorNumber,\r
74 Msr,\r
75 MSR_IA32_APIC_BASE,\r
76 MSR_IA32_APIC_BASE_REGISTER,\r
77 Bits.EXTD,\r
78 (State) ? 1 : 0\r
79 );\r
80 return RETURN_SUCCESS;\r
81}\r