From 01a8520fc9941dce458f75b40aab349a3a797e3e Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 18 Oct 2009 09:49:59 -0400 Subject: [PATCH] Move smbios definitions to header file; fix compile on older gcc. The build with old versions of gcc can't handle duplicate struct definitions. So, move smbios defs to common header. --- src/coreboot.c | 1 + src/paravirt.c | 14 ++-- src/post.c | 3 +- src/smbios.c | 171 +------------------------------------------------ src/smbios.h | 166 +++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 3 - 6 files changed, 175 insertions(+), 183 deletions(-) create mode 100644 src/smbios.h diff --git a/src/coreboot.c b/src/coreboot.c index 8ba3fe7..7e0e361 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -11,6 +11,7 @@ #include "mptable.h" // MPTABLE_SIGNATURE #include "biosvar.h" // GET_EBDA #include "lzmadecode.h" // LzmaDecode +#include "smbios.h" // smbios_init /**************************************************************** diff --git a/src/paravirt.c b/src/paravirt.c index da5923b..6f48d2e 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -7,9 +7,10 @@ // // This file may be distributed under the terms of the GNU LGPLv3 license. -#include "config.h" -#include "ioport.h" -#include "paravirt.h" +#include "config.h" // CONFIG_COREBOOT +#include "ioport.h" // outw +#include "paravirt.h" // qemu_cfg_port_probe +#include "smbios.h" // struct smbios_structure_header int qemu_cfg_present; @@ -180,13 +181,6 @@ size_t qemu_cfg_smbios_load_field(int type, size_t offset, void *addr) return 0; } -/* This goes at the beginning of every SMBIOS structure. */ -struct smbios_structure_header { - u8 type; - u8 length; - u16 handle; -} PACKED; - int qemu_cfg_smbios_load_external(int type, char **p, unsigned *nr_structs, unsigned *max_struct_size, char *end) { diff --git a/src/post.c b/src/post.c index 674f402..a566b34 100644 --- a/src/post.c +++ b/src/post.c @@ -20,7 +20,8 @@ #include "mptable.h" // mptable_init #include "boot.h" // IPL #include "usb.h" // usb_setup -#include "paravirt.h" +#include "smbios.h" // smbios_init +#include "paravirt.h" // qemu_cfg_port_probe void __set_irq(int vector, void *loc) diff --git a/src/smbios.c b/src/smbios.c index ad0d0c4..f1b43f2 100644 --- a/src/smbios.c +++ b/src/smbios.c @@ -7,175 +7,8 @@ #include "util.h" // dprintf #include "biosvar.h" // GET_EBDA -#include "paravirt.h" - -/**************************************************************** - * smbios tables - ****************************************************************/ - -/* SMBIOS entry point -- must be written to a 16-bit aligned address - between 0xf0000 and 0xfffff. - */ -struct smbios_entry_point { - char anchor_string[4]; - u8 checksum; - u8 length; - u8 smbios_major_version; - u8 smbios_minor_version; - u16 max_structure_size; - u8 entry_point_revision; - u8 formatted_area[5]; - char intermediate_anchor_string[5]; - u8 intermediate_checksum; - u16 structure_table_length; - u32 structure_table_address; - u16 number_of_structures; - u8 smbios_bcd_revision; -} PACKED; - -/* This goes at the beginning of every SMBIOS structure. */ -struct smbios_structure_header { - u8 type; - u8 length; - u16 handle; -} PACKED; - -/* SMBIOS type 0 - BIOS Information */ -struct smbios_type_0 { - struct smbios_structure_header header; - u8 vendor_str; - u8 bios_version_str; - u16 bios_starting_address_segment; - u8 bios_release_date_str; - u8 bios_rom_size; - u8 bios_characteristics[8]; - u8 bios_characteristics_extension_bytes[2]; - u8 system_bios_major_release; - u8 system_bios_minor_release; - u8 embedded_controller_major_release; - u8 embedded_controller_minor_release; -} PACKED; - -/* SMBIOS type 1 - System Information */ -struct smbios_type_1 { - struct smbios_structure_header header; - u8 manufacturer_str; - u8 product_name_str; - u8 version_str; - u8 serial_number_str; - u8 uuid[16]; - u8 wake_up_type; - u8 sku_number_str; - u8 family_str; -} PACKED; - -/* SMBIOS type 3 - System Enclosure (v2.3) */ -struct smbios_type_3 { - struct smbios_structure_header header; - u8 manufacturer_str; - u8 type; - u8 version_str; - u8 serial_number_str; - u8 asset_tag_number_str; - u8 boot_up_state; - u8 power_supply_state; - u8 thermal_state; - u8 security_status; - u32 oem_defined; - u8 height; - u8 number_of_power_cords; - u8 contained_element_count; - // contained elements follow -} PACKED; - -/* SMBIOS type 4 - Processor Information (v2.0) */ -struct smbios_type_4 { - struct smbios_structure_header header; - u8 socket_designation_str; - u8 processor_type; - u8 processor_family; - u8 processor_manufacturer_str; - u32 processor_id[2]; - u8 processor_version_str; - u8 voltage; - u16 external_clock; - u16 max_speed; - u16 current_speed; - u8 status; - u8 processor_upgrade; - u16 l1_cache_handle; - u16 l2_cache_handle; - u16 l3_cache_handle; -} PACKED; - -/* SMBIOS type 16 - Physical Memory Array - * Associated with one type 17 (Memory Device). - */ -struct smbios_type_16 { - struct smbios_structure_header header; - u8 location; - u8 use; - u8 error_correction; - u32 maximum_capacity; - u16 memory_error_information_handle; - u16 number_of_memory_devices; -} PACKED; - -/* SMBIOS type 17 - Memory Device - * Associated with one type 19 - */ -struct smbios_type_17 { - struct smbios_structure_header header; - u16 physical_memory_array_handle; - u16 memory_error_information_handle; - u16 total_width; - u16 data_width; - u16 size; - u8 form_factor; - u8 device_set; - u8 device_locator_str; - u8 bank_locator_str; - u8 memory_type; - u16 type_detail; -} PACKED; - -/* SMBIOS type 19 - Memory Array Mapped Address */ -struct smbios_type_19 { - struct smbios_structure_header header; - u32 starting_address; - u32 ending_address; - u16 memory_array_handle; - u8 partition_width; -} PACKED; - -/* SMBIOS type 20 - Memory Device Mapped Address */ -struct smbios_type_20 { - struct smbios_structure_header header; - u32 starting_address; - u32 ending_address; - u16 memory_device_handle; - u16 memory_array_mapped_address_handle; - u8 partition_row_position; - u8 interleave_position; - u8 interleaved_data_depth; -} PACKED; - -/* SMBIOS type 32 - System Boot Information */ -struct smbios_type_32 { - struct smbios_structure_header header; - u8 reserved[6]; - u8 boot_status; -} PACKED; - -/* SMBIOS type 127 -- End-of-table */ -struct smbios_type_127 { - struct smbios_structure_header header; -} PACKED; - - -/**************************************************************** - * smbios init - ****************************************************************/ +#include "paravirt.h" // qemu_cfg_smbios_load_field +#include "smbios.h" // struct smbios_entry_point static void smbios_entry_point_init(u16 max_structure_size, diff --git a/src/smbios.h b/src/smbios.h new file mode 100644 index 0000000..7bf2bed --- /dev/null +++ b/src/smbios.h @@ -0,0 +1,166 @@ +#ifndef __SMBIOS_H +#define __SMBIOS_H + +// smbios.c +void smbios_init(void); + +/* SMBIOS entry point -- must be written to a 16-bit aligned address + between 0xf0000 and 0xfffff. + */ +struct smbios_entry_point { + char anchor_string[4]; + u8 checksum; + u8 length; + u8 smbios_major_version; + u8 smbios_minor_version; + u16 max_structure_size; + u8 entry_point_revision; + u8 formatted_area[5]; + char intermediate_anchor_string[5]; + u8 intermediate_checksum; + u16 structure_table_length; + u32 structure_table_address; + u16 number_of_structures; + u8 smbios_bcd_revision; +} PACKED; + +/* This goes at the beginning of every SMBIOS structure. */ +struct smbios_structure_header { + u8 type; + u8 length; + u16 handle; +} PACKED; + +/* SMBIOS type 0 - BIOS Information */ +struct smbios_type_0 { + struct smbios_structure_header header; + u8 vendor_str; + u8 bios_version_str; + u16 bios_starting_address_segment; + u8 bios_release_date_str; + u8 bios_rom_size; + u8 bios_characteristics[8]; + u8 bios_characteristics_extension_bytes[2]; + u8 system_bios_major_release; + u8 system_bios_minor_release; + u8 embedded_controller_major_release; + u8 embedded_controller_minor_release; +} PACKED; + +/* SMBIOS type 1 - System Information */ +struct smbios_type_1 { + struct smbios_structure_header header; + u8 manufacturer_str; + u8 product_name_str; + u8 version_str; + u8 serial_number_str; + u8 uuid[16]; + u8 wake_up_type; + u8 sku_number_str; + u8 family_str; +} PACKED; + +/* SMBIOS type 3 - System Enclosure (v2.3) */ +struct smbios_type_3 { + struct smbios_structure_header header; + u8 manufacturer_str; + u8 type; + u8 version_str; + u8 serial_number_str; + u8 asset_tag_number_str; + u8 boot_up_state; + u8 power_supply_state; + u8 thermal_state; + u8 security_status; + u32 oem_defined; + u8 height; + u8 number_of_power_cords; + u8 contained_element_count; + // contained elements follow +} PACKED; + +/* SMBIOS type 4 - Processor Information (v2.0) */ +struct smbios_type_4 { + struct smbios_structure_header header; + u8 socket_designation_str; + u8 processor_type; + u8 processor_family; + u8 processor_manufacturer_str; + u32 processor_id[2]; + u8 processor_version_str; + u8 voltage; + u16 external_clock; + u16 max_speed; + u16 current_speed; + u8 status; + u8 processor_upgrade; + u16 l1_cache_handle; + u16 l2_cache_handle; + u16 l3_cache_handle; +} PACKED; + +/* SMBIOS type 16 - Physical Memory Array + * Associated with one type 17 (Memory Device). + */ +struct smbios_type_16 { + struct smbios_structure_header header; + u8 location; + u8 use; + u8 error_correction; + u32 maximum_capacity; + u16 memory_error_information_handle; + u16 number_of_memory_devices; +} PACKED; + +/* SMBIOS type 17 - Memory Device + * Associated with one type 19 + */ +struct smbios_type_17 { + struct smbios_structure_header header; + u16 physical_memory_array_handle; + u16 memory_error_information_handle; + u16 total_width; + u16 data_width; + u16 size; + u8 form_factor; + u8 device_set; + u8 device_locator_str; + u8 bank_locator_str; + u8 memory_type; + u16 type_detail; +} PACKED; + +/* SMBIOS type 19 - Memory Array Mapped Address */ +struct smbios_type_19 { + struct smbios_structure_header header; + u32 starting_address; + u32 ending_address; + u16 memory_array_handle; + u8 partition_width; +} PACKED; + +/* SMBIOS type 20 - Memory Device Mapped Address */ +struct smbios_type_20 { + struct smbios_structure_header header; + u32 starting_address; + u32 ending_address; + u16 memory_device_handle; + u16 memory_array_mapped_address_handle; + u8 partition_row_position; + u8 interleave_position; + u8 interleaved_data_depth; +} PACKED; + +/* SMBIOS type 32 - System Boot Information */ +struct smbios_type_32 { + struct smbios_structure_header header; + u8 reserved[6]; + u8 boot_status; +} PACKED; + +/* SMBIOS type 127 -- End-of-table */ +struct smbios_type_127 { + struct smbios_structure_header header; +} PACKED; + +#endif // smbios.h diff --git a/src/util.h b/src/util.h index 9380190..6cf27ac 100644 --- a/src/util.h +++ b/src/util.h @@ -246,9 +246,6 @@ void wrmsr_smp(u32 index, u64 val); void smp_probe(void); void smp_probe_setup(void); -// smbios.c -void smbios_init(void); - // coreboot.c struct cbfs_file; struct cbfs_file *cbfs_findprefix(const char *prefix, struct cbfs_file *last); -- 2.39.5