Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> |
| 4 | * |
| 5 | * Adapted from coreboot src/arch/x86/smbios.c |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 9 | #include <mapmem.h> |
Alexander Graf | fb22808 | 2016-08-19 01:23:23 +0200 | [diff] [blame] | 10 | #include <smbios.h> |
| 11 | #include <tables_csum.h> |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 12 | #include <version.h> |
Alexander Graf | e44b3c0 | 2016-08-19 01:23:28 +0200 | [diff] [blame] | 13 | #ifdef CONFIG_CPU |
| 14 | #include <cpu.h> |
| 15 | #include <dm.h> |
| 16 | #include <dm/uclass-internal.h> |
| 17 | #endif |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 18 | |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 19 | /** |
| 20 | * smbios_add_string() - add a string to the string area |
| 21 | * |
| 22 | * This adds a string to the string area which is appended directly after |
| 23 | * the formatted portion of an SMBIOS structure. |
| 24 | * |
| 25 | * @start: string area start address |
| 26 | * @str: string to add |
| 27 | * @return: string number in the string area |
| 28 | */ |
| 29 | static int smbios_add_string(char *start, const char *str) |
| 30 | { |
| 31 | int i = 1; |
| 32 | char *p = start; |
| 33 | |
| 34 | for (;;) { |
| 35 | if (!*p) { |
| 36 | strcpy(p, str); |
| 37 | p += strlen(str); |
| 38 | *p++ = '\0'; |
| 39 | *p++ = '\0'; |
| 40 | |
| 41 | return i; |
| 42 | } |
| 43 | |
| 44 | if (!strcmp(p, str)) |
| 45 | return i; |
| 46 | |
| 47 | p += strlen(p) + 1; |
| 48 | i++; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * smbios_string_table_len() - compute the string area size |
| 54 | * |
| 55 | * This computes the size of the string area including the string terminator. |
| 56 | * |
| 57 | * @start: string area start address |
| 58 | * @return: string area size |
| 59 | */ |
| 60 | static int smbios_string_table_len(char *start) |
| 61 | { |
| 62 | char *p = start; |
| 63 | int i, len = 0; |
| 64 | |
| 65 | while (*p) { |
| 66 | i = strlen(p) + 1; |
| 67 | p += i; |
| 68 | len += i; |
| 69 | } |
| 70 | |
| 71 | return len + 1; |
| 72 | } |
| 73 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 74 | static int smbios_write_type0(ulong *current, int handle) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 75 | { |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 76 | struct smbios_type0 *t; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 77 | int len = sizeof(struct smbios_type0); |
| 78 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 79 | t = map_sysmem(*current, len); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 80 | memset(t, 0, sizeof(struct smbios_type0)); |
| 81 | fill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle); |
| 82 | t->vendor = smbios_add_string(t->eos, "U-Boot"); |
| 83 | t->bios_ver = smbios_add_string(t->eos, PLAIN_VERSION); |
| 84 | t->bios_release_date = smbios_add_string(t->eos, U_BOOT_DMI_DATE); |
Alexander Graf | 66f96e1 | 2016-08-19 01:23:29 +0200 | [diff] [blame] | 85 | #ifdef CONFIG_ROM_SIZE |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 86 | t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1; |
Alexander Graf | 66f96e1 | 2016-08-19 01:23:29 +0200 | [diff] [blame] | 87 | #endif |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 88 | t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED | |
| 89 | BIOS_CHARACTERISTICS_SELECTABLE_BOOT | |
| 90 | BIOS_CHARACTERISTICS_UPGRADEABLE; |
| 91 | #ifdef CONFIG_GENERATE_ACPI_TABLE |
| 92 | t->bios_characteristics_ext1 = BIOS_CHARACTERISTICS_EXT1_ACPI; |
| 93 | #endif |
Alexander Graf | 66f96e1 | 2016-08-19 01:23:29 +0200 | [diff] [blame] | 94 | #ifdef CONFIG_EFI_LOADER |
| 95 | t->bios_characteristics_ext1 |= BIOS_CHARACTERISTICS_EXT1_UEFI; |
| 96 | #endif |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 97 | t->bios_characteristics_ext2 = BIOS_CHARACTERISTICS_EXT2_TARGET; |
Alexander Graf | 66f96e1 | 2016-08-19 01:23:29 +0200 | [diff] [blame] | 98 | |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 99 | t->bios_major_release = 0xff; |
| 100 | t->bios_minor_release = 0xff; |
| 101 | t->ec_major_release = 0xff; |
| 102 | t->ec_minor_release = 0xff; |
| 103 | |
| 104 | len = t->length + smbios_string_table_len(t->eos); |
| 105 | *current += len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 106 | unmap_sysmem(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 107 | |
| 108 | return len; |
| 109 | } |
| 110 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 111 | static int smbios_write_type1(ulong *current, int handle) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 112 | { |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 113 | struct smbios_type1 *t; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 114 | int len = sizeof(struct smbios_type1); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 115 | char *serial_str = env_get("serial#"); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 116 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 117 | t = map_sysmem(*current, len); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 118 | memset(t, 0, sizeof(struct smbios_type1)); |
| 119 | fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle); |
Bin Meng | 543a82b | 2016-05-22 01:45:38 -0700 | [diff] [blame] | 120 | t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); |
| 121 | t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME); |
Alexander Graf | 9a3e3e2 | 2016-08-19 01:23:31 +0200 | [diff] [blame] | 122 | if (serial_str) { |
Christian Gmeiner | e812e2c | 2018-07-30 13:22:06 +0200 | [diff] [blame] | 123 | strncpy((char *)t->uuid, serial_str, sizeof(t->uuid)); |
Alexander Graf | 9a3e3e2 | 2016-08-19 01:23:31 +0200 | [diff] [blame] | 124 | t->serial_number = smbios_add_string(t->eos, serial_str); |
| 125 | } |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 126 | |
| 127 | len = t->length + smbios_string_table_len(t->eos); |
| 128 | *current += len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 129 | unmap_sysmem(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 130 | |
| 131 | return len; |
| 132 | } |
| 133 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 134 | static int smbios_write_type2(ulong *current, int handle) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 135 | { |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 136 | struct smbios_type2 *t; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 137 | int len = sizeof(struct smbios_type2); |
| 138 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 139 | t = map_sysmem(*current, len); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 140 | memset(t, 0, sizeof(struct smbios_type2)); |
| 141 | fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle); |
Bin Meng | 543a82b | 2016-05-22 01:45:38 -0700 | [diff] [blame] | 142 | t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); |
| 143 | t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 144 | t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING; |
| 145 | t->board_type = SMBIOS_BOARD_MOTHERBOARD; |
| 146 | |
| 147 | len = t->length + smbios_string_table_len(t->eos); |
| 148 | *current += len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 149 | unmap_sysmem(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 150 | |
| 151 | return len; |
| 152 | } |
| 153 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 154 | static int smbios_write_type3(ulong *current, int handle) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 155 | { |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 156 | struct smbios_type3 *t; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 157 | int len = sizeof(struct smbios_type3); |
| 158 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 159 | t = map_sysmem(*current, len); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 160 | memset(t, 0, sizeof(struct smbios_type3)); |
| 161 | fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle); |
Bin Meng | 543a82b | 2016-05-22 01:45:38 -0700 | [diff] [blame] | 162 | t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 163 | t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP; |
| 164 | t->bootup_state = SMBIOS_STATE_SAFE; |
| 165 | t->power_supply_state = SMBIOS_STATE_SAFE; |
| 166 | t->thermal_state = SMBIOS_STATE_SAFE; |
| 167 | t->security_status = SMBIOS_SECURITY_NONE; |
| 168 | |
| 169 | len = t->length + smbios_string_table_len(t->eos); |
| 170 | *current += len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 171 | unmap_sysmem(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 172 | |
| 173 | return len; |
| 174 | } |
| 175 | |
Alexander Graf | e44b3c0 | 2016-08-19 01:23:28 +0200 | [diff] [blame] | 176 | static void smbios_write_type4_dm(struct smbios_type4 *t) |
| 177 | { |
| 178 | u16 processor_family = SMBIOS_PROCESSOR_FAMILY_UNKNOWN; |
| 179 | const char *vendor = "Unknown"; |
| 180 | const char *name = "Unknown"; |
| 181 | |
| 182 | #ifdef CONFIG_CPU |
| 183 | char processor_name[49]; |
| 184 | char vendor_name[49]; |
| 185 | struct udevice *dev = NULL; |
| 186 | |
| 187 | uclass_find_first_device(UCLASS_CPU, &dev); |
| 188 | if (dev) { |
| 189 | struct cpu_platdata *plat = dev_get_parent_platdata(dev); |
| 190 | |
| 191 | if (plat->family) |
| 192 | processor_family = plat->family; |
| 193 | t->processor_id[0] = plat->id[0]; |
| 194 | t->processor_id[1] = plat->id[1]; |
| 195 | |
| 196 | if (!cpu_get_vendor(dev, vendor_name, sizeof(vendor_name))) |
| 197 | vendor = vendor_name; |
| 198 | if (!cpu_get_desc(dev, processor_name, sizeof(processor_name))) |
| 199 | name = processor_name; |
| 200 | } |
| 201 | #endif |
| 202 | |
| 203 | t->processor_family = processor_family; |
| 204 | t->processor_manufacturer = smbios_add_string(t->eos, vendor); |
| 205 | t->processor_version = smbios_add_string(t->eos, name); |
| 206 | } |
| 207 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 208 | static int smbios_write_type4(ulong *current, int handle) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 209 | { |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 210 | struct smbios_type4 *t; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 211 | int len = sizeof(struct smbios_type4); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 212 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 213 | t = map_sysmem(*current, len); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 214 | memset(t, 0, sizeof(struct smbios_type4)); |
| 215 | fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle); |
| 216 | t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL; |
Alexander Graf | e44b3c0 | 2016-08-19 01:23:28 +0200 | [diff] [blame] | 217 | smbios_write_type4_dm(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 218 | t->status = SMBIOS_PROCESSOR_STATUS_ENABLED; |
| 219 | t->processor_upgrade = SMBIOS_PROCESSOR_UPGRADE_NONE; |
| 220 | t->l1_cache_handle = 0xffff; |
| 221 | t->l2_cache_handle = 0xffff; |
| 222 | t->l3_cache_handle = 0xffff; |
| 223 | t->processor_family2 = t->processor_family; |
| 224 | |
| 225 | len = t->length + smbios_string_table_len(t->eos); |
| 226 | *current += len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 227 | unmap_sysmem(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 228 | |
| 229 | return len; |
| 230 | } |
| 231 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 232 | static int smbios_write_type32(ulong *current, int handle) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 233 | { |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 234 | struct smbios_type32 *t; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 235 | int len = sizeof(struct smbios_type32); |
| 236 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 237 | t = map_sysmem(*current, len); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 238 | memset(t, 0, sizeof(struct smbios_type32)); |
| 239 | fill_smbios_header(t, SMBIOS_SYSTEM_BOOT_INFORMATION, len, handle); |
| 240 | |
| 241 | *current += len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 242 | unmap_sysmem(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 243 | |
| 244 | return len; |
| 245 | } |
| 246 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 247 | static int smbios_write_type127(ulong *current, int handle) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 248 | { |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 249 | struct smbios_type127 *t; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 250 | int len = sizeof(struct smbios_type127); |
| 251 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 252 | t = map_sysmem(*current, len); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 253 | memset(t, 0, sizeof(struct smbios_type127)); |
| 254 | fill_smbios_header(t, SMBIOS_END_OF_TABLE, len, handle); |
| 255 | |
| 256 | *current += len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 257 | unmap_sysmem(t); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 258 | |
| 259 | return len; |
| 260 | } |
| 261 | |
| 262 | static smbios_write_type smbios_write_funcs[] = { |
| 263 | smbios_write_type0, |
| 264 | smbios_write_type1, |
| 265 | smbios_write_type2, |
| 266 | smbios_write_type3, |
| 267 | smbios_write_type4, |
| 268 | smbios_write_type32, |
| 269 | smbios_write_type127 |
| 270 | }; |
| 271 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 272 | ulong write_smbios_table(ulong addr) |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 273 | { |
| 274 | struct smbios_entry *se; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 275 | ulong table_addr; |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 276 | ulong tables; |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 277 | int len = 0; |
| 278 | int max_struct_size = 0; |
| 279 | int handle = 0; |
| 280 | char *istart; |
| 281 | int isize; |
| 282 | int i; |
| 283 | |
| 284 | /* 16 byte align the table address */ |
| 285 | addr = ALIGN(addr, 16); |
| 286 | |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 287 | se = map_sysmem(addr, sizeof(struct smbios_entry)); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 288 | memset(se, 0, sizeof(struct smbios_entry)); |
| 289 | |
| 290 | addr += sizeof(struct smbios_entry); |
| 291 | addr = ALIGN(addr, 16); |
| 292 | tables = addr; |
| 293 | |
| 294 | /* populate minimum required tables */ |
| 295 | for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) { |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 296 | int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++); |
Christian Gmeiner | 5566caf | 2018-07-30 13:22:07 +0200 | [diff] [blame] | 297 | |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 298 | max_struct_size = max(max_struct_size, tmp); |
| 299 | len += tmp; |
| 300 | } |
| 301 | |
| 302 | memcpy(se->anchor, "_SM_", 4); |
| 303 | se->length = sizeof(struct smbios_entry); |
| 304 | se->major_ver = SMBIOS_MAJOR_VER; |
| 305 | se->minor_ver = SMBIOS_MINOR_VER; |
| 306 | se->max_struct_size = max_struct_size; |
| 307 | memcpy(se->intermediate_anchor, "_DMI_", 5); |
| 308 | se->struct_table_length = len; |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 309 | |
| 310 | /* |
| 311 | * We must use a pointer here so things work correctly on sandbox. The |
| 312 | * user of this table is not aware of the mapping of addresses to |
| 313 | * sandbox's DRAM buffer. |
| 314 | */ |
| 315 | table_addr = (ulong)map_sysmem(tables, 0); |
| 316 | if (sizeof(table_addr) > sizeof(u32) && table_addr > (ulong)UINT_MAX) { |
| 317 | /* |
| 318 | * We need to put this >32-bit pointer into the table but the |
| 319 | * field is only 32 bits wide. |
| 320 | */ |
| 321 | printf("WARNING: SMBIOS table_address overflow %llx\n", |
| 322 | (unsigned long long)table_addr); |
| 323 | table_addr = 0; |
| 324 | } |
| 325 | se->struct_table_address = table_addr; |
| 326 | |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 327 | se->struct_count = handle; |
| 328 | |
| 329 | /* calculate checksums */ |
| 330 | istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET; |
| 331 | isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET; |
| 332 | se->intermediate_checksum = table_compute_checksum(istart, isize); |
| 333 | se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry)); |
Simon Glass | 2d93add | 2018-11-22 13:46:37 -0700 | [diff] [blame] | 334 | unmap_sysmem(se); |
Bin Meng | ae5bedb | 2015-10-12 05:23:41 -0700 | [diff] [blame] | 335 | |
| 336 | return addr; |
| 337 | } |