drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / payloads / coreinfo / nvram_module.c
blob99c6e9b69f84c34ae6d8e726819850a822c1d405
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include "coreinfo.h"
5 #if CONFIG(MODULE_NVRAM)
7 /**
8 * Dump 256 bytes of NVRAM.
9 */
10 static void dump_nvram(WINDOW *win, int row, int col)
12 int i, x = 0, y = 0;
14 /* Print vertical and horizontal index numbers. */
15 for (i = 0; i < 16; i++) {
16 mvwprintw(win, ((i < 8) ? 4 : 5) + i, 1, "%2.2X ", i * 0x10);
17 mvwprintw(win, 2, 4 + (i * 3), "%2.2X ", i);
20 /* Print vertical and horizontal line. */
21 for (i = 0; i < 18; i++)
22 mvwaddch(win, 3 + i, 3, ACS_VLINE);
23 for (i = 0; i < 48; i++)
24 mvwaddch(win, 3, 3 + i, (i == 0) ? ACS_ULCORNER : ACS_HLINE);
26 /* Dump NVRAM contents. */
27 for (i = 1; i < 257; i++) {
28 mvwprintw(win, row + y, col + x, "%02x ", nvram_read(i - 1));
29 x += 3;
30 if (i % 16 == 0) {
31 y++; /* Start a newline after 16 bytes. */
32 x = 0;
34 if (i % 128 == 0) {
35 y++; /* Add an empty line after 128 bytes. */
36 x = 0;
41 static int nvram_module_redraw(WINDOW *win)
43 print_module_title(win, "NVRAM Dump");
44 dump_nvram(win, 4, 4);
45 return 0;
48 static int nvram_module_init(void)
50 return 0;
53 struct coreinfo_module nvram_module = {
54 .name = "NVRAM",
55 .init = nvram_module_init,
56 .redraw = nvram_module_redraw,
59 #else
61 struct coreinfo_module nvram_module = {
64 #endif