Documentation/releases: Finalize 4.11, start 4.12
[coreboot.git] / payloads / coreinfo / nvram_module.c
blob45edfb37b70392da6ed0b1a6bfb4acdb5c83540b
1 /*
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.
16 #include "coreinfo.h"
18 #if CONFIG(MODULE_NVRAM)
20 /**
21 * Dump 256 bytes of NVRAM.
23 static void dump_nvram(WINDOW *win, int row, int col)
25 int i, x = 0, y = 0;
27 /* Print vertical and horizontal index numbers. */
28 for (i = 0; i < 16; i++) {
29 mvwprintw(win, ((i < 8) ? 4 : 5) + i, 1, "%2.2X ", i * 0x10);
30 mvwprintw(win, 2, 4 + (i * 3), "%2.2X ", i);
33 /* Print vertical and horizontal line. */
34 for (i = 0; i < 18; i++)
35 mvwaddch(win, 3 + i, 3, ACS_VLINE);
36 for (i = 0; i < 48; i++)
37 mvwaddch(win, 3, 3 + i, (i == 0) ? ACS_ULCORNER : ACS_HLINE);
39 /* Dump NVRAM contents. */
40 for (i = 1; i < 257; i++) {
41 mvwprintw(win, row + y, col + x, "%02x ", nvram_read(i - 1));
42 x += 3;
43 if (i % 16 == 0) {
44 y++; /* Start a newline after 16 bytes. */
45 x = 0;
47 if (i % 128 == 0) {
48 y++; /* Add an empty line after 128 bytes. */
49 x = 0;
54 static int nvram_module_redraw(WINDOW *win)
56 print_module_title(win, "NVRAM Dump");
57 dump_nvram(win, 4, 4);
58 return 0;
61 static int nvram_module_init(void)
63 return 0;
66 struct coreinfo_module nvram_module = {
67 .name = "NVRAM",
68 .init = nvram_module_init,
69 .redraw = nvram_module_redraw,
72 #else
74 struct coreinfo_module nvram_module = {
77 #endif