2 #include "../../kernel/arch/i386/include/archconst.h"
4 #ifndef CONFIG_MAX_CPUS
5 #define CONFIG_MAX_CPUS 1
8 static const char * x86_flag
[] = {
75 static void print_cpu_flags(u32_t
* flags
)
79 for (i
= 0; i
< 2; i
++) {
80 for (j
= 0; j
< 32; j
++) {
81 if (flags
[i
] & (1 << j
) &&
82 x86_flag
[i
* 32 + j
][0])
83 buf_printf("%s ", x86_flag
[i
* 32 + j
]);
89 static void print_cpu(struct cpu_info
* cpu_info
, unsigned id
)
91 buf_printf("%-16s: %d\n", "processor", id
);
94 switch (cpu_info
->vendor
) {
95 case CPU_VENDOR_INTEL
:
96 buf_printf("%-16s: %s\n", "vendor_id", "GenuineIntel");
97 buf_printf("%-16s: %s\n", "model name", "Intel");
100 buf_printf("%-16s: %s\n", "vendor_id", "AuthenticAMD");
101 buf_printf("%-16s: %s\n", "model name", "AMD");
104 buf_printf("%-16: %s\n", "vendor_id", "unknown");
107 buf_printf("%-16s: %d\n", "cpu family", cpu_info
->family
);
108 buf_printf("%-16s: %d\n", "model", cpu_info
->model
);
109 buf_printf("%-16s: %d\n", "stepping", cpu_info
->stepping
);
110 buf_printf("%-16s: %d\n", "cpu MHz", cpu_info
->freq
);
111 buf_printf("%-16s: ", "flags");
112 print_cpu_flags(cpu_info
->flags
);
117 void root_cpuinfo(void)
119 struct cpu_info cpu_info
[CONFIG_MAX_CPUS
];
120 struct machine machine
;
123 if (sys_getmachine(&machine
)) {
124 printf("PROCFS: cannot get machine\n");
127 if (sys_getcpuinfo(&cpu_info
)) {
128 printf("PROCFS: cannot get cpu info\n");
132 for (c
= 0; c
< machine
.processors_count
; c
++)
133 print_cpu(&cpu_info
[c
], c
);