PeiBoardInitLib.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /** @file
  2. @copyright
  3. Copyright 2018 - 2021 Intel Corporation.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. /**
  7. The constructor function for Board Init Libray.
  8. @param FileHandle Handle of the file being invoked.
  9. @param PeiServices Describes the list of possible PEI Services.
  10. @retval EFI_SUCCESS Table initialization successfully.
  11. @retval EFI_OUT_OF_RESOURCES No enough memory to initialize table.
  12. **/
  13. #include "PeiBoardInit.h"
  14. #include <UncoreCommonIncludes.h>
  15. #include <Library/PchMultiPchBase.h>
  16. #include <Ppi/DynamicSiLibraryPpi.h>
  17. EFI_STATUS
  18. EFIAPI
  19. TypeBoardPortTemplatePeiBoardInitLibConstructor (
  20. IN EFI_PEI_FILE_HANDLE FileHandle,
  21. IN CONST EFI_PEI_SERVICES **PeiServices
  22. )
  23. {
  24. EFI_STATUS Status = EFI_SUCCESS;
  25. UBA_CONFIG_DATABASE_PPI *UbaConfigPpi;
  26. EFI_HOB_GUID_TYPE *GuidHob;
  27. EFI_PLATFORM_INFO *PlatformInfo;
  28. UINT8 SocketIndex;
  29. UINT8 ChannelIndex;
  30. GuidHob = GetFirstGuidHob (&gEfiPlatformInfoGuid);
  31. ASSERT (GuidHob != NULL);
  32. if (GuidHob == NULL) {
  33. return EFI_NOT_FOUND;
  34. }
  35. PlatformInfo = GET_GUID_HOB_DATA(GuidHob);
  36. if (PlatformInfo->BoardId == TypeBoardPortTemplate) {
  37. DEBUG ((DEBUG_INFO, "PEI UBA init BoardId 0x%X: BoardPortTemplate\n", PlatformInfo->BoardId));
  38. // Socket 0 has SMT DIMM connector, Socket 1 has PTH DIMM connector
  39. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; SocketIndex++) {
  40. for (ChannelIndex = 0; ChannelIndex < MAX_CH; ChannelIndex++) {
  41. switch (SocketIndex) {
  42. case 0:
  43. PlatformInfo->MemoryConnectorType[SocketIndex][ChannelIndex] = DimmConnectorSmt;
  44. break;
  45. case 1:
  46. // Fall through since socket 1 is PTH type
  47. default:
  48. // Use the more restrictive type as the default case
  49. PlatformInfo->MemoryConnectorType[SocketIndex][ChannelIndex] = DimmConnectorPth;
  50. break;
  51. }
  52. }
  53. }
  54. BuildGuidDataHob (
  55. &gEfiPlatformInfoGuid,
  56. &(PlatformInfo),
  57. sizeof (EFI_PLATFORM_INFO)
  58. );
  59. Status = PeiServicesLocatePpi (
  60. &gUbaConfigDatabasePpiGuid,
  61. 0,
  62. NULL,
  63. (VOID **) &UbaConfigPpi
  64. );
  65. if (EFI_ERROR(Status)) {
  66. return Status;
  67. }
  68. Status = UbaConfigPpi->InitSku (
  69. UbaConfigPpi,
  70. PlatformInfo->BoardId,
  71. NULL,
  72. NULL
  73. );
  74. ASSERT_EFI_ERROR (Status);
  75. Status = TypeBoardPortTemplateInstallGpioData (UbaConfigPpi);
  76. if (EFI_ERROR(Status)) {
  77. return Status;
  78. }
  79. Status = TypeBoardPortTemplateInstallPcdData (UbaConfigPpi);
  80. if (EFI_ERROR(Status)) {
  81. return Status;
  82. }
  83. Status = TypeBoardPortTemplateInstallSoftStrapData (UbaConfigPpi);
  84. if (EFI_ERROR(Status)) {
  85. return Status;
  86. }
  87. Status = TypeBoardPortTemplatePchEarlyUpdate (UbaConfigPpi);
  88. if (EFI_ERROR(Status)) {
  89. return Status;
  90. }
  91. Status = TypeBoardPortTemplatePlatformUpdateUsbOcMappings (UbaConfigPpi);
  92. if (EFI_ERROR(Status)) {
  93. return Status;
  94. }
  95. Status = TypeBoardPortTemplateInstallSlotTableData (UbaConfigPpi);
  96. if (EFI_ERROR(Status)) {
  97. return Status;
  98. }
  99. Status = TypeBoardPortTemplateInstallKtiEparamData (UbaConfigPpi);
  100. if (EFI_ERROR(Status)) {
  101. return Status;
  102. }
  103. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; SocketIndex++) {
  104. //
  105. // Set default memory type connector.
  106. // Socket 0: DimmConnectorSmt
  107. // Socket 1: DimmConnectorPth
  108. //
  109. if (SocketIndex % 2 == 0) {
  110. (*PeiServices)->SetMem (&PlatformInfo->MemoryConnectorType[SocketIndex], sizeof (PlatformInfo->MemoryConnectorType[SocketIndex]), DimmConnectorSmt);
  111. } else {
  112. (*PeiServices)->SetMem (&PlatformInfo->MemoryConnectorType[SocketIndex], sizeof (PlatformInfo->MemoryConnectorType[SocketIndex]), DimmConnectorPth);
  113. }
  114. }
  115. //
  116. // Initialize InterposerType to InterposerUnknown
  117. //
  118. for (SocketIndex = 0; SocketIndex < MAX_SOCKET; ++SocketIndex) {
  119. PlatformInfo->InterposerType[SocketIndex] = InterposerUnknown;
  120. }
  121. //
  122. // TypeBoardPortTemplateIioPortBifurcationInit will use PlatformInfo->InterposerType for PPO.
  123. //
  124. Status = TypeBoardPortTemplateIioPortBifurcationInit (UbaConfigPpi);
  125. if (EFI_ERROR(Status)) {
  126. return Status;
  127. }
  128. }
  129. return Status;
  130. }