1 /* $NetBSD: main.c,v 1.16 2009/03/18 10:22:30 cegger Exp $ */
5 * Matthias Drochner. All rights reserved.
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
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>
48 extern char bootprog_name
[], bootprog_rev
[], bootprog_kernrev
[];
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
},
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
));
70 printf("boot returned\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"
84 bootprog_name
, bootprog_rev
, bootprog_kernrev
,
85 getbasemem(), getextmem());
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 */
106 /* if that fails, let BIOS look for boot device */
112 command_help(char *arg
)
114 printf("commands are:\n"
115 "boot [filename] [-acdqsv]\n"
116 " (ex. \"netbsd.old -s\"\n"
123 command_quit(char *arg
)
125 printf("Exiting... goodbye...\n");
130 command_boot(char *arg
)
135 if (parseboot(arg
, &filename
, &howto
))
136 bootit(filename
, howto
);