2 CPU Features DXE driver to initialize CPU features.
4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/BaseLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/UefiLib.h>
14 #include <Library/UefiBootServicesTableLib.h>
15 #include <Library/RegisterCpuFeaturesLib.h>
16 #include <Library/HobLib.h>
18 #include <Protocol/SmmConfiguration.h>
19 #include <Guid/CpuFeaturesInitDone.h>
23 Worker function to perform CPU feature initialization.
27 CpuFeaturesInitializeWorker (
36 CpuFeaturesInitialize ();
39 // Install CPU Features Init Done Protocol
42 Status
= gBS
->InstallProtocolInterface (
44 &gEdkiiCpuFeaturesInitDoneGuid
,
48 ASSERT_EFI_ERROR (Status
);
52 Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs.
54 @param[in] Event The Event that is being processed, not used.
55 @param[in] Context Event Context, not used.
59 SmmConfigurationEventNotify (
65 EFI_SMM_CONFIGURATION_PROTOCOL
*SmmConfiguration
;
68 // Make sure this notification is for this handler
70 Status
= gBS
->LocateProtocol (&gEfiSmmConfigurationProtocolGuid
, NULL
, (VOID
**)&SmmConfiguration
);
71 if (EFI_ERROR (Status
)) {
75 CpuFeaturesInitializeWorker ();
79 CPU Features driver entry point function.
81 If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one
82 SMM Configuration Protocol notify function to perform CPU features
83 initialization. Otherwise, it will perform CPU features initialization
86 @param ImageHandle Image handle this driver.
87 @param SystemTable Pointer to the System Table.
89 @retval EFI_SUCCESS CPU Features is initialized successfully.
93 CpuFeaturesDxeInitialize (
94 IN EFI_HANDLE ImageHandle
,
95 IN EFI_SYSTEM_TABLE
*SystemTable
102 if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid
) != NULL
) {
104 // Try to find HOB first. This HOB exist means CPU features have
105 // been initialized by CpuFeaturesPei driver, just install
106 // gEdkiiCpuFeaturesInitDoneGuid.
109 Status
= gBS
->InstallProtocolInterface (
111 &gEdkiiCpuFeaturesInitDoneGuid
,
112 EFI_NATIVE_INTERFACE
,
115 ASSERT_EFI_ERROR (Status
);
119 if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation
)) {
121 // Install notification callback on SMM Configuration Protocol
123 EfiCreateProtocolNotifyEvent (
124 &gEfiSmmConfigurationProtocolGuid
,
126 SmmConfigurationEventNotify
,
131 CpuFeaturesInitializeWorker ();