You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smbios.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef _GPXE_SMBIOS_H
  2. #define _GPXE_SMBIOS_H
  3. /** @file
  4. *
  5. * System Management BIOS
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <stdint.h>
  10. #include <gpxe/api.h>
  11. #include <config/general.h>
  12. #include <gpxe/uaccess.h>
  13. /**
  14. * Provide an SMBIOS API implementation
  15. *
  16. * @v _prefix Subsystem prefix
  17. * @v _api_func API function
  18. * @v _func Implementing function
  19. */
  20. #define PROVIDE_SMBIOS( _subsys, _api_func, _func ) \
  21. PROVIDE_SINGLE_API ( SMBIOS_PREFIX_ ## _subsys, _api_func, _func )
  22. /* Include all architecture-independent SMBIOS API headers */
  23. #include <gpxe/efi/efi_smbios.h>
  24. /* Include all architecture-dependent SMBIOS API headers */
  25. #include <bits/smbios.h>
  26. /** Signature for SMBIOS entry point */
  27. #define SMBIOS_SIGNATURE \
  28. ( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) )
  29. /**
  30. * SMBIOS entry point
  31. *
  32. * This is the single table which describes the list of SMBIOS
  33. * structures. It is located by scanning through the BIOS segment.
  34. */
  35. struct smbios_entry {
  36. /** Signature
  37. *
  38. * Must be equal to SMBIOS_SIGNATURE
  39. */
  40. uint32_t signature;
  41. /** Checksum */
  42. uint8_t checksum;
  43. /** Length */
  44. uint8_t len;
  45. /** Major version */
  46. uint8_t major;
  47. /** Minor version */
  48. uint8_t minor;
  49. /** Maximum structure size */
  50. uint16_t max;
  51. /** Entry point revision */
  52. uint8_t revision;
  53. /** Formatted area */
  54. uint8_t formatted[5];
  55. /** DMI Signature */
  56. uint8_t dmi_signature[5];
  57. /** DMI checksum */
  58. uint8_t dmi_checksum;
  59. /** Structure table length */
  60. uint16_t smbios_len;
  61. /** Structure table address */
  62. uint32_t smbios_address;
  63. /** Number of SMBIOS structures */
  64. uint16_t smbios_count;
  65. /** BCD revision */
  66. uint8_t bcd_revision;
  67. } __attribute__ (( packed ));
  68. /** An SMBIOS structure header */
  69. struct smbios_header {
  70. /** Type */
  71. uint8_t type;
  72. /** Length */
  73. uint8_t len;
  74. /** Handle */
  75. uint16_t handle;
  76. } __attribute__ (( packed ));
  77. /** SMBIOS structure descriptor */
  78. struct smbios_structure {
  79. /** Copy of SMBIOS structure header */
  80. struct smbios_header header;
  81. /** Offset of structure within SMBIOS */
  82. size_t offset;
  83. /** Length of strings section */
  84. size_t strings_len;
  85. };
  86. /** SMBIOS system information structure */
  87. struct smbios_system_information {
  88. /** SMBIOS structure header */
  89. struct smbios_header header;
  90. /** Manufacturer string */
  91. uint8_t manufacturer;
  92. /** Product string */
  93. uint8_t product;
  94. /** Version string */
  95. uint8_t version;
  96. /** Serial number string */
  97. uint8_t serial;
  98. /** UUID */
  99. uint8_t uuid[16];
  100. /** Wake-up type */
  101. uint8_t wakeup;
  102. } __attribute__ (( packed ));
  103. /** SMBIOS system information structure type */
  104. #define SMBIOS_TYPE_SYSTEM_INFORMATION 1
  105. /** SMBIOS enclosure information structure */
  106. struct smbios_enclosure_information {
  107. /** SMBIOS structure header */
  108. struct smbios_header header;
  109. /** Manufacturer string */
  110. uint8_t manufacturer;
  111. /** Type string */
  112. uint8_t type;
  113. /** Version string */
  114. uint8_t version;
  115. /** Serial number string */
  116. uint8_t serial;
  117. /** Asset tag */
  118. uint8_t asset_tag;
  119. } __attribute__ (( packed ));
  120. /** SMBIOS enclosure information structure type */
  121. #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3
  122. /**
  123. * SMBIOS entry point descriptor
  124. *
  125. * This contains the information from the SMBIOS entry point that we
  126. * care about.
  127. */
  128. struct smbios {
  129. /** Start of SMBIOS structures */
  130. userptr_t address;
  131. /** Length of SMBIOS structures */
  132. size_t len;
  133. /** Number of SMBIOS structures */
  134. unsigned int count;
  135. };
  136. extern int find_smbios ( struct smbios *smbios );
  137. extern int find_smbios_structure ( unsigned int type,
  138. struct smbios_structure *structure );
  139. extern int read_smbios_structure ( struct smbios_structure *structure,
  140. void *data, size_t len );
  141. extern int read_smbios_string ( struct smbios_structure *structure,
  142. unsigned int index,
  143. void *data, size_t len );
  144. #endif /* _GPXE_SMBIOS_H */