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: %10d", 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, (const chtype)"|");
44 mvwaddch(win, row + y, col + 76, (const chtype)"|");
46 mvwprintw(win, row + y, col + x + 9, "%02x", ptr[i - 1]);
47 mvwprintw(win, row + y, 62 + count++, "%c", ptr[i - 1]);
49 if (x == 24) /* One more space after column/byte 8. */
52 y++; /* Start a newline after 16 bytes. */
58 static int ramdump_module_redraw(WINDOW *win)
60 print_module_title(win, "RAM Dump");
61 dump_ram(win, cursor * 256, 2, 2);
66 static int ramdump_module_handle(int key)
70 if (cursor == cursor_max)
80 if (cursor == cursor_max)
82 cursor += 4096; /* Jump in 1MB steps. */
87 cursor -= 4096; /* Jump in 1MB steps. */
91 if (cursor > cursor_max)
100 struct coreinfo_module ramdump_module = {
102 .init = ramdump_module_init,
103 .redraw = ramdump_module_redraw,
104 .handle = ramdump_module_handle,
109 struct coreinfo_module ramdump_module = {