fix cross compilationor libpayload / coreinfo by honoring
[coreboot.git] / payloads / coreinfo / coreinfo.c
index 6055925f1378d704c3e4f3579ba108c41769cac4..aa8be10eaeb7307e0d17a28fc6fb85a9fa3731ac 100644 (file)
@@ -29,6 +29,7 @@ extern struct coreinfo_module pci_module;
 extern struct coreinfo_module coreboot_module;
 extern struct coreinfo_module nvram_module;
 extern struct coreinfo_module bootlog_module;
+extern struct coreinfo_module ramdump_module;
 extern struct coreinfo_module lar_module;
 
 struct coreinfo_module *system_modules[] = {
@@ -41,6 +42,9 @@ struct coreinfo_module *system_modules[] = {
 #ifdef CONFIG_MODULE_NVRAM
        &nvram_module,
 #endif
+#ifdef CONFIG_MODULE_RAMDUMP
+       &ramdump_module,
+#endif
 };
 
 struct coreinfo_module *coreboot_modules[] = {
@@ -73,10 +77,7 @@ struct coreinfo_cat {
        }
 };
 
-
-static WINDOW *modwin;
-static WINDOW *menuwin;
-
+static WINDOW *modwin, *menuwin;
 static int curwin;
 
 void print_module_title(WINDOW *win, const char *title)
@@ -87,7 +88,6 @@ void print_module_title(WINDOW *win, const char *title)
        mvwprintw(win, 0, 1, title);
 
        wmove(win, 1, 1);
-
        for (i = 0; i < 78; i++)
                waddch(win, '\304');
 }
@@ -107,7 +107,8 @@ static void print_submenu(struct coreinfo_cat *cat)
                return;
 
        for (i = 0; i < cat->count; i++)
-               ptr += sprintf(ptr, "[%c: %s] ", 'A' + i, cat->modules[i]->name);
+               ptr += sprintf(ptr, "[%c: %s] ", 'A' + i,
+                              cat->modules[i]->name);
 
        mvwprintw(menuwin, 0, 0, menu);
 }
@@ -117,14 +118,14 @@ static void print_time_and_date(void)
 {
        struct tm tm;
 
-       while(nvram_updating())
+       while (nvram_updating())
                mdelay(10);
 
        rtc_read_clock(&tm);
 
        mvwprintw(menuwin, 0, 57, "%02d/%02d/%04d - %02d:%02d:%02d",
-               tm.tm_mon, tm.tm_mday, 1900+tm.tm_year, tm.tm_hour,
-               tm.tm_min, tm.tm_sec);
+                 tm.tm_mon, tm.tm_mday, 1900 + tm.tm_year, tm.tm_hour,
+                 tm.tm_min, tm.tm_sec);
 }
 #endif
 
@@ -135,7 +136,6 @@ static void print_menu(void)
        char *ptr = menu;
 
        wmove(menuwin, 1, 0);
-
        for (j = 0; j < SCREEN_X; j++)
                waddch(menuwin, ' ');
 
@@ -155,11 +155,9 @@ static void print_menu(void)
 
 static void center(int row, const char *str)
 {
-       int len = strlen(str);
-       int j;
+       int j, len = strlen(str);
 
        wmove(stdscr, row, 0);
-
        for (j = 0; j < SCREEN_X; j++)
                waddch(stdscr, ' ');
 
@@ -180,8 +178,6 @@ static void header(int row, const char *str)
 
        ptr += sprintf(ptr, "[ %s ]", str);
 
-
-
        for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++)
                ptr += sprintf(ptr, "=");
 
@@ -203,10 +199,8 @@ static void handle_category_key(struct coreinfo_cat *cat, int key)
 {
        if (key >= 'a' && key <= 'z') {
                int index = key - 'a';
-
                if (index < cat->count) {
-
-               cat->cur = index;
+                       cat->cur = index;
                        redraw_module(cat);
                        return;
                }
@@ -222,7 +216,7 @@ static void loop(void)
 {
        int key;
 
-       center(0, "coreinfo v0.1");
+       center(0, CONFIG_PAYLOAD_INFO_NAME " " CONFIG_PAYLOAD_INFO_VERSION);
        refresh();
 
        print_menu();
@@ -269,9 +263,6 @@ int main(void)
 {
        int i, j;
 
-       curses_enable_serial(0);
-       curses_enable_vga(1);
-
        initscr();
 
        init_pair(1, COLOR_WHITE, COLOR_GREEN);
@@ -287,7 +278,6 @@ int main(void)
 
        for (i = 0; i < SCREEN_Y - 1; i++) {
                wmove(modwin, i - 1, 0);
-
                for (j = 0; j < SCREEN_X; j++)
                        waddch(modwin, ' ');
        }
@@ -295,12 +285,15 @@ int main(void)
        wrefresh(modwin);
 
        for (i = 0; i < ARRAY_SIZE(categories); i++) {
-               for(j = 0; j < categories[i].count; j++)
+               for (j = 0; j < categories[i].count; j++)
                        categories[i].modules[j]->init();
-
        }
 
        loop();
 
        return 0;
 }
+
+PAYLOAD_INFO(name, CONFIG_PAYLOAD_INFO_NAME);
+PAYLOAD_INFO(listname, CONFIG_PAYLOAD_INFO_LISTNAME);
+PAYLOAD_INFO(desc, CONFIG_PAYLOAD_INFO_DESC);