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 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 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 void header(int row, const char *str)
88 int len = strlen(str) + 4;
90 for(i = 0; i < (SCREEN_X - len) / 2; i++)
91 ptr += sprintf(ptr, "=");
93 ptr += sprintf(ptr, "[ %s ]", str);
96 for(i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X ; i++)
97 ptr += sprintf(ptr, "=");
99 mvprintw(row, 0, buf);
102 static void redraw_module(void)
105 modules[curwin]->redraw(modwin);
113 center(0, "coreinfo v0.1");
116 modules[curwin]->redraw(modwin);
125 if (key >= KEY_F(1) && key <= KEY_F(9)) {
126 unsigned char ch = key - KEY_F(1);
128 if (ch < MODULE_COUNT) {
135 if (modules[curwin]->handle)
136 if (modules[curwin]->handle(key))
145 curses_enable_serial(0);
146 curses_enable_vga(1);
150 init_pair(1, COLOR_WHITE, COLOR_GREEN);
151 init_pair(2, COLOR_BLACK, COLOR_WHITE);
152 init_pair(3, COLOR_WHITE, COLOR_WHITE);
154 modwin = newwin(23, 80, 1, 0);
156 wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
157 wattrset(modwin, COLOR_PAIR(2));
159 for(i = 0; i < 23; i++) {
160 wmove(modwin, i - 1, 0);
162 for(j = 0; j < SCREEN_X; j++)
168 for(i = 0; i < MODULE_COUNT; i++)