UbaIioConfigLib.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /** @file
  2. DxeUbaIioConfigLib implementation.
  3. @copyright
  4. Copyright 2012 - 2018 Intel Corporation. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <Base.h>
  8. #include <Uefi.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/BaseMemoryLib.h>
  11. #include <Library/MemoryAllocationLib.h>
  12. #include <Library/UefiBootServicesTableLib.h>
  13. #include <Library/DebugLib.h>
  14. #include <Protocol/UbaCfgDb.h>
  15. #include <Library/UbaIioConfigLib.h>
  16. EFI_STATUS
  17. PlatformIioConfigInit (
  18. IN OUT IIO_BIFURCATION_DATA_ENTRY **BifurcationTable,
  19. IN OUT UINT8 *BifurcationEntries,
  20. IN OUT IIO_SLOT_CONFIG_DATA_ENTRY **SlotTable,
  21. IN OUT UINT8 *SlotEntries
  22. )
  23. {
  24. EFI_STATUS Status;
  25. UBA_CONFIG_DATABASE_PROTOCOL *UbaConfigProtocol = NULL;
  26. UINTN DataLength = 0;
  27. PLATFORM_IIO_CONFIG_UPDATE_TABLE IioUpdateTable;
  28. Status = gBS->LocateProtocol (
  29. &gUbaConfigDatabaseProtocolGuid,
  30. NULL,
  31. &UbaConfigProtocol
  32. );
  33. if (EFI_ERROR (Status)) {
  34. return Status;
  35. }
  36. DataLength = sizeof (IioUpdateTable);
  37. Status = UbaConfigProtocol->GetData (
  38. UbaConfigProtocol,
  39. &gPlatformIioConfigDataDxeGuid,
  40. &IioUpdateTable,
  41. &DataLength
  42. );
  43. if (EFI_ERROR (Status)) {
  44. return Status;
  45. }
  46. ASSERT (IioUpdateTable.Signature == PLATFORM_IIO_CONFIG_UPDATE_SIGNATURE);
  47. ASSERT (IioUpdateTable.Version == PLATFORM_IIO_CONFIG_UPDATE_VERSION);
  48. *BifurcationTable = IioUpdateTable.IioBifurcationTablePtr;
  49. *BifurcationEntries = (UINT8) (IioUpdateTable.IioBifurcationTableSize / sizeof(IIO_BIFURCATION_DATA_ENTRY));
  50. *SlotTable = IioUpdateTable.IioSlotTablePtr;
  51. *SlotEntries = (UINT8)(IioUpdateTable.IioSlotTableSize / sizeof(IIO_SLOT_CONFIG_DATA_ENTRY));
  52. return EFI_SUCCESS;
  53. }
  54. EFI_STATUS
  55. PlatformIioConfigInit2 (
  56. IN UINT8 SkuPersonalityType,
  57. IN OUT IIO_BIFURCATION_DATA_ENTRY **BifurcationTable,
  58. IN OUT UINT8 *BifurcationEntries,
  59. IN OUT IIO_SLOT_CONFIG_DATA_ENTRY **SlotTable,
  60. IN OUT UINT8 *SlotEntries
  61. )
  62. {
  63. EFI_STATUS Status;
  64. UBA_CONFIG_DATABASE_PROTOCOL *UbaConfigProtocol = NULL;
  65. UINTN DataLength = 0;
  66. PLATFORM_IIO_CONFIG_UPDATE_TABLE IioUpdateTable;
  67. Status = gBS->LocateProtocol (
  68. &gUbaConfigDatabaseProtocolGuid,
  69. NULL,
  70. &UbaConfigProtocol
  71. );
  72. if (EFI_ERROR (Status)) {
  73. return Status;
  74. }
  75. DataLength = sizeof (IioUpdateTable);
  76. if (SkuPersonalityType == 1) {
  77. Status = UbaConfigProtocol->GetData (
  78. UbaConfigProtocol,
  79. &gPlatformIioConfigDataDxeGuid_1,
  80. &IioUpdateTable,
  81. &DataLength
  82. );
  83. } else if (SkuPersonalityType == 2) {
  84. Status = UbaConfigProtocol->GetData (
  85. UbaConfigProtocol,
  86. &gPlatformIioConfigDataDxeGuid_2,
  87. &IioUpdateTable,
  88. &DataLength
  89. );
  90. } else if (SkuPersonalityType == 3) {
  91. Status = UbaConfigProtocol->GetData (
  92. UbaConfigProtocol,
  93. &gPlatformIioConfigDataDxeGuid_3,
  94. &IioUpdateTable,
  95. &DataLength
  96. );
  97. } else {
  98. Status = UbaConfigProtocol->GetData (
  99. UbaConfigProtocol,
  100. &gPlatformIioConfigDataDxeGuid,
  101. &IioUpdateTable,
  102. &DataLength
  103. );
  104. }
  105. if (EFI_ERROR (Status)) {
  106. return Status;
  107. }
  108. ASSERT (IioUpdateTable.Signature == PLATFORM_IIO_CONFIG_UPDATE_SIGNATURE);
  109. ASSERT (IioUpdateTable.Version == PLATFORM_IIO_CONFIG_UPDATE_VERSION);
  110. *BifurcationTable = IioUpdateTable.IioBifurcationTablePtr;
  111. *BifurcationEntries = (UINT8) (IioUpdateTable.IioBifurcationTableSize / sizeof(IIO_BIFURCATION_DATA_ENTRY));
  112. *SlotTable = IioUpdateTable.IioSlotTablePtr;
  113. *SlotEntries = (UINT8)(IioUpdateTable.IioSlotTableSize / sizeof(IIO_SLOT_CONFIG_DATA_ENTRY));
  114. return EFI_SUCCESS;
  115. }