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
);
93 switch (cpu_info
->vendor
) {
94 case CPU_VENDOR_INTEL
:
95 buf_printf("%-16s: %s\n", "vendor_id", "GenuineIntel");
96 buf_printf("%-16s: %s\n", "model name", "Intel");
99 buf_printf("%-16s: %s\n", "vendor_id", "AuthenticAMD");
100 buf_printf("%-16s: %s\n", "model name", "AMD");
103 buf_printf("%-16: %s\n", "vendor_id", "unknown");
106 buf_printf("%-16s: %d\n", "cpu family", cpu_info
->family
);
107 buf_printf("%-16s: %d\n", "model", cpu_info
->model
);
108 buf_printf("%-16s: %d\n", "stepping", cpu_info
->stepping
);
109 buf_printf("%-16s: %d\n", "cpu MHz", cpu_info
->freq
);
110 buf_printf("%-16s: ", "flags");
111 print_cpu_flags(cpu_info
->flags
);
116 void root_cpuinfo(void)
118 struct cpu_info cpu_info
[CONFIG_MAX_CPUS
];
119 struct machine machine
;
122 if (sys_getmachine(&machine
)) {
123 printf("PROCFS: cannot get machine\n");
126 if (sys_getcpuinfo(&cpu_info
)) {
127 printf("PROCFS: cannot get cpu info\n");
131 for (c
= 0; c
< machine
.processors_count
; c
++)
132 print_cpu(&cpu_info
[c
], c
);