/* 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 */
u64 struct_table_address;
};
+/* These two structures should use the same amount of 16-byte-aligned space */
+static_assert(ALIGN(16, sizeof(struct smbios_entry)) ==
+ ALIGN(16, sizeof(struct smbios3_entry)));
+
/* BIOS characteristics */
#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
#define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
addr = ALIGN(addr, 16);
start_addr = addr;
- addr += sizeof(struct smbios_entry);
+ /*
+ * So far we don't know which struct will be used, but they both end
+ * up using the same amount of 16-bit-aligned space
+ */
+ addr += max(sizeof(struct smbios_entry), sizeof(struct smbios3_entry));
addr = ALIGN(addr, 16);
tables = addr;
* We must use a pointer here so things work correctly on sandbox. The
* user of this table is not aware of the mapping of addresses to
* sandbox's DRAM buffer.
+ *
+ * Check the address of the end of the tables. If it is above 4GB then
+ * it is sensible to use SMBIOS3 even if the start of the table is below
+ * 4GB (this case is very unlikely to happen in practice)
*/
table_addr = (ulong)map_sysmem(tables, 0);
- if (sizeof(table_addr) > sizeof(u32) && table_addr > (ulong)UINT_MAX) {
+ if (sizeof(table_addr) > sizeof(u32) && addr >= (ulong)UINT_MAX) {
+ struct smbios3_entry *se;
/*
* We need to put this >32-bit pointer into the table but the
* field is only 32 bits wide.
*/
- printf("WARNING: SMBIOS table_address overflow %llx\n",
- (unsigned long long)table_addr);
- addr = 0;
+ log_debug("WARNING: Using SMBIOS3.0 due to table-address overflow %lx\n",
+ table_addr);
+ se = map_sysmem(start_addr, sizeof(struct smbios_entry));
+ memset(se, '\0', sizeof(struct smbios_entry));
+ memcpy(se->anchor, "_SM3_", 5);
+ se->length = sizeof(struct smbios3_entry);
+ se->major_ver = SMBIOS_MAJOR_VER;
+ se->minor_ver = SMBIOS_MINOR_VER;
+ se->doc_rev = 0;
+ se->entry_point_rev = 1;
+ se->max_struct_size = len;
+ se->struct_table_address = table_addr;
+ se->checksum = table_compute_checksum(se,
+ sizeof(struct smbios3_entry));
} else {
struct smbios_entry *se;