2 CPU Features DXE driver to initialize CPU features.
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
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.
17 #include <Library/BaseLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/UefiLib.h>
20 #include <Library/UefiBootServicesTableLib.h>
21 #include <Library/RegisterCpuFeaturesLib.h>
22 #include <Library/HobLib.h>
24 #include <Protocol/SmmConfiguration.h>
25 #include <Guid/CpuFeaturesInitDone.h>
29 Worker function to perform CPU feature initialization.
33 CpuFeaturesInitializeWorker (
42 CpuFeaturesInitialize ();
45 // Install CPU Features Init Done Protocol
48 Status
= gBS
->InstallProtocolInterface (
50 &gEdkiiCpuFeaturesInitDoneGuid
,
54 ASSERT_EFI_ERROR (Status
);
58 Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs.
60 @param[in] Event The Event that is being processed, not used.
61 @param[in] Context Event Context, not used.
65 SmmConfigurationEventNotify (
71 EFI_SMM_CONFIGURATION_PROTOCOL
*SmmConfiguration
;
74 // Make sure this notification is for this handler
76 Status
= gBS
->LocateProtocol (&gEfiSmmConfigurationProtocolGuid
, NULL
, (VOID
**)&SmmConfiguration
);
77 if (EFI_ERROR (Status
)) {
81 CpuFeaturesInitializeWorker ();
85 CPU Features driver entry point function.
87 If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one
88 SMM Configuration Protocol notify function to perform CPU features
89 initialization. Otherwise, it will perform CPU features initialization
92 @param ImageHandle Image handle this driver.
93 @param SystemTable Pointer to the System Table.
95 @retval EFI_SUCCESS CPU Features is initialized successfully.
99 CpuFeaturesDxeInitialize (
100 IN EFI_HANDLE ImageHandle
,
101 IN EFI_SYSTEM_TABLE
*SystemTable
108 if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid
) != NULL
) {
110 // Try to find HOB first. This HOB exist means CPU features have
111 // been initialized by CpuFeaturesPei driver, just install
112 // gEdkiiCpuFeaturesInitDoneGuid.
115 Status
= gBS
->InstallProtocolInterface (
117 &gEdkiiCpuFeaturesInitDoneGuid
,
118 EFI_NATIVE_INTERFACE
,
121 ASSERT_EFI_ERROR (Status
);
125 if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation
)) {
127 // Install notification callback on SMM Configuration Protocol
129 EfiCreateProtocolNotifyEvent (
130 &gEfiSmmConfigurationProtocolGuid
,
132 SmmConfigurationEventNotify
,
137 CpuFeaturesInitializeWorker ();