2 * This file is part of the coreinfo project.
4 * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
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
22 #ifdef CONFIG_MODULE_BOOTLOG
24 #define CONFIG_COREBOOT_PRINTK_BUFFER_ADDR 0x90000
25 #define CONFIG_COREBOOT_PRINTK_BUFFER_SIZE 65536
28 static s32 cursor = 0;
29 static s32 cursor_max;
31 static int bootlog_module_init(void)
34 volatile unsigned long *ptr =
35 (void *)(CONFIG_COREBOOT_PRINTK_BUFFER_ADDR + 16); /* FIXME */
37 buf = malloc(CONFIG_COREBOOT_PRINTK_BUFFER_SIZE);
42 memcpy(buf, (char *)ptr, CONFIG_COREBOOT_PRINTK_BUFFER_SIZE);
44 cursor_max = CONFIG_COREBOOT_PRINTK_BUFFER_SIZE;
45 for (i = 0; i < 20; i++) {
48 } while (*(buf + cursor_max) != '\n');
50 cursor_max++; /* Stay _behind_ the newline. */
52 /* TODO: Maybe a _cleanup hook where we call free()? */
57 static int bootlog_module_redraw(WINDOW *win)
60 char *tmp = buf + cursor;
62 print_module_title(win, "Coreboot Bootlog");
64 /* FIXME: Handle lines longer than 80 characters. */
66 mvwaddch(win, y + 2, x, isprint(*tmp) ? *tmp : ' ');
72 tmp++; /* Skip the newline. */
79 /* TODO: Simplify code. */
80 static int bootlog_module_handle(int key)
86 if (cursor == cursor_max)
88 while (*(buf + cursor) != '\n')
90 cursor++; /* Skip the newline. */
95 cursor--; /* Skip the newline. */
98 } while (*(buf + cursor) != '\n');
99 cursor++; /* Stay _behind_ the newline. */
102 if (cursor == cursor_max)
104 for (i = 0; i < 20; i++) {
105 while (*(buf + cursor) != '\n')
107 cursor++; /* Skip the newline. */
113 for (i = 0; i < 20; i++) {
116 } while (*(buf + cursor) != '\n');
118 cursor++; /* Stay _behind_ the newline. */
122 if (cursor > cursor_max)
131 struct coreinfo_module bootlog_module = {
133 .init = bootlog_module_init,
134 .redraw = bootlog_module_redraw,
135 .handle = bootlog_module_handle,
140 struct coreinfo_module bootlog_module = {