]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/PlatformInitPei/PlatformInfoInit.c
Vlv2TbltDevicePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformInitPei / PlatformInfoInit.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9 Module Name:
10
11 PlatformInfoInit.c
12
13 Abstract:
14 Platform Info Driver.
15
16 --*/
17
18 #include "PlatformEarlyInit.h"
19
20 #define LEN_64M 0x4000000
21
22 //
23 // Default PCI32 resource size
24 //
25 #define RES_MEM32_MIN_LEN 0x38000000
26
27 #define RES_IO_BASE 0x0D00
28 #define RES_IO_LIMIT 0xFFFF
29
30 #define MemoryCeilingVariable L"MemCeil."
31
32 EFI_STATUS
33 CheckOsSelection (
34 IN CONST EFI_PEI_SERVICES **PeiServices,
35 IN SYSTEM_CONFIGURATION *SystemConfiguration
36 )
37 {
38 EFI_STATUS Status;
39 EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
40 UINTN VariableSize;
41 EFI_OS_SELECTION_HOB *OsSelectionHob;
42 UINT8 OsSelection;
43 UINT8 *LpssDataHobPtr;
44 UINT8 *LpssDataVarPtr;
45 UINTN i;
46
47 Status = (*PeiServices)->LocatePpi (
48 PeiServices,
49 &gEfiPeiReadOnlyVariable2PpiGuid,
50 0,
51 NULL,
52 (void **)&Variable
53 );
54 if (!EFI_ERROR(Status)) {
55 VariableSize = sizeof (OsSelection);
56 Status = Variable->GetVariable (
57 Variable,
58 L"OsSelection",
59 &gOsSelectionVariableGuid,
60 NULL,
61 &VariableSize,
62 &OsSelection
63 );
64
65 if (!EFI_ERROR(Status) && (SystemConfiguration->ReservedO != OsSelection)) {
66 //
67 // Build HOB for OsSelection
68 //
69 OsSelectionHob = BuildGuidHob (&gOsSelectionVariableGuid, sizeof (EFI_OS_SELECTION_HOB));
70 ASSERT (OsSelectionHob != NULL);
71
72 OsSelectionHob->OsSelectionChanged = TRUE;
73 OsSelectionHob->OsSelection = OsSelection;
74 SystemConfiguration->ReservedO = OsSelectionHob->OsSelection;
75
76 //
77 // Load LPSS and SCC default configurations
78 //
79 OsSelectionHob->LpssData.LpsseMMCEnabled = FALSE;
80 OsSelectionHob->LpssData.LpssSdioEnabled = TRUE;
81 OsSelectionHob->LpssData.LpssSdcardEnabled = TRUE;
82 OsSelectionHob->LpssData.LpssSdCardSDR25Enabled = FALSE;
83 OsSelectionHob->LpssData.LpssSdCardDDR50Enabled = TRUE;
84 OsSelectionHob->LpssData.LpssMipiHsi = FALSE;
85 OsSelectionHob->LpssData.LpsseMMC45Enabled = TRUE;
86 OsSelectionHob->LpssData.LpsseMMC45DDR50Enabled = TRUE;
87 OsSelectionHob->LpssData.LpsseMMC45HS200Enabled = FALSE;
88 OsSelectionHob->LpssData.LpsseMMC45RetuneTimerValue = 8;
89 OsSelectionHob->LpssData.eMMCBootMode = 1; // Auto Detect
90
91
92 SystemConfiguration->Lpe = OsSelectionHob->Lpe;
93 SystemConfiguration->PchAzalia = SystemConfiguration->PchAzalia;
94 LpssDataHobPtr = &OsSelectionHob->LpssData.LpssPciModeEnabled;
95 LpssDataVarPtr = &SystemConfiguration->LpssPciModeEnabled;
96
97 for (i = 0; i < sizeof(EFI_PLATFORM_LPSS_DATA); i++) {
98 *LpssDataVarPtr = *LpssDataHobPtr;
99 LpssDataVarPtr++;
100 LpssDataHobPtr++;
101 }
102 }
103 }
104
105 return EFI_SUCCESS;
106 }
107
108
109 EFI_STATUS
110 PlatformInfoUpdate (
111 IN CONST EFI_PEI_SERVICES **PeiServices,
112 IN OUT EFI_PLATFORM_INFO_HOB *PlatformInfoHob,
113 IN SYSTEM_CONFIGURATION *SystemConfiguration
114 )
115 {
116 EFI_STATUS Status;
117 EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
118 UINTN VariableSize;
119 UINT32 MemoryCeiling;
120
121 //
122 // Checking PCI32 resource from previous boot to determine the memory ceiling
123 //
124 Status = (*PeiServices)->LocatePpi (
125 PeiServices,
126 &gEfiPeiReadOnlyVariable2PpiGuid,
127 0,
128 NULL,
129 (void **)&Variable
130 );
131 if (!EFI_ERROR(Status)) {
132 //
133 // Get the memory ceiling
134 //
135 VariableSize = sizeof(MemoryCeiling);
136 Status = Variable->GetVariable (
137 Variable,
138 MemoryCeilingVariable,
139 &gEfiGlobalVariableGuid,
140 NULL,
141 &VariableSize,
142 &MemoryCeiling
143 );
144 if(!EFI_ERROR(Status)) {
145 //
146 // Set the new PCI32 resource Base if the variable available
147 //
148 PlatformInfoHob->PciData.PciResourceMem32Base = MemoryCeiling;
149 PlatformInfoHob->MemData.MemMaxTolm = MemoryCeiling;
150 PlatformInfoHob->MemData.MemTolm = MemoryCeiling;
151
152 //
153 // Platform PCI MMIO Size in unit of 1MB
154 //
155 PlatformInfoHob->MemData.MmioSize = 0x1000 - (UINT16)(PlatformInfoHob->MemData.MemMaxTolm >> 20);
156 }
157 }
158
159 return EFI_SUCCESS;
160 }
161
162 /**
163 Initialize the platform related info hob according to the
164 pre-determine value or setup option
165
166 @retval EFI_SUCCESS Memory initialization completed successfully.
167 @retval Others All other error conditions encountered result in an ASSERT.
168 **/
169 EFI_STATUS
170 InitializePlatform (
171 IN CONST EFI_PEI_SERVICES **PeiServices,
172 IN EFI_PLATFORM_INFO_HOB *PlatformInfoHob,
173 IN SYSTEM_CONFIGURATION *SystemConfiguration
174 )
175 {
176 //
177 // -- cchew10 need to update here.
178 //
179 return EFI_SUCCESS;
180 }
181