3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 Platform Info driver to public platform related HOB data
18 #include "PlatformInfoDxe.h"
21 Entry point for the driver.
23 This routine get the platform HOB data from PEI and publish
24 as Platform Info variable that can be accessed during boot service and
27 @param ImageHandle Image Handle.
28 @param SystemTable EFI System Table.
30 @retval Status Function execution status.
36 IN EFI_HANDLE ImageHandle
,
37 IN EFI_SYSTEM_TABLE
*SystemTable
41 EFI_PLATFORM_INFO_HOB
*PlatformInfoHobPtr
;
42 EFI_PEI_HOB_POINTERS GuidHob
;
43 EFI_PLATFORM_INFO_HOB TmpHob
;
45 EFI_OS_SELECTION_HOB
*OsSlectionHobPtr
;
47 SYSTEM_CONFIGURATION SystemConfiguration
;
48 UINT8
*LpssDataHobPtr
;
49 UINT8
*LpssDataVarPtr
;
52 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
53 Status
= gRT
->GetVariable(
61 if (EFI_ERROR (Status
) || VarSize
!= sizeof(SYSTEM_CONFIGURATION
)) {
62 //The setup variable is corrupted
63 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
64 Status
= gRT
->GetVariable(
71 ASSERT_EFI_ERROR (Status
);
74 VarSize
= sizeof(Selection
);
75 Status
= gRT
->GetVariable(
77 &gOsSelectionVariableGuid
,
83 if (EFI_ERROR(Status
)) {
84 Selection
= SystemConfiguration
.ReservedO
;
85 Status
= gRT
->SetVariable (
87 &gOsSelectionVariableGuid
,
88 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
94 GuidHob
.Raw
= GetHobList ();
95 if (GuidHob
.Raw
!= NULL
) {
96 if ((GuidHob
.Raw
= GetNextGuidHob (&gOsSelectionVariableGuid
, GuidHob
.Raw
)) != NULL
) {
97 OsSlectionHobPtr
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
99 if (OsSlectionHobPtr
->OsSelectionChanged
) {
100 SystemConfiguration
.ReservedO
= OsSlectionHobPtr
->OsSelection
;
103 // Load Audio default configuration
105 SystemConfiguration
.Lpe
= OsSlectionHobPtr
->Lpe
;
106 SystemConfiguration
.PchAzalia
= OsSlectionHobPtr
->PchAzalia
;
109 // Load LPSS and SCC default configurations
111 LpssDataHobPtr
= &OsSlectionHobPtr
->LpssData
.LpssPciModeEnabled
;
112 LpssDataVarPtr
= &SystemConfiguration
.LpssPciModeEnabled
;
113 for (i
= 0; i
< sizeof(EFI_PLATFORM_LPSS_DATA
); i
++) {
114 *LpssDataVarPtr
= *LpssDataHobPtr
;
119 SystemConfiguration
.GOPEnable
= TRUE
;
121 Status
= gRT
->SetVariable (
123 &gEfiNormalSetupGuid
,
124 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
125 sizeof(SYSTEM_CONFIGURATION
),
128 ASSERT_EFI_ERROR (Status
);
133 GuidHob
.Raw
= GetHobList ();
134 if (GuidHob
.Raw
== NULL
) {
135 return EFI_NOT_FOUND
;
138 if ((GuidHob
.Raw
= GetNextGuidHob (&gEfiPlatformInfoGuid
, GuidHob
.Raw
)) != NULL
) {
139 PlatformInfoHobPtr
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
140 VarSize
= sizeof(EFI_PLATFORM_INFO_HOB
);
141 Status
= gRT
->GetVariable(
143 &gEfiVlv2VariableGuid
,
149 if (EFI_ERROR(Status
) || CompareMem (&TmpHob
, PlatformInfoHobPtr
, VarSize
)) {
152 // Write the Platform Info to volatile memory
154 Status
= gRT
->SetVariable(
156 &gEfiVlv2VariableGuid
,
157 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
158 sizeof(EFI_PLATFORM_INFO_HOB
),
161 if (EFI_ERROR(Status
)) {