summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-05-06 22:00:55 +0000
committerJordan Crouse <jordan.crouse@amd.com>2008-05-06 22:00:55 +0000
commit7ce2666249c429aa541f5e440cc7f30edb8a5c78 (patch)
tree4ffaf7899c6813e8744d8503ec917d27b92a283f
parent646ee3eae942880f254a6ce0726ffd0cd902c8f0 (diff)
downloadcoreboot-7ce2666249c429aa541f5e440cc7f30edb8a5c78.tar.xz
The previous commit had more in it then I wanted - so I am reverting
this and re-commiting so that the history and comments are correct. Signed-off-by: Jordan Crouse <jordan.crouse@amd.com> Acked-by: Jordan Crouse <jordan.crouse@amd.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3284 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--payloads/coreinfo/coreinfo.c117
1 files changed, 23 insertions, 94 deletions
diff --git a/payloads/coreinfo/coreinfo.c b/payloads/coreinfo/coreinfo.c
index c515d29bab..13a08f24a2 100644
--- a/payloads/coreinfo/coreinfo.c
+++ b/payloads/coreinfo/coreinfo.c
@@ -28,46 +28,24 @@ extern struct coreinfo_module coreboot_module;
extern struct coreinfo_module nvram_module;
extern struct coreinfo_module bootlog_module;
-struct coreinfo_module *system_modules[] = {
+struct coreinfo_module *modules[] = {
#ifdef CONFIG_MODULE_CPUINFO
&cpuinfo_module,
#endif
#ifdef CONFIG_MODULE_PCI
&pci_module,
#endif
-#ifdef CONFIG_MODULE_NVRAM
- &nvram_module,
-#endif
-};
-
-struct coreinfo_module *coreboot_modules[] = {
#ifdef CONFIG_MODULE_COREBOOT
&coreboot_module,
#endif
+#ifdef CONFIG_MODULE_NVRAM
+ &nvram_module,
+#endif
#ifdef CONFIG_MODULE_BOOTLOG
&bootlog_module,
#endif
};
-struct coreinfo_cat {
- char name[15];
- int cur;
- int count;
- struct coreinfo_module **modules;
-} categories[] = {
- {
- .name = "System",
- .modules = system_modules,
- .count = ARRAY_SIZE(system_modules),
- },
- {
- .name = "Coreboot",
- .modules = coreboot_modules,
- .count = ARRAY_SIZE(coreboot_modules),
- }
-};
-
-
static WINDOW *modwin;
static int curwin;
@@ -84,26 +62,6 @@ void print_module_title(WINDOW *win, const char *title)
waddch(win, '\304');
}
-static void print_submenu(struct coreinfo_cat *cat)
-{
- int i, j;
- char menu[80];
- char *ptr = menu;
-
- wmove(stdscr, 22, 0);
-
- for (j = 0; j < SCREEN_X; j++)
- waddch(stdscr, ' ');
-
- if (!cat->count)
- return;
-
- for (i = 0; i < cat->count; i++)
- ptr += sprintf(ptr, "[%c: %s] ", 'A' + i, cat->modules[i]->name);
-
- mvprintw(22, 0, menu);
-}
-
static void print_menu(void)
{
int i, j;
@@ -115,14 +73,11 @@ static void print_menu(void)
for (j = 0; j < SCREEN_X; j++)
waddch(stdscr, ' ');
- for (i = 0; i < ARRAY_SIZE(categories); i++) {
- if (categories[i].count == 0)
- continue;
-
- ptr += sprintf(ptr, "F%d: %s ", i + 1, categories[i].name);
- }
+ for (i = 0; i < ARRAY_SIZE(modules); i++)
+ ptr += sprintf(ptr, "F%d: %s ", i + 1, modules[i]->name);
- mvprintw(23, 0, menu);
+ if (ARRAY_SIZE(modules) != 0)
+ mvprintw(23, 0, menu);
#ifdef CONFIG_SHOW_DATE_TIME
mvprintw(23, 59, "%02d/%02d/20%02d - %02d:%02d:%02d",
@@ -162,8 +117,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, "=");
@@ -171,35 +124,16 @@ static void header(int row, const char *str)
}
#endif
-static void redraw_module(struct coreinfo_cat *cat)
+static void redraw_module(void)
{
- if (cat->count == 0)
+ if (ARRAY_SIZE(modules) == 0)
return;
wclear(modwin);
- cat->modules[cat->cur]->redraw(modwin);
+ modules[curwin]->redraw(modwin);
refresh();
}
-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;
- redraw_module(cat);
- return;
- }
- }
-
- if (cat->count && cat->modules[cat->cur]->handle) {
- if (cat->modules[cat->cur]->handle(key))
- redraw_module(cat);
- }
-}
-
static void loop(void)
{
int key;
@@ -207,8 +141,9 @@ static void loop(void)
center(0, "coreinfo v0.1");
print_menu();
- print_submenu(&categories[curwin]);
- redraw_module(&categories[curwin]);
+ if (ARRAY_SIZE(modules) != 0)
+ modules[curwin]->redraw(modwin);
+ refresh();
while (1) {
key = getch();
@@ -219,21 +154,18 @@ static void loop(void)
if (key >= KEY_F(1) && key <= KEY_F(9)) {
unsigned char ch = key - KEY_F(1);
- if (ch <= ARRAY_SIZE(categories)) {
- if (ch == ARRAY_SIZE(categories))
+ if (ch <= ARRAY_SIZE(modules)) {
+ if (ch == ARRAY_SIZE(modules))
continue;
- if (categories[ch].count == 0)
- continue;
-
curwin = ch;
- print_submenu(&categories[curwin]);
- redraw_module(&categories[curwin]);
+ redraw_module();
continue;
}
}
-
- handle_category_key(&categories[curwin], key);
+ if (ARRAY_SIZE(modules) != 0 && modules[curwin]->handle)
+ if (modules[curwin]->handle(key))
+ redraw_module();
}
}
@@ -250,7 +182,7 @@ int main(void)
init_pair(2, COLOR_BLACK, COLOR_WHITE);
init_pair(3, COLOR_WHITE, COLOR_WHITE);
- modwin = newwin(22, 80, 1, 0);
+ modwin = newwin(23, 80, 1, 0);
wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
wattrset(modwin, COLOR_PAIR(2));
@@ -264,11 +196,8 @@ int main(void)
refresh();
- for (i = 0; i < ARRAY_SIZE(categories); i++) {
- for(j = 0; j < categories[i].count; j++)
- categories[i].modules[j]->init();
-
- }
+ for (i = 0; i < ARRAY_SIZE(modules); i++)
+ modules[i]->init();
loop();