static int smbios_write_type0(unsigned long *current, int handle) { struct smbios_type0 *t = (struct smbios_type0 *)*current; int len = sizeof(struct smbios_type0); memset(t, 0, sizeof(struct smbios_type0)); t->type = SMBIOS_BIOS_INFORMATION; t->handle = handle; t->length = len - 2; t->vendor = smbios_add_string(t->eos, "coreboot"); #if !IS_ENABLED(CONFIG_CHROMEOS) t->bios_release_date = smbios_add_string(t->eos, coreboot_dmi_date); t->bios_version = smbios_add_string(t->eos, smbios_mainboard_bios_version()); #else #define SPACES \ " " t->bios_release_date = smbios_add_string(t->eos, coreboot_dmi_date); #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) u32 version_offset = (u32)smbios_string_table_len(t->eos); #endif t->bios_version = smbios_add_string(t->eos, SPACES); #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) /* SMBIOS offsets start at 1 rather than 0 */ chromeos_get_chromeos_acpi()->vbt10 = (u32)t->eos + (version_offset - 1); #endif #endif /* CONFIG_CHROMEOS */ /* As a work around to prevent a compiler error, temporarily specify * 16 MiB flash sizes when ROM size >= 16 MiB. An update is necessary * once the SMBIOS specification addresses ROM sizes > 16 MiB. */ uint32_t rom_size = CONFIG_ROM_SIZE; rom_size = MIN(CONFIG_ROM_SIZE, 16 * MiB); t->bios_rom_size = (rom_size / 65535) - 1; t->system_bios_major_release = 4; t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED | BIOS_CHARACTERISTICS_SELECTABLE_BOOT | BIOS_CHARACTERISTICS_UPGRADEABLE; if (IS_ENABLED(CONFIG_CARDBUS_PLUGIN_SUPPORT)) t->bios_characteristics |= BIOS_CHARACTERISTICS_PC_CARD; if (IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)) t->bios_characteristics_ext1 = BIOS_EXT1_CHARACTERISTICS_ACPI; t->bios_characteristics_ext2 = BIOS_EXT2_CHARACTERISTICS_TARGET; len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type0(unsigned long *current, int handle) { struct smbios_type0 *t = (struct smbios_type0 *)*current; int len = sizeof(struct smbios_type0); memset(t, 0, sizeof(struct smbios_type0)); t->type = SMBIOS_BIOS_INFORMATION; t->handle = handle; t->length = len - 2; t->vendor = smbios_add_string(t->eos, "coreboot"); #if !CONFIG_CHROMEOS t->bios_release_date = smbios_add_string(t->eos, COREBOOT_DMI_DATE); if (strlen(CONFIG_LOCALVERSION)) t->bios_version = smbios_add_string(t->eos, CONFIG_LOCALVERSION); else t->bios_version = smbios_add_string(t->eos, COREBOOT_VERSION); #else #define SPACES \ " " t->bios_release_date = smbios_add_string(t->eos, COREBOOT_DMI_DATE); u32 version_offset = (u32)smbios_string_table_len(t->eos); t->bios_version = smbios_add_string(t->eos, SPACES); /* SMBIOS offsets start at 1 rather than 0 */ vboot_data->vbt10 = (u32)t->eos + (version_offset - 1); #endif { const struct cbfs_header *header; u32 romsize = CONFIG_ROM_SIZE; header = cbfs_get_header(CBFS_DEFAULT_MEDIA); if (header != CBFS_HEADER_INVALID_ADDRESS) romsize = ntohl(header->romsize); t->bios_rom_size = (romsize / 65535) - 1; } t->system_bios_major_release = 4; t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED | #if CONFIG_CARDBUS_PLUGIN_SUPPORT BIOS_CHARACTERISTICS_PC_CARD | #endif BIOS_CHARACTERISTICS_SELECTABLE_BOOT | BIOS_CHARACTERISTICS_UPGRADEABLE; #if CONFIG_GENERATE_ACPI_TABLES t->bios_characteristics_ext1 = BIOS_EXT1_CHARACTERISTICS_ACPI; #endif t->bios_characteristics_ext2 = BIOS_EXT2_CHARACTERISTICS_TARGET; len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type0(unsigned long *current, int handle) { struct smbios_type0 *t = (struct smbios_type0 *)*current; int len = sizeof(struct smbios_type0); memset(t, 0, sizeof(struct smbios_type0)); t->type = SMBIOS_BIOS_INFORMATION; t->handle = handle; t->length = len - 2; t->vendor = smbios_add_string(t->eos, "coreboot"); #if !CONFIG_CHROMEOS t->bios_release_date = smbios_add_string(t->eos, coreboot_dmi_date); t->bios_version = smbios_add_string(t->eos, smbios_mainboard_bios_version()); #else #define SPACES \ " " t->bios_release_date = smbios_add_string(t->eos, coreboot_dmi_date); #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) u32 version_offset = (u32)smbios_string_table_len(t->eos); #endif t->bios_version = smbios_add_string(t->eos, SPACES); #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) /* SMBIOS offsets start at 1 rather than 0 */ vboot_data->vbt10 = (u32)t->eos + (version_offset - 1); #endif #endif /* CONFIG_CHROMEOS */ t->bios_rom_size = (CONFIG_ROM_SIZE / 65535) - 1; t->system_bios_major_release = 4; t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED | #if CONFIG_CARDBUS_PLUGIN_SUPPORT BIOS_CHARACTERISTICS_PC_CARD | #endif BIOS_CHARACTERISTICS_SELECTABLE_BOOT | BIOS_CHARACTERISTICS_UPGRADEABLE; #if CONFIG_HAVE_ACPI_TABLES t->bios_characteristics_ext1 = BIOS_EXT1_CHARACTERISTICS_ACPI; #endif t->bios_characteristics_ext2 = BIOS_EXT2_CHARACTERISTICS_TARGET; len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
int smbios_write_type41(unsigned long *current, int *handle, const char *name, u8 instance, u16 segment, u8 bus, u8 device, u8 function) { struct smbios_type41 *t = (struct smbios_type41 *)*current; int len = sizeof(struct smbios_type41); memset(t, 0, sizeof(struct smbios_type41)); t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION; t->handle = *handle; t->length = len - 2; t->reference_designation = smbios_add_string(t->eos, name); t->device_type = SMBIOS_DEVICE_TYPE_OTHER; t->device_status = 1; t->device_type_instance = instance; t->segment_group_number = segment; t->bus_number = bus; t->device_number = device; t->function_number = function; len = t->length + smbios_string_table_len(t->eos); *current += len; *handle += 1; return len; }
static int smbios_write_type4(unsigned long *current, int handle) { struct cpuid_result res; struct smbios_type4 *t = (struct smbios_type4 *)*current; int len = sizeof(struct smbios_type4); /* Provide sane defaults even for CPU without CPUID */ res.eax = res.edx = 0; res.ebx = 0x10000; if (cpu_have_cpuid()) { res = cpuid(1); } memset(t, 0, sizeof(struct smbios_type4)); t->type = SMBIOS_PROCESSOR_INFORMATION; t->handle = handle; t->length = len - 2; t->processor_id[0] = res.eax; t->processor_id[1] = res.edx; t->processor_manufacturer = smbios_cpu_vendor(t->eos); t->processor_version = smbios_processor_name(t->eos); t->processor_family = (res.eax > 0) ? 0x0c : 0x6; t->processor_type = 3; /* System Processor */ t->processor_upgrade = 0x06; t->core_count = (res.ebx >> 16) & 0xff; t->l1_cache_handle = 0xffff; t->l2_cache_handle = 0xffff; t->l3_cache_handle = 0xffff; t->processor_upgrade = 1; len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type11(unsigned long *current, int *handle) { struct smbios_type11 *t = (struct smbios_type11 *)*current; int len; struct device *dev; memset(t, 0, sizeof *t); t->type = SMBIOS_OEM_STRINGS; t->handle = *handle; t->length = len = sizeof *t - 2; for(dev = all_devices; dev; dev = dev->next) { if (dev->ops && dev->ops->get_smbios_strings) dev->ops->get_smbios_strings(dev, t); } if (t->count == 0) { memset(t, 0, sizeof *t); return 0; } len += smbios_string_table_len(t->eos); *current += len; (*handle)++; return len; }
static int smbios_write_type2(unsigned long *current, int handle, const int chassis_handle) { struct smbios_type2 *t = (struct smbios_type2 *)*current; int len = sizeof(struct smbios_type2); memset(t, 0, sizeof(struct smbios_type2)); t->type = SMBIOS_BOARD_INFORMATION; t->handle = handle; t->length = len - 2; t->manufacturer = smbios_add_string(t->eos, smbios_mainboard_manufacturer()); t->product_name = smbios_add_string(t->eos, smbios_mainboard_product_name()); t->serial_number = smbios_add_string(t->eos, smbios_mainboard_serial_number()); t->version = smbios_add_string(t->eos, smbios_mainboard_version()); t->asset_tag = smbios_add_string(t->eos, smbios_mainboard_asset_tag()); t->feature_flags = smbios_mainboard_feature_flags(); t->location_in_chassis = smbios_add_string(t->eos, smbios_mainboard_location_in_chassis()); t->board_type = smbios_mainboard_board_type(); t->chassis_handle = chassis_handle; len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type1(unsigned long *current, int handle) { struct smbios_type1 *t = (struct smbios_type1 *)*current; int len = sizeof(struct smbios_type1); memset(t, 0, sizeof(struct smbios_type1)); t->type = SMBIOS_SYSTEM_INFORMATION; t->handle = handle; t->length = len - 2; t->manufacturer = smbios_add_string(t->eos, smbios_mainboard_manufacturer()); t->product_name = smbios_add_string(t->eos, smbios_mainboard_product_name()); t->serial_number = smbios_add_string(t->eos, smbios_mainboard_serial_number()); t->sku = smbios_add_string(t->eos, smbios_mainboard_sku()); t->version = smbios_add_string(t->eos, smbios_mainboard_version()); #ifdef CONFIG_MAINBOARD_FAMILY t->family = smbios_add_string(t->eos, smbios_mainboard_family()); #endif smbios_mainboard_set_uuid(t->uuid); len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type1(unsigned long *current, int handle) { struct smbios_type1 *t = (struct smbios_type1 *)*current; int len = sizeof(struct smbios_type1); memset(t, 0, sizeof(struct smbios_type1)); t->type = SMBIOS_SYSTEM_INFORMATION; t->handle = handle; t->length = len - 2; t->manufacturer = smbios_add_string(t->eos, CONFIG_MAINBOARD_VENDOR); t->product_name = smbios_add_string(t->eos, CONFIG_MAINBOARD_PART_NUMBER); t->serial_number = smbios_add_string(t->eos, smbios_mainboard_serial_number()); t->version = smbios_add_string(t->eos, smbios_mainboard_version()); len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type2(unsigned long *current, int handle) { struct smbios_type2 *t = (struct smbios_type2 *)*current; int len = sizeof(struct smbios_type2); memset(t, 0, sizeof(struct smbios_type2)); t->type = SMBIOS_BOARD_INFORMATION; t->handle = handle; t->length = len - 2; t->manufacturer = smbios_add_string(t->eos, smbios_mainboard_manufacturer()); t->product_name = smbios_add_string(t->eos, smbios_mainboard_product_name()); t->serial_number = smbios_add_string(t->eos, smbios_mainboard_serial_number()); t->version = smbios_add_string(t->eos, smbios_mainboard_version()); len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type3(unsigned long *current, int handle) { struct smbios_type3 *t = (struct smbios_type3 *)*current; int len = sizeof(struct smbios_type3); memset(t, 0, sizeof(struct smbios_type3)); t->type = SMBIOS_SYSTEM_ENCLOSURE; t->handle = handle; t->length = len - 2; t->manufacturer = smbios_add_string(t->eos, CONFIG_MAINBOARD_VENDOR); t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE; t->thermal_state = SMBIOS_STATE_SAFE; t->_type = 3; t->security_status = SMBIOS_STATE_SAFE; len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int smbios_write_type3(unsigned long *current, int handle) { struct smbios_type3 *t = (struct smbios_type3 *)*current; int len = sizeof(struct smbios_type3); memset(t, 0, sizeof(struct smbios_type3)); t->type = SMBIOS_SYSTEM_ENCLOSURE; t->handle = handle; t->length = len - 2; t->manufacturer = smbios_add_string(t->eos, smbios_mainboard_manufacturer()); t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE; t->thermal_state = SMBIOS_STATE_SAFE; if(IS_ENABLED(CONFIG_SYSTEM_TYPE_LAPTOP)) { t->_type = SMBIOS_ENCLOSURE_NOTEBOOK; } else { t->_type = SMBIOS_ENCLOSURE_DESKTOP; } t->security_status = SMBIOS_STATE_SAFE; len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int qemu_get_smbios_data17(int handle, int parent_handle, unsigned long *current) { struct smbios_type17 *t = (struct smbios_type17 *)*current; int len; memset(t, 0, sizeof(struct smbios_type17)); t->type = SMBIOS_MEMORY_DEVICE; t->handle = handle; t->phys_memory_array_handle = parent_handle; t->length = sizeof(struct smbios_type17) - 2; t->size = qemu_get_memory_size() / 1024; t->data_width = 64; t->total_width = 64; t->form_factor = 9; /* DIMM */ t->device_locator = smbios_add_string(t->eos, "Virtual"); t->memory_type = 0x12; /* DDR */ t->type_detail = 0x80; /* Synchronous */ t->speed = 200; t->clock_speed = 200; t->manufacturer = smbios_add_string(t->eos, CONFIG_MAINBOARD_VENDOR); len = t->length + smbios_string_table_len(t->eos); *current += len; return len; }
static int lumpy_smbios_type41_irq(int *handle, unsigned long *current, const char *name, u8 irq, u8 addr) { struct smbios_type41 *t = (struct smbios_type41 *)*current; int len = sizeof(struct smbios_type41); memset(t, 0, sizeof(struct smbios_type41)); t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION; t->handle = *handle; t->length = len - 2; t->reference_designation = smbios_add_string(t->eos, name); t->device_type = SMBIOS_DEVICE_TYPE_OTHER; t->device_status = 1; t->device_type_instance = irq; t->segment_group_number = 0; t->bus_number = addr; t->function_number = 0; t->device_number = 0; len = t->length + smbios_string_table_len(t->eos); *current += len; *handle += 1; return len; }
static int create_smbios_type17_for_dimm(struct dimm_info *dimm, unsigned long *current, int *handle) { struct smbios_type17 *t = (struct smbios_type17 *)*current; uint8_t length; char locator[40]; memset(t, 0, sizeof(struct smbios_type17)); t->memory_type = dimm->ddr_type; t->clock_speed = dimm->ddr_frequency; t->speed = dimm->ddr_frequency; t->type = SMBIOS_MEMORY_DEVICE; t->size = dimm->dimm_size; t->data_width = 8 * (1 << (dimm->bus_width & 0x7)); t->total_width = t->data_width + 8 * ((dimm->bus_width & 0x18) >> 3); switch (dimm->mod_type) { case SPD_RDIMM: case SPD_MINI_RDIMM: t->form_factor = MEMORY_FORMFACTOR_RIMM; break; case SPD_UDIMM: case SPD_MICRO_DIMM: case SPD_MINI_UDIMM: t->form_factor = MEMORY_FORMFACTOR_DIMM; break; case SPD_SODIMM: t->form_factor = MEMORY_FORMFACTOR_SODIMM; break; default: t->form_factor = MEMORY_FORMFACTOR_UNKNOWN; break; } smbios_fill_dimm_manufacturer_from_id(dimm->mod_id, t); /* put '\0' in the end of data */ length = sizeof(dimm->serial); dimm->serial[length - 1] = '\0'; if (dimm->serial[0] == 0) t->serial_number = smbios_add_string(t->eos, "None"); else t->serial_number = smbios_add_string(t->eos, (const char *)dimm->serial); snprintf(locator, sizeof(locator), "Channel-%d-DIMM-%d", dimm->channel_num, dimm->dimm_num); t->device_locator = smbios_add_string(t->eos, locator); snprintf(locator, sizeof(locator), "BANK %d", dimm->bank_locator); t->bank_locator = smbios_add_string(t->eos, locator); /* put '\0' in the end of data */ length = sizeof(dimm->module_part_number); dimm->module_part_number[length - 1] = '\0'; t->part_number = smbios_add_string(t->eos, (const char *)dimm->module_part_number); /* Synchronous = 1 */ t->type_detail = 0x0080; /* no handle for error information */ t->memory_error_information_handle = 0xFFFE; t->attributes = dimm->rank_per_dimm; t->handle = *handle; *handle += 1; t->length = sizeof(struct smbios_type17) - 2; return t->length + smbios_string_table_len(t->eos); }