123220Smckusick /* 229293Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323220Smckusick * All rights reserved. The Berkeley software License Agreement 423220Smckusick * specifies the terms and conditions for redistribution. 523220Smckusick * 6*32199Skarels * @(#)bootxx.c 7.2 (Berkeley) 09/16/87 723220Smckusick */ 87464Skre 97464Skre #include "../h/param.h" 107464Skre #include "../h/inode.h" 117464Skre #include "../h/fs.h" 127464Skre #include "../h/vm.h" 137464Skre #include <a.out.h> 147464Skre #include "saio.h" 157464Skre #include "../h/reboot.h" 167464Skre 17*32199Skarels char bootprog[] = "boot"; 18*32199Skarels extern unsigned opendev; 197464Skre 207464Skre /* 217464Skre * Boot program... arguments passed in r10 and r11 227464Skre * are passed through to the full boot program. 237464Skre */ 247464Skre 257464Skre main() 267464Skre { 2726828Skarels register unsigned howto, devtype; /* howto=r11, devtype=r10 */ 2826828Skarels int io, unit, partition; 2926828Skarels register char *cp; 307464Skre 317464Skre #ifdef lint 32*32199Skarels howto = 0; devtype = 0; devtype = devtype; 337464Skre #endif 3425438Skarels printf("loading %s\n", bootprog); 357464Skre io = open(bootprog, 0); 367464Skre if (io >= 0) 37*32199Skarels copyunix(howto, opendev, io); 3825438Skarels _stop("boot failed\n"); 397464Skre } 407464Skre 417464Skre /*ARGSUSED*/ 427464Skre copyunix(howto, devtype, io) 437464Skre register howto, devtype, io; /* howto=r11, devtype=r10 */ 447464Skre { 457464Skre struct exec x; 467464Skre register int i; 477464Skre char *addr; 487464Skre 497464Skre i = read(io, (char *)&x, sizeof x); 507464Skre if (i != sizeof x || 517464Skre (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410)) 527464Skre _stop("Bad format\n"); 537464Skre if ((x.a_magic == 0413 || x.a_magic == 0410) && 547464Skre lseek(io, 0x400, 0) == -1) 557464Skre goto shread; 567464Skre if (read(io, (char *)0, x.a_text) != x.a_text) 577464Skre goto shread; 587464Skre addr = (char *)x.a_text; 597464Skre if (x.a_magic == 0413 || x.a_magic == 0410) 607464Skre while ((int)addr & CLOFSET) 617464Skre *addr++ = 0; 627464Skre if (read(io, addr, x.a_data) != x.a_data) 637464Skre goto shread; 647464Skre addr += x.a_data; 657464Skre x.a_bss += 128*512; /* slop */ 667464Skre for (i = 0; i < x.a_bss; i++) 677464Skre *addr++ = 0; 687464Skre x.a_entry &= 0x7fffffff; 697464Skre (*((int (*)()) x.a_entry))(); 7025438Skarels return; 717464Skre shread: 727464Skre _stop("Short read\n"); 737464Skre } 74