hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
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
/** @file
  Sample to provide FSP wrapper related function.
 
  @copyright
  Copyright 2014 - 2021 Intel Corporation. <BR>
 
  SPDX-License-Identifier: BSD-2-Clause-Patent
**/
 
#include <PiPei.h>
#include <Library/PeiServicesLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/LargeVariableReadLib.h>
 
#include <FspmUpd.h>
#include <Guid/PlatformInfo.h>
#include <Ppi/UpiPolicyPpi.h>
 
VOID *
GetFspNvsBuffer (
  VOID
)
{
  EFI_STATUS          Status;
  UINTN                     FspNvsBufferSize;
  VOID                      *FspNvsBufferPtr;
 
  FspNvsBufferPtr   = NULL;
  FspNvsBufferSize  = 0;
  Status = GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHobGuid, &FspNvsBufferSize, NULL);
  if (Status == EFI_BUFFER_TOO_SMALL) {
    DEBUG ((DEBUG_INFO, "FspNvsBuffer Size = %d\n", FspNvsBufferSize));
    FspNvsBufferPtr = AllocateZeroPool (FspNvsBufferSize);
    if (FspNvsBufferPtr == NULL) {
      DEBUG ((DEBUG_ERROR, "Error: Cannot create FspNvsBuffer, out of memory!\n"));
    ASSERT (FALSE);
    return NULL;
  }
    Status = GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHobGuid, &FspNvsBufferSize, FspNvsBufferPtr);
    if (EFI_ERROR (Status)) {
      DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variable Status: %r\n", Status));
      ASSERT_EFI_ERROR (Status);
    return NULL;
  }
 
    return FspNvsBufferPtr;
 
  } else if (Status == EFI_NOT_FOUND) {
    DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does not exist (this is likely a first boot)\n"));
  } else {
    DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variable Status: %r\n", Status));
    ASSERT_EFI_ERROR (Status);
  }
 
    return NULL;
  }
 
