BSD 4_4 release
[unix-history] / usr / src / sys / vax / stand / bootxx.c
index 7569537..9452519 100644 (file)
@@ -1,20 +1,46 @@
-/*
- * Copyright (c) 1982 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1982, 1986 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  *
  *
- *     @(#)bootxx.c    6.2 (Berkeley) %G%
+ *     @(#)bootxx.c    7.7 (Berkeley) 5/4/91
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/inode.h"
-#include "../h/fs.h"
-#include "../h/vm.h"
+#include "sys/param.h"
+#include "sys/vm.h"
+#include "sys/reboot.h"
 #include <a.out.h>
 #include <a.out.h>
-#include "saio.h"
-#include "../h/reboot.h"
+#include "stand/saio.h"
 
 
-char bootprog[] = "xx(0,0)boot";
+char bootprog[] = "boot";
+extern unsigned opendev;
 
 /*
  * Boot program... arguments passed in r10 and r11
 
 /*
  * Boot program... arguments passed in r10 and r11
@@ -23,18 +49,18 @@ char bootprog[] = "xx(0,0)boot";
 
 main()
 {
 
 main()
 {
-       register howto, devtype;        /* howto=r11, devtype=r10 */
-       int io;
+       register unsigned howto, devtype;       /* howto=r11, devtype=r10 */
+       int io, unit, partition;
+       register char *cp;
 
 #ifdef lint
 
 #ifdef lint
-       howto = 0; devtype = 0;
+       howto = 0; devtype = 0; devtype = devtype;
 #endif
 #endif
-       printf("loading %s", bootprog);
+       printf("loading %s\n", bootprog);
        io = open(bootprog, 0);
        if (io >= 0)
        io = open(bootprog, 0);
        if (io >= 0)
-               copyunix(howto, devtype, io);
-       printf("boot failed");
-       _exit();
+               copyunix(howto, opendev, io);
+       _stop("boot failed\n");
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
@@ -46,16 +72,15 @@ copyunix(howto, devtype, io)
        char *addr;
 
        i = read(io, (char *)&x, sizeof x);
        char *addr;
 
        i = read(io, (char *)&x, sizeof x);
-       if (i != sizeof x ||
-           (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410))
+       if (i != sizeof x || N_BADMAG(x))
                _stop("Bad format\n");
                _stop("Bad format\n");
-       if ((x.a_magic == 0413 || x.a_magic == 0410) &&
-           lseek(io, 0x400, 0) == -1)
+       if ((x.a_magic == ZMAGIC || x.a_magic == NMAGIC) &&
+           lseek(io, 0x400, L_SET) == -1)
                goto shread;
        if (read(io, (char *)0, x.a_text) != x.a_text)
                goto shread;
        addr = (char *)x.a_text;
                goto shread;
        if (read(io, (char *)0, x.a_text) != x.a_text)
                goto shread;
        addr = (char *)x.a_text;
-       if (x.a_magic == 0413 || x.a_magic == 0410)
+       if (x.a_magic == ZMAGIC || x.a_magic == NMAGIC)
                while ((int)addr & CLOFSET)
                        *addr++ = 0;
        if (read(io, addr, x.a_data) != x.a_data)
                while ((int)addr & CLOFSET)
                        *addr++ = 0;
        if (read(io, addr, x.a_data) != x.a_data)
@@ -66,7 +91,7 @@ copyunix(howto, devtype, io)
                *addr++ = 0;
        x.a_entry &= 0x7fffffff;
        (*((int (*)()) x.a_entry))();
                *addr++ = 0;
        x.a_entry &= 0x7fffffff;
        (*((int (*)()) x.a_entry))();
-       _exit();
+       return;
 shread:
        _stop("Short read\n");
 }
 shread:
        _stop("Short read\n");
 }