1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #if CONFIG(MODULE_RAMDUMP)
8 static s64 cursor_max
= (1 * 1024 * 1024 * 1024); /* Max. 1 GB RAM for now. */
10 static int ramdump_module_init(void)
15 static void dump_ram(WINDOW
*win
, uint32_t addr
, int row
, int col
)
17 int i
, x
= 0, y
= 0, count
= 0;
18 volatile uint8_t *ptr
= (void *)(addr
);
20 mvwprintw(win
, 0, col
+ 54, "RAM address: 0x%08x", addr
);
22 /* Dump 256 bytes of RAM. */
23 for (i
= 1; i
< 257; i
++) {
25 mvwprintw(win
, row
+ y
, col
- 1, "%08x", addr
+ 16 * y
);
26 mvwaddch(win
, row
+ y
, col
+ 59, '|');
27 mvwaddch(win
, row
+ y
, col
+ 76, '|');
29 mvwprintw(win
, row
+ y
, col
+ x
+ 9, "%02x", ptr
[i
- 1]);
30 mvwprintw(win
, row
+ y
, 62 + count
++, "%c",
31 isprint(ptr
[i
- 1]) ? ptr
[i
- 1] : ' ');
33 if (x
== 24) /* One more space after column/byte 8. */
36 y
++; /* Start a newline after 16 bytes. */
42 static int ramdump_module_redraw(WINDOW
*win
)
44 print_module_title(win
, "RAM Dump");
45 dump_ram(win
, cursor
* 256, 2, 2);
50 static int ramdump_module_handle(int key
)
66 cursor
+= 4096; /* Jump in 1MB steps. */
69 cursor
-= 4096; /* Jump in 1MB steps. */
73 if (cursor
> cursor_max
)
82 struct coreinfo_module ramdump_module
= {
84 .init
= ramdump_module_init
,
85 .redraw
= ramdump_module_redraw
,
86 .handle
= ramdump_module_handle
,
91 struct coreinfo_module ramdump_module
= {