VOID
EFIAPI
UpdateFspmUpdData (
  IN OUT VOID         *FspUpdRgnPtr
  )
{
  FSPM_UPD                     *FspmUpd;
  EFI_STATUS                   Status;
  UPI_POLICY_PPI               *UpiPolicyPpi;
  KTI_HOST_IN                  *Upi;
  UINTN                        Index;
  VOID                         *FSPTempMem;
  EFI_HOB_GUID_TYPE               *GuidHob;
  EFI_PLATFORM_INFO               *PlatformInfo;
 
  GuidHob       = GetFirstGuidHob (&gEfiPlatformInfoGuid);
  ASSERT (GuidHob != NULL);
  PlatformInfo  = GET_GUID_HOB_DATA(GuidHob);
 
  Status = PeiServicesLocatePpi (&gUpiSiPolicyPpiGuid, 0, NULL, &UpiPolicyPpi);
  ASSERT_EFI_ERROR(Status);
 
  Upi = &UpiPolicyPpi->Upi;
  FspmUpd = (FSPM_UPD*)FspUpdRgnPtr;
 
  FSPTempMem = (VOID *)(UINTN)(PcdGet32(PcdTemporaryRamBase) + PcdGet32(PcdPeiTemporaryRamRcHeapSize));;
  if (FSPTempMem != NULL) {
    FspmUpd->FspmArchUpd.StackBase = (VOID*)(((UINTN)FSPTempMem) & (~0xFFF));
    FspmUpd->FspmArchUpd.StackSize = PcdGet32(PcdFspTemporaryRamSize);
  }
 
  for (Index = 0; Index < MAX_SOCKET; Index ++)  {
    FspmUpd->FspmConfig.BusRatio[Index] = Upi->BusRatio[Index];
    FspmUpd->FspmConfig.KtiFpgaEnable[Index] = Upi->KtiFpgaEnable[Index];
  }
 
  FspmUpd->FspmConfig.D2KCreditConfig = Upi->D2KCreditConfig;
  FspmUpd->FspmConfig.SnoopThrottleConfig = Upi->SnoopThrottleConfig;
  FspmUpd->FspmConfig.LegacyVgaSoc = Upi->LegacyVgaSoc;
  FspmUpd->FspmConfig.LegacyVgaStack = Upi->LegacyVgaStack;
  FspmUpd->FspmConfig.P2pRelaxedOrdering = Upi->P2pRelaxedOrdering;
  FspmUpd->FspmConfig.SncEn = Upi->SncEn;
  FspmUpd->FspmConfig.UmaClustering = Upi->UmaClustering;
  FspmUpd->FspmConfig.IoDcMode = Upi->IoDcMode;
  FspmUpd->FspmConfig.DegradePrecedence = Upi->DegradePrecedence;
  FspmUpd->FspmConfig.Degrade4SPreference = Upi->Degrade4SPreference;
  FspmUpd->FspmConfig.DirectoryModeEn = Upi->DirectoryModeEn;
  FspmUpd->FspmConfig.XptPrefetchEn = Upi->XptPrefetchEn;
  FspmUpd->FspmConfig.KtiPrefetchEn = Upi->KtiPrefetchEn;
  FspmUpd->FspmConfig.XptRemotePrefetchEn = Upi->XptRemotePrefetchEn;
  FspmUpd->FspmConfig.DdrtQosMode = Upi->DdrtQosMode;
  FspmUpd->FspmConfig.KtiLinkSpeedMode = Upi->KtiLinkSpeedMode;
  FspmUpd->FspmConfig.KtiLinkSpeed = Upi->KtiLinkSpeed;
  FspmUpd->FspmConfig.KtiLinkL0pEn = Upi->KtiLinkL0pEn;
  FspmUpd->FspmConfig.KtiLinkL1En = Upi->KtiLinkL1En;
  FspmUpd->FspmConfig.KtiFailoverEn = Upi->KtiFailoverEn;
  FspmUpd->FspmConfig.KtiLbEn = Upi->KtiLbEn;
  FspmUpd->FspmConfig.KtiCrcMode = Upi->KtiCrcMode;
  FspmUpd->FspmConfig.KtiCpuSktHotPlugEn = Upi->KtiCpuSktHotPlugEn;
  FspmUpd->FspmConfig.KtiCpuSktHotPlugTopology = Upi->KtiCpuSktHotPlugTopology;
  FspmUpd->FspmConfig.KtiSkuMismatchCheck = Upi->KtiSkuMismatchCheck;
  FspmUpd->FspmConfig.IrqThreshold = Upi->IrqThreshold;
  FspmUpd->FspmConfig.TorThresLoctoremNorm = Upi->TorThresLoctoremNorm;
  FspmUpd->FspmConfig.TorThresLoctoremEmpty = Upi->TorThresLoctoremEmpty;
  FspmUpd->FspmConfig.MbeBwCal = Upi->MbeBwCal;
  FspmUpd->FspmConfig.TscSyncEn = Upi->TscSyncEn;
  FspmUpd->FspmConfig.StaleAtoSOptEn = Upi->StaleAtoSOptEn;
  FspmUpd->FspmConfig.LLCDeadLineAlloc = Upi->LLCDeadLineAlloc;
  FspmUpd->FspmConfig.SplitLock = Upi->SplitLock;
  FspmUpd->FspmConfig.mmCfgBase = Upi->mmCfgBase;
  FspmUpd->FspmConfig.mmCfgSize = Upi->mmCfgSize;
  FspmUpd->FspmConfig.mmiohBase = Upi->mmiohBase;
  FspmUpd->FspmConfig.CpuPaLimit = Upi->CpuPaLimit;
  FspmUpd->FspmConfig.highGap = Upi->highGap;
  FspmUpd->FspmConfig.mmiohSize = Upi->mmiohSize;
  FspmUpd->FspmConfig.isocEn = Upi->isocEn;
  FspmUpd->FspmConfig.dcaEn = Upi->dcaEn;
  FspmUpd->FspmConfig.BoardTypeBitmask = Upi->BoardTypeBitmask;
  FspmUpd->FspmConfig.AllLanesPtr = Upi->AllLanesPtr;
  FspmUpd->FspmConfig.PerLanePtr = Upi->PerLanePtr;
  FspmUpd->FspmConfig.AllLanesSizeOfTable = Upi->AllLanesSizeOfTable;
  FspmUpd->FspmConfig.PerLaneSizeOfTable = Upi->PerLaneSizeOfTable;
  FspmUpd->FspmConfig.WaitTimeForPSBP = Upi->WaitTimeForPSBP;
  FspmUpd->FspmConfig.WaSerializationEn = Upi->WaSerializationEn;
  FspmUpd->FspmConfig.KtiInEnableMktme = Upi->KtiInEnableMktme;
  FspmUpd->FspmConfig.BoardId = PlatformInfo->BoardId;
  FspmUpd->FspmArchUpd.NvsBufferPtr = GetFspNvsBuffer ();
}
 
/**
  This function overrides the default configurations in the FSP-S UPD data region.
 
  @param[in,out] FspUpdRgnPtr   A pointer to the UPD data region data strcture.
 
**/
VOID
EFIAPI
UpdateFspsUpdData (
  IN OUT VOID        *FspUpdRgnPtr
  )
{
}
 
/**
  Update TempRamExit parameter.
 
  @note At this point, memory is ready, PeiServices are available to use.
 
  @return TempRamExit parameter.
**/
VOID *
EFIAPI
UpdateTempRamExitParam (
  VOID
  )
{
  return NULL;
}
 
/**
  Get S3 PEI memory information.
 
  @note At this point, memory is ready, and PeiServices are available to use.
  Platform can get some data from SMRAM directly.
 
  @param[out] S3PeiMemSize  PEI memory size to be installed in S3 phase.
  @param[out] S3PeiMemBase  PEI memory base to be installed in S3 phase.
 
  @return If S3 PEI memory information is got successfully.
**/
EFI_STATUS
EFIAPI
GetS3MemoryInfo (
  OUT UINT64               *S3PeiMemSize,
  OUT EFI_PHYSICAL_ADDRESS *S3PeiMemBase
  )
{
  return EFI_UNSUPPORTED;
}
 
/**
  Perform platform related reset in FSP wrapper.
 
  This function will reset the system with requested ResetType.
 
  @param[in] FspStatusResetType  The type of reset the platform has to perform.
**/
VOID
EFIAPI
CallFspWrapperResetSystem (
  IN UINT32    FspStatusResetType
  )
{
  //
  // Perform reset according to the type.
  //
 
  CpuDeadLoop();
}