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;
29 extern struct coreinfo_module bootlog_module;
31 struct coreinfo_module *modules[] = {
32 #ifdef CONFIG_MODULE_CPUINFO
35 #ifdef CONFIG_MODULE_PCI
38 #ifdef CONFIG_MODULE_COREBOOT
41 #ifdef CONFIG_MODULE_NVRAM
44 #ifdef CONFIG_MODULE_BOOTLOG
49 static WINDOW *modwin;
52 void print_module_title(WINDOW *win, const char *title)
56 wattrset(win, COLOR_PAIR(2));
57 mvwprintw(win, 0, 1, title);
61 for (i = 0; i < 78; i++)
65 static void print_menu(void)
73 for (j = 0; j < SCREEN_X; j++)
76 for (i = 0; i < ARRAY_SIZE(modules); i++)
77 ptr += sprintf(ptr, "F%d: %s ", i + 1, modules[i]->name);
79 if (ARRAY_SIZE(modules) != 0)
80 mvprintw(23, 0, menu);
82 #ifdef CONFIG_SHOW_DATE_TIME
83 mvprintw(23, 59, "%02d/%02d/20%02d - %02d:%02d:%02d",
84 bcd2dec(nvram_read(NVRAM_RTC_MONTH)),
85 bcd2dec(nvram_read(NVRAM_RTC_DAY)),
86 bcd2dec(nvram_read(NVRAM_RTC_YEAR)),
87 bcd2dec(nvram_read(NVRAM_RTC_HOURS)),
88 bcd2dec(nvram_read(NVRAM_RTC_MINUTES)),
89 bcd2dec(nvram_read(NVRAM_RTC_SECONDS)));
93 static void center(int row, const char *str)
95 int len = strlen(str);
98 wmove(stdscr, row, 0);
100 for (j = 0; j < SCREEN_X; j++)
103 mvprintw(row, (SCREEN_X - len) / 2, str);
106 /* FIXME: Currently unused. */
108 static void header(int row, const char *str)
113 int len = strlen(str) + 4;
115 for (i = 0; i < (SCREEN_X - len) / 2; i++)
116 ptr += sprintf(ptr, "=");
118 ptr += sprintf(ptr, "[ %s ]", str);
120 for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++)
121 ptr += sprintf(ptr, "=");
123 mvprintw(row, 0, buf);
127 static void redraw_module(void)
129 if (ARRAY_SIZE(modules) == 0)
133 modules[curwin]->redraw(modwin);
137 static void loop(void)
141 center(0, "coreinfo v0.1");
144 if (ARRAY_SIZE(modules) != 0)
145 modules[curwin]->redraw(modwin);
154 if (key >= KEY_F(1) && key <= KEY_F(9)) {
155 unsigned char ch = key - KEY_F(1);
157 if (ch <= ARRAY_SIZE(modules)) {
158 if (ch == ARRAY_SIZE(modules))
166 if (ARRAY_SIZE(modules) != 0 && modules[curwin]->handle)
167 if (modules[curwin]->handle(key))
176 curses_enable_serial(0);
177 curses_enable_vga(1);
181 init_pair(1, COLOR_WHITE, COLOR_GREEN);
182 init_pair(2, COLOR_BLACK, COLOR_WHITE);
183 init_pair(3, COLOR_WHITE, COLOR_WHITE);
185 modwin = newwin(23, 80, 1, 0);
187 wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
188 wattrset(modwin, COLOR_PAIR(2));
190 for (i = 0; i < 23; i++) {
191 wmove(modwin, i - 1, 0);
193 for (j = 0; j < SCREEN_X; j++)
199 for (i = 0; i < ARRAY_SIZE(modules); i++)