#ifndef _SMBIOS_H_
#define _SMBIOS_H_
-#include <dm/ofnode.h>
+#include <linux/types.h>
/* SMBIOS spec version implemented */
#define SMBIOS_MAJOR_VER 3
-#define SMBIOS_MINOR_VER 0
+#define SMBIOS_MINOR_VER 7
+
+enum {
+ SMBIOS_STR_MAX = 64, /* Maximum length allowed for a string */
+};
/* SMBIOS structure types */
enum {
u8 bcd_rev;
};
+/**
+ * struct smbios3_entry - SMBIOS 3.0 (64-bit) Entry Point structure
+ */
+struct __packed smbios3_entry {
+ /** @anchor: anchor string */
+ u8 anchor[5];
+ /** @checksum: checksum of the entry point structure */
+ u8 checksum;
+ /** @length: length of the entry point structure */
+ u8 length;
+ /** @major_ver: major version of the SMBIOS specification */
+ u8 major_ver;
+ /** @minor_ver: minor version of the SMBIOS specification */
+ u8 minor_ver;
+ /** @docrev: revision of the SMBIOS specification */
+ u8 doc_rev;
+ /** @entry_point_rev: revision of the entry point structure */
+ u8 entry_point_rev;
+ /** @reserved: reserved */
+ u8 reserved;
+ /** maximum size of SMBIOS table */
+ u32 table_maximum_size;
+ /** @struct_table_address: 64-bit physical starting address */
+ u64 struct_table_address;
+};
+
/* BIOS characteristics */
#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
#define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
#define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
#define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
-#define BIOS_CHARACTERISTICS_EXT1_UEFI (1 << 3)
+#define BIOS_CHARACTERISTICS_EXT2_UEFI (1 << 3)
#define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
struct __packed smbios_type0 {
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
+/**
+ * enum smbios_wakeup_type - wake-up type
+ *
+ * These constants are used for the Wake-Up Type field in the SMBIOS
+ * System Information (Type 1) structure.
+ */
+enum smbios_wakeup_type {
+ /** @SMBIOS_WAKEUP_TYPE_RESERVED: Reserved */
+ SMBIOS_WAKEUP_TYPE_RESERVED,
+ /** @SMBIOS_WAKEUP_TYPE_OTHER: Other */
+ SMBIOS_WAKEUP_TYPE_OTHER,
+ /** @SMBIOS_WAKEUP_TYPE_UNKNOWN: Unknown */
+ SMBIOS_WAKEUP_TYPE_UNKNOWN,
+ /** @SMBIOS_WAKEUP_TYPE_APM_TIMER: APM Timer */
+ SMBIOS_WAKEUP_TYPE_APM_TIMER,
+ /** @SMBIOS_WAKEUP_TYPE_MODEM_RING: Modem Ring */
+ SMBIOS_WAKEUP_TYPE_MODEM_RING,
+ /** @SMBIOS_WAKEUP_TYPE_LAN_REMOTE: LAN Remote */
+ SMBIOS_WAKEUP_TYPE_LAN_REMOTE,
+ /** @SMBIOS_WAKEUP_TYPE_POWER_SWITCH: Power Switch */
+ SMBIOS_WAKEUP_TYPE_POWER_SWITCH,
+ /** @SMBIOS_WAKEUP_TYPE_PCI_PME: PCI PME# */
+ SMBIOS_WAKEUP_TYPE_PCI_PME,
+ /** @SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED: AC Power Restored */
+ SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED,
+};
+
struct __packed smbios_type1 {
u8 type;
u8 length;
u8 chassis_location;
u16 chassis_handle;
u8 board_type;
+ u8 number_contained_objects;
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
u16 handle;
u8 reserved[6];
u8 boot_status;
- u8 eos[SMBIOS_STRUCT_EOS_BYTES];
+ char eos[SMBIOS_STRUCT_EOS_BYTES];
};
struct __packed smbios_type127 {
u8 type;
u8 length;
u16 handle;
- u8 eos[SMBIOS_STRUCT_EOS_BYTES];
+ char eos[SMBIOS_STRUCT_EOS_BYTES];
};
struct __packed smbios_header {
header->handle = handle;
}
-/**
- * Function prototype to write a specific type of SMBIOS structure
- *
- * @addr: start address to write the structure
- * @handle: the structure's handle, a unique 16-bit number
- * @node: node containing the information to write (ofnode_null() if none)
- * @return: size of the structure
- */
-typedef int (*smbios_write_type)(ulong *addr, int handle, ofnode node);
-
/**
* write_smbios_table() - Write SMBIOS table
*
* This writes SMBIOS table at a given address.
*
- * @addr: start address to write SMBIOS table. If this is not
- * 16-byte-aligned then it will be aligned before the table is written
- * @return: end address of SMBIOS table (and start address for next entry)
+ * @addr: start address to write SMBIOS table, 16-byte-alignment
+ * recommended. Note that while the SMBIOS tables themself have no alignment
+ * requirement, some systems may requires alignment. For example x86 systems
+ * which put tables at f0000 require 16-byte alignment
+ *
+ * Return: end address of SMBIOS table (and start address for next entry)
+ * or NULL in case of an error
*/
ulong write_smbios_table(ulong addr);
*
* @header: pointer to struct smbios_header
* @index: string index
- * @return: NULL or a valid const char pointer
+ * @return: NULL or a valid char pointer
+ */
+char *smbios_string(const struct smbios_header *header, int index);
+
+/**
+ * smbios_update_version() - Update the version string
+ *
+ * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
+ * main loop has started) to update the BIOS version string (SMBIOS table 0).
+ *
+ * @version: New version string to use
+ * Return: 0 if OK, -ENOENT if no version string was previously written,
+ * -ENOSPC if the new string is too large to fit
+ */
+int smbios_update_version(const char *version);
+
+/**
+ * smbios_update_version_full() - Update the version string
+ *
+ * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
+ * main loop has started) to update the BIOS version string (SMBIOS table 0).
+ * It scans for the correct place to put the version, so does not need U-Boot
+ * to have actually written the tables itself (e.g. if a previous bootloader
+ * did it).
+ *
+ * @smbios_tab: Start of SMBIOS tables
+ * @version: New version string to use
+ * Return: 0 if OK, -ENOENT if no version string was previously written,
+ * -ENOSPC if the new string is too large to fit
+ */
+int smbios_update_version_full(void *smbios_tab, const char *version);
+
+/**
+ * smbios_prepare_measurement() - Update smbios table for the measurement
+ *
+ * TCG specification requires to measure static configuration information.
+ * This function clear the device dependent parameters such as
+ * serial number for the measurement.
+ *
+ * @entry: pointer to a struct smbios3_entry
+ * @header: pointer to a struct smbios_header
*/
-const char *smbios_string(const struct smbios_header *header, int index);
+void smbios_prepare_measurement(const struct smbios3_entry *entry,
+ struct smbios_header *header);
#endif /* _SMBIOS_H_ */