1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
/** @file
Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "SystemBoardPei.h"
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <IioBifurcationSlotTable.h>
extern IIO_BIFURCATION_ENTRY mIioBifurcationTable[];
extern UINT8 mIioBifurcationTableEntries;
extern IIO_SLOT_CONFIG_ENTRY mIioSlotTable[];
extern UINT8 mIioSlotTableEntries;
//
// System board PPI structure
//
static SYSTEM_BOARD_PPI mSystemBoardPpi = {
SystemIioPortBifurcationInit, // Set IIO Bifurcation ports configuration
GetUplinkPortInformation,
};
static EFI_PEI_PPI_DESCRIPTOR mSystemBoardPpiDesc = {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEfiPeiSystemBoardPpiGuid,
&mSystemBoardPpi
};
/**
GetUplinkPortInformation - Get uplink port information
@param IioIndex - socket ID.
@retval PortIndex for uplink port
**/
UINT8
EFIAPI
GetUplinkPortInformation (
IN UINT8 IioIndex
)
{
UINT8 UplinkPortIndex;
UplinkPortIndex = GetUplinkPortInformationCommon(IioIndex);
return UplinkPortIndex;
}
/**
SystemIioPortBifurcationInit - Program the UDS data structure with OEM IIO init values
for SLOTs and Bifurcation.
@param mSB - pointer to this protocol
@param IioUds - Pointer to the IIO UDS datastructure.
@retval EFI_SUCCESS
**/
VOID
InternalSystemIioPortBifurcationInitCommon (
IN OUT IIO_GLOBALS *IioGlobalData,
IN OUT IIO_BIFURCATION_ENTRY **BifurcationTable,
IN OUT UINT8 *BifurcationEntries,
IN OUT IIO_SLOT_CONFIG_ENTRY **SlotTable,
IN OUT UINT8 *SlotEntries
)
{
UINT8 PortIndex;//, iio;
/// This function outline:
//// 1 Based on platform apply the default bifurcation and slot configuration.
//// 2 Apply dynamic overrides based on GPIO and other configurations.
//// 3 Hide unused ports due bifurcation.
for (PortIndex = 0; PortIndex < MAX_SOCKET*NUMBER_PORTS_PER_SOCKET; PortIndex++) {
IioGlobalData->SetupData.PEXPHIDE[PortIndex] = 0;
IioGlobalData->SetupData.HidePEXPMenu[PortIndex] = 0;
}
*BifurcationEntries = 0;
*SlotEntries = 0;
// Purley Intel boards are not Multi-PCH
IioGlobalData->IioVar.IioVData.MultiPch = 0;
*BifurcationTable = (IIO_BIFURCATION_ENTRY *)(UINTN)PcdGet64 (PcdIioBifurcationTable);
*BifurcationEntries = PcdGet8 (PcdIioBifurcationTableEntries);
*SlotTable = (IIO_SLOT_CONFIG_ENTRY *)(UINTN)PcdGet64 (PcdIioSlotTable);
*SlotEntries = PcdGet8 (PcdIioSlotTableEntries);
}
/**
SystemIioPortBifurcationInit - Program the IIO_GLOBALS data structure with OEM IIO init values
for SLOTs and Bifurcation.
@param mSB - pointer to this protocol
@param IioUds - Pointer to the IIO UDS datastructure.
@retval EFI_SUCCESS
**/
VOID
SystemIioPortBifurcationInit (
IN IIO_GLOBALS *IioGlobalData
)
{
UINT8 IioIndex;
IIO_BIFURCATION_ENTRY *BifurcationTable = NULL;
UINT8 BifurcationEntries;
IIO_SLOT_CONFIG_ENTRY *SlotTable = NULL;
UINT8 SlotEntries;
// This function outline:
// 1. Based on platform apply the default bifurcation and slot configuration.
// 2. Apply dynamic overrides based on GPIO and other configurations.
// 3. Hide unused ports due bifurcation.
SystemIioPortBifurcationInitCommon(IioGlobalData, &BifurcationTable, &BifurcationEntries, &SlotTable, &SlotEntries);
/// Set the default bifurcations for this platform.
SetBifurcations(IioGlobalData, BifurcationTable, BifurcationEntries);
ConfigSlots(IioGlobalData, SlotTable, SlotEntries);
OverrideConfigSlots(IioGlobalData, SlotTable, SlotEntries);
// All overrides have been applied now.
// Hide root ports whose lanes are assigned preceding ports.
for (IioIndex = Iio_Socket0; IioIndex < MaxIIO; IioIndex++) {
if (IioGlobalData->IioVar.IioVData.SocketPresent[IioIndex]) {
SystemHideIioPortsCommon(IioGlobalData, IioIndex);
}
}
}
/**
This function dump raw data.
@param Data raw data
@param Size raw data size
**/
VOID
InternalDumpData (
IN UINT8 *Data,
IN UINTN Size
)
{
UINTN Index;
for (Index = 0; Index < Size; Index++) {
DEBUG ((EFI_D_INFO, "%02x", (UINTN)Data[Index]));
}
}
/**
This function dump raw data with colume format.
@param Data raw data
@param Size raw data size
**/
VOID
InternalDumpHex (
IN UINT8 *Data,
IN UINTN Size
)
{
UINTN Index;
UINTN Count;
UINTN Left;
#define COLUME_SIZE (16 * 2)
Count = Size / COLUME_SIZE;
Left = Size % COLUME_SIZE;
for (Index = 0; Index < Count; Index++) {
DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
InternalDumpData (Data + Index * COLUME_SIZE, COLUME_SIZE);
DEBUG ((EFI_D_INFO, "\n"));
}
if (Left != 0) {
DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
InternalDumpData (Data + Index * COLUME_SIZE, Left);
DEBUG ((EFI_D_INFO, "\n"));
}
}
VOID
DumpConfig (
VOID
)
{
DEBUG ((DEBUG_INFO, "PcdSetupData - 0x%x\n", PcdGetSize (PcdSetupData)));
InternalDumpHex (PcdGetPtr (PcdSetupData), PcdGetSize (PcdSetupData));
DEBUG ((DEBUG_INFO, "PcdPchRcConfigurationData - 0x%x\n", PcdGetSize (PcdPchRcConfigurationData)));
InternalDumpHex (PcdGetPtr (PcdPchRcConfigurationData), PcdGetSize (PcdPchRcConfigurationData));
DEBUG ((DEBUG_INFO, "PcdSocketIioConfigData - 0x%x\n", PcdGetSize (PcdSocketIioConfigData)));
InternalDumpHex (PcdGetPtr (PcdSocketIioConfigData), PcdGetSize (PcdSocketIioConfigData));
DEBUG ((DEBUG_INFO, "PcdSocketCommonRcConfigData - 0x%x\n", PcdGetSize (PcdSocketCommonRcConfigData)));
InternalDumpHex (PcdGetPtr (PcdSocketCommonRcConfigData), PcdGetSize (PcdSocketCommonRcConfigData));
DEBUG ((DEBUG_INFO, "PcdSocketMpLinkConfigData - 0x%x\n", PcdGetSize (PcdSocketMpLinkConfigData)));
InternalDumpHex (PcdGetPtr (PcdSocketMpLinkConfigData), PcdGetSize (PcdSocketMpLinkConfigData));
DEBUG ((DEBUG_INFO, "PcdSocketMemoryConfigData - 0x%x\n", PcdGetSize (PcdSocketMemoryConfigData)));
InternalDumpHex (PcdGetPtr (PcdSocketMemoryConfigData), PcdGetSize (PcdSocketMemoryConfigData));
DEBUG ((DEBUG_INFO, "PcdSocketPowerManagementConfigData - 0x%x\n", PcdGetSize (PcdSocketPowerManagementConfigData)));
InternalDumpHex (PcdGetPtr (PcdSocketPowerManagementConfigData), PcdGetSize (PcdSocketPowerManagementConfigData));
DEBUG ((DEBUG_INFO, "PcdSocketProcessorCoreConfigData - 0x%x\n", PcdGetSize (PcdSocketProcessorCoreConfigData)));
InternalDumpHex (PcdGetPtr (PcdSocketProcessorCoreConfigData), PcdGetSize (PcdSocketProcessorCoreConfigData));
}
//
// PEI entry point - SystemBoardPpi entry point
//
/**
PEI system board PPI intialization main entry point. This will setup up a PPI that will handle providing system board level
configuration for the platform.
@param FileHandle Pointer to the PEIM FFS file header.
@param PeiServices General purpose services available to every PEIM.
@retval EFI_SUCCESS Operation completed successfully.
@retval Otherwise System board initialization failed.
**/
EFI_STATUS
EFIAPI
SystemBoardPeiEntry (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
DEBUG ((EFI_D_ERROR, "--> SystemBoard PEI BoardDetection\n"));
//DumpConfig ();
//
// Initialize system board information PPI
//
Status = PeiServicesInstallPpi(&mSystemBoardPpiDesc);
ASSERT_EFI_ERROR (Status);
return Status;
}
|