xref: /aosp_15_r20/external/coreboot/src/cpu/x86/name/name.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <cpu/cpu.h>
4 #include <cpu/x86/name.h>
5 #include <stdint.h>
6 #include <string.h>
7 
fill_processor_name(char * processor_name)8 void fill_processor_name(char *processor_name)
9 {
10 	struct cpuid_result regs;
11 	char *processor_name_start;
12 	uint32_t name_as_ints[13];
13 	int i;
14 
15 	for (i = 0; i < 3; i++) {
16 		regs = cpuid(0x80000002 + i);
17 		name_as_ints[i * 4 + 0] = regs.eax;
18 		name_as_ints[i * 4 + 1] = regs.ebx;
19 		name_as_ints[i * 4 + 2] = regs.ecx;
20 		name_as_ints[i * 4 + 3] = regs.edx;
21 	}
22 
23 	name_as_ints[12] = 0;
24 
25 	/* Skip leading spaces. */
26 	processor_name_start = (char *)name_as_ints;
27 	while (*processor_name_start == ' ')
28 		processor_name_start++;
29 
30 	strcpy(processor_name, processor_name_start);
31 }
32