2 * Dump memory map information
12 #define E820_CHUNK 128
19 static void dump_e820(struct backend
*be
)
21 com32sys_t ireg
, oreg
;
22 struct e820_info
*curr
;
23 struct e820_info
*buf
, *p
;
26 curr
= lmalloc(sizeof *curr
);
30 memset(&ireg
, 0, sizeof ireg
);
31 memset(&curr
, 0, sizeof curr
);
34 ireg
.edx
.l
= 0x534d4150;
35 ireg
.ecx
.l
= sizeof curr
->data
;
36 ireg
.es
= SEG(curr
->data
);
37 ireg
.edi
.w
[0] = OFFS(curr
->data
);
40 __intcall(0x15, &ireg
, &oreg
);
41 if ((oreg
.eflags
.l
& EFLAGS_CF
) ||
42 oreg
.eax
.l
!= 0x534d4150)
45 if (nentry
>= nalloc
) {
47 buf
= realloc(buf
, nalloc
*sizeof *buf
);
51 memcpy(buf
[nentry
].data
, curr
->data
, sizeof curr
->data
);
52 buf
[nentry
].ebx
= ireg
.ebx
.l
;
53 buf
[nentry
].len
= oreg
.ecx
.l
;
56 ireg
.ebx
.l
= oreg
.ebx
.l
;
60 cpio_writefile(be
, "memmap/15e820", buf
, nentry
*sizeof *buf
);
66 void dump_memory_map(struct backend
*be
)
68 com32sys_t ireg
, oreg
;
70 cpio_mkdir(be
, "memmap");
72 memset(&ireg
, 0, sizeof ireg
);
73 __intcall(0x12, &ireg
, &oreg
);
74 cpio_writefile(be
, "memmap/12", &oreg
, sizeof oreg
);
77 __intcall(0x15, &ireg
, &oreg
);
78 cpio_writefile(be
, "memmap/1588", &oreg
, sizeof oreg
);
80 ireg
.eax
.w
[0] = 0xe801;
81 __intcall(0x15, &ireg
, &oreg
);
82 cpio_writefile(be
, "memmap/15e801", &oreg
, sizeof oreg
);