libpayload: Remove bitfield use from EHCI data structures
[coreboot.git] / payloads / coreinfo / cpuinfo_module.c
index a9641407c71b64e88f1015072ae8cc46b82abf52..7b6a3f1f42466fbb2f0122d32233b75e1a98b8dd 100644 (file)
@@ -21,6 +21,8 @@
  */
 
 #include "coreinfo.h"
+
+#ifdef CONFIG_MODULE_CPUINFO
 #include <arch/rdtsc.h>
 
 #define VENDOR_INTEL 0x756e6547
 #define VENDOR_SIS   0x20536953
 
 /* CPUID 0x00000001 EDX flags */
-const char *generic_cap_flags[] = {
+static const char *generic_cap_flags[] = {
        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
        "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
        "pat", "pse36", "psn", "clflsh", NULL, "ds", "acpi", "mmx",
        "fxsr", "sse", "sse2", "ss", "ht", "tm", NULL, "pbe"
 };
 
-  /* CPUID 0x00000001 ECX flags */
-const char *intel_cap_generic_ecx_flags[] = {
+/* CPUID 0x00000001 ECX flags */
+static const char *intel_cap_generic_ecx_flags[] = {
        "sse3", NULL, NULL, "monitor", "ds-cpl", "vmx", NULL, "est",
        "tm2", "ssse3", "cntx-id", NULL, NULL, "cx16", "xTPR", NULL,
        NULL, NULL, "dca", NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
 };
+
 /* CPUID 0x80000001 EDX flags */
-const char *intel_cap_extended_edx_flags[] = {
+static const char *intel_cap_extended_edx_flags[] = {
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, "SYSCALL", NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, "xd", NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, "em64t", NULL, NULL,
 };
+
 /* CPUID 0x80000001 ECX flags */
-const char *intel_cap_extended_ecx_flags[] = {
+static const char *intel_cap_extended_ecx_flags[] = {
        "lahf_lm", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
 
-const char *amd_cap_generic_ecx_flags[] = {
+static const char *amd_cap_generic_ecx_flags[] = {
        "sse3", NULL, NULL, "mwait", NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, "cmpxchg16b", NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, "popcnt",
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
 };
 
-const char *amd_cap_extended_edx_flags[] = {
+static const char *amd_cap_extended_edx_flags[] = {
        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
        "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
        "pat", "pse36", NULL, "mp", "nx", NULL, "mmxext", "mmx",
@@ -77,7 +81,7 @@ const char *amd_cap_extended_edx_flags[] = {
        NULL, "lm", "3dnowext", "3dnow"
 }; /* "mp" defined for CPUs prior to AMD family 0xf */
 
-const char *amd_cap_extended_ecx_flags[] = {
+static const char *amd_cap_extended_ecx_flags[] = {
        "lahf/sahf", "CmpLegacy", "svm", "ExtApicSpace",
        "LockMovCr0", "abm", "sse4a", "misalignsse",
        "3dnowPref", "osvw", "ibs", NULL, "skinit", "wdt", NULL, NULL,
@@ -88,19 +92,19 @@ const char *amd_cap_extended_ecx_flags[] = {
 static unsigned long vendor;
 static unsigned int cpu_khz;
 
-void decode_flags(WINDOW *win, unsigned long reg, const char **flags, int *row)
+static void decode_flags(WINDOW *win, unsigned long reg, const char **flags,
+                        int *row)
 {
-       int index = 0;
        int i;
        int lrow = *row;
 
        wmove(win, lrow, 2);
 
-       for(i = 0; i < 32; i++) {
+       for (i = 0; i < 32; i++) {
                if (flags[i] == NULL)
                        continue;
 
-               if (reg & (1 << i)) 
+               if (reg & (1 << i))
                        wprintw(win, "%s ", flags[i]);
 
                if (i && (i % 16) == 0) {
@@ -112,11 +116,9 @@ void decode_flags(WINDOW *win, unsigned long reg, const char **flags, int *row)
        *row = lrow;
 }
 
-
 static void get_features(WINDOW *win, int *row)
 {
        unsigned long eax, ebx, ecx, edx;
-       int index = 0;
        int lrow = *row;
 
        wmove(win, lrow++, 1);
@@ -127,7 +129,7 @@ static void get_features(WINDOW *win, int *row)
 
        lrow++;
 
-       switch(vendor) {
+       switch (vendor) {
        case VENDOR_AMD:
                wmove(win, lrow++, 1);
                wprintw(win, "AMD Extended Flags: ");
@@ -136,7 +138,6 @@ static void get_features(WINDOW *win, int *row)
                decode_flags(win, edx, amd_cap_extended_edx_flags, &lrow);
                decode_flags(win, ecx, amd_cap_extended_ecx_flags, &lrow);
                break;
-
        case VENDOR_INTEL:
                wmove(win, lrow++, 1);
                wprintw(win, "Intel Extended Flags: ");
@@ -152,38 +153,35 @@ static void get_features(WINDOW *win, int *row)
 
 static void do_name(WINDOW *win, int row)
 {
-       char str[80];
+       char name[49], *p;
        unsigned long eax, ebx, ecx, edx;
        int i, t;
-       char name[49], *p;
 
        p = name;
 
-       for(i = 0x80000002; i <= 0x80000004; i++) {
+       for (i = 0x80000002; i <= 0x80000004; i++) {
                docpuid(i, &eax, &ebx, &ecx, &edx);
 
                if (eax == 0)
                        break;
 
-               for(t = 0; t < 4; t++)
+               for (t = 0; t < 4; t++)
                        *p++ = eax >> (8 * t);
-               for(t = 0; t < 4; t++)
+               for (t = 0; t < 4; t++)
                        *p++ = ebx >> (8 * t);
-               for(t = 0; t < 4; t++)
+               for (t = 0; t < 4; t++)
                        *p++ = ecx >> (8 * t);
-               for(t = 0; t < 4; t++)
+               for (t = 0; t < 4; t++)
                        *p++ = edx >> (8 * t);
        }
 
-       mvwprintw(win, row,1, "Processor: %s", name);
+       mvwprintw(win, row, 1, "Processor: %s", name);
 }
 
-int cpuinfo_module_redraw(WINDOW *win)
+static int cpuinfo_module_redraw(WINDOW *win)
 {
        unsigned long eax, ebx, ecx, edx;
-
        unsigned int brand;
-       char str[80];
        char *vstr;
        int row = 2;
 
@@ -191,8 +189,8 @@ int cpuinfo_module_redraw(WINDOW *win)
 
        docpuid(0, NULL, &vendor, NULL, NULL);
 
-       switch(vendor) {
-       case  VENDOR_INTEL:
+       switch (vendor) {
+       case VENDOR_INTEL:
                vstr = "Intel";
                break;
        case VENDOR_AMD:
@@ -213,6 +211,10 @@ int cpuinfo_module_redraw(WINDOW *win)
                break;
        case VENDOR_SIS:
                vstr = "SiS";
+               break;
+       default:
+               vstr = "Unknown";
+               break;
        }
 
        mvwprintw(win, row++, 1, "Vendor: %s", vstr);
@@ -221,7 +223,7 @@ int cpuinfo_module_redraw(WINDOW *win)
 
        docpuid(0x00000001, &eax, &ebx, &ecx, &edx);
 
-       mvwprintw(win, row++, 1, "Family: %X",(eax >> 8) & 0x0f);
+       mvwprintw(win, row++, 1, "Family: %X", (eax >> 8) & 0x0f);
        mvwprintw(win, row++, 1, "Model: %X",
                  ((eax >> 4) & 0xf) | ((eax >> 16) & 0xf) << 4);
 
@@ -229,44 +231,49 @@ int cpuinfo_module_redraw(WINDOW *win)
 
        if (vendor == VENDOR_AMD) {
                docpuid(0x80000001, &eax, &ebx, &ecx, &edx);
-               brand = ((ebx >> 9) & 0x1F);
+               brand = ((ebx >> 9) & 0x1f);
 
-               mvwprintw(win, row++, 1,"Brand: %X", brand);
+               mvwprintw(win, row++, 1, "Brand: %X", brand);
        }
 
-       if (cpu_khz != 0) {
-               mvwprintw(win, row++, 1, "CPU Speed: %d Mhz",
-                               cpu_khz / 1000);
-       }
-       else {
+       if (cpu_khz != 0)
+               mvwprintw(win, row++, 1, "CPU Speed: %d Mhz", cpu_khz / 1000);
+       else
                mvwprintw(win, row++, 1, "CPU Speed: Error");
-       }
 
        row++;
        get_features(win, &row);
+
+       return 0;
 }
 
-unsigned int getticks(void) 
+static unsigned int getticks(void)
 {
        unsigned long long start, end;
 
-       /* Read the number of ticks during the period */
-
+       /* Read the number of ticks during the period. */
        start = rdtsc();
        mdelay(100);
        end = rdtsc();
 
-       return (unsigned int) ((end - start) / 100);
+       return (unsigned int)((end - start) / 100);
 }
 
-int cpuinfo_module_init(void)
+static int cpuinfo_module_init(void)
 {
        cpu_khz = getticks();
+       return 0;
 }
 
 struct coreinfo_module cpuinfo_module = {
        .name = "CPU Info",
        .init = cpuinfo_module_init,
        .redraw = cpuinfo_module_redraw,
-       .handle = NULL,
 };
+
+#else
+
+struct coreinfo_module cpuinfo_module = {
+};
+
+#endif