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_NVRAM
25 * Dump 256 bytes of NVRAM.
27 static void dump_nvram(WINDOW *win, int row, int col)
31 /* Print vertical and horizontal index numbers. */
32 for (i = 0; i < 16; i++) {
33 mvwprintw(win, ((i < 8) ? 4 : 5) + i, 1, "%2.2X ", i);
34 mvwprintw(win, 2, 4 + (i * 3), "%2.2X ", i);
37 /* Print vertical and horizontal line. */
38 for (i = 0; i < 18; i++)
39 mvwaddch(win, 3 + i, 3, ACS_VLINE);
40 for (i = 0; i < 48; i++)
41 mvwaddch(win, 3, 3 + i, (i == 0) ? ACS_ULCORNER : ACS_HLINE);
43 /* Dump NVRAM contents. */
44 for (i = 1; i < 257; i++) {
45 mvwprintw(win, row + y, col + x, "%02x ", nvram_read(i - 1));
48 y++; /* Start a newline after 16 bytes. */
52 y++; /* Add an empty line after 128 bytes. */
58 static int nvram_module_redraw(WINDOW *win)
60 print_module_title(win, "NVRAM Dump");
61 dump_nvram(win, 4, 4);
65 static int nvram_module_init(void)
70 struct coreinfo_module nvram_module = {
72 .init = nvram_module_init,
73 .redraw = nvram_module_redraw,
78 struct coreinfo_module nvram_module = {