1 /* ProcFS - cpuinfo.c - generator for the cpuinfo file */
6 #include "../../kernel/arch/i386/include/archconst.h"
9 #ifndef CONFIG_MAX_CPUS
10 #define CONFIG_MAX_CPUS 1
14 static const char * x86_flag
[] = {
82 * Output a space-separated list of supported CPU flags. x86 only.
85 print_x86_cpu_flags(u32_t
* flags
)
89 for (i
= 0; i
< 2; i
++) {
90 for (j
= 0; j
< 32; j
++) {
91 if (flags
[i
] & (1 << j
) && x86_flag
[i
* 32 + j
][0])
92 buf_printf("%s ", x86_flag
[i
* 32 + j
]);
100 * Print information for a single CPU.
103 print_cpu(struct cpu_info
* cpu_info
, unsigned id
)
106 buf_printf("%-16s: %d\n", "processor", id
);
108 #if defined(__i386__)
109 switch (cpu_info
->vendor
) {
110 case CPU_VENDOR_INTEL
:
111 buf_printf("%-16s: %s\n", "vendor_id", "GenuineIntel");
112 buf_printf("%-16s: %s\n", "model name", "Intel");
115 buf_printf("%-16s: %s\n", "vendor_id", "AuthenticAMD");
116 buf_printf("%-16s: %s\n", "model name", "AMD");
119 buf_printf("%-16s: %s\n", "vendor_id", "unknown");
122 buf_printf("%-16s: %d\n", "cpu family", cpu_info
->family
);
123 buf_printf("%-16s: %d\n", "model", cpu_info
->model
);
124 buf_printf("%-16s: %d\n", "stepping", cpu_info
->stepping
);
125 buf_printf("%-16s: %d\n", "cpu MHz", cpu_info
->freq
);
126 buf_printf("%-16s: ", "flags");
127 print_x86_cpu_flags(cpu_info
->flags
);
133 * Generate the contents of /proc/cpuinfo.
138 struct cpu_info cpu_info
[CONFIG_MAX_CPUS
];
139 struct machine machine
;
142 if (sys_getmachine(&machine
)) {
143 printf("PROCFS: cannot get machine\n");
146 if (sys_getcpuinfo(&cpu_info
)) {
147 printf("PROCFS: cannot get CPU info\n");
151 for (c
= 0; c
< machine
.processors_count
; c
++)
152 print_cpu(&cpu_info
[c
], c
);