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 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #ifndef _IPXE_SMBIOS_H
  2. #define _IPXE_SMBIOS_H
  3. /** @file
  4. *
  5. * System Management BIOS
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/api.h>
  11. #include <config/general.h>
  12. #include <ipxe/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 <ipxe/efi/efi_smbios.h>
  24. #include <ipxe/linux/linux_smbios.h>
  25. /* Include all architecture-dependent SMBIOS API headers */
  26. #include <bits/smbios.h>
  27. /** Signature for SMBIOS entry point */
  28. #define SMBIOS_SIGNATURE \
  29. ( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) )
  30. /**
  31. * SMBIOS entry point
  32. *
  33. * This is the single table which describes the list of SMBIOS
  34. * structures. It is located by scanning through the BIOS segment.
  35. */
  36. struct smbios_entry {
  37. /** Signature
  38. *
  39. * Must be equal to SMBIOS_SIGNATURE
  40. */
  41. uint32_t signature;
  42. /** Checksum */
  43. uint8_t checksum;
  44. /** Length */
  45. uint8_t len;
  46. /** Major version */
  47. uint8_t major;
  48. /** Minor version */
  49. uint8_t minor;
  50. /** Maximum structure size */
  51. uint16_t max;
  52. /** Entry point revision */
  53. uint8_t revision;
  54. /** Formatted area */
  55. uint8_t formatted[5];
  56. /** DMI Signature */
  57. uint8_t dmi_signature[5];
  58. /** DMI checksum */
  59. uint8_t dmi_checksum;
  60. /** Structure table length */
  61. uint16_t smbios_len;
  62. /** Structure table address */
  63. uint32_t smbios_address;
  64. /** Number of SMBIOS structures */
  65. uint16_t smbios_count;
  66. /** BCD revision */
  67. uint8_t bcd_revision;
  68. } __attribute__ (( packed ));
  69. /** An SMBIOS structure header */
  70. struct smbios_header {
  71. /** Type */
  72. uint8_t type;
  73. /** Length */
  74. uint8_t len;
  75. /** Handle */
  76. uint16_t handle;
  77. } __attribute__ (( packed ));
  78. /** SMBIOS structure descriptor */
  79. struct smbios_structure {
  80. /** Copy of SMBIOS structure header */
  81. struct smbios_header header;
  82. /** Offset of structure within SMBIOS */
  83. size_t offset;
  84. /** Length of strings section */
  85. size_t strings_len;
  86. };
  87. /** SMBIOS system information structure */
  88. struct smbios_system_information {
  89. /** SMBIOS structure header */
  90. struct smbios_header header;
  91. /** Manufacturer string */
  92. uint8_t manufacturer;
  93. /** Product string */
  94. uint8_t product;
  95. /** Version string */
  96. uint8_t version;
  97. /** Serial number string */
  98. uint8_t serial;
  99. /** UUID */
  100. uint8_t uuid[16];
  101. /** Wake-up type */
  102. uint8_t wakeup;
  103. } __attribute__ (( packed ));
  104. /** SMBIOS system information structure type */
  105. #define SMBIOS_TYPE_SYSTEM_INFORMATION 1
  106. /** SMBIOS base board information structure */
  107. struct smbios_base_board_information {
  108. /** SMBIOS structure header */
  109. struct smbios_header header;
  110. /** Manufacturer string */
  111. uint8_t manufacturer;
  112. /** Product string */
  113. uint8_t product;
  114. /** Version string */
  115. uint8_t version;
  116. /** Serial number string */
  117. uint8_t serial;
  118. } __attribute__ (( packed ));
  119. /** SMBIOS base board information structure type */
  120. #define SMBIOS_TYPE_BASE_BOARD_INFORMATION 2
  121. /** SMBIOS enclosure information structure */
  122. struct smbios_enclosure_information {
  123. /** SMBIOS structure header */
  124. struct smbios_header header;
  125. /** Manufacturer string */
  126. uint8_t manufacturer;
  127. /** Type string */
  128. uint8_t type;
  129. /** Version string */
  130. uint8_t version;
  131. /** Serial number string */
  132. uint8_t serial;
  133. /** Asset tag */
  134. uint8_t asset_tag;
  135. } __attribute__ (( packed ));
  136. /** SMBIOS enclosure information structure type */
  137. #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3
  138. /**
  139. * SMBIOS entry point descriptor
  140. *
  141. * This contains the information from the SMBIOS entry point that we
  142. * care about.
  143. */
  144. struct smbios {
  145. /** Start of SMBIOS structures */
  146. userptr_t address;
  147. /** Length of SMBIOS structures */
  148. size_t len;
  149. /** Number of SMBIOS structures */
  150. unsigned int count;
  151. /** SMBIOS version */
  152. uint16_t version;
  153. };
  154. /**
  155. * Calculate SMBIOS version
  156. *
  157. * @v major Major version
  158. * @v minor Minor version
  159. * @ret version SMBIOS version
  160. */
  161. #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) )
  162. extern int find_smbios ( struct smbios *smbios );
  163. extern int find_smbios_entry ( userptr_t start, size_t len,
  164. struct smbios_entry *entry );
  165. extern int find_smbios_structure ( unsigned int type, unsigned int instance,
  166. struct smbios_structure *structure );
  167. extern int read_smbios_structure ( struct smbios_structure *structure,
  168. void *data, size_t len );
  169. extern int read_smbios_string ( struct smbios_structure *structure,
  170. unsigned int index,
  171. void *data, size_t len );
  172. extern int smbios_version ( void );
  173. #endif /* _IPXE_SMBIOS_H */