]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c
UefiCpuPkg/CpuFeatures: Change files format to DOS
[mirror_edk2.git] / UefiCpuPkg / CpuFeatures / CpuFeaturesDxe.c
1 /** @file
2 CPU Features DXE driver to initialize CPU features.
3
4 Copyright (c) 2017, 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
23 #include <Protocol/SmmConfiguration.h>
24 #include <Guid/CpuFeaturesInitDone.h>
25
26
27 /**
28 Worker function to perform CPU feature initialization.
29
30 **/
31 VOID
32 CpuFeaturesInitializeWorker (
33 VOID
34 )
35 {
36 EFI_STATUS Status;
37 EFI_HANDLE Handle;
38
39 CpuFeaturesDetect ();
40
41 CpuFeaturesInitialize ();
42
43 //
44 // Install CPU Features Init Done Protocol
45 //
46 Handle = NULL;
47 Status = gBS->InstallProtocolInterface (
48 &Handle,
49 &gEdkiiCpuFeaturesInitDoneGuid,
50 EFI_NATIVE_INTERFACE,
51 NULL
52 );
53 ASSERT_EFI_ERROR (Status);
54 }
55
56 /**
57 Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs.
58
59 @param[in] Event The Event that is being processed, not used.
60 @param[in] Context Event Context, not used.
61 **/
62 VOID
63 EFIAPI
64 SmmConfigurationEventNotify (
65 IN EFI_EVENT Event,
66 IN VOID *Context
67 )
68 {
69 EFI_STATUS Status;
70 EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;
71
72 //
73 // Make sure this notification is for this handler
74 //
75 Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration);
76 if (EFI_ERROR (Status)) {
77 return;
78 }
79
80 CpuFeaturesInitializeWorker ();
81 }
82
83 /**
84 CPU Features driver entry point function.
85
86 If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one
87 SMM Configuration Protocol notify function to perform CPU features
88 initialization. Otherwise, it will perform CPU features initialization
89 directly.
90
91 @param ImageHandle Image handle this driver.
92 @param SystemTable Pointer to the System Table.
93
94 @retval EFI_SUCCESS CPU Features is initialized successfully.
95 **/
96 EFI_STATUS
97 EFIAPI
98 CpuFeaturesDxeInitialize (
99 IN EFI_HANDLE ImageHandle,
100 IN EFI_SYSTEM_TABLE *SystemTable
101 )
102 {
103 VOID *Registration;
104
105 if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) {
106 //
107 // Install notification callback on SMM Configuration Protocol
108 //
109 EfiCreateProtocolNotifyEvent (
110 &gEfiSmmConfigurationProtocolGuid,
111 TPL_CALLBACK,
112 SmmConfigurationEventNotify,
113 NULL,
114 &Registration
115 );
116 } else {
117 CpuFeaturesInitializeWorker ();
118 }
119
120 return EFI_SUCCESS;
121 }
122