13cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** @file 23cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 33cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 43cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 53cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 63cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This program and the accompanying materials are licensed and made available under 73cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 83cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei the terms and conditions of the BSD License that accompanies this distribution. 93cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The full text of the license may be found at 113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei http://opensource.org/licenses/bsd-license.php. 133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 233cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiModule Name: 243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PlatformInfoDxe.c 263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 273cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiAbstract: 283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Platform Info driver to public platform related HOB data 293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei--*/ 313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include "PlatformInfoDxe.h" 333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Entry point for the driver. 363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This routine get the platform HOB data from PEI and publish 383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei as Platform Info variable that can be accessed during boot service and 393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei runtime. 403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param ImageHandle Image Handle. 423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SystemTable EFI System Table. 433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval Status Function execution status. 453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 473cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_STATUS 483cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 493cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiPlatformInfoInit ( 503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_HANDLE ImageHandle, 513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_SYSTEM_TABLE *SystemTable 523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PLATFORM_INFO_HOB *PlatformInfoHobPtr; 563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PEI_HOB_POINTERS GuidHob; 573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PLATFORM_INFO_HOB TmpHob; 583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN VarSize; 593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_OS_SELECTION_HOB *OsSlectionHobPtr; 603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 Selection; 613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SYSTEM_CONFIGURATION SystemConfiguration; 623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 *LpssDataHobPtr; 633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 *LpssDataVarPtr; 643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN i; 65620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 66620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He VarSize = sizeof(SYSTEM_CONFIGURATION); 67620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gRT->GetVariable( 68620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NORMAL_SETUP_NAME, 69620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &gEfiNormalSetupGuid, 70620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NULL, 71620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &VarSize, 72620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &SystemConfiguration 73620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ); 74620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 75620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { 76620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He //The setup variable is corrupted 77620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He VarSize = sizeof(SYSTEM_CONFIGURATION); 783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable( 793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei L"SetupRecovery", 803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &VarSize, 833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &SystemConfiguration 843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT_EFI_ERROR (Status); 863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VarSize = sizeof(Selection); 893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable( 903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei L"OsSelection", 913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gOsSelectionVariableGuid, 923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &VarSize, 943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Selection 953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (EFI_ERROR(Status)) { 983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Selection = SystemConfiguration.ReservedO; 993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->SetVariable ( 1003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei L"OsSelection", 1013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gOsSelectionVariableGuid, 1023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, 1033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof(Selection), 1043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Selection 1053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei GuidHob.Raw = GetHobList (); 1093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (GuidHob.Raw != NULL) { 1103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if ((GuidHob.Raw = GetNextGuidHob (&gOsSelectionVariableGuid, GuidHob.Raw)) != NULL) { 1113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OsSlectionHobPtr = GET_GUID_HOB_DATA (GuidHob.Guid); 1123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (OsSlectionHobPtr->OsSelectionChanged) { 1143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SystemConfiguration.ReservedO = OsSlectionHobPtr->OsSelection; 1153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Load Audio default configuration 1183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SystemConfiguration.Lpe = OsSlectionHobPtr->Lpe; 1203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SystemConfiguration.PchAzalia = OsSlectionHobPtr->PchAzalia; 1213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Load LPSS and SCC default configurations 1243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei LpssDataHobPtr = &OsSlectionHobPtr->LpssData.LpssPciModeEnabled; 1263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei LpssDataVarPtr = &SystemConfiguration.LpssPciModeEnabled; 1273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei for (i = 0; i < sizeof(EFI_PLATFORM_LPSS_DATA); i++) { 1283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei *LpssDataVarPtr = *LpssDataHobPtr; 129620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He LpssDataVarPtr++; 1303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei LpssDataHobPtr++; 1313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SystemConfiguration.GOPEnable = TRUE; 1343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->SetVariable ( 1363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NORMAL_SETUP_NAME, 1373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 1383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, 1393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof(SYSTEM_CONFIGURATION), 1403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &SystemConfiguration 1413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT_EFI_ERROR (Status); 1433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei GuidHob.Raw = GetHobList (); 1483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (GuidHob.Raw == NULL) { 1493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return EFI_NOT_FOUND; 1503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != NULL) { 1533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PlatformInfoHobPtr = GET_GUID_HOB_DATA (GuidHob.Guid); 1543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VarSize = sizeof(EFI_PLATFORM_INFO_HOB); 1553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable( 1563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei L"PlatformInfo", 1573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiVlv2VariableGuid, 1583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 1593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &VarSize, 1603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &TmpHob 1613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 162620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 1633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (EFI_ERROR(Status) || CompareMem (&TmpHob, PlatformInfoHobPtr, VarSize)) { 1643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Write the Platform Info to volatile memory 1673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->SetVariable( 1693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei L"PlatformInfo", 1703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiVlv2VariableGuid, 1713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, 1723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof(EFI_PLATFORM_INFO_HOB), 1733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PlatformInfoHobPtr 1743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 175 if (EFI_ERROR(Status)) { 176 return Status; 177 } 178 } 179 } 180 181 return EFI_SUCCESS; 182} 183 184