PlatformInfoInit.c 5.8 KB

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