Adding debian version 4.03+dfsg-7.
[syslinux-debian/hramrach.git] / com32 / sysdump / main.c
blobd0d40a7b48bfacfe4a7f3816bf5f483f2ad708d1
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
4 * Copyright 2010 Intel Corporation; author: H. Peter Anvin
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 * Boston MA 02111-1307, USA; either version 2 of the License, or
10 * (at your option) any later version; incorporated herein by reference.
12 * ----------------------------------------------------------------------- */
14 #include <stdio.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include <stdbool.h>
18 #include <inttypes.h>
19 #include <dprintf.h>
20 #include <console.h>
21 #include <sys/cpu.h>
22 #include "../../version.h"
23 #include "backend.h"
24 #include "sysdump.h"
26 const char program[] = "sysdump";
27 const char version[] = "SYSDUMP " VERSION_STR " " DATE "\n";
29 __noreturn die(const char *msg)
31 printf("%s: %s\n", program, msg);
32 exit(1);
35 static void dump_all(struct backend *be, const char *argv[])
37 cpio_init(be, argv);
39 cpio_writefile(be, "sysdump", version, sizeof version-1);
41 dump_memory_map(be);
42 dump_memory(be);
43 dump_dmi(be);
44 dump_acpi(be);
45 dump_cpuid(be);
46 dump_pci(be);
47 dump_vesa_tables(be);
49 cpio_close(be);
50 flush_data(be);
53 static struct backend *backends[] =
55 &be_tftp,
56 &be_ymodem,
57 &be_srec,
58 NULL
61 __noreturn usage(void)
63 struct backend **bep, *be;
65 printf("Usage:\n");
66 for (bep = backends ; (be = *bep) ; bep++)
67 printf(" %s %s %s\n", program, be->name, be->helpmsg);
69 exit(1);
72 int main(int argc, char *argv[])
74 struct backend **bep, *be;
76 openconsole(&dev_null_r, &dev_stdcon_w);
77 fputs(version, stdout);
79 if (argc < 2)
80 usage();
82 for (bep = backends ; (be = *bep) ; bep++) {
83 if (!strcmp(be->name, argv[1]))
84 break;
87 if (!be || argc < be->minargs + 2)
88 usage();
90 /* Do this as early as possible */
91 snapshot_lowmem();
93 printf("Backend: %s\n", be->name);
95 /* Do the actual data dump */
96 dump_all(be, (const char **)argv + 2);
98 return 0;