SMBIOS: Introduce struct for SMBIOS table header

All SMBIOS `type X` tables start with the same 4-byte header. Add a
struct definition for it, and use it where applicable. The union is
temporary and allows doing the necessary changes in smaller commits.

Change-Id: Ibd9a80010f83fd7ebefc014b981d430f5723808c
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55906
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
Angel Pons 2021-06-28 16:06:28 +02:00 committed by Patrick Georgi
parent 631cd29efb
commit ca01baa065
2 changed files with 148 additions and 52 deletions

View File

@ -10,9 +10,14 @@
static int smbios_write_intel_wifi(struct device *dev, int *handle, unsigned long *current) static int smbios_write_intel_wifi(struct device *dev, int *handle, unsigned long *current)
{ {
struct smbios_type_intel_wifi { struct smbios_type_intel_wifi {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 str; u8 str;
u8 eos[2]; u8 eos[2];
} __packed; } __packed;

View File

@ -276,10 +276,21 @@ struct smbios_entry30 {
u64 struct_table_address; u64 struct_table_address;
} __packed; } __packed;
struct smbios_type0 { struct smbios_header {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
} __packed;
struct smbios_type0 {
union {
struct {
u8 type;
u8 length;
u16 handle;
};
struct smbios_header header;
};
u8 vendor; u8 vendor;
u8 bios_version; u8 bios_version;
u16 bios_start_segment; u16 bios_start_segment;
@ -297,9 +308,14 @@ struct smbios_type0 {
} __packed; } __packed;
struct smbios_type1 { struct smbios_type1 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 manufacturer; u8 manufacturer;
u8 product_name; u8 product_name;
u8 version; u8 version;
@ -334,9 +350,14 @@ typedef enum {
} smbios_board_type; } smbios_board_type;
struct smbios_type2 { struct smbios_type2 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 manufacturer; u8 manufacturer;
u8 product_name; u8 product_name;
u8 version; u8 version;
@ -389,9 +410,14 @@ typedef enum {
} smbios_enclosure_type; } smbios_enclosure_type;
struct smbios_type3 { struct smbios_type3 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 manufacturer; u8 manufacturer;
u8 _type; u8 _type;
u8 version; u8 version;
@ -411,9 +437,14 @@ struct smbios_type3 {
} __packed; } __packed;
struct smbios_type4 { struct smbios_type4 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 socket_designation; u8 socket_designation;
u8 processor_type; u8 processor_type;
u8 processor_family; u8 processor_family;
@ -524,9 +555,14 @@ enum smbios_cache_associativity {
#define SMBIOS_CACHE_OP_MODE_UNKNOWN 3 #define SMBIOS_CACHE_OP_MODE_UNKNOWN 3
struct smbios_type7 { struct smbios_type7 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 socket_designation; u8 socket_designation;
u16 cache_configuration; u16 cache_configuration;
u16 max_cache_size; u16 max_cache_size;
@ -640,9 +676,14 @@ struct port_information {
}; };
struct smbios_type8 { struct smbios_type8 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 internal_reference_designator; u8 internal_reference_designator;
u8 internal_connector_type; u8 internal_connector_type;
u8 external_reference_designator; u8 external_reference_designator;
@ -777,9 +818,14 @@ struct slot_peer_groups {
} __packed; } __packed;
struct smbios_type9 { struct smbios_type9 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 slot_designation; u8 slot_designation;
u8 slot_type; u8 slot_type;
u8 slot_data_bus_width; u8 slot_data_bus_width;
@ -798,17 +844,27 @@ struct smbios_type9 {
} __packed; } __packed;
struct smbios_type11 { struct smbios_type11 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 count; u8 count;
u8 eos[2]; u8 eos[2];
} __packed; } __packed;
struct smbios_type15 { struct smbios_type15 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u16 area_length; u16 area_length;
u16 header_offset; u16 header_offset;
u16 data_offset; u16 data_offset;
@ -838,9 +894,14 @@ enum {
#define SMBIOS_USE_EXTENDED_MAX_CAPACITY (1 << 31) #define SMBIOS_USE_EXTENDED_MAX_CAPACITY (1 << 31)
struct smbios_type16 { struct smbios_type16 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 location; u8 location;
u8 use; u8 use;
u8 memory_error_correction; u8 memory_error_correction;
@ -852,9 +913,14 @@ struct smbios_type16 {
} __packed; } __packed;
struct smbios_type17 { struct smbios_type17 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u16 phys_memory_array_handle; u16 phys_memory_array_handle;
u16 memory_error_information_handle; u16 memory_error_information_handle;
u16 total_width; u16 total_width;
@ -881,9 +947,14 @@ struct smbios_type17 {
} __packed; } __packed;
struct smbios_type19 { struct smbios_type19 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u32 starting_address; u32 starting_address;
u32 ending_address; u32 ending_address;
u16 memory_array_handle; u16 memory_array_handle;
@ -894,18 +965,28 @@ struct smbios_type19 {
} __packed; } __packed;
struct smbios_type32 { struct smbios_type32 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 reserved[6]; u8 reserved[6];
u8 boot_status; u8 boot_status;
u8 eos[2]; u8 eos[2];
} __packed; } __packed;
struct smbios_type38 { struct smbios_type38 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 interface_type; u8 interface_type;
u8 ipmi_rev; u8 ipmi_rev;
u8 i2c_slave_addr; u8 i2c_slave_addr;
@ -940,9 +1021,14 @@ typedef enum {
#define SMBIOS_DEVICE_TYPE_COUNT 10 #define SMBIOS_DEVICE_TYPE_COUNT 10
struct smbios_type41 { struct smbios_type41 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 reference_designation; u8 reference_designation;
u8 device_type: 7; u8 device_type: 7;
u8 device_status: 1; u8 device_status: 1;
@ -955,9 +1041,14 @@ struct smbios_type41 {
} __packed; } __packed;
struct smbios_type127 { struct smbios_type127 {
union {
struct {
u8 type; u8 type;
u8 length; u8 length;
u16 handle; u16 handle;
};
struct smbios_header header;
};
u8 eos[2]; u8 eos[2];
} __packed; } __packed;