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"
|
|
|
|
|
|
|
|
#define SCREEN_Y 24
|
|
|
|
#define SCREEN_X 80
|
|
|
|
|
|
|
|
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-03-20 01:11:05 +01:00
|
|
|
|
2008-03-27 21:46:49 +01:00
|
|
|
struct coreinfo_module *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
|
|
|
|
#ifdef CONFIG_MODULE_COREBOOT
|
2008-03-27 21:46:49 +01:00
|
|
|
&coreboot_module,
|
2008-03-31 22:30:18 +02:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_MODULE_NVRAM
|
|
|
|
&nvram_module,
|
|
|
|
#endif
|
2008-04-22 22:19:53 +02:00
|
|
|
#ifdef CONFIG_MODULE_BOOTLOG
|
|
|
|
&bootlog_module,
|
|
|
|
#endif
|
2008-03-20 01:11:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static WINDOW *modwin;
|
|
|
|
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-03-20 01:11:05 +01:00
|
|
|
waddch(win, '\304');
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
wmove(stdscr, 23, 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, ' ');
|
|
|
|
|
2008-03-27 21:46:49 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(modules); i++)
|
2008-03-20 01:11:05 +01:00
|
|
|
ptr += sprintf(ptr, "F%d: %s ", i + 1, modules[i]->name);
|
|
|
|
|
2008-04-04 18:49:09 +02:00
|
|
|
if (ARRAY_SIZE(modules) != 0)
|
|
|
|
mvprintw(23, 0, menu);
|
2008-03-31 22:30:18 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_SHOW_DATE_TIME
|
|
|
|
mvprintw(23, 59, "%02d/%02d/20%02d - %02d:%02d:%02d",
|
|
|
|
bcd2dec(nvram_read(NVRAM_RTC_MONTH)),
|
|
|
|
bcd2dec(nvram_read(NVRAM_RTC_DAY)),
|
|
|
|
bcd2dec(nvram_read(NVRAM_RTC_YEAR)),
|
|
|
|
bcd2dec(nvram_read(NVRAM_RTC_HOURS)),
|
|
|
|
bcd2dec(nvram_read(NVRAM_RTC_MINUTES)),
|
|
|
|
bcd2dec(nvram_read(NVRAM_RTC_SECONDS)));
|
|
|
|
#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
|
|
|
{
|
|
|
|
int len = strlen(str);
|
|
|
|
int j;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
static void redraw_module(void)
|
|
|
|
{
|
2008-04-04 18:49:09 +02:00
|
|
|
if (ARRAY_SIZE(modules) == 0)
|
|
|
|
return;
|
|
|
|
|
2008-03-20 01:11:05 +01:00
|
|
|
wclear(modwin);
|
|
|
|
modules[curwin]->redraw(modwin);
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2008-03-23 16:34:04 +01:00
|
|
|
static void loop(void)
|
2008-03-20 01:11:05 +01:00
|
|
|
{
|
|
|
|
int key;
|
|
|
|
|
|
|
|
center(0, "coreinfo v0.1");
|
|
|
|
|
|
|
|
print_menu();
|
2008-04-04 18:49:09 +02:00
|
|
|
if (ARRAY_SIZE(modules) != 0)
|
|
|
|
modules[curwin]->redraw(modwin);
|
2008-03-20 01:11:05 +01:00
|
|
|
refresh();
|
|
|
|
|
2008-03-20 02:11:28 +01:00
|
|
|
while (1) {
|
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-04-04 18:49:09 +02:00
|
|
|
if (ch <= ARRAY_SIZE(modules)) {
|
|
|
|
if (ch == ARRAY_SIZE(modules))
|
|
|
|
continue;
|
2008-03-20 01:11:05 +01:00
|
|
|
curwin = ch;
|
|
|
|
redraw_module();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-04 18:49:09 +02:00
|
|
|
if (ARRAY_SIZE(modules) != 0 && modules[curwin]->handle)
|
2008-03-20 01:11:05 +01:00
|
|
|
if (modules[curwin]->handle(key))
|
|
|
|
redraw_module();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
curses_enable_serial(0);
|
|
|
|
curses_enable_vga(1);
|
|
|
|
|
|
|
|
initscr();
|
|
|
|
|
|
|
|
init_pair(1, COLOR_WHITE, COLOR_GREEN);
|
|
|
|
init_pair(2, COLOR_BLACK, COLOR_WHITE);
|
|
|
|
init_pair(3, COLOR_WHITE, COLOR_WHITE);
|
|
|
|
|
|
|
|
modwin = newwin(23, 80, 1, 0);
|
|
|
|
|
|
|
|
wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
|
|
|
|
wattrset(modwin, COLOR_PAIR(2));
|
|
|
|
|
2008-03-20 02:11:28 +01:00
|
|
|
for (i = 0; i < 23; i++) {
|
2008-03-20 01:11:05 +01:00
|
|
|
wmove(modwin, i - 1, 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(modwin, ' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
2008-03-27 21:46:49 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(modules); i++)
|
2008-03-20 01:11:05 +01:00
|
|
|
modules[i]->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
|
|
|
}
|