SmbiosLib.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /** @file
  2. Provides library functions for common SMBIOS operations. Only available to DXE
  3. and UEFI module types.
  4. Copyright (c) 2012, Apple Inc. All rights reserved.
  5. Portitions Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #ifndef _SMBIOS_LIB_H__
  9. #define _SMBIOS_LIB_H__
  10. #include <IndustryStandard/SmBios.h>
  11. #include <Protocol/Smbios.h>
  12. ///
  13. /// Cache copy of the SMBIOS Protocol pointer
  14. ///
  15. extern EFI_SMBIOS_PROTOCOL *gSmbios;
  16. ///
  17. /// Template for SMBIOS table initialization.
  18. /// The SMBIOS_TABLE_STRING types in the formated area must match the
  19. /// StringArray sequene.
  20. ///
  21. typedef struct {
  22. //
  23. // formatted area of a given SMBIOS record
  24. //
  25. SMBIOS_STRUCTURE *Entry;
  26. //
  27. // NULL terminated array of ASCII strings to be added to the SMBIOS record.
  28. //
  29. CHAR8 **StringArray;
  30. } SMBIOS_TEMPLATE_ENTRY;
  31. /**
  32. Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
  33. entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table.
  34. @param Template Array of SMBIOS_TEMPLATE_ENTRY entries.
  35. @retval EFI_SUCCESS New SMBIOS tables were created.
  36. @retval EFI_OUT_OF_RESOURCES New SMBIOS tables were not created.
  37. **/
  38. EFI_STATUS
  39. EFIAPI
  40. SmbiosLibInitializeFromTemplate (
  41. IN SMBIOS_TEMPLATE_ENTRY *Template
  42. );
  43. /**
  44. Create SMBIOS record.
  45. Converts a fixed SMBIOS structure and an array of pointers to strings into
  46. an SMBIOS record where the strings are cat'ed on the end of the fixed record
  47. and terminated via a double NULL and add to SMBIOS table.
  48. SMBIOS_TABLE_TYPE32 gSmbiosType12 = {
  49. { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
  50. 1 // StringCount
  51. };
  52. CHAR8 *gSmbiosType12Strings[] = {
  53. "Not Found",
  54. NULL
  55. };
  56. ...
  57. AddSmbiosEntryFromTemplate (
  58. (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12,
  59. gSmbiosType12Strings
  60. );
  61. @param SmbiosEntry Fixed SMBIOS structure
  62. @param StringArray Array of strings to convert to an SMBIOS string pack.
  63. NULL is OK.
  64. @retval EFI_SUCCESS New SmbiosEntry was added to SMBIOS table.
  65. @retval EFI_OUT_OF_RESOURCES SmbiosEntry was not added.
  66. **/
  67. EFI_STATUS
  68. EFIAPI
  69. SmbiosLibCreateEntry (
  70. IN SMBIOS_STRUCTURE *SmbiosEntry,
  71. IN CHAR8 **StringArray
  72. );
  73. /**
  74. Update the string associated with an existing SMBIOS record.
  75. This function allows the update of specific SMBIOS strings. The number of valid strings for any
  76. SMBIOS record is defined by how many strings were present when Add() was called.
  77. @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
  78. @param[in] StringNumber The non-zero string number of the string to update.
  79. @param[in] String Update the StringNumber string with String.
  80. @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
  81. @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
  82. @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
  83. @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
  84. **/
  85. EFI_STATUS
  86. EFIAPI
  87. SmbiosLibUpdateString (
  88. IN EFI_SMBIOS_HANDLE SmbiosHandle,
  89. IN SMBIOS_TABLE_STRING StringNumber,
  90. IN CHAR8 *String
  91. );
  92. /**
  93. Update the string associated with an existing SMBIOS record.
  94. This function allows the update of specific SMBIOS strings. The number of valid strings for any
  95. SMBIOS record is defined by how many strings were present when Add() was called.
  96. @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
  97. @param[in] StringNumber The non-zero string number of the string to update.
  98. @param[in] String Update the StringNumber string with String.
  99. @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
  100. @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
  101. @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
  102. @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
  103. **/
  104. EFI_STATUS
  105. EFIAPI
  106. SmbiosLibUpdateUnicodeString (
  107. IN EFI_SMBIOS_HANDLE SmbiosHandle,
  108. IN SMBIOS_TABLE_STRING StringNumber,
  109. IN CHAR16 *String
  110. );
  111. /**
  112. Allow caller to read a specific SMBIOS string
  113. @param[in] Header SMBIOS record that contains the string.
  114. @param[in[ StringNumber Instance of SMBIOS string 1 - N.
  115. @retval NULL Instance of Type SMBIOS string was not found.
  116. @retval Other Pointer to matching SMBIOS string.
  117. **/
  118. CHAR8 *
  119. EFIAPI
  120. SmbiosLibReadString (
  121. IN SMBIOS_STRUCTURE *Header,
  122. IN EFI_SMBIOS_STRING StringNumber
  123. );
  124. /**
  125. Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
  126. @param[in] Type Type of the next SMBIOS record to return.
  127. @param[in[ Instance Instance of SMBIOS record 0 - N-1.
  128. @param[out] SmbiosHandle Returns SMBIOS handle for the matching record.
  129. @retval NULL Instance of Type SMBIOS record was not found.
  130. @retval Other Pointer to matching SMBIOS record.
  131. **/
  132. SMBIOS_STRUCTURE *
  133. EFIAPI
  134. SmbiosLibGetRecord (
  135. IN EFI_SMBIOS_TYPE Type,
  136. IN UINTN Instance,
  137. OUT EFI_SMBIOS_HANDLE *SmbiosHandle
  138. );
  139. /**
  140. Remove an SMBIOS record.
  141. This function removes an SMBIOS record using the handle specified by SmbiosHandle.
  142. @param[in] SmbiosHandle The handle of the SMBIOS record to remove.
  143. @retval EFI_SUCCESS SMBIOS record was removed.
  144. @retval EFI_INVALID_PARAMETER SmbiosHandle does not specify a valid SMBIOS record.
  145. **/
  146. EFI_STATUS
  147. EFIAPI
  148. SmbiosLibRemove (
  149. OUT EFI_SMBIOS_HANDLE SmbiosHandle
  150. );
  151. #endif