summaryrefslogtreecommitdiff
path: root/src/cpu/x86/name/name.c
blob: 1b71e5d8e8abf404cf23b6267027101d3522e946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* SPDX-License-Identifier: GPL-2.0-only */

#include <cpu/cpu.h>
#include <cpu/x86/name.h>
#include <stdint.h>
#include <string.h>

void fill_processor_name(char *processor_name)
{
	struct cpuid_result regs;
	char *processor_name_start;
	uint32_t name_as_ints[13];
	int i;

	for (i = 0; i < 3; i++) {
		regs = cpuid(0x80000002 + i);
		name_as_ints[i * 4 + 0] = regs.eax;
		name_as_ints[i * 4 + 1] = regs.ebx;
		name_as_ints[i * 4 + 2] = regs.ecx;
		name_as_ints[i * 4 + 3] = regs.edx;
	}

	name_as_ints[12] = 0;

	/* Skip leading spaces. */
	processor_name_start = (char *)name_as_ints;
	while (*processor_name_start == ' ')
		processor_name_start++;

	strcpy(processor_name, processor_name_start);
}