2 * Dump memory map information
11 #define E820_CHUNK 128
18 static void dump_e820(struct upload_backend
*be
)
20 com32sys_t ireg
, oreg
;
21 struct e820_info
*curr
;
22 struct e820_info
*buf
, *p
;
25 curr
= lmalloc(sizeof *curr
);
29 memset(&ireg
, 0, sizeof ireg
);
30 memset(&curr
, 0, sizeof curr
);
33 ireg
.edx
.l
= 0x534d4150;
34 ireg
.ecx
.l
= sizeof curr
->data
;
35 ireg
.es
= SEG(curr
->data
);
36 ireg
.edi
.w
[0] = OFFS(curr
->data
);
39 __intcall(0x15, &ireg
, &oreg
);
40 if ((oreg
.eflags
.l
& EFLAGS_CF
) ||
41 oreg
.eax
.l
!= 0x534d4150)
44 if (nentry
>= nalloc
) {
46 buf
= realloc(buf
, nalloc
*sizeof *buf
);
50 memcpy(buf
[nentry
].data
, curr
->data
, sizeof curr
->data
);
51 buf
[nentry
].ebx
= ireg
.ebx
.l
;
52 buf
[nentry
].len
= oreg
.ecx
.l
;
55 ireg
.ebx
.l
= oreg
.ebx
.l
;
59 cpio_writefile(be
, "memmap/15e820", buf
, nentry
*sizeof *buf
);
65 void dump_memory_map(struct upload_backend
*be
)
67 com32sys_t ireg
, oreg
;
69 cpio_mkdir(be
, "memmap");
71 memset(&ireg
, 0, sizeof ireg
);
72 __intcall(0x12, &ireg
, &oreg
);
73 cpio_writefile(be
, "memmap/12", &oreg
, sizeof oreg
);
75 memset(&ireg
, 0, sizeof ireg
);
77 __intcall(0x15, &ireg
, &oreg
);
78 cpio_writefile(be
, "memmap/1588", &oreg
, sizeof oreg
);
80 memset(&ireg
, 0, sizeof ireg
);
81 ireg
.eax
.w
[0] = 0xe801;
82 __intcall(0x15, &ireg
, &oreg
);
83 cpio_writefile(be
, "memmap/15e801", &oreg
, sizeof oreg
);