1 /* ----------------------------------------------------------------------- *
3 * Copyright 2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
8 * Boston MA 02110-1301, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
16 * Dump the memory map of the system
28 } __attribute__((packed
));
30 static const char * const e820_types
[] = {
37 static void dump_e820(void)
39 com32sys_t ireg
, oreg
;
43 memset(&ireg
, 0, sizeof ireg
);
45 ireg
.eax
.w
[0] = 0xe820;
46 ireg
.edx
.l
= 0x534d4150;
47 ireg
.ecx
.l
= sizeof(struct e820_data
);
48 ireg
.edi
.w
[0] = OFFS(__com32
.cs_bounce
);
49 ireg
.es
= SEG(__com32
.cs_bounce
);
52 __intcall(0x15, &ireg
, &oreg
);
53 if (oreg
.eflags
.l
& EFLAGS_CF
||
54 oreg
.eax
.l
!= 0x534d4150)
57 memcpy(&ed
, __com32
.cs_bounce
, sizeof ed
);
59 /* ebx base length end type */
60 printf("%8x %016llx %016llx %016llx %x",
61 ireg
.ebx
.l
, ed
.base
, ed
.len
, ed
.base
+ed
.len
, ed
.type
);
64 if (type
< sizeof(e820_types
)/sizeof(e820_types
[0]))
65 printf(" %s", e820_types
[type
]);
69 ireg
.ebx
.l
= oreg
.ebx
.l
;
73 static void dump_legacy(void)
75 com32sys_t ireg
, oreg
;
76 uint16_t dosram
= *(uint16_t *)0x413;
77 struct { uint16_t offs
, seg
; } * const ivt
= (void *)0;
79 memset(&ireg
, 0, sizeof ireg
);
81 __intcall(0x12, &ireg
, &oreg
);
83 printf("INT 15h = %04x:%04x DOS RAM: %dK (0x%05x) INT 12h: %dK (0x%05x)\n",
84 ivt
[0x15].seg
, ivt
[0x15].offs
,
86 oreg
.eax
.w
[0], oreg
.eax
.w
[0] << 10);
89 __intcall(0x15, &ireg
, &oreg
);
91 printf("INT 15 88: 0x%04x (%uK) ",
92 oreg
.eax
.w
[0], oreg
.eax
.w
[0]);
94 ireg
.eax
.w
[0] = 0xe801;
95 __intcall(0x15, &ireg
, &oreg
);
97 printf("INT 15 E801: 0x%04x (%uK) 0x%04x (%uK)\n",
98 oreg
.ecx
.w
[0], oreg
.ecx
.w
[0], oreg
.edx
.w
[0], oreg
.edx
.w
[0] << 6);
103 openconsole(&dev_null_r
, &dev_stdcon_w
);