iPXE
smbios.h
Go to the documentation of this file.
00001 #ifndef _IPXE_SMBIOS_H
00002 #define _IPXE_SMBIOS_H
00003 
00004 /** @file
00005  *
00006  * System Management BIOS
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/api.h>
00014 #include <config/general.h>
00015 #include <ipxe/uaccess.h>
00016 
00017 /**
00018  * Provide an SMBIOS API implementation
00019  *
00020  * @v _prefix           Subsystem prefix
00021  * @v _api_func         API function
00022  * @v _func             Implementing function
00023  */
00024 #define PROVIDE_SMBIOS( _subsys, _api_func, _func ) \
00025         PROVIDE_SINGLE_API ( SMBIOS_PREFIX_ ## _subsys, _api_func, _func )
00026 
00027 /* Include all architecture-independent SMBIOS API headers */
00028 #include <ipxe/efi/efi_smbios.h>
00029 #include <ipxe/linux/linux_smbios.h>
00030 
00031 /* Include all architecture-dependent SMBIOS API headers */
00032 #include <bits/smbios.h>
00033 
00034 /** Signature for SMBIOS entry point */
00035 #define SMBIOS_SIGNATURE \
00036         ( ( '_' << 0 ) + ( 'S' << 8 ) + ( 'M' << 16 ) + ( '_' << 24 ) )
00037 
00038 /**
00039  * SMBIOS entry point
00040  *
00041  * This is the single table which describes the list of SMBIOS
00042  * structures.  It is located by scanning through the BIOS segment.
00043  */
00044 struct smbios_entry {
00045         /** Signature
00046          *
00047          * Must be equal to SMBIOS_SIGNATURE
00048          */
00049         uint32_t signature;
00050         /** Checksum */
00051         uint8_t checksum;
00052         /** Length */
00053         uint8_t len;
00054         /** Major version */
00055         uint8_t major;
00056         /** Minor version */
00057         uint8_t minor;
00058         /** Maximum structure size */
00059         uint16_t max;
00060         /** Entry point revision */
00061         uint8_t revision;
00062         /** Formatted area */
00063         uint8_t formatted[5];
00064         /** DMI Signature */
00065         uint8_t dmi_signature[5];
00066         /** DMI checksum */
00067         uint8_t dmi_checksum;
00068         /** Structure table length */
00069         uint16_t smbios_len;
00070         /** Structure table address */
00071         uint32_t smbios_address;
00072         /** Number of SMBIOS structures */
00073         uint16_t smbios_count;
00074         /** BCD revision */
00075         uint8_t bcd_revision;
00076 } __attribute__ (( packed ));
00077 
00078 /** An SMBIOS structure header */
00079 struct smbios_header {
00080         /** Type */
00081         uint8_t type;
00082         /** Length */
00083         uint8_t len;
00084         /** Handle */
00085         uint16_t handle;
00086 } __attribute__ (( packed ));
00087 
00088 /** SMBIOS structure descriptor */
00089 struct smbios_structure {
00090         /** Copy of SMBIOS structure header */
00091         struct smbios_header header;
00092         /** Offset of structure within SMBIOS */
00093         size_t offset;
00094         /** Length of strings section */
00095         size_t strings_len;
00096 };
00097 
00098 /** SMBIOS system information structure */
00099 struct smbios_system_information {
00100         /** SMBIOS structure header */
00101         struct smbios_header header;
00102         /** Manufacturer string */
00103         uint8_t manufacturer;
00104         /** Product string */
00105         uint8_t product;
00106         /** Version string */
00107         uint8_t version;
00108         /** Serial number string */
00109         uint8_t serial;
00110         /** UUID */
00111         uint8_t uuid[16];
00112         /** Wake-up type */
00113         uint8_t wakeup;
00114 } __attribute__ (( packed ));
00115 
00116 /** SMBIOS system information structure type */
00117 #define SMBIOS_TYPE_SYSTEM_INFORMATION 1
00118 
00119 /** SMBIOS base board information structure */
00120 struct smbios_base_board_information {
00121         /** SMBIOS structure header */
00122         struct smbios_header header;
00123         /** Manufacturer string */
00124         uint8_t manufacturer;
00125         /** Product string */
00126         uint8_t product;
00127         /** Version string */
00128         uint8_t version;
00129         /** Serial number string */
00130         uint8_t serial;
00131 } __attribute__ (( packed ));
00132 
00133 /** SMBIOS base board information structure type */
00134 #define SMBIOS_TYPE_BASE_BOARD_INFORMATION 2
00135 
00136 /** SMBIOS enclosure information structure */
00137 struct smbios_enclosure_information {
00138         /** SMBIOS structure header */
00139         struct smbios_header header;
00140         /** Manufacturer string */
00141         uint8_t manufacturer;
00142         /** Type string */
00143         uint8_t type;
00144         /** Version string */
00145         uint8_t version;
00146         /** Serial number string */
00147         uint8_t serial;
00148         /** Asset tag */
00149         uint8_t asset_tag;
00150 } __attribute__ (( packed ));
00151 
00152 /** SMBIOS enclosure information structure type */
00153 #define SMBIOS_TYPE_ENCLOSURE_INFORMATION 3
00154 
00155 /** SMBIOS OEM strings structure type */
00156 #define SMBIOS_TYPE_OEM_STRINGS 11
00157 
00158 /**
00159  * SMBIOS entry point descriptor
00160  *
00161  * This contains the information from the SMBIOS entry point that we
00162  * care about.
00163  */
00164 struct smbios {
00165         /** Start of SMBIOS structures */
00166         userptr_t address;
00167         /** Length of SMBIOS structures */
00168         size_t len;
00169         /** Number of SMBIOS structures */
00170         unsigned int count;
00171         /** SMBIOS version */
00172         uint16_t version;
00173 };
00174 
00175 /**
00176  * Calculate SMBIOS version
00177  *
00178  * @v major             Major version
00179  * @v minor             Minor version
00180  * @ret version         SMBIOS version
00181  */
00182 #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) )
00183 
00184 extern int find_smbios ( struct smbios *smbios );
00185 extern int find_smbios_entry ( userptr_t start, size_t len,
00186                                struct smbios_entry *entry );
00187 extern int find_smbios_structure ( unsigned int type, unsigned int instance,
00188                                    struct smbios_structure *structure );
00189 extern int read_smbios_structure ( struct smbios_structure *structure,
00190                                    void *data, size_t len );
00191 extern int read_smbios_string ( struct smbios_structure *structure,
00192                                 unsigned int index,
00193                                 void *data, size_t len );
00194 extern int smbios_version ( void );
00195 
00196 #endif /* _IPXE_SMBIOS_H */