1*433d6423SLionel Sambuc #include "inc.h" 2*433d6423SLionel Sambuc #include "../../kernel/arch/i386/include/archconst.h" 3*433d6423SLionel Sambuc 4*433d6423SLionel Sambuc #ifndef CONFIG_MAX_CPUS 5*433d6423SLionel Sambuc #define CONFIG_MAX_CPUS 1 6*433d6423SLionel Sambuc #endif 7*433d6423SLionel Sambuc 8*433d6423SLionel Sambuc static const char * x86_flag[] = { 9*433d6423SLionel Sambuc "fpu", 10*433d6423SLionel Sambuc "vme", 11*433d6423SLionel Sambuc "de", 12*433d6423SLionel Sambuc "pse", 13*433d6423SLionel Sambuc "tsc", 14*433d6423SLionel Sambuc "msr", 15*433d6423SLionel Sambuc "pae", 16*433d6423SLionel Sambuc "mce", 17*433d6423SLionel Sambuc "cx8", 18*433d6423SLionel Sambuc "apic", 19*433d6423SLionel Sambuc "", 20*433d6423SLionel Sambuc "sep", 21*433d6423SLionel Sambuc "mtrr", 22*433d6423SLionel Sambuc "pge", 23*433d6423SLionel Sambuc "mca", 24*433d6423SLionel Sambuc "cmov", 25*433d6423SLionel Sambuc "pat", 26*433d6423SLionel Sambuc "pse36", 27*433d6423SLionel Sambuc "psn", 28*433d6423SLionel Sambuc "clfsh", 29*433d6423SLionel Sambuc "", 30*433d6423SLionel Sambuc "dts", 31*433d6423SLionel Sambuc "acpi", 32*433d6423SLionel Sambuc "mmx", 33*433d6423SLionel Sambuc "fxsr", 34*433d6423SLionel Sambuc "sse", 35*433d6423SLionel Sambuc "sse2", 36*433d6423SLionel Sambuc "ss", 37*433d6423SLionel Sambuc "ht", 38*433d6423SLionel Sambuc "tm", 39*433d6423SLionel Sambuc "", 40*433d6423SLionel Sambuc "pbe", 41*433d6423SLionel Sambuc "pni", 42*433d6423SLionel Sambuc "", 43*433d6423SLionel Sambuc "", 44*433d6423SLionel Sambuc "monitor", 45*433d6423SLionel Sambuc "ds_cpl", 46*433d6423SLionel Sambuc "vmx", 47*433d6423SLionel Sambuc "smx", 48*433d6423SLionel Sambuc "est", 49*433d6423SLionel Sambuc "tm2", 50*433d6423SLionel Sambuc "ssse3", 51*433d6423SLionel Sambuc "cid", 52*433d6423SLionel Sambuc "", 53*433d6423SLionel Sambuc "", 54*433d6423SLionel Sambuc "cx16", 55*433d6423SLionel Sambuc "xtpr", 56*433d6423SLionel Sambuc "pdcm", 57*433d6423SLionel Sambuc "", 58*433d6423SLionel Sambuc "", 59*433d6423SLionel Sambuc "dca", 60*433d6423SLionel Sambuc "sse4_1", 61*433d6423SLionel Sambuc "sse4_2", 62*433d6423SLionel Sambuc "x2apic", 63*433d6423SLionel Sambuc "movbe", 64*433d6423SLionel Sambuc "popcnt", 65*433d6423SLionel Sambuc "", 66*433d6423SLionel Sambuc "", 67*433d6423SLionel Sambuc "xsave", 68*433d6423SLionel Sambuc "osxsave", 69*433d6423SLionel Sambuc "", 70*433d6423SLionel Sambuc "", 71*433d6423SLionel Sambuc "", 72*433d6423SLionel Sambuc "", 73*433d6423SLionel Sambuc }; 74*433d6423SLionel Sambuc 75*433d6423SLionel Sambuc static void print_cpu_flags(u32_t * flags) 76*433d6423SLionel Sambuc { 77*433d6423SLionel Sambuc int i, j; 78*433d6423SLionel Sambuc 79*433d6423SLionel Sambuc for (i = 0; i < 2; i++) { 80*433d6423SLionel Sambuc for (j = 0; j < 32; j++) { 81*433d6423SLionel Sambuc if (flags[i] & (1 << j) && 82*433d6423SLionel Sambuc x86_flag[i * 32 + j][0]) 83*433d6423SLionel Sambuc buf_printf("%s ", x86_flag[i * 32 + j]); 84*433d6423SLionel Sambuc } 85*433d6423SLionel Sambuc } 86*433d6423SLionel Sambuc buf_printf("\n"); 87*433d6423SLionel Sambuc } 88*433d6423SLionel Sambuc 89*433d6423SLionel Sambuc static void print_cpu(struct cpu_info * cpu_info, unsigned id) 90*433d6423SLionel Sambuc { 91*433d6423SLionel Sambuc buf_printf("%-16s: %d\n", "processor", id); 92*433d6423SLionel Sambuc 93*433d6423SLionel Sambuc #if defined(__i386__) 94*433d6423SLionel Sambuc switch (cpu_info->vendor) { 95*433d6423SLionel Sambuc case CPU_VENDOR_INTEL: 96*433d6423SLionel Sambuc buf_printf("%-16s: %s\n", "vendor_id", "GenuineIntel"); 97*433d6423SLionel Sambuc buf_printf("%-16s: %s\n", "model name", "Intel"); 98*433d6423SLionel Sambuc break; 99*433d6423SLionel Sambuc case CPU_VENDOR_AMD: 100*433d6423SLionel Sambuc buf_printf("%-16s: %s\n", "vendor_id", "AuthenticAMD"); 101*433d6423SLionel Sambuc buf_printf("%-16s: %s\n", "model name", "AMD"); 102*433d6423SLionel Sambuc break; 103*433d6423SLionel Sambuc default: 104*433d6423SLionel Sambuc buf_printf("%-16: %s\n", "vendor_id", "unknown"); 105*433d6423SLionel Sambuc } 106*433d6423SLionel Sambuc 107*433d6423SLionel Sambuc buf_printf("%-16s: %d\n", "cpu family", cpu_info->family); 108*433d6423SLionel Sambuc buf_printf("%-16s: %d\n", "model", cpu_info->model); 109*433d6423SLionel Sambuc buf_printf("%-16s: %d\n", "stepping", cpu_info->stepping); 110*433d6423SLionel Sambuc buf_printf("%-16s: %d\n", "cpu MHz", cpu_info->freq); 111*433d6423SLionel Sambuc buf_printf("%-16s: ", "flags"); 112*433d6423SLionel Sambuc print_cpu_flags(cpu_info->flags); 113*433d6423SLionel Sambuc buf_printf("\n"); 114*433d6423SLionel Sambuc #endif 115*433d6423SLionel Sambuc } 116*433d6423SLionel Sambuc 117*433d6423SLionel Sambuc void root_cpuinfo(void) 118*433d6423SLionel Sambuc { 119*433d6423SLionel Sambuc struct cpu_info cpu_info[CONFIG_MAX_CPUS]; 120*433d6423SLionel Sambuc struct machine machine; 121*433d6423SLionel Sambuc unsigned c; 122*433d6423SLionel Sambuc 123*433d6423SLionel Sambuc if (sys_getmachine(&machine)) { 124*433d6423SLionel Sambuc printf("PROCFS: cannot get machine\n"); 125*433d6423SLionel Sambuc return; 126*433d6423SLionel Sambuc } 127*433d6423SLionel Sambuc if (sys_getcpuinfo(&cpu_info)) { 128*433d6423SLionel Sambuc printf("PROCFS: cannot get cpu info\n"); 129*433d6423SLionel Sambuc return; 130*433d6423SLionel Sambuc } 131*433d6423SLionel Sambuc 132*433d6423SLionel Sambuc for (c = 0; c < machine.processors_count; c++) 133*433d6423SLionel Sambuc print_cpu(&cpu_info[c], c); 134*433d6423SLionel Sambuc } 135