Last change
on this file was
e16e8f2,
checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago
|
bootstuff
|
-
Property mode set to
100644
|
File size:
946 bytes
|
Rev | Line | |
---|
[e16e8f2] | 1 | /* |
---|
| 2 | * Dump memory |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | #include <stdio.h> |
---|
| 6 | #include <string.h> |
---|
| 7 | #include <stdlib.h> |
---|
| 8 | #include <sys/cpu.h> |
---|
| 9 | #include "sysdump.h" |
---|
| 10 | |
---|
| 11 | static char *lowmem; |
---|
| 12 | static size_t lowmem_len; |
---|
| 13 | |
---|
| 14 | void *zero_addr; /* Hack to keep gcc from complaining */ |
---|
| 15 | |
---|
| 16 | void snapshot_lowmem(void) |
---|
| 17 | { |
---|
| 18 | extern void _start(void); |
---|
| 19 | |
---|
| 20 | lowmem_len = (size_t)_start; |
---|
| 21 | lowmem = malloc(lowmem_len); |
---|
| 22 | if (lowmem) { |
---|
| 23 | printf("Snapshotting lowmem... "); |
---|
| 24 | cli(); |
---|
| 25 | memcpy(lowmem, zero_addr, lowmem_len); |
---|
| 26 | sti(); |
---|
| 27 | printf("ok\n"); |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | static void dump_memory_range(struct upload_backend *be, const void *where, |
---|
| 32 | const void *addr, size_t len) |
---|
| 33 | { |
---|
| 34 | char filename[32]; |
---|
| 35 | |
---|
| 36 | sprintf(filename, "memory/%08zx", (size_t)addr); |
---|
| 37 | cpio_writefile(be, filename, where, len); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | void dump_memory(struct upload_backend *be) |
---|
| 41 | { |
---|
| 42 | printf("Dumping memory... "); |
---|
| 43 | |
---|
| 44 | cpio_mkdir(be, "memory"); |
---|
| 45 | |
---|
| 46 | if (lowmem) |
---|
| 47 | dump_memory_range(be, lowmem, zero_addr, lowmem_len); |
---|
| 48 | |
---|
| 49 | printf("done.\n"); |
---|
| 50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.