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_RAMDUMP
24 static s64 cursor = 0;
25 static s64 cursor_max = (1 * 1024 * 1024 * 1024); /* Max. 1 GB RAM for now. */
27 static int ramdump_module_init(void)
32 static void dump_ram(WINDOW *win, uint32_t addr, int row, int col)
34 int i, x = 0, y = 0, count = 0;
35 volatile uint8_t *ptr = (void *)(addr);
37 mvwprintw(win, 0, col + 54, "RAM address: %10x", addr);
39 /* Dump 256 bytes of RAM. */
40 for (i = 1; i < 257; i++) {
42 mvwprintw(win, row + y, col - 1, "%08x", addr + 16 * y);
43 mvwaddch(win, row + y, col + 59, '|');
44 mvwaddch(win, row + y, col + 76, '|');
46 mvwprintw(win, row + y, col + x + 9, "%02x", ptr[i - 1]);
47 mvwprintw(win, row + y, 62 + count++, "%c",
48 isprint(ptr[i - 1]) ? ptr[i - 1] : ' ');
50 if (x == 24) /* One more space after column/byte 8. */
53 y++; /* Start a newline after 16 bytes. */
59 static int ramdump_module_redraw(WINDOW *win)
61 print_module_title(win, "RAM Dump");
62 dump_ram(win, cursor * 256, 2, 2);
67 static int ramdump_module_handle(int key)
83 cursor += 4096; /* Jump in 1MB steps. */
86 cursor -= 4096; /* Jump in 1MB steps. */
90 if (cursor > cursor_max)
99 struct coreinfo_module ramdump_module = {
101 .init = ramdump_module_init,
102 .redraw = ramdump_module_redraw,
103 .handle = ramdump_module_handle,
108 struct coreinfo_module ramdump_module = {