Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 2 | |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 3 | #include <string.h> |
| 4 | #include <smbios.h> |
| 5 | #include <console/console.h> |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 6 | #include <arch/cpu.h> |
| 7 | #include <cpu/x86/name.h> |
Angel Pons | d62a501 | 2021-06-28 17:18:06 +0200 | [diff] [blame] | 8 | |
Konstantin Aladyshev | d0df1d7 | 2017-08-01 15:52:46 +0300 | [diff] [blame] | 9 | static int smbios_cpu_vendor(u8 *start) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 10 | { |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 11 | if (cpu_have_cpuid()) { |
Ryan Salsamendi | 1b5eda0 | 2017-06-11 18:50:32 -0700 | [diff] [blame] | 12 | u32 tmp[4]; |
| 13 | const struct cpuid_result res = cpuid(0); |
| 14 | tmp[0] = res.ebx; |
| 15 | tmp[1] = res.edx; |
| 16 | tmp[2] = res.ecx; |
| 17 | tmp[3] = 0; |
| 18 | return smbios_add_string(start, (const char *)tmp); |
| 19 | } else { |
| 20 | return smbios_add_string(start, "Unknown"); |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 21 | } |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 22 | } |
| 23 | |
Konstantin Aladyshev | d0df1d7 | 2017-08-01 15:52:46 +0300 | [diff] [blame] | 24 | static int smbios_processor_name(u8 *start) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 25 | { |
Nico Huber | aa9643e | 2017-06-20 14:49:04 +0200 | [diff] [blame] | 26 | u32 tmp[13]; |
Ryan Salsamendi | 1b5eda0 | 2017-06-11 18:50:32 -0700 | [diff] [blame] | 27 | const char *str = "Unknown Processor Name"; |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 28 | if (cpu_have_cpuid()) { |
Ryan Salsamendi | 1b5eda0 | 2017-06-11 18:50:32 -0700 | [diff] [blame] | 29 | int i; |
Felix Held | 73e9ac6 | 2023-02-20 17:46:41 +0100 | [diff] [blame] | 30 | struct cpuid_result res; |
| 31 | if (cpu_cpuid_extended_level() >= 0x80000004) { |
Ryan Salsamendi | 1b5eda0 | 2017-06-11 18:50:32 -0700 | [diff] [blame] | 32 | int j = 0; |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 33 | for (i = 0; i < 3; i++) { |
| 34 | res = cpuid(0x80000002 + i); |
Ryan Salsamendi | 1b5eda0 | 2017-06-11 18:50:32 -0700 | [diff] [blame] | 35 | tmp[j++] = res.eax; |
| 36 | tmp[j++] = res.ebx; |
| 37 | tmp[j++] = res.ecx; |
| 38 | tmp[j++] = res.edx; |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 39 | } |
Ryan Salsamendi | 1b5eda0 | 2017-06-11 18:50:32 -0700 | [diff] [blame] | 40 | tmp[12] = 0; |
| 41 | str = (const char *)tmp; |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 42 | } |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 43 | } |
Ryan Salsamendi | 1b5eda0 | 2017-06-11 18:50:32 -0700 | [diff] [blame] | 44 | return smbios_add_string(start, str); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Elyes HAOUAS | 28fa33c | 2019-01-25 13:46:43 +0100 | [diff] [blame] | 47 | static int get_socket_type(void) |
| 48 | { |
| 49 | if (CONFIG(CPU_INTEL_SLOT_1)) |
Li, Jincheng | aa99012 | 2023-01-03 15:43:40 +0800 | [diff] [blame] | 50 | return PROCESSOR_UPGRADE_SLOT_1; |
Kyösti Mälkki | 7b73e852 | 2022-11-08 04:43:41 +0000 | [diff] [blame] | 51 | if (CONFIG(CPU_INTEL_SOCKET_MPGA604)) |
Li, Jincheng | aa99012 | 2023-01-03 15:43:40 +0800 | [diff] [blame] | 52 | return PROCESSOR_UPGRADE_SOCKET_MPGA604; |
Elyes HAOUAS | 28fa33c | 2019-01-25 13:46:43 +0100 | [diff] [blame] | 53 | if (CONFIG(CPU_INTEL_SOCKET_LGA775)) |
Li, Jincheng | aa99012 | 2023-01-03 15:43:40 +0800 | [diff] [blame] | 54 | return PROCESSOR_UPGRADE_SOCKET_LGA775; |
Zhixing Ma | 42bb7df | 2022-09-30 14:22:41 -0700 | [diff] [blame] | 55 | if (CONFIG(SOC_INTEL_ALDERLAKE)) |
Li, Jincheng | aa99012 | 2023-01-03 15:43:40 +0800 | [diff] [blame] | 56 | return PROCESSOR_UPGRADE_SOCKET_LGA1700; |
Jay Patel | b7da7d5 | 2023-03-13 11:29:59 -0700 | [diff] [blame] | 57 | if (CONFIG(SOC_INTEL_METEORLAKE)) |
| 58 | return PROCESSOR_UPGRADE_OTHER; |
David Hendricks | 6041699 | 2023-01-28 15:35:37 -0800 | [diff] [blame] | 59 | if (CONFIG(SOC_INTEL_SKYLAKE_SP)) |
| 60 | return PROCESSOR_UPGRADE_SOCKET_LGA3647_1; |
| 61 | if (CONFIG(SOC_INTEL_COOPERLAKE_SP)) |
| 62 | return PROCESSOR_UPGRADE_SOCKET_LGA4189; |
Christian Walter | 55129b3 | 2022-09-08 13:17:50 +0200 | [diff] [blame] | 63 | if (CONFIG(SOC_INTEL_SAPPHIRERAPIDS_SP)) |
| 64 | return PROCESSOR_UPGRADE_SOCKET_LGA4677; |
Elyes HAOUAS | 28fa33c | 2019-01-25 13:46:43 +0100 | [diff] [blame] | 65 | |
Li, Jincheng | aa99012 | 2023-01-03 15:43:40 +0800 | [diff] [blame] | 66 | return PROCESSOR_UPGRADE_UNKNOWN; |
Elyes HAOUAS | 28fa33c | 2019-01-25 13:46:43 +0100 | [diff] [blame] | 67 | } |
| 68 | |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 69 | unsigned int __weak smbios_processor_family(struct cpuid_result res) |
| 70 | { |
| 71 | return (res.eax > 0) ? 0x0c : 0x6; |
| 72 | } |
| 73 | |
Subrata Banik | e2b5fee | 2021-07-23 21:02:45 +0530 | [diff] [blame] | 74 | static size_t get_number_of_caches(size_t max_logical_cpus_sharing_cache) |
Morgan Jang | 8ae391d | 2020-10-06 16:26:17 +0800 | [diff] [blame] | 75 | { |
Morgan Jang | 8ae391d | 2020-10-06 16:26:17 +0800 | [diff] [blame] | 76 | size_t number_of_cpus_per_package = 0; |
| 77 | size_t max_logical_cpus_per_package = 0; |
| 78 | struct cpuid_result res; |
| 79 | |
| 80 | if (!cpu_have_cpuid()) |
| 81 | return 1; |
| 82 | |
| 83 | res = cpuid(1); |
| 84 | |
| 85 | max_logical_cpus_per_package = (res.ebx >> 16) & 0xff; |
| 86 | |
Morgan Jang | 8ae391d | 2020-10-06 16:26:17 +0800 | [diff] [blame] | 87 | /* Check if it's last level cache */ |
| 88 | if (max_logical_cpus_sharing_cache == max_logical_cpus_per_package) |
| 89 | return 1; |
| 90 | |
| 91 | if (cpuid_get_max_func() >= 0xb) { |
| 92 | res = cpuid_ext(0xb, 1); |
| 93 | number_of_cpus_per_package = res.ebx & 0xff; |
| 94 | } else { |
| 95 | number_of_cpus_per_package = max_logical_cpus_per_package; |
| 96 | } |
| 97 | |
| 98 | return number_of_cpus_per_package / max_logical_cpus_sharing_cache; |
| 99 | } |
| 100 | |
Arthur Heymans | 13c8dc5 | 2022-04-07 22:08:23 +0200 | [diff] [blame] | 101 | #define MAX_CPUS_ENABLED (CONFIG_MAX_CPUS > 0xff ? 0xff : CONFIG_MAX_CPUS) |
| 102 | |
Benjamin Doron | ea13dc3 | 2023-06-20 12:21:27 -0400 | [diff] [blame] | 103 | int smbios_write_type4(unsigned long *current, int handle) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 104 | { |
Patrick Rudolph | b01ac7e | 2020-07-26 14:23:37 +0200 | [diff] [blame] | 105 | unsigned int cpu_voltage; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 106 | struct cpuid_result res; |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 107 | uint16_t characteristics = 0; |
Tim Chu | 27bf0c8 | 2020-09-16 00:34:08 -0700 | [diff] [blame] | 108 | static unsigned int cnt = 0; |
| 109 | char buf[8]; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 110 | |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 111 | /* Provide sane defaults even for CPU without CPUID */ |
| 112 | res.eax = res.edx = 0; |
| 113 | res.ebx = 0x10000; |
| 114 | |
Lee Leahy | 9c7c6f7 | 2017-03-16 11:24:09 -0700 | [diff] [blame] | 115 | if (cpu_have_cpuid()) |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 116 | res = cpuid(1); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 117 | |
Angel Pons | d62a501 | 2021-06-28 17:18:06 +0200 | [diff] [blame] | 118 | struct smbios_type4 *t = smbios_carve_table(*current, SMBIOS_PROCESSOR_INFORMATION, |
| 119 | sizeof(*t), handle); |
Tim Chu | 27bf0c8 | 2020-09-16 00:34:08 -0700 | [diff] [blame] | 120 | |
| 121 | snprintf(buf, sizeof(buf), "CPU%d", cnt++); |
| 122 | t->socket_designation = smbios_add_string(t->eos, buf); |
| 123 | |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 124 | t->processor_id[0] = res.eax; |
| 125 | t->processor_id[1] = res.edx; |
| 126 | t->processor_manufacturer = smbios_cpu_vendor(t->eos); |
| 127 | t->processor_version = smbios_processor_name(t->eos); |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 128 | t->processor_family = smbios_processor_family(res); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 129 | t->processor_type = 3; /* System Processor */ |
Andrey Petrov | 515ef38 | 2019-11-15 13:19:08 -0800 | [diff] [blame] | 130 | /* |
| 131 | * If CPUID leaf 11 is available, calculate "core count" by dividing |
| 132 | * SMT_ID (logical processors in a core) by Core_ID (number of cores). |
| 133 | * This seems to be the way to arrive to a number of cores mentioned on |
| 134 | * ark.intel.com. |
| 135 | */ |
| 136 | if (cpu_have_cpuid() && cpuid_get_max_func() >= 0xb) { |
| 137 | uint32_t leaf_b_cores = 0, leaf_b_threads = 0; |
| 138 | res = cpuid_ext(0xb, 1); |
| 139 | leaf_b_cores = res.ebx; |
| 140 | res = cpuid_ext(0xb, 0); |
| 141 | leaf_b_threads = res.ebx; |
| 142 | /* if hyperthreading is not available, pretend this is 1 */ |
Fabio Aiuto | 0805c70 | 2022-08-19 17:25:25 +0200 | [diff] [blame] | 143 | if (leaf_b_threads == 0) |
Andrey Petrov | 515ef38 | 2019-11-15 13:19:08 -0800 | [diff] [blame] | 144 | leaf_b_threads = 1; |
Fabio Aiuto | 0805c70 | 2022-08-19 17:25:25 +0200 | [diff] [blame] | 145 | |
Patrick Rudolph | 7a83582 | 2020-07-22 16:00:53 +0200 | [diff] [blame] | 146 | t->core_count2 = leaf_b_cores / leaf_b_threads; |
| 147 | t->core_count = t->core_count2 > 0xff ? 0xff : t->core_count2; |
Francois Toguo | 597922e | 2019-03-27 18:13:07 -0700 | [diff] [blame] | 148 | t->thread_count2 = leaf_b_cores; |
| 149 | t->thread_count = t->thread_count2 > 0xff ? 0xff : t->thread_count2; |
Andrey Petrov | 515ef38 | 2019-11-15 13:19:08 -0800 | [diff] [blame] | 150 | } else { |
| 151 | t->core_count = (res.ebx >> 16) & 0xff; |
Patrick Rudolph | 7a83582 | 2020-07-22 16:00:53 +0200 | [diff] [blame] | 152 | t->core_count2 = t->core_count; |
| 153 | t->thread_count2 = t->core_count2; |
Francois Toguo | 597922e | 2019-03-27 18:13:07 -0700 | [diff] [blame] | 154 | t->thread_count = t->thread_count2; |
Andrey Petrov | 515ef38 | 2019-11-15 13:19:08 -0800 | [diff] [blame] | 155 | } |
Andrey Petrov | 2e032f0 | 2019-10-23 15:31:51 -0700 | [diff] [blame] | 156 | /* Assume we enable all the cores always, capped only by MAX_CPUS */ |
Arthur Heymans | 13c8dc5 | 2022-04-07 22:08:23 +0200 | [diff] [blame] | 157 | t->core_enabled = MIN(t->core_count, MAX_CPUS_ENABLED); |
Patrick Rudolph | 7a83582 | 2020-07-22 16:00:53 +0200 | [diff] [blame] | 158 | t->core_enabled2 = MIN(t->core_count2, CONFIG_MAX_CPUS); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 159 | t->l1_cache_handle = 0xffff; |
| 160 | t->l2_cache_handle = 0xffff; |
| 161 | t->l3_cache_handle = 0xffff; |
Johnny Lin | d344054 | 2020-01-30 18:21:22 +0800 | [diff] [blame] | 162 | t->serial_number = smbios_add_string(t->eos, smbios_processor_serial_number()); |
Angel Pons | bf2f91c | 2020-07-29 18:14:59 +0200 | [diff] [blame] | 163 | t->status = SMBIOS_PROCESSOR_STATUS_CPU_ENABLED | SMBIOS_PROCESSOR_STATUS_POPULATED; |
Elyes HAOUAS | 28fa33c | 2019-01-25 13:46:43 +0100 | [diff] [blame] | 164 | t->processor_upgrade = get_socket_type(); |
Andrey Petrov | 2e032f0 | 2019-10-23 15:31:51 -0700 | [diff] [blame] | 165 | if (cpu_have_cpuid() && cpuid_get_max_func() >= 0x16) { |
Andrey Petrov | 2e032f0 | 2019-10-23 15:31:51 -0700 | [diff] [blame] | 166 | t->current_speed = cpuid_eax(0x16); /* base frequency */ |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 167 | t->external_clock = cpuid_ecx(0x16); |
Andrey Petrov | 2e032f0 | 2019-10-23 15:31:51 -0700 | [diff] [blame] | 168 | } else { |
Andrey Petrov | 2e032f0 | 2019-10-23 15:31:51 -0700 | [diff] [blame] | 169 | t->current_speed = smbios_cpu_get_current_speed_mhz(); |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 170 | t->external_clock = smbios_processor_external_clock(); |
Andrey Petrov | 2e032f0 | 2019-10-23 15:31:51 -0700 | [diff] [blame] | 171 | } |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 172 | |
Tim Chu | 40d4599 | 2020-12-14 21:44:40 -0800 | [diff] [blame] | 173 | /* This field identifies a capability for the system, not the processor itself. */ |
| 174 | t->max_speed = smbios_cpu_get_max_speed_mhz(); |
| 175 | |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 176 | if (cpu_have_cpuid()) { |
| 177 | res = cpuid(1); |
| 178 | |
| 179 | if ((res.ecx) & BIT(5)) |
| 180 | characteristics |= BIT(6); /* BIT6: Enhanced Virtualization */ |
| 181 | |
| 182 | if ((res.edx) & BIT(28)) |
| 183 | characteristics |= BIT(4); /* BIT4: Hardware Thread */ |
| 184 | |
Felix Held | 1eea841 | 2023-09-23 03:44:02 +0200 | [diff] [blame] | 185 | if (cpu_cpuid_extended_level() >= 0x80000001) { |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 186 | res = cpuid(0x80000001); |
| 187 | |
| 188 | if ((res.edx) & BIT(20)) |
| 189 | characteristics |= BIT(5); /* BIT5: Execute Protection */ |
| 190 | } |
| 191 | } |
| 192 | t->processor_characteristics = characteristics | smbios_processor_characteristics(); |
Patrick Rudolph | b01ac7e | 2020-07-26 14:23:37 +0200 | [diff] [blame] | 193 | cpu_voltage = smbios_cpu_get_voltage(); |
| 194 | if (cpu_voltage > 0) |
| 195 | t->voltage = 0x80 | cpu_voltage; |
Morgan Jang | 92bcc4f | 2020-07-24 10:36:18 +0800 | [diff] [blame] | 196 | |
Angel Pons | a37701a | 2021-06-28 17:36:53 +0200 | [diff] [blame] | 197 | const int len = smbios_full_table_len(&t->header, t->eos); |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 198 | *current += len; |
| 199 | return len; |
| 200 | } |
| 201 | |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 202 | /* |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 203 | * Parse the "Deterministic Cache Parameters" as provided by Intel in |
| 204 | * leaf 4 or AMD in extended leaf 0x8000001d. |
| 205 | * |
| 206 | * @param current Pointer to memory address to write the tables to |
| 207 | * @param handle Pointer to handle for the tables |
| 208 | * @param max_struct_size Pointer to maximum struct size |
Patrick Rudolph | 15589b4 | 2019-03-30 17:51:06 +0100 | [diff] [blame] | 209 | * @param type4 Pointer to SMBIOS type 4 structure |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 210 | */ |
Benjamin Doron | ea13dc3 | 2023-06-20 12:21:27 -0400 | [diff] [blame] | 211 | int smbios_write_type7_cache_parameters(unsigned long *current, |
| 212 | int *handle, |
| 213 | int *max_struct_size, |
| 214 | struct smbios_type4 *type4) |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 215 | { |
Subrata Banik | e2b5fee | 2021-07-23 21:02:45 +0530 | [diff] [blame] | 216 | unsigned int cnt = CACHE_L1D; |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 217 | int len = 0; |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 218 | |
| 219 | if (!cpu_have_cpuid()) |
| 220 | return len; |
| 221 | |
Subrata Banik | 6efc4aa | 2021-09-01 12:40:47 +0530 | [diff] [blame] | 222 | enum cpu_type dcache_cpuid = cpu_check_deterministic_cache_cpuid_supported(); |
| 223 | if (dcache_cpuid == CPUID_TYPE_INVALID || dcache_cpuid == CPUID_COMMAND_UNSUPPORTED) { |
Subrata Banik | 5586c79 | 2021-09-02 13:17:18 +0530 | [diff] [blame] | 224 | printk(BIOS_DEBUG, "SMBIOS: Unknown CPU or CPU doesn't support Deterministic " |
| 225 | "Cache CPUID leaf\n"); |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 226 | return len; |
| 227 | } |
| 228 | |
| 229 | while (1) { |
| 230 | enum smbios_cache_associativity associativity; |
| 231 | enum smbios_cache_type type; |
Subrata Banik | e2b5fee | 2021-07-23 21:02:45 +0530 | [diff] [blame] | 232 | struct cpu_cache_info info; |
| 233 | if (!fill_cpu_cache_info(cnt++, &info)) |
| 234 | continue; |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 235 | |
Subrata Banik | e2b5fee | 2021-07-23 21:02:45 +0530 | [diff] [blame] | 236 | const u8 cache_type = info.type; |
| 237 | const u8 level = info.level; |
| 238 | const size_t assoc = info.num_ways; |
| 239 | const size_t cache_share = info.num_cores_shared; |
| 240 | const size_t cache_size = info.size * get_number_of_caches(cache_share); |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 241 | |
| 242 | if (!cache_type) |
| 243 | /* No more caches in the system */ |
| 244 | break; |
| 245 | |
| 246 | switch (cache_type) { |
| 247 | case 1: |
| 248 | type = SMBIOS_CACHE_TYPE_DATA; |
| 249 | break; |
| 250 | case 2: |
| 251 | type = SMBIOS_CACHE_TYPE_INSTRUCTION; |
| 252 | break; |
| 253 | case 3: |
| 254 | type = SMBIOS_CACHE_TYPE_UNIFIED; |
| 255 | break; |
| 256 | default: |
| 257 | type = SMBIOS_CACHE_TYPE_UNKNOWN; |
| 258 | break; |
| 259 | } |
| 260 | |
Subrata Banik | e2b5fee | 2021-07-23 21:02:45 +0530 | [diff] [blame] | 261 | if (info.fully_associative) |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 262 | associativity = SMBIOS_CACHE_ASSOCIATIVITY_FULL; |
| 263 | else |
| 264 | associativity = smbios_cache_associativity(assoc); |
| 265 | |
Patrick Rudolph | 15589b4 | 2019-03-30 17:51:06 +0100 | [diff] [blame] | 266 | const int h = (*handle)++; |
| 267 | |
| 268 | update_max(len, *max_struct_size, smbios_write_type7(current, h, |
Morgan Jang | 8ae391d | 2020-10-06 16:26:17 +0800 | [diff] [blame] | 269 | level, smbios_cache_sram_type(), associativity, |
Patrick Rudolph | 15589b4 | 2019-03-30 17:51:06 +0100 | [diff] [blame] | 270 | type, cache_size, cache_size)); |
| 271 | |
| 272 | if (type4) { |
| 273 | switch (level) { |
| 274 | case 1: |
| 275 | type4->l1_cache_handle = h; |
| 276 | break; |
| 277 | case 2: |
| 278 | type4->l2_cache_handle = h; |
| 279 | break; |
| 280 | case 3: |
| 281 | type4->l3_cache_handle = h; |
| 282 | break; |
| 283 | } |
| 284 | } |
Patrick Rudolph | fc5b809 | 2019-03-30 17:37:28 +0100 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | return len; |
| 288 | } |