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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* ProcFS - cpuinfo.c - generator for the cpuinfo file */
#include "inc.h"
#if defined(__i386__)
#include "../../kernel/arch/i386/include/archconst.h"
#endif
#ifndef CONFIG_MAX_CPUS
#define CONFIG_MAX_CPUS 1
#endif
#if defined(__i386__)
static const char * x86_flag[] = {
"fpu",
"vme",
"de",
"pse",
"tsc",
"msr",
"pae",
"mce",
"cx8",
"apic",
"",
"sep",
"mtrr",
"pge",
"mca",
"cmov",
"pat",
"pse36",
"psn",
"clfsh",
"",
"dts",
"acpi",
"mmx",
"fxsr",
"sse",
"sse2",
"ss",
"ht",
"tm",
"",
"pbe",
"pni",
"",
"",
"monitor",
"ds_cpl",
"vmx",
"smx",
"est",
"tm2",
"ssse3",
"cid",
"",
"",
"cx16",
"xtpr",
"pdcm",
"",
"",
"dca",
"sse4_1",
"sse4_2",
"x2apic",
"movbe",
"popcnt",
"",
"",
"xsave",
"osxsave",
"",
"",
"",
"",
};
/*
* Output a space-separated list of supported CPU flags. x86 only.
*/
static void
print_x86_cpu_flags(u32_t * flags)
{
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 32; j++) {
if (flags[i] & (1 << j) && x86_flag[i * 32 + j][0])
buf_printf("%s ", x86_flag[i * 32 + j]);
}
}
buf_printf("\n");
}
#endif
/*
* Print information for a single CPU.
*/
static void
print_cpu(struct cpu_info * cpu_info, unsigned id)
{
buf_printf("%-16s: %d\n", "processor", id);
#if defined(__i386__)
switch (cpu_info->vendor) {
case CPU_VENDOR_INTEL:
buf_printf("%-16s: %s\n", "vendor_id", "GenuineIntel");
buf_printf("%-16s: %s\n", "model name", "Intel");
break;
case CPU_VENDOR_AMD:
buf_printf("%-16s: %s\n", "vendor_id", "AuthenticAMD");
buf_printf("%-16s: %s\n", "model name", "AMD");
break;
default:
buf_printf("%-16s: %s\n", "vendor_id", "unknown");
}
buf_printf("%-16s: %d\n", "cpu family", cpu_info->family);
buf_printf("%-16s: %d\n", "model", cpu_info->model);
buf_printf("%-16s: %d\n", "stepping", cpu_info->stepping);
buf_printf("%-16s: %d\n", "cpu MHz", cpu_info->freq);
buf_printf("%-16s: ", "flags");
print_x86_cpu_flags(cpu_info->flags);
buf_printf("\n");
#endif
}
/*
* Generate the contents of /proc/cpuinfo.
*/
void
root_cpuinfo(void)
{
struct cpu_info cpu_info[CONFIG_MAX_CPUS];
struct machine machine;
unsigned int c;
if (sys_getmachine(&machine)) {
printf("PROCFS: cannot get machine\n");
return;
}
if (sys_getcpuinfo(&cpu_info)) {
printf("PROCFS: cannot get CPU info\n");
return;
}
for (c = 0; c < machine.processors_count; c++)
print_cpu(&cpu_info[c], c);
}
|