2 * This file is part of the coreinfo project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 extern struct coreinfo_module cpuinfo_module;
26 extern struct coreinfo_module pci_module;
27 extern struct coreinfo_module coreboot_module;
29 #define MODULE_COUNT 3
31 struct coreinfo_module *modules[MODULE_COUNT] = {
37 static WINDOW *modwin;
40 void print_module_title(WINDOW *win, const char *title)
44 wattrset(win, COLOR_PAIR(2));
45 mvwprintw(win, 0, 1, title);
49 for (i = 0; i < 78; i++)
53 static void print_menu(void)
61 for (j = 0; j < SCREEN_X; j++)
64 for (i = 0; i < MODULE_COUNT; i++)
65 ptr += sprintf(ptr, "F%d: %s ", i + 1, modules[i]->name);
67 mvprintw(23, 0, menu);
70 static void center(int row, const char *str)
72 int len = strlen(str);
75 wmove(stdscr, row, 0);
77 for (j = 0; j < SCREEN_X; j++)
80 mvprintw(row, (SCREEN_X - len) / 2, str);
83 /* FIXME: Currently unused. */
85 static void header(int row, const char *str)
90 int len = strlen(str) + 4;
92 for (i = 0; i < (SCREEN_X - len) / 2; i++)
93 ptr += sprintf(ptr, "=");
95 ptr += sprintf(ptr, "[ %s ]", str);
97 for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++)
98 ptr += sprintf(ptr, "=");
100 mvprintw(row, 0, buf);
104 static void redraw_module(void)
107 modules[curwin]->redraw(modwin);
111 static void loop(void)
115 center(0, "coreinfo v0.1");
118 modules[curwin]->redraw(modwin);
127 if (key >= KEY_F(1) && key <= KEY_F(9)) {
128 unsigned char ch = key - KEY_F(1);
130 if (ch < MODULE_COUNT) {
137 if (modules[curwin]->handle)
138 if (modules[curwin]->handle(key))
147 curses_enable_serial(0);
148 curses_enable_vga(1);
152 init_pair(1, COLOR_WHITE, COLOR_GREEN);
153 init_pair(2, COLOR_BLACK, COLOR_WHITE);
154 init_pair(3, COLOR_WHITE, COLOR_WHITE);
156 modwin = newwin(23, 80, 1, 0);
158 wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
159 wattrset(modwin, COLOR_PAIR(2));
161 for (i = 0; i < 23; i++) {
162 wmove(modwin, i - 1, 0);
164 for (j = 0; j < SCREEN_X; j++)
170 for (i = 0; i < MODULE_COUNT; i++)