[PATCH] dmi: dmi_decode: check type 3 chassis type with acpi preferred_pm_profile

Colin Ian King colin.king at canonical.com
Wed Feb 1 14:47:17 UTC 2012


On 01/02/12 06:32, Alex Hung wrote:
> Signed-off-by: Alex Hung<alex.hung at canonical.com>
> ---
>   src/dmi/dmi_decode/dmi_decode.c |   88 +++++++++++++++++++++++++++++++++++++++
>   src/lib/include/fwts_acpi.h     |   10 ++++
>   src/lib/include/fwts_smbios.h   |   31 ++++++++++++++
>   3 files changed, 129 insertions(+), 0 deletions(-)
>
> diff --git a/src/dmi/dmi_decode/dmi_decode.c b/src/dmi/dmi_decode/dmi_decode.c
> index c922ee4..ffb75b2 100644
> --- a/src/dmi/dmi_decode/dmi_decode.c
> +++ b/src/dmi/dmi_decode/dmi_decode.c
> @@ -55,6 +55,12 @@
>   #define GET_UINT32(x) (uint32_t)(*(const uint32_t *)(x))
>   #define GET_UINT64(x) (uint64_t)(*(const uint64_t *)(x))
>
> +#define CHASSIS_OTHER			0x00
> +#define CHASSIS_DESKTOP			0x01
> +#define CHASSIS_WORKSTATION		0x02
> +#define CHASSIS_MOBILE			0x04
> +#define CHASSIS_SERVER			0x08
> +
>   typedef struct {
>   	const char *label;
>   	const char *field;
> @@ -66,6 +72,11 @@ typedef struct {
>   	uint16_t   new;
>   } fwts_dmi_version;
>
> +typedef struct {
> +	uint8_t   original;
> +	uint8_t   mapped;
> +} fwts_chassis_type_map;
> +
>   static const fwts_dmi_pattern dmi_patterns[] = {
>   	{ "DMISerialNumber",	"Serial Number", 	"0123456789" },
>   	{ "DMIAssetTag",	"Asset Tag",		"1234567890" },
> @@ -78,6 +89,51 @@ static const char *uuid_patterns[] = {
>   	NULL,
>   };
>
> +static const fwts_chassis_type_map fwts_dmi_chassis_type[] = {
> +	{ FWTS_SMBIOS_CHASSIS_INVALID,			CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_OTHER,			CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_UNKNOWN,			CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_DESKTOP,			CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_LOW_PROFILE_DESKTOP,	CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_PIZZA_BOX,		CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_MINI_TOWER,		CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_TOWER,			CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_PORTABLE,			CHASSIS_MOBILE },
> +	{ FWTS_SMBIOS_CHASSIS_LAPTOP,			CHASSIS_MOBILE },
> +	{ FWTS_SMBIOS_CHASSIS_NOTEBOOK,			CHASSIS_MOBILE },
> +	{ FWTS_SMBIOS_CHASSIS_HANDHELD,			CHASSIS_MOBILE },
> +	{ FWTS_SMBIOS_CHASSIS_DOCKING_STATION,		CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_ALL_IN_ONE,		CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_SUB_NOTEBOOK,		CHASSIS_MOBILE },
> +	{ FWTS_SMBIOS_CHASSIS_SPACE_SAVING,		CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_LUNCH_BOX,		CHASSIS_DESKTOP | CHASSIS_MOBILE},
> +	{ FWTS_SMBIOS_CHASSIS_MAIN_SERVER_CHASSIS,	CHASSIS_SERVER },
> +	{ FWTS_SMBIOS_CHASSIS_EXPANISON_CHASSIS,	CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_SUB_CHASSIS,		CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_BUS_EXPANSION_CHASSIS,	CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_PERIPHERAL_CHASSIS,	CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_RAID_CHASSIS,		CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_RACK_MOUNT_CHASSIS,	CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_SEALED_CASE_PC,		CHASSIS_DESKTOP },
> +	{ FWTS_SMBIOS_CHASSIS_MULTI_SYSTEM_CHASSIS,	CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_COMPACT_PCI,		CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_ADVANCED_TCA,		CHASSIS_OTHER },
> +	{ FWTS_SMBIOS_CHASSIS_BLADE,			CHASSIS_SERVER },
> +	{ FWTS_SMBIOS_CHASSIS_BLASE_ENCLOSURE,		CHASSIS_SERVER }
> +};
> +
> +static const fwts_chassis_type_map fwts_acpi_pm_profile_type[] = {
> +	{ FWTS_FACP_UNSPECIFIED,	CHASSIS_OTHER },
> +	{ FWTS_FACP_DESKTOP,		CHASSIS_DESKTOP },
> +	{ FWTS_FACP_MOBILE,		CHASSIS_MOBILE },
> +	{ FWTS_FACP_WORKSTATION,	CHASSIS_WORKSTATION },
> +	{ FWTS_FACP_ENTERPRISE_SERVER,	CHASSIS_SERVER },
> +	{ FWTS_FACP_SOHO_SERVER,	CHASSIS_SERVER | CHASSIS_DESKTOP },
> +	{ FWTS_FACP_APPLIANCE_PC,	CHASSIS_DESKTOP },
> +	{ FWTS_FACP_PERFORMANCE_SERVER,	CHASSIS_SERVER },
> +	{ FWTS_FACP_TABLET,		CHASSIS_MOBILE }
> +};
> +
>   /* Remapping table from buggy version numbers to correct values */
>   static const fwts_dmi_version dmi_versions[] = {
>   	{ 0x021f, 0x0203 },
> @@ -244,6 +300,8 @@ static void dmi_decode_entry(fwts_framework *fw,
>   	int	failed_count = fw->minor_tests.failed;
>   	int	battery_count;
>   	int	ret;
> +	fwts_acpi_table_info *acpi_table;
> +	fwts_acpi_table_fadt *fadt;
>
>   	switch (hdr->type) {
>   		case 0: /* 7.1 */
> @@ -296,6 +354,36 @@ static void dmi_decode_entry(fwts_framework *fw,
>   				break;
>   			dmi_str_check(fw, table, addr, "Manufacturer", hdr, 0x4);
>   			dmi_min_max_mask_uint8_check(fw, table, addr, "Chassis Type", hdr, 0x5, 0x1, 0x1d, 0x0, 0x7f);
> +			if (fwts_acpi_find_table(fw, "FACP", 0,&acpi_table) != FWTS_OK)
> +				break;
> +			if (acpi_table == NULL)
> +				break;
> +			fadt = (fwts_acpi_table_fadt *)acpi_table->data;
> +			if (fadt->preferred_pm_profile>=
> +				(sizeof(fwts_acpi_pm_profile_type) / sizeof(fwts_chassis_type_map))) {
> +				fwts_failed(fw, LOG_LEVEL_HIGH, DMI_INVALID_HARDWARE_ENTRY,
> +					"Incorrect Chassis Type "
> +					"ACPI FACP reports %x",
> +					fadt->preferred_pm_profile);
> +				break;
> +			}
> +			if (data[5]>=
> +				(sizeof(fwts_dmi_chassis_type) / sizeof(fwts_chassis_type_map))) {
> +				fwts_failed(fw, LOG_LEVEL_HIGH, DMI_INVALID_HARDWARE_ENTRY,
> +					"Incorrect Chassis Type "
> +					"SMBIOS Type 3 reports %x ",
> +					data[5]);
> +				break;
> +			}
> +			if (!(fwts_acpi_pm_profile_type[fadt->preferred_pm_profile].mapped&
> +			    fwts_dmi_chassis_type[data[5]].mapped)) {
> +				fwts_failed(fw, LOG_LEVEL_HIGH, DMI_INVALID_HARDWARE_ENTRY,
> +					"Unmatched Chassis Type "
> +					"SMBIOS Type 3 reports %x "
> +					"ACPI FACP reports %x",
> +					data[5],
> +					fadt->preferred_pm_profile);
> +			}
>   			dmi_min_max_mask_uint8_check(fw, table, addr, "Chassis Lock", hdr, 0x5, 0x0, 0x1, 0x7, 0x1);
>   			dmi_str_check(fw, table, addr, "Version", hdr, 0x6);
>   			dmi_str_check(fw, table, addr, "Serial Number", hdr, 0x7);
> diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
> index d9f74c4..5b85dc5 100644
> --- a/src/lib/include/fwts_acpi.h
> +++ b/src/lib/include/fwts_acpi.h
> @@ -22,6 +22,16 @@
>
>   #define FWTS_ACPI_TABLES_PATH   "/sys/firmware/acpi/tables"
>
> +#define FWTS_FACP_UNSPECIFIED		(0x00)
> +#define FWTS_FACP_DESKTOP		(0x01)
> +#define FWTS_FACP_MOBILE		(0x02)
> +#define FWTS_FACP_WORKSTATION		(0x03)
> +#define FWTS_FACP_ENTERPRISE_SERVER	(0x04)
> +#define FWTS_FACP_SOHO_SERVER		(0x05)
> +#define FWTS_FACP_APPLIANCE_PC		(0x06)
> +#define FWTS_FACP_PERFORMANCE_SERVER	(0x07)
> +#define FWTS_FACP_TABLET		(0x08)
> +
>   #define FWTS_FACP_IAPC_BOOT_ARCH_LEGACY_DEVICES		(0x0001)
>   #define FWTS_FACP_IAPC_BOOT_ARCH_8042			(0x0002)
>   #define FWTS_FACP_IAPC_BOOT_ARCH_VGA_NOT_PRESENT	(0x0004)
> diff --git a/src/lib/include/fwts_smbios.h b/src/lib/include/fwts_smbios.h
> index b63fe36..98479b5 100644
> --- a/src/lib/include/fwts_smbios.h
> +++ b/src/lib/include/fwts_smbios.h
> @@ -27,6 +27,37 @@
>   #define FWTS_SMBIOS_REGION_END       (0x000fffff)
>   #define FWTS_SMBIOS_REGION_SIZE      (FWTS_SMBIOS_REGION_END - FWTS_SMBIOS_REGION_START)
>
> +#define FWTS_SMBIOS_CHASSIS_INVALID			(0x00)
> +#define FWTS_SMBIOS_CHASSIS_OTHER			(0X01)
> +#define FWTS_SMBIOS_CHASSIS_UNKNOWN			(0x02)
> +#define FWTS_SMBIOS_CHASSIS_DESKTOP			(0x03)
> +#define FWTS_SMBIOS_CHASSIS_LOW_PROFILE_DESKTOP		(0x04)
> +#define FWTS_SMBIOS_CHASSIS_PIZZA_BOX			(0x05)
> +#define FWTS_SMBIOS_CHASSIS_MINI_TOWER			(0x06)
> +#define FWTS_SMBIOS_CHASSIS_TOWER			(0x07)
> +#define FWTS_SMBIOS_CHASSIS_PORTABLE			(0x08)
> +#define FWTS_SMBIOS_CHASSIS_LAPTOP			(0x09)
> +#define FWTS_SMBIOS_CHASSIS_NOTEBOOK			(0x0A)
> +#define FWTS_SMBIOS_CHASSIS_HANDHELD			(0x0B)
> +#define FWTS_SMBIOS_CHASSIS_DOCKING_STATION		(0x0C)
> +#define FWTS_SMBIOS_CHASSIS_ALL_IN_ONE			(0x0D)
> +#define FWTS_SMBIOS_CHASSIS_SUB_NOTEBOOK		(0x0E)
> +#define FWTS_SMBIOS_CHASSIS_SPACE_SAVING		(0x0F)
> +#define FWTS_SMBIOS_CHASSIS_LUNCH_BOX			(0x10)
> +#define FWTS_SMBIOS_CHASSIS_MAIN_SERVER_CHASSIS		(0x11)
> +#define FWTS_SMBIOS_CHASSIS_EXPANISON_CHASSIS		(0x12)
> +#define FWTS_SMBIOS_CHASSIS_SUB_CHASSIS			(0x13)
> +#define FWTS_SMBIOS_CHASSIS_BUS_EXPANSION_CHASSIS	(0x14)
> +#define FWTS_SMBIOS_CHASSIS_PERIPHERAL_CHASSIS		(0x15)
> +#define FWTS_SMBIOS_CHASSIS_RAID_CHASSIS		(0x16)
> +#define FWTS_SMBIOS_CHASSIS_RACK_MOUNT_CHASSIS		(0x17)
> +#define FWTS_SMBIOS_CHASSIS_SEALED_CASE_PC		(0x18)
> +#define FWTS_SMBIOS_CHASSIS_MULTI_SYSTEM_CHASSIS	(0x19)
> +#define FWTS_SMBIOS_CHASSIS_COMPACT_PCI			(0x1A)
> +#define FWTS_SMBIOS_CHASSIS_ADVANCED_TCA		(0x1B)
> +#define FWTS_SMBIOS_CHASSIS_BLADE			(0x1C)
> +#define FWTS_SMBIOS_CHASSIS_BLASE_ENCLOSURE		(0x1D)
> +
>   typedef enum {
>   	FWTS_SMBIOS_UNKNOWN = -1,
>   	FWTS_SMBIOS_DMI_LEGACY = 0,

Acked-by: Colin King <colin.king at canonical.com>




More information about the fwts-devel mailing list