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;
28 extern struct coreinfo_module nvram_module;
30 struct coreinfo_module *modules[] = {
31 #ifdef CONFIG_MODULE_CPUINFO
34 #ifdef CONFIG_MODULE_PCI
37 #ifdef CONFIG_MODULE_COREBOOT
40 #ifdef CONFIG_MODULE_NVRAM
45 static WINDOW *modwin;
48 void print_module_title(WINDOW *win, const char *title)
52 wattrset(win, COLOR_PAIR(2));
53 mvwprintw(win, 0, 1, title);
57 for (i = 0; i < 78; i++)
61 static void print_menu(void)
69 for (j = 0; j < SCREEN_X; j++)
72 for (i = 0; i < ARRAY_SIZE(modules); i++)
73 ptr += sprintf(ptr, "F%d: %s ", i + 1, modules[i]->name);
75 mvprintw(23, 0, menu);
77 #ifdef CONFIG_SHOW_DATE_TIME
78 mvprintw(23, 59, "%02d/%02d/20%02d - %02d:%02d:%02d",
79 bcd2dec(nvram_read(NVRAM_RTC_MONTH)),
80 bcd2dec(nvram_read(NVRAM_RTC_DAY)),
81 bcd2dec(nvram_read(NVRAM_RTC_YEAR)),
82 bcd2dec(nvram_read(NVRAM_RTC_HOURS)),
83 bcd2dec(nvram_read(NVRAM_RTC_MINUTES)),
84 bcd2dec(nvram_read(NVRAM_RTC_SECONDS)));
88 static void center(int row, const char *str)
90 int len = strlen(str);
93 wmove(stdscr, row, 0);
95 for (j = 0; j < SCREEN_X; j++)
98 mvprintw(row, (SCREEN_X - len) / 2, str);
101 /* FIXME: Currently unused. */
103 static void header(int row, const char *str)
108 int len = strlen(str) + 4;
110 for (i = 0; i < (SCREEN_X - len) / 2; i++)
111 ptr += sprintf(ptr, "=");
113 ptr += sprintf(ptr, "[ %s ]", str);
115 for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++)
116 ptr += sprintf(ptr, "=");
118 mvprintw(row, 0, buf);
122 static void redraw_module(void)
125 modules[curwin]->redraw(modwin);
129 static void loop(void)
133 center(0, "coreinfo v0.1");
136 modules[curwin]->redraw(modwin);
145 if (key >= KEY_F(1) && key <= KEY_F(9)) {
146 unsigned char ch = key - KEY_F(1);
148 if (ch < ARRAY_SIZE(modules)) {
155 if (modules[curwin]->handle)
156 if (modules[curwin]->handle(key))
165 curses_enable_serial(0);
166 curses_enable_vga(1);
170 init_pair(1, COLOR_WHITE, COLOR_GREEN);
171 init_pair(2, COLOR_BLACK, COLOR_WHITE);
172 init_pair(3, COLOR_WHITE, COLOR_WHITE);
174 modwin = newwin(23, 80, 1, 0);
176 wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
177 wattrset(modwin, COLOR_PAIR(2));
179 for (i = 0; i < 23; i++) {
180 wmove(modwin, i - 1, 0);
182 for (j = 0; j < SCREEN_X; j++)
188 for (i = 0; i < ARRAY_SIZE(modules); i++)