Adding debian version 4.03+dfsg-7.
[syslinux-debian/hramrach.git] / com32 / sysdump / memory.c
blob6552e7f38bf561f37d0fd568a281abc6e58a5627
1 /*
2 * Dump memory
3 */
5 #include <stdio.h>
6 #include <string.h>
7 #include <stdlib.h>
8 #include <sys/cpu.h>
9 #include "sysdump.h"
10 #include "backend.h"
12 static char *lowmem;
13 static size_t lowmem_len;
15 void *zero_addr; /* Hack to keep gcc from complaining */
17 void snapshot_lowmem(void)
19 extern void _start(void);
21 lowmem_len = (size_t)_start;
22 lowmem = malloc(lowmem_len);
23 if (lowmem) {
24 printf("Snapshotting lowmem... ");
25 cli();
26 memcpy(lowmem, zero_addr, lowmem_len);
27 sti();
28 printf("ok\n");
32 static void dump_memory_range(struct backend *be, const void *where,
33 const void *addr, size_t len)
35 char filename[32];
37 sprintf(filename, "memory/%08zx", (size_t)addr);
38 cpio_writefile(be, filename, where, len);
41 void dump_memory(struct backend *be)
43 printf("Dumping memory... ");
45 cpio_mkdir(be, "memory");
47 if (lowmem)
48 dump_memory_range(be, lowmem, zero_addr, lowmem_len);
50 printf("done.\n");