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
|
Remove address from GPLv2 headers
As per discussion with lawyers[tm], it's not a good idea to
shorten the license header too much - not for legal reasons
but because there are tools that look for them, and giving
them a standard pattern simplifies things.
However, we got confirmation that we don't have to update
every file ever added to coreboot whenever the FSF gets a
new lease, but can drop the address instead.
util/kconfig is excluded because that's imported code that
we may want to synchronize every now and then.
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} +
$ find * -type f
-a \! -name \*.patch \
-a \! -name \*_shipped \
-a \! -name LICENSE_GPL \
-a \! -name LGPL.txt \
-a \! -name COPYING \
-a \! -name DISCLAIMER \
-exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} +
Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9233
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-03-26 15:17:45 +01:00
|
|
|
* Foundation, Inc.
|
2008-03-20 01:11:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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-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;
|
2008-05-07 22:43:15 +02:00
|
|
|
extern struct coreinfo_module lar_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,
|
|
|
|
#endif
|
2015-06-30 01:08:39 +02:00
|
|
|
#if IS_ENABLED(CONFIG_MODULE_LAR)
|
2009-07-07 17:10:13 +02:00
|
|
|
&lar_module,
|
|
|
|
#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);
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
|
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 */
|
|
|
|
|
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);
|