Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/64035 )
Change subject: arch/x86/smbios.c: Allow creating entries for empty DIMM slots ......................................................................
arch/x86/smbios.c: Allow creating entries for empty DIMM slots
Properly handle meminfo DIMMs with `dimm_size` of 0, which represent empty slots. This allows platform code to create dummy meminfo DIMMs so that SMBIOS tables have type 17 entries for empty DIMM slots.
Change-Id: I17ae83edf94483bd2eeef5524ff82721c196b8ba Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/arch/x86/smbios.c 1 file changed, 34 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/64035/1
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index c48ce86..c0057b6 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -277,6 +277,30 @@ return smbios_full_table_len(&t->header, t->eos); }
+static int create_smbios_type17_for_empty_slot(struct dimm_info *dimm, + unsigned long *current, int *handle, + int type16_handle) +{ + struct smbios_type17 *t = smbios_carve_table(*current, SMBIOS_MEMORY_DEVICE, + sizeof(*t), *handle); + t->phys_memory_array_handle = type16_handle; + /* no handle for error information */ + t->memory_error_information_handle = 0xfffe; + t->total_width = 0xffff; /* Unknown */ + t->data_width = 0xffff; /* Unknown */ + t->form_factor = 0x2; /* Unknown */ + smbios_fill_dimm_locator(dimm, t); /* Device and Bank */ + t->memory_type = 0x2; /* Unknown */ + t->type_detail = 0x2; /* Unknown */ + t->manufacturer = smbios_add_string(t->eos, "NO DIMM"); + t->serial_number = smbios_add_string(t->eos, "NO DIMM"); + t->asset_tag = smbios_add_string(t->eos, "NO DIMM"); + t->part_number = smbios_add_string(t->eos, "NO DIMM"); + + *handle += 1; + return smbios_full_table_len(&t->header, t->eos); +} + #define VERSION_VPD "firmware_version" static const char *vpd_get_bios_version(void) { @@ -944,15 +968,19 @@
printk(BIOS_INFO, "Create SMBIOS type 17\n"); for (i = 0; i < meminfo->dimm_cnt && i < ARRAY_SIZE(meminfo->dimm); i++) { - struct dimm_info *dimm; - dimm = &meminfo->dimm[i]; + struct dimm_info *d = &meminfo->dimm[i]; /* * Windows 10 GetPhysicallyInstalledSystemMemory functions reads SMBIOS tables * type 16 and type 17. The type 17 tables need to point to a type 16 table. * Otherwise, the physical installed memory size is guessed from the system * memory map, which results in a slightly smaller value than the actual size. */ - const int len = create_smbios_type17_for_dimm(dimm, current, handle, type16); + int len; + if (d->dimm_size > 0) + len = create_smbios_type17_for_dimm(d, current, handle, type16); + else + len = create_smbios_type17_for_empty_slot(d, current, handle, type16); + *current += len; totallen += len; } @@ -1043,6 +1071,9 @@ for (i = 0; i < meminfo->dimm_cnt && i < ARRAY_SIZE(meminfo->dimm); i++) { struct dimm_info *dimm; dimm = &meminfo->dimm[i]; + if (dimm->dimm_size == 0) + continue; + u32 end_addr = start_addr + (dimm->dimm_size << 10) - 1; totallen += smbios_write_type20_table(current, handle, start_addr, end_addr, type17_handle, type19_handle);