]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformInfoDxe / PlatformInfoDxe.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 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 Module Name:
15
16 PlatformInfoDxe.c
17
18 Abstract:
19 Platform Info driver to public platform related HOB data
20
21 --*/
22
23 #include "PlatformInfoDxe.h"
24
25 /**
26 Entry point for the driver.
27
28 This routine get the platform HOB data from PEI and publish
29 as Platform Info variable that can be accessed during boot service and
30 runtime.
31
32 @param ImageHandle Image Handle.
33 @param SystemTable EFI System Table.
34
35 @retval Status Function execution status.
36
37 **/
38 EFI_STATUS
39 EFIAPI
40 PlatformInfoInit (
41 IN EFI_HANDLE ImageHandle,
42 IN EFI_SYSTEM_TABLE *SystemTable
43 )
44 {
45 EFI_STATUS Status;
46 EFI_PLATFORM_INFO_HOB *PlatformInfoHobPtr;
47 EFI_PEI_HOB_POINTERS GuidHob;
48 EFI_PLATFORM_INFO_HOB TmpHob;
49 UINTN VarSize;
50 EFI_OS_SELECTION_HOB *OsSlectionHobPtr;
51 UINT8 Selection;
52 SYSTEM_CONFIGURATION SystemConfiguration;
53 UINT8 *LpssDataHobPtr;
54 UINT8 *LpssDataVarPtr;
55 UINTN i;
56
57 VarSize = sizeof(SYSTEM_CONFIGURATION);
58 Status = gRT->GetVariable(
59 NORMAL_SETUP_NAME,
60 &gEfiNormalSetupGuid,
61 NULL,
62 &VarSize,
63 &SystemConfiguration
64 );
65
66 VarSize = sizeof(Selection);
67 Status = gRT->GetVariable(
68 L"OsSelection",
69 &gOsSelectionVariableGuid,
70 NULL,
71 &VarSize,
72 &Selection
73 );
74
75 if (EFI_ERROR(Status)) {
76 Selection = SystemConfiguration.ReservedO;
77 Status = gRT->SetVariable (
78 L"OsSelection",
79 &gOsSelectionVariableGuid,
80 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
81 sizeof(Selection),
82 &Selection
83 );
84 }
85
86 GuidHob.Raw = GetHobList ();
87 if (GuidHob.Raw != NULL) {
88 if ((GuidHob.Raw = GetNextGuidHob (&gOsSelectionVariableGuid, GuidHob.Raw)) != NULL) {
89 OsSlectionHobPtr = GET_GUID_HOB_DATA (GuidHob.Guid);
90
91 if (OsSlectionHobPtr->OsSelectionChanged) {
92 SystemConfiguration.ReservedO = OsSlectionHobPtr->OsSelection;
93
94 //
95 // Load Audio default configuration
96 //
97 SystemConfiguration.Lpe = OsSlectionHobPtr->Lpe;
98 SystemConfiguration.PchAzalia = OsSlectionHobPtr->PchAzalia;
99
100 //
101 // Load LPSS and SCC default configurations
102 //
103 LpssDataHobPtr = &OsSlectionHobPtr->LpssData.LpssPciModeEnabled;
104 LpssDataVarPtr = &SystemConfiguration.LpssPciModeEnabled;
105 for (i = 0; i < sizeof(EFI_PLATFORM_LPSS_DATA); i++) {
106 *LpssDataVarPtr = *LpssDataHobPtr;
107 LpssDataVarPtr++;
108 LpssDataHobPtr++;
109 }
110
111 SystemConfiguration.GOPEnable = TRUE;
112
113 Status = gRT->SetVariable (
114 NORMAL_SETUP_NAME,
115 &gEfiNormalSetupGuid,
116 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
117 sizeof(SYSTEM_CONFIGURATION),
118 &SystemConfiguration
119 );
120 ASSERT_EFI_ERROR (Status);
121 }
122 }
123 }
124
125 GuidHob.Raw = GetHobList ();
126 if (GuidHob.Raw == NULL) {
127 return EFI_NOT_FOUND;
128 }
129
130 if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != NULL) {
131 PlatformInfoHobPtr = GET_GUID_HOB_DATA (GuidHob.Guid);
132 VarSize = sizeof(EFI_PLATFORM_INFO_HOB);
133 Status = gRT->GetVariable(
134 L"PlatformInfo",
135 &gEfiVlv2VariableGuid,
136 NULL,
137 &VarSize,
138 &TmpHob
139 );
140
141 if (EFI_ERROR(Status) || CompareMem (&TmpHob, PlatformInfoHobPtr, VarSize)) {
142
143 //
144 // Write the Platform Info to volatile memory
145 //
146 Status = gRT->SetVariable(
147 L"PlatformInfo",
148 &gEfiVlv2VariableGuid,
149 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
150 sizeof(EFI_PLATFORM_INFO_HOB),
151 PlatformInfoHobPtr
152 );
153 if (EFI_ERROR(Status)) {
154 return Status;
155 }
156 }
157 }
158
159 return EFI_SUCCESS;
160 }
161