2008-03-20 01:11:05 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreinfo project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "coreinfo.h"
|
|
|
|
|
2008-05-21 15:49:03 +02:00
|
|
|
#define KEY_ESC 27
|
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
extern struct coreinfo_module cpuinfo_module;
|
|
|
|
extern struct coreinfo_module pci_module;
|
|
|
|
extern struct coreinfo_module coreboot_module;
|
2008-11-11 20:53:42 +01:00
|
|
|
extern struct coreinfo_module multiboot_module;
|
2008-03-31 22:30:18 +02:00
|
|
|
extern struct coreinfo_module nvram_module;
|
2008-04-22 22:19:53 +02:00
|
|
|
extern struct coreinfo_module bootlog_module;
|
2008-07-08 18:18:38 +02:00
|
|
|
extern struct coreinfo_module ramdump_module;
|
2009-07-07 17:10:13 +02:00
|
|
|
extern struct coreinfo_module cbfs_module;
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
struct coreinfo_module *system_modules[] = {
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_CPUINFO)
|
2008-03-20 01:11:05 +01:00
|
|
|
&cpuinfo_module,
|
2008-03-31 22:30:18 +02:00
|
|
|
#endif
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_PCI)
|
2008-03-20 01:11:05 +01:00
|
|
|
&pci_module,
|
2008-03-31 22:30:18 +02:00
|
|
|
#endif
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_NVRAM)
|
2008-05-07 00:00:55 +02:00
|
|
|
&nvram_module,
|
|
|
|
#endif
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_RAMDUMP)
|
2008-07-08 18:18:38 +02:00
|
|
|
&ramdump_module,
|
|
|
|
#endif
|
2008-05-07 00:03:16 +02:00
|
|
|
};
|
|
|
|
|
2008-11-11 20:53:42 +01:00
|
|
|
struct coreinfo_module *firmware_modules[] = {
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_COREBOOT)
|
2008-05-07 00:03:16 +02:00
|
|
|
&coreboot_module,
|
|
|
|
#endif
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_MULTIBOOT)
|
2008-11-11 20:53:42 +01:00
|
|
|
&multiboot_module,
|
|
|
|
#endif
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_BOOTLOG)
|
2008-04-22 22:19:53 +02:00
|
|
|
&bootlog_module,
|
2009-07-07 17:10:13 +02:00
|
|
|
#endif
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_CBFS)
|
2009-07-07 17:10:13 +02:00
|
|
|
&cbfs_module,
|
2008-05-07 22:43:15 +02:00
|
|
|
#endif
|
2008-03-20 01:11:05 +01:00
|
|
|
};
|
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
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),
|
|
|
|
},
|
|
|
|
{
|
2008-11-11 20:53:42 +01:00
|
|
|
.name = "Firmware",
|
|
|
|
.modules = firmware_modules,
|
|
|
|
.count = ARRAY_SIZE(firmware_modules),
|
2008-05-07 00:03:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-08-07 16:35:39 +02:00
|
|
|
static WINDOW *modwin, *menuwin;
|
2008-03-20 01:11:05 +01:00
|
|
|
static int curwin;
|
|
|
|
|
|
|
|
void print_module_title(WINDOW *win, const char *title)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
wattrset(win, COLOR_PAIR(2));
|
|
|
|
mvwprintw(win, 0, 1, title);
|
|
|
|
|
|
|
|
wmove(win, 1, 1);
|
2008-03-20 02:11:28 +01:00
|
|
|
for (i = 0; i < 78; i++)
|
2008-08-11 22:35:32 +02:00
|
|
|
waddch(win, ACS_HLINE);
|
2008-03-20 01:11:05 +01:00
|
|
|
}
|
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
static void print_submenu(struct coreinfo_cat *cat)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
char menu[80];
|
|
|
|
char *ptr = menu;
|
|
|
|
|
2008-05-20 22:16:03 +02:00
|
|
|
wmove(menuwin, 0, 0);
|
2008-05-07 00:03:16 +02:00
|
|
|
|
|
|
|
for (j = 0; j < SCREEN_X; j++)
|
2008-05-20 22:16:03 +02:00
|
|
|
waddch(menuwin, ' ');
|
2008-05-07 00:03:16 +02:00
|
|
|
|
|
|
|
if (!cat->count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < cat->count; i++)
|
2008-08-07 16:35:39 +02:00
|
|
|
ptr += sprintf(ptr, "[%c: %s] ", 'A' + i,
|
|
|
|
cat->modules[i]->name);
|
2008-05-07 00:03:16 +02:00
|
|
|
|
2008-05-20 22:16:03 +02:00
|
|
|
mvwprintw(menuwin, 0, 0, menu);
|
2008-05-07 00:03:16 +02:00
|
|
|
}
|
|
|
|
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_SHOW_DATE_TIME)
|
2008-05-07 00:15:31 +02:00
|
|
|
static void print_time_and_date(void)
|
|
|
|
{
|
|
|
|
struct tm tm;
|
|
|
|
|
2008-07-18 16:08:18 +02:00
|
|
|
while (nvram_updating())
|
2008-05-07 00:15:31 +02:00
|
|
|
mdelay(10);
|
|
|
|
|
|
|
|
rtc_read_clock(&tm);
|
|
|
|
|
2016-04-04 19:44:30 +02:00
|
|
|
mvwprintw(menuwin, 1, 57, "%02d/%02d/%04d - %02d:%02d:%02d",
|
2015-11-14 18:16:58 +01:00
|
|
|
tm.tm_mon + 1, tm.tm_mday, 1900 + tm.tm_year, tm.tm_hour,
|
2008-07-18 16:08:18 +02:00
|
|
|
tm.tm_min, tm.tm_sec);
|
2008-05-07 00:15:31 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-03-23 16:34:04 +01:00
|
|
|
static void print_menu(void)
|
2008-03-20 02:11:28 +01:00
|
|
|
{
|
2008-03-20 21:05:22 +01:00
|
|
|
int i, j;
|
2008-03-20 01:11:05 +01:00
|
|
|
char menu[80];
|
|
|
|
char *ptr = menu;
|
|
|
|
|
2008-05-20 22:16:03 +02:00
|
|
|
wmove(menuwin, 1, 0);
|
2008-03-20 02:11:28 +01:00
|
|
|
for (j = 0; j < SCREEN_X; j++)
|
2008-05-20 22:16:03 +02:00
|
|
|
waddch(menuwin, ' ');
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
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);
|
|
|
|
}
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-20 22:16:03 +02:00
|
|
|
mvwprintw(menuwin, 1, 0, menu);
|
2008-03-31 22:30:18 +02:00
|
|
|
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_SHOW_DATE_TIME)
|
2008-05-07 00:15:31 +02:00
|
|
|
print_time_and_date();
|
2008-03-31 22:30:18 +02:00
|
|
|
#endif
|
2008-03-20 01:11:05 +01:00
|
|
|
}
|
|
|
|
|
2008-03-23 16:34:04 +01:00
|
|
|
static void center(int row, const char *str)
|
2008-03-20 01:11:05 +01:00
|
|
|
{
|
2008-08-07 16:35:39 +02:00
|
|
|
int j, len = strlen(str);
|
2008-03-20 01:11:05 +01:00
|
|
|
|
|
|
|
wmove(stdscr, row, 0);
|
2008-03-20 02:11:28 +01:00
|
|
|
for (j = 0; j < SCREEN_X; j++)
|
2008-03-20 01:11:05 +01:00
|
|
|
waddch(stdscr, ' ');
|
|
|
|
|
|
|
|
mvprintw(row, (SCREEN_X - len) / 2, str);
|
|
|
|
}
|
|
|
|
|
2008-03-23 16:34:04 +01:00
|
|
|
/* FIXME: Currently unused. */
|
|
|
|
#if 0
|
|
|
|
static void header(int row, const char *str)
|
2008-03-20 01:11:05 +01:00
|
|
|
{
|
|
|
|
char buf[SCREEN_X];
|
|
|
|
char *ptr = buf;
|
|
|
|
int i;
|
|
|
|
int len = strlen(str) + 4;
|
|
|
|
|
2008-03-20 02:11:28 +01:00
|
|
|
for (i = 0; i < (SCREEN_X - len) / 2; i++)
|
2008-03-20 01:11:05 +01:00
|
|
|
ptr += sprintf(ptr, "=");
|
|
|
|
|
|
|
|
ptr += sprintf(ptr, "[ %s ]", str);
|
|
|
|
|
2008-03-20 02:11:28 +01:00
|
|
|
for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++)
|
2008-03-20 01:11:05 +01:00
|
|
|
ptr += sprintf(ptr, "=");
|
|
|
|
|
|
|
|
mvprintw(row, 0, buf);
|
|
|
|
}
|
2008-03-23 16:34:04 +01:00
|
|
|
#endif
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
static void redraw_module(struct coreinfo_cat *cat)
|
2008-03-20 01:11:05 +01:00
|
|
|
{
|
2008-05-07 00:03:16 +02:00
|
|
|
if (cat->count == 0)
|
2008-04-04 18:49:09 +02:00
|
|
|
return;
|
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
wclear(modwin);
|
2008-05-07 00:03:16 +02:00
|
|
|
cat->modules[cat->cur]->redraw(modwin);
|
2008-05-20 22:16:03 +02:00
|
|
|
wrefresh(modwin);
|
2008-03-20 01:11:05 +01:00
|
|
|
}
|
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
static void handle_category_key(struct coreinfo_cat *cat, int key)
|
|
|
|
{
|
|
|
|
if (key >= 'a' && key <= 'z') {
|
|
|
|
int index = key - 'a';
|
|
|
|
if (index < cat->count) {
|
2008-07-18 16:08:18 +02:00
|
|
|
cat->cur = index;
|
2008-05-07 00:03:16 +02:00
|
|
|
redraw_module(cat);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cat->count && cat->modules[cat->cur]->handle) {
|
|
|
|
if (cat->modules[cat->cur]->handle(key))
|
|
|
|
redraw_module(cat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:56:31 +01:00
|
|
|
static void print_no_modules_selected(void)
|
|
|
|
{
|
|
|
|
int height = getmaxy(stdscr), i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(categories); i++)
|
|
|
|
if (categories[i].count > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
color_set(2, NULL); // White on black
|
|
|
|
center(height / 2, "No modules selected");
|
|
|
|
}
|
|
|
|
|
2016-03-10 06:33:00 +01:00
|
|
|
static int first_nonempty_category(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(categories); i++)
|
|
|
|
if (categories[i].count > 0)
|
|
|
|
return i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-23 16:34:04 +01:00
|
|
|
static void loop(void)
|
2008-03-20 01:11:05 +01:00
|
|
|
{
|
|
|
|
int key;
|
|
|
|
|
2008-08-05 16:36:20 +02:00
|
|
|
center(0, CONFIG_PAYLOAD_INFO_NAME " " CONFIG_PAYLOAD_INFO_VERSION);
|
2016-03-10 04:56:31 +01:00
|
|
|
print_no_modules_selected();
|
2008-05-20 22:16:03 +02:00
|
|
|
refresh();
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2016-03-10 06:33:00 +01:00
|
|
|
curwin = first_nonempty_category();
|
2008-03-20 01:11:05 +01:00
|
|
|
print_menu();
|
2008-05-07 00:03:16 +02:00
|
|
|
print_submenu(&categories[curwin]);
|
|
|
|
redraw_module(&categories[curwin]);
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-07 00:15:31 +02:00
|
|
|
halfdelay(10);
|
|
|
|
|
2008-03-20 02:11:28 +01:00
|
|
|
while (1) {
|
2016-03-12 08:17:28 +01:00
|
|
|
int ch = -1;
|
|
|
|
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_SHOW_DATE_TIME)
|
2008-05-07 00:15:31 +02:00
|
|
|
print_time_and_date();
|
2008-05-20 22:16:03 +02:00
|
|
|
wrefresh(menuwin);
|
2008-05-07 00:15:31 +02:00
|
|
|
#endif
|
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
key = getch();
|
|
|
|
|
|
|
|
if (key == ERR)
|
2008-03-20 02:11:28 +01:00
|
|
|
continue;
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2016-03-12 08:17:28 +01:00
|
|
|
if (key >= KEY_F(1) && key <= KEY_F(9))
|
|
|
|
ch = key - KEY_F(1);
|
|
|
|
if (key >= '1' && key <= '9')
|
|
|
|
ch = key - '1';
|
2008-05-07 00:03:16 +02:00
|
|
|
|
2016-03-12 08:17:28 +01:00
|
|
|
if (ch >= 0 && ch <= ARRAY_SIZE(categories)) {
|
|
|
|
if (ch == ARRAY_SIZE(categories))
|
|
|
|
continue;
|
|
|
|
if (categories[ch].count == 0)
|
2008-03-20 01:11:05 +01:00
|
|
|
continue;
|
2016-03-12 08:17:28 +01:00
|
|
|
|
|
|
|
curwin = ch;
|
|
|
|
print_submenu(&categories[curwin]);
|
|
|
|
redraw_module(&categories[curwin]);
|
|
|
|
continue;
|
2008-03-20 01:11:05 +01:00
|
|
|
}
|
|
|
|
|
2008-05-21 15:49:03 +02:00
|
|
|
if (key == KEY_ESC)
|
2008-05-20 22:16:34 +02:00
|
|
|
return;
|
2008-05-07 00:03:16 +02:00
|
|
|
|
|
|
|
handle_category_key(&categories[curwin], key);
|
2008-03-20 01:11:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_LP_USB)
|
2012-12-06 01:22:47 +01:00
|
|
|
usb_initialize();
|
|
|
|
#endif
|
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
initscr();
|
|
|
|
|
2012-12-06 01:26:03 +01:00
|
|
|
start_color();
|
2008-03-20 01:11:05 +01:00
|
|
|
init_pair(1, COLOR_WHITE, COLOR_GREEN);
|
2012-12-06 01:26:03 +01:00
|
|
|
init_pair(2, COLOR_WHITE, COLOR_BLACK);
|
|
|
|
init_pair(3, COLOR_BLACK, COLOR_WHITE);
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-20 22:16:03 +02:00
|
|
|
modwin = newwin(SCREEN_Y - 3, SCREEN_X, 1, 0);
|
|
|
|
menuwin = newwin(2, SCREEN_X, SCREEN_Y - 2, 0);
|
2008-03-20 01:11:05 +01:00
|
|
|
|
|
|
|
wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
|
|
|
|
wattrset(modwin, COLOR_PAIR(2));
|
2008-05-20 22:16:03 +02:00
|
|
|
wattrset(menuwin, COLOR_PAIR(1) | A_BOLD);
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-09-24 16:21:02 +02:00
|
|
|
werase(modwin);
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(categories); i++) {
|
2008-07-18 16:08:18 +02:00
|
|
|
for (j = 0; j < categories[i].count; j++)
|
2008-05-07 00:03:16 +02:00
|
|
|
categories[i].modules[j]->init();
|
|
|
|
}
|
2008-03-20 02:11:28 +01:00
|
|
|
|
2012-12-06 01:22:47 +01:00
|
|
|
noecho(); /* don't let curses echo keyboard chars */
|
|
|
|
keypad(stdscr, TRUE); /* allow KEY_F(n) keys to be seen */
|
2015-11-14 18:16:58 +01:00
|
|
|
curs_set(0); /* Hide blinking cursor */
|
2012-12-06 01:22:47 +01:00
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
loop();
|
2008-03-20 21:05:22 +01:00
|
|
|
|
2015-09-27 15:53:40 +02:00
|
|
|
/* reboot */
|
|
|
|
outb(0x6, 0xcf9);
|
|
|
|
halt();
|
2008-03-20 21:05:22 +01:00
|
|
|
return 0;
|
2008-03-20 01:11:05 +01:00
|
|
|
}
|
2008-05-27 22:07:47 +02:00
|
|
|
|
2008-08-05 16:36:20 +02:00
|
|
|
PAYLOAD_INFO(name, CONFIG_PAYLOAD_INFO_NAME);
|
|
|
|
PAYLOAD_INFO(listname, CONFIG_PAYLOAD_INFO_LISTNAME);
|
|
|
|
PAYLOAD_INFO(desc, CONFIG_PAYLOAD_INFO_DESC);
|