123220Smckusick /* 223220Smckusick * Copyright (c) 1982 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*25438Skarels * @(#)bootxx.c 6.3 (Berkeley) 11/08/85 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 1711185Ssam char bootprog[] = "xx(0,0)boot"; 187464Skre 197464Skre /* 207464Skre * Boot program... arguments passed in r10 and r11 217464Skre * are passed through to the full boot program. 227464Skre */ 237464Skre 247464Skre main() 257464Skre { 267464Skre register howto, devtype; /* howto=r11, devtype=r10 */ 277464Skre int io; 287464Skre 297464Skre #ifdef lint 307464Skre howto = 0; devtype = 0; 317464Skre #endif 32*25438Skarels printf("loading %s\n", bootprog); 337464Skre io = open(bootprog, 0); 347464Skre if (io >= 0) 357464Skre copyunix(howto, devtype, io); 36*25438Skarels _stop("boot failed\n"); 377464Skre } 387464Skre 397464Skre /*ARGSUSED*/ 407464Skre copyunix(howto, devtype, io) 417464Skre register howto, devtype, io; /* howto=r11, devtype=r10 */ 427464Skre { 437464Skre struct exec x; 447464Skre register int i; 457464Skre char *addr; 467464Skre 477464Skre i = read(io, (char *)&x, sizeof x); 487464Skre if (i != sizeof x || 497464Skre (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410)) 507464Skre _stop("Bad format\n"); 517464Skre if ((x.a_magic == 0413 || x.a_magic == 0410) && 527464Skre lseek(io, 0x400, 0) == -1) 537464Skre goto shread; 547464Skre if (read(io, (char *)0, x.a_text) != x.a_text) 557464Skre goto shread; 567464Skre addr = (char *)x.a_text; 577464Skre if (x.a_magic == 0413 || x.a_magic == 0410) 587464Skre while ((int)addr & CLOFSET) 597464Skre *addr++ = 0; 607464Skre if (read(io, addr, x.a_data) != x.a_data) 617464Skre goto shread; 627464Skre addr += x.a_data; 637464Skre x.a_bss += 128*512; /* slop */ 647464Skre for (i = 0; i < x.a_bss; i++) 657464Skre *addr++ = 0; 667464Skre x.a_entry &= 0x7fffffff; 677464Skre (*((int (*)()) x.a_entry))(); 68*25438Skarels return; 697464Skre shread: 707464Skre _stop("Short read\n"); 717464Skre } 72