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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "coreinfo.h"
|
|
|
|
|
2008-05-20 22:16:03 +02:00
|
|
|
#define SCREEN_Y 25
|
2008-03-20 01:11:05 +01:00
|
|
|
#define SCREEN_X 80
|
|
|
|
|
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-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;
|
2008-05-07 22:43:15 +02:00
|
|
|
extern struct coreinfo_module lar_module;
|
2008-03-20 01:11:05 +01:00
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
struct coreinfo_module *system_modules[] = {
|
2008-03-31 22:30:18 +02:00
|
|
|
#ifdef CONFIG_MODULE_CPUINFO
|
2008-03-20 01:11:05 +01:00
|
|
|
&cpuinfo_module,
|
2008-03-31 22:30:18 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_MODULE_PCI
|
2008-03-20 01:11:05 +01:00
|
|
|
&pci_module,
|
2008-03-31 22:30:18 +02:00
|
|
|
#endif
|
2008-05-07 00:00:55 +02:00
|
|
|
#ifdef CONFIG_MODULE_NVRAM
|
|
|
|
&nvram_module,
|
|
|
|
#endif
|
2008-07-08 18:18:38 +02:00
|
|
|
#ifdef CONFIG_MODULE_RAMDUMP
|
|
|
|
&ramdump_module,
|
|
|
|
#endif
|
2008-05-07 00:03:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct coreinfo_module *coreboot_modules[] = {
|
|
|
|
#ifdef CONFIG_MODULE_COREBOOT
|
|
|
|
&coreboot_module,
|
|
|
|
#endif
|
2008-04-22 22:19:53 +02:00
|
|
|
#ifdef CONFIG_MODULE_BOOTLOG
|
|
|
|
&bootlog_module,
|
|
|
|
#endif
|
2008-05-07 22:43:15 +02:00
|
|
|
#ifdef CONFIG_MODULE_LAR
|
|
|
|
&lar_module
|
|
|
|
#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),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "Coreboot",
|
|
|
|
.modules = coreboot_modules,
|
|
|
|
.count = ARRAY_SIZE(coreboot_modules),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-05-07 00:15:31 +02:00
|
|
|
#ifdef CONFIG_SHOW_DATE_TIME
|
|
|
|
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);
|
|
|
|
|
2008-05-20 22:16:03 +02:00
|
|
|
mvwprintw(menuwin, 0, 57, "%02d/%02d/%04d - %02d:%02d:%02d",
|
2008-08-07 16:35:39 +02:00
|
|
|
tm.tm_mon, 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
|
|
|
|
|
|
|
#ifdef 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
2008-05-20 22:16:03 +02:00
|
|
|
refresh();
|
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) {
|
2008-05-07 00:15:31 +02:00
|
|
|
#ifdef CONFIG_SHOW_DATE_TIME
|
|
|
|
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
|
|
|
|
|
|
|
if (key >= KEY_F(1) && key <= KEY_F(9)) {
|
|
|
|
unsigned char ch = key - KEY_F(1);
|
|
|
|
|
2008-05-07 00:03:16 +02:00
|
|
|
if (ch <= ARRAY_SIZE(categories)) {
|
|
|
|
if (ch == ARRAY_SIZE(categories))
|
2008-04-04 18:49:09 +02:00
|
|
|
continue;
|
2008-05-07 00:03:16 +02:00
|
|
|
if (categories[ch].count == 0)
|
|
|
|
continue;
|
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
curwin = ch;
|
2008-05-07 00:03:16 +02:00
|
|
|
print_submenu(&categories[curwin]);
|
|
|
|
redraw_module(&categories[curwin]);
|
2008-03-20 01:11:05 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
initscr();
|
|
|
|
|
|
|
|
init_pair(1, COLOR_WHITE, COLOR_GREEN);
|
|
|
|
init_pair(2, COLOR_BLACK, COLOR_WHITE);
|
|
|
|
init_pair(3, COLOR_WHITE, COLOR_WHITE);
|
|
|
|
|
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
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
loop();
|
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);
|