2 * fbsdboot.c Boot FreeBSD from DOS
\r
4 * (C) 1994 by Christian Gusenbauer (cg@fimp01.fim.uni-linz.ac.at)
\r
5 * All Rights Reserved.
\r
7 * Permission to use, copy, modify and distribute this software and its
\r
8 * documentation is hereby granted, provided that both the copyright
\r
9 * notice and this permission notice appear in all copies of the
\r
10 * software, derivative works or modified versions, and any portions
\r
11 * thereof, and that both notices appear in supporting documentation.
\r
13 * I ALLOW YOU USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. I DISCLAIM
\r
14 * ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
\r
15 * USE OF THIS SOFTWARE.
\r
20 #include <process.h>
\r
24 #include "bootinfo.h"
\r
25 #include "dosboot.h"
\r
26 #include "protmod.h"
\r
31 #define ptr2pa(x) (((((long)(x))&0xffff0000l)>>12l)+(((long)(x))&0xffffl))
\r
33 static void usage(char *name)
\r
35 fprintf(stderr, "FreeBSD boot Version %d.%d\n", MAV, MIV);
\r
36 fprintf(stderr, "(c) 1994, 1995 Christian Gusenbauer,\n cg@fimp01.fim.uni-linz.ac.at\n\n");
\r
37 fprintf(stderr, "usage: %s [ options ] [ kernelname ]\n", name);
\r
38 fprintf(stderr, "where options are:\n");
\r
39 fprintf(stderr, "\t-r ... use compiled-in rootdev\n");
\r
40 fprintf(stderr, "\t-s ... reboot to single user only\n");
\r
41 fprintf(stderr, "\t-a ... ask for file name to reboot from\n");
\r
42 fprintf(stderr, "\t-d ... give control to kernel debugger\n");
\r
43 fprintf(stderr, "\t-g ... give control to GDB debugger\n");
\r
44 fprintf(stderr, "\t-c ... invoke user configuration routing\n");
\r
45 fprintf(stderr, "\t-v ... print all potentially useful info\n");
\r
46 fprintf(stderr, "\t-C ... use cdrom as root\n");
\r
47 fprintf(stderr, "\t-D ... boot a kernel from a DOS medium\n");
\r
48 fprintf(stderr, "\t (default: c:\\kernel)\n");
\r
52 static unsigned int memsize(int x)
\r
75 int main(int argc, char *argv[])
\r
77 char *kernel="/kernel", *ptr;
\r
80 extern unsigned long get_diskinfo(int);
\r
85 for (i = 1; i < argc; i++) { /* check arguments */
\r
86 if (argv[i][0] != '-') { /* kernel name */
\r
91 while (*ptr) { /* check options */
\r
93 case 'r': howto |= RB_DFLTROOT; break;
\r
94 case 's': howto |= RB_SINGLE; break;
\r
95 case 'a': howto |= RB_ASKNAME; break;
\r
96 case 'c': howto |= RB_CONFIG; break;
\r
97 case 'd': howto |= RB_KDB; break;
\r
98 case 'g': howto |= RB_GDB; break;
\r
99 case 'v': howto |= RB_VERBOSE; break;
\r
100 case 'C': howto |= RB_CDROM; break;
\r
101 case 'D': dos = 1; kernel = "c:\\kernel"; break;
\r
103 default: usage(argv[0]);
\r
109 bootinfo.bi_version = BOOTINFO_VERSION;
\r
110 for (i = 0; i < N_BIOS_GEOM; i++)
\r
111 bootinfo.bi_bios_geom[i] = get_diskinfo(0x80+i);
\r
112 bootinfo.bi_basemem = memsize(0);
\r
113 bootinfo.bi_extmem = memsize(1);
\r
114 bootinfo.bi_memsizes_valid = 0; /* that is not yet valid!! */
\r
115 bootinfo.bi_kernelname = (char *) ptr2pa(kernel);
\r
116 bootinfo.bi_nfs_diskless = NULL;
\r
117 bootinfo.bi_size = sizeof(bootinfo);
\r
120 dosboot(howto, kernel); /* boot given kernel from DOS partition */
\r
122 bsdboot(0x80, howto, kernel); /* boot from FreeBSD partition */
\r