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.2KB

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