Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / i386 / stand / netboot / main.c
blobd8fbd606fd88fb38216249cf4603e3c89b56aa50
1 /* $NetBSD: main.c,v 1.16 2009/03/18 10:22:30 cegger Exp $ */
3 /*
4 * Copyright (c) 1996
5 * Matthias Drochner. All rights reserved.
6 * Copyright (c) 1996
7 * Perry E. Metzger. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgements:
19 * This product includes software developed for the NetBSD Project
20 * by Matthias Drochner.
21 * This product includes software developed for the NetBSD Project
22 * by Perry E. Metzger.
23 * 4. The names of the authors may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #include <lib/libkern/libkern.h>
42 #include <lib/libsa/stand.h>
44 #include <libi386.h>
46 int errno;
48 extern char bootprog_name[], bootprog_rev[], bootprog_kernrev[];
50 #define TIMEOUT 5
52 void command_help(char *);
53 void command_quit(char *);
54 void command_boot(char *);
56 const struct bootblk_command commands[] = {
57 { "help", command_help },
58 { "?", command_help },
59 { "quit", command_quit },
60 { "boot", command_boot },
61 { NULL, NULL },
64 int
65 bootit(const char *filename, int howto)
67 if (exec_netbsd(filename, 0, howto, 0, clear_pc_screen) < 0)
68 printf("boot: %s\n", strerror(errno));
69 else
70 printf("boot returned\n");
71 return (-1);
74 static void
75 print_banner(void)
77 clear_pc_screen();
79 printf("\n"
80 ">> %s, Revision %s (from NetBSD %s)\n"
81 ">> Memory: %d/%d k\n"
82 "Press return to boot now, any other key for boot menu\n"
83 "starting in ",
84 bootprog_name, bootprog_rev, bootprog_kernrev,
85 getbasemem(), getextmem());
88 int
89 main(void)
91 char c;
93 initio(CONSDEV_AUTO);
94 gateA20();
96 print_banner();
98 c = awaitkey(TIMEOUT, 1);
99 if ((c != '\r') && (c != '\n') && (c != '\0')) {
100 printf("type \"?\" or \"help\" for help.\n");
101 bootmenu(); /* does not return */
104 bootit("netbsd", 0);
106 /* if that fails, let BIOS look for boot device */
107 return (1);
110 /* ARGSUSED */
111 void
112 command_help(char *arg)
114 printf("commands are:\n"
115 "boot [filename] [-acdqsv]\n"
116 " (ex. \"netbsd.old -s\"\n"
117 "help|?\n"
118 "quit\n");
121 /* ARGSUSED */
122 void
123 command_quit(char *arg)
125 printf("Exiting... goodbye...\n");
126 exit(0);
129 void
130 command_boot(char *arg)
132 char *filename;
133 int howto;
135 if (parseboot(arg, &filename, &howto))
136 bootit(filename, howto);