VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c@ 95013

最後變更 在這個檔案從95013是 80721,由 vboxsync 提交於 6 年 前

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.3 KB
 
1/** @file
2 CPU Features DXE driver to initialize CPU features.
3
4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include <PiDxe.h>
10
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>
17
18#include <Protocol/SmmConfiguration.h>
19#include <Guid/CpuFeaturesInitDone.h>
20
21
22/**
23 Worker function to perform CPU feature initialization.
24
25**/
26VOID
27CpuFeaturesInitializeWorker (
28 VOID
29 )
30{
31 EFI_STATUS Status;
32 EFI_HANDLE Handle;
33
34 CpuFeaturesDetect ();
35
36 CpuFeaturesInitialize ();
37
38 //
39 // Install CPU Features Init Done Protocol
40 //
41 Handle = NULL;
42 Status = gBS->InstallProtocolInterface (
43 &Handle,
44 &gEdkiiCpuFeaturesInitDoneGuid,
45 EFI_NATIVE_INTERFACE,
46 NULL
47 );
48 ASSERT_EFI_ERROR (Status);
49}
50
51/**
52 Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs.
53
54 @param[in] Event The Event that is being processed, not used.
55 @param[in] Context Event Context, not used.
56**/
57VOID
58EFIAPI
59SmmConfigurationEventNotify (
60 IN EFI_EVENT Event,
61 IN VOID *Context
62 )
63{
64 EFI_STATUS Status;
65 EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;
66
67 //
68 // Make sure this notification is for this handler
69 //
70 Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration);
71 if (EFI_ERROR (Status)) {
72 return;
73 }
74
75 CpuFeaturesInitializeWorker ();
76}
77
78/**
79 CPU Features driver entry point function.
80
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
84 directly.
85
86 @param ImageHandle Image handle this driver.
87 @param SystemTable Pointer to the System Table.
88
89 @retval EFI_SUCCESS CPU Features is initialized successfully.
90**/
91EFI_STATUS
92EFIAPI
93CpuFeaturesDxeInitialize (
94 IN EFI_HANDLE ImageHandle,
95 IN EFI_SYSTEM_TABLE *SystemTable
96 )
97{
98 VOID *Registration;
99 EFI_STATUS Status;
100 EFI_HANDLE Handle;
101
102 if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) != NULL) {
103 //
104 // Try to find HOB first. This HOB exist means CPU features have
105 // been initialized by CpuFeaturesPei driver, just install
106 // gEdkiiCpuFeaturesInitDoneGuid.
107 //
108 Handle = NULL;
109 Status = gBS->InstallProtocolInterface (
110 &Handle,
111 &gEdkiiCpuFeaturesInitDoneGuid,
112 EFI_NATIVE_INTERFACE,
113 NULL
114 );
115 ASSERT_EFI_ERROR (Status);
116 return Status;
117 }
118
119 if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) {
120 //
121 // Install notification callback on SMM Configuration Protocol
122 //
123 EfiCreateProtocolNotifyEvent (
124 &gEfiSmmConfigurationProtocolGuid,
125 TPL_CALLBACK,
126 SmmConfigurationEventNotify,
127 NULL,
128 &Registration
129 );
130 } else {
131 CpuFeaturesInitializeWorker ();
132 }
133
134 return EFI_SUCCESS;
135}
136
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette