]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c
BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / UefiCpuPkg / CpuFeatures / CpuFeaturesDxe.c
1 /** @file
2 CPU Features DXE driver to initialize CPU features.
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 <PiDxe.h>
16
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>
23
24 #include <Protocol/SmmConfiguration.h>
25 #include <Guid/CpuFeaturesInitDone.h>
26
27
28 /**
29 Worker function to perform CPU feature initialization.
30
31 **/
32 VOID
33 CpuFeaturesInitializeWorker (
34 VOID
35 )
36 {
37 EFI_STATUS Status;
38 EFI_HANDLE Handle;
39
40 CpuFeaturesDetect ();
41
42 CpuFeaturesInitialize ();
43
44 //
45 // Install CPU Features Init Done Protocol
46 //
47 Handle = NULL;
48 Status = gBS->InstallProtocolInterface (
49 &Handle,
50 &gEdkiiCpuFeaturesInitDoneGuid,
51 EFI_NATIVE_INTERFACE,
52 NULL
53 );
54 ASSERT_EFI_ERROR (Status);
55 }
56
57 /**
58 Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs.
59
60 @param[in] Event The Event that is being processed, not used.
61 @param[in] Context Event Context, not used.
62 **/
63 VOID
64 EFIAPI
65 SmmConfigurationEventNotify (
66 IN EFI_EVENT Event,
67 IN VOID *Context
68 )
69 {
70 EFI_STATUS Status;
71 EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;
72
73 //
74 // Make sure this notification is for this handler
75 //
76 Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration);
77 if (EFI_ERROR (Status)) {
78 return;
79 }
80
81 CpuFeaturesInitializeWorker ();
82 }
83
84 /**
85 CPU Features driver entry point function.
86
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
90 directly.
91
92 @param ImageHandle Image handle this driver.
93 @param SystemTable Pointer to the System Table.
94
95 @retval EFI_SUCCESS CPU Features is initialized successfully.
96 **/
97 EFI_STATUS
98 EFIAPI
99 CpuFeaturesDxeInitialize (
100 IN EFI_HANDLE ImageHandle,
101 IN EFI_SYSTEM_TABLE *SystemTable
102 )
103 {
104 VOID *Registration;
105 EFI_STATUS Status;
106 EFI_HANDLE Handle;
107
108 if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) != NULL) {
109 //
110 // Try to find HOB first. This HOB exist means CPU features have
111 // been initialized by CpuFeaturesPei driver, just install
112 // gEdkiiCpuFeaturesInitDoneGuid.
113 //
114 Handle = NULL;
115 Status = gBS->InstallProtocolInterface (
116 &Handle,
117 &gEdkiiCpuFeaturesInitDoneGuid,
118 EFI_NATIVE_INTERFACE,
119 NULL
120 );
121 ASSERT_EFI_ERROR (Status);
122 return Status;
123 }
124
125 if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) {
126 //
127 // Install notification callback on SMM Configuration Protocol
128 //
129 EfiCreateProtocolNotifyEvent (
130 &gEfiSmmConfigurationProtocolGuid,
131 TPL_CALLBACK,
132 SmmConfigurationEventNotify,
133 NULL,
134 &Registration
135 );
136 } else {
137 CpuFeaturesInitializeWorker ();
138 }
139
140 return EFI_SUCCESS;
141 }
142