NEWS: Update for 6.03 release
[syslinux.git] / memdisk / e820test.c
blob0bd6c4c4b9a8ae4233d99b4833c68984687adeaa
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2001-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., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * e820hack.c
16 * Test of INT 15:E820 canonicalization/manipulation routine
19 #include <string.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <inttypes.h>
23 #include "e820.h"
25 void *sys_bounce; /* Dummy */
27 extern void parse_mem(void);
28 extern uint32_t dos_mem, low_mem, high_mem;
30 void __attribute__ ((noreturn)) die(void)
32 abort();
35 void printranges(void)
37 int i;
39 for (i = 0; i < nranges; i++) {
40 printf("%016llx %016llx %d\n",
41 ranges[i].start,
42 ranges[i + 1].start - ranges[i].start, ranges[i].type);
46 int main(void)
48 uint64_t start, len;
49 uint32_t type;
50 char line[BUFSIZ], *p;
52 e820map_init();
53 printranges();
55 while (fgets(line, BUFSIZ, stdin)) {
56 p = strchr(line, ':');
57 p = p ? p + 1 : line;
58 if (sscanf(p, " %llx %llx %d", &start, &len, &type) == 3) {
59 putchar('\n');
60 printf("%016llx %016llx %d <-\n", start, len, type);
61 putchar('\n');
62 insertrange(start, len, type);
63 printranges();
67 parse_mem();
69 putchar('\n');
70 printf("DOS mem = %#10x (%u K)\n", dos_mem, dos_mem >> 10);
71 printf("Low mem = %#10x (%u K)\n", low_mem, low_mem >> 10);
72 printf("High mem = %#10x (%u K)\n", high_mem, high_mem >> 10);
73 putchar('\n');
75 /* Now, steal a chunk (2K) of DOS memory and make sure it registered OK */
76 insertrange(dos_mem - 2048, 2048, 2, 1); /* Type 2 = reserved */
78 printranges();
79 parse_mem();
81 putchar('\n');
82 printf("DOS mem = %#10x (%u K)\n", dos_mem, dos_mem >> 10);
83 printf("Low mem = %#10x (%u K)\n", low_mem, low_mem >> 10);
84 printf("High mem = %#10x (%u K)\n", high_mem, high_mem >> 10);
85 putchar('\n');
87 return 0;