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
27 extern struct coreinfo_module cpuinfo_module;
28 extern struct coreinfo_module pci_module;
29 extern struct coreinfo_module coreboot_module;
30 extern struct coreinfo_module multiboot_module;
31 extern struct coreinfo_module nvram_module;
32 extern struct coreinfo_module bootlog_module;
33 extern struct coreinfo_module ramdump_module;
34 extern struct coreinfo_module lar_module;
35 extern struct coreinfo_module cbfs_module;
37 struct coreinfo_module *system_modules[] = {
38 #ifdef CONFIG_MODULE_CPUINFO
41 #ifdef CONFIG_MODULE_PCI
44 #ifdef CONFIG_MODULE_NVRAM
47 #ifdef CONFIG_MODULE_RAMDUMP
52 struct coreinfo_module *firmware_modules[] = {
53 #ifdef CONFIG_MODULE_COREBOOT
56 #ifdef CONFIG_MODULE_MULTIBOOT
59 #ifdef CONFIG_MODULE_BOOTLOG
62 #ifdef CONFIG_MODULE_LAR
65 #ifdef CONFIG_MODULE_CBFS
74 struct coreinfo_module **modules;
78 .modules = system_modules,
79 .count = ARRAY_SIZE(system_modules),
83 .modules = firmware_modules,
84 .count = ARRAY_SIZE(firmware_modules),
88 static WINDOW *modwin, *menuwin;
91 void print_module_title(WINDOW *win, const char *title)
95 wattrset(win, COLOR_PAIR(2));
96 mvwprintw(win, 0, 1, title);
99 for (i = 0; i < 78; i++)
100 waddch(win, ACS_HLINE);
103 static void print_submenu(struct coreinfo_cat *cat)
109 wmove(menuwin, 0, 0);
111 for (j = 0; j < SCREEN_X; j++)
112 waddch(menuwin, ' ');
117 for (i = 0; i < cat->count; i++)
118 ptr += sprintf(ptr, "[%c: %s] ", 'A' + i,
119 cat->modules[i]->name);
121 mvwprintw(menuwin, 0, 0, menu);
124 #ifdef CONFIG_SHOW_DATE_TIME
125 static void print_time_and_date(void)
129 while (nvram_updating())
134 mvwprintw(menuwin, 0, 57, "%02d/%02d/%04d - %02d:%02d:%02d",
135 tm.tm_mon, tm.tm_mday, 1900 + tm.tm_year, tm.tm_hour,
136 tm.tm_min, tm.tm_sec);
140 static void print_menu(void)
146 wmove(menuwin, 1, 0);
147 for (j = 0; j < SCREEN_X; j++)
148 waddch(menuwin, ' ');
150 for (i = 0; i < ARRAY_SIZE(categories); i++) {
151 if (categories[i].count == 0)
154 ptr += sprintf(ptr, "F%d: %s ", i + 1, categories[i].name);
157 mvwprintw(menuwin, 1, 0, menu);
159 #ifdef CONFIG_SHOW_DATE_TIME
160 print_time_and_date();
164 static void center(int row, const char *str)
166 int j, len = strlen(str);
168 wmove(stdscr, row, 0);
169 for (j = 0; j < SCREEN_X; j++)
172 mvprintw(row, (SCREEN_X - len) / 2, str);
175 /* FIXME: Currently unused. */
177 static void header(int row, const char *str)
182 int len = strlen(str) + 4;
184 for (i = 0; i < (SCREEN_X - len) / 2; i++)
185 ptr += sprintf(ptr, "=");
187 ptr += sprintf(ptr, "[ %s ]", str);
189 for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++)
190 ptr += sprintf(ptr, "=");
192 mvprintw(row, 0, buf);
196 static void redraw_module(struct coreinfo_cat *cat)
202 cat->modules[cat->cur]->redraw(modwin);
206 static void handle_category_key(struct coreinfo_cat *cat, int key)
208 if (key >= 'a' && key <= 'z') {
209 int index = key - 'a';
210 if (index < cat->count) {
217 if (cat->count && cat->modules[cat->cur]->handle) {
218 if (cat->modules[cat->cur]->handle(key))
223 static void loop(void)
227 center(0, CONFIG_PAYLOAD_INFO_NAME " " CONFIG_PAYLOAD_INFO_VERSION);
231 print_submenu(&categories[curwin]);
232 redraw_module(&categories[curwin]);
237 #ifdef CONFIG_SHOW_DATE_TIME
238 print_time_and_date();
247 if (key >= KEY_F(1) && key <= KEY_F(9)) {
248 unsigned char ch = key - KEY_F(1);
250 if (ch <= ARRAY_SIZE(categories)) {
251 if (ch == ARRAY_SIZE(categories))
253 if (categories[ch].count == 0)
257 print_submenu(&categories[curwin]);
258 redraw_module(&categories[curwin]);
266 handle_category_key(&categories[curwin], key);
276 init_pair(1, COLOR_WHITE, COLOR_GREEN);
277 init_pair(2, COLOR_BLACK, COLOR_WHITE);
278 init_pair(3, COLOR_WHITE, COLOR_WHITE);
280 modwin = newwin(SCREEN_Y - 3, SCREEN_X, 1, 0);
281 menuwin = newwin(2, SCREEN_X, SCREEN_Y - 2, 0);
283 wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
284 wattrset(modwin, COLOR_PAIR(2));
285 wattrset(menuwin, COLOR_PAIR(1) | A_BOLD);
289 for (i = 0; i < ARRAY_SIZE(categories); i++) {
290 for (j = 0; j < categories[i].count; j++)
291 categories[i].modules[j]->init();
299 PAYLOAD_INFO(name, CONFIG_PAYLOAD_INFO_NAME);
300 PAYLOAD_INFO(listname, CONFIG_PAYLOAD_INFO_LISTNAME);
301 PAYLOAD_INFO(desc, CONFIG_PAYLOAD_INFO_DESC);