Type1SystemInformation.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /** @file
  2. SMBIOS Type 1 (System information) table for ARM RD platforms.
  3. This file installs SMBIOS Type 1 (System information) table for Arm's
  4. Reference Design platforms. Type 1 table defines attributes of the
  5. overall system such as manufacturer, product name, UUID etc.
  6. Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
  7. SPDX-License-Identifier: BSD-2-Clause-Patent
  8. @par Specification Reference:
  9. - SMBIOS Reference Specification 3.4.0, Chapter 7.2
  10. **/
  11. #include <Library/BaseMemoryLib.h>
  12. #include <Library/DebugLib.h>
  13. #include <Library/PcdLib.h>
  14. #include <Protocol/Smbios.h>
  15. #include "SgiPlatform.h"
  16. #define TYPE1_STRINGS \
  17. "ARM LTD\0" /* Manufacturer */ \
  18. "Version not set\0" /* Version */ \
  19. "Serial not set\0" /* Serial number */ \
  20. "Not Applicable\0" /* SKU */ \
  21. "Not Applicable\0" /* Family */ \
  22. "SGI575\0" /* Product Names */ \
  23. "RdN1Edge\0" \
  24. "RdN1EdgeX2\0" \
  25. "RdE1Edge\0" \
  26. "RdV1\0" \
  27. "RdV1Mc\0" \
  28. "RdN2\0" \
  29. "RdN2Cfg1\0" \
  30. "RdN2Cfg2\0"
  31. typedef enum {
  32. ManufacturerName = 1,
  33. Version,
  34. SerialNumber,
  35. Sku,
  36. Family,
  37. ProductNameBase
  38. } TYPE1_STRING_ELEMENTS;
  39. /* SMBIOS Type1 structure */
  40. #pragma pack(1)
  41. typedef struct {
  42. SMBIOS_TABLE_TYPE1 Base;
  43. CHAR8 Strings[sizeof (TYPE1_STRINGS)];
  44. } ARM_RD_SMBIOS_TYPE1;
  45. #pragma pack()
  46. STATIC GUID mSmbiosUid[] = {
  47. /* Sgi575 */
  48. {0xdd7cad0a, 0x227c, 0x4ed4, {0x9f, 0x42, 0xa9, 0x8b, 0xd6, 0xa2, 0x42, 0x6c}},
  49. /* Rd-N1-Edge */
  50. {0x80984efe, 0x404a, 0x43e0, {0xad, 0xa4, 0x63, 0xa0, 0xe0, 0xc4, 0x5e, 0x60}},
  51. /* Rd-N1-Edge-X2 */
  52. {0x2cc4f916, 0x267a, 0x4251, {0x95, 0x6e, 0xf0, 0x49, 0x82, 0xbe, 0x94, 0x58}},
  53. /* Rd-E1-Edge */
  54. {0x567f35c4, 0x104f, 0x447b, {0xa0, 0x94, 0x89, 0x2f, 0xbd, 0xb6, 0x5a, 0x55}},
  55. /* Rd-V1 */
  56. {0xc481f0b1, 0x237c, 0x42d7, {0x98, 0xb2, 0xb4, 0xb4, 0x8d, 0xb5, 0x4f, 0x50}},
  57. /* Rd-V1Mc */
  58. {0x1f3a0806, 0x18b5, 0x4eca, {0xad, 0xcd, 0xba, 0x9b, 0x07, 0xb1, 0x0a, 0xcf}},
  59. /* Rd-N2 */
  60. {0xf2cded73, 0x37f9, 0x4ec9, {0xd9, 0xf9, 0x89, 0x9b, 0x74, 0x91, 0x20, 0x49}},
  61. /* Rd-N2-Cfg1 */
  62. {0xa4941d3d, 0xfac3, 0x4ace, {0x9a, 0x7e, 0xce, 0x26, 0x76, 0x64, 0x5e, 0xda}},
  63. /* Rd-N2-Cfg2 */
  64. {0xd2946d07, 0x8057, 0x4c26, {0xbf, 0x53, 0x78, 0xa6, 0x5b, 0xe1, 0xc1, 0x60}},
  65. };
  66. /* System information */
  67. STATIC ARM_RD_SMBIOS_TYPE1 mArmRdSmbiosType1 = {
  68. {
  69. {
  70. // SMBIOS header
  71. EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, // Type 1
  72. sizeof (SMBIOS_TABLE_TYPE1), // Length
  73. SMBIOS_HANDLE_PI_RESERVED, // Assign an unused handle number
  74. },
  75. ManufacturerName, // Manufacturer
  76. ProductNameBase, // Product Name, update dynamically
  77. Version, // Version
  78. SerialNumber, // Serial
  79. {0}, // UUID, Update dymanically
  80. 1, // Wakeup type other
  81. Sku, // SKU
  82. Family, // Family
  83. },
  84. // Text strings (unformatted)
  85. TYPE1_STRINGS
  86. };
  87. /**
  88. Install SMBIOS System information Table.
  89. Install the SMBIOS system information (type 1) table for Arm's reference
  90. design platforms.
  91. @param[in] Smbios SMBIOS protocol.
  92. @retval EFI_SUCCESS Record was added.
  93. @retval EFI_NOT_FOUND Unknown product id.
  94. @retval EFI_OUT_OF_RESOURCES Record was not added.
  95. @retval EFI_ALREADY_STARTED The SmbiosHandle passed is already in use.
  96. **/
  97. EFI_STATUS
  98. InstallType1SystemInformation (
  99. IN EFI_SMBIOS_PROTOCOL *Smbios
  100. )
  101. {
  102. EFI_STATUS Status;
  103. EFI_SMBIOS_HANDLE SmbiosHandle;
  104. UINT8 ProductId;
  105. SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType1)->Handle;
  106. ProductId = SgiGetProductId ();
  107. /* Choose the product name from TYPE1_STRINGS based on the product ID */
  108. if (ProductId != UnknownId) {
  109. mArmRdSmbiosType1.Base.ProductName =
  110. ProductNameBase + (ProductId - 1);
  111. CopyGuid (&mArmRdSmbiosType1.Base.Uuid,
  112. &mSmbiosUid[ProductId - 1]);
  113. } else {
  114. return EFI_NOT_FOUND;
  115. }
  116. /* Install type 1 table */
  117. Status = Smbios->Add (
  118. Smbios,
  119. NULL,
  120. &SmbiosHandle,
  121. (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType1
  122. );
  123. if (EFI_ERROR (Status)) {
  124. DEBUG ((
  125. DEBUG_ERROR,
  126. "SMBIOS: Failed to install Type1 SMBIOS table.\n"
  127. ));
  128. }
  129. return Status;
  130. }