Annotation of 41BSD/4.0.upgrade/sys/stand/boot.c, revision 1.1.1.1

1.1       root        1: /*     boot.c  4.6     81/12/01        */
                      2: 
                      3: #include "../h/param.h"
                      4: #include "../h/ino.h"
                      5: #include "../h/inode.h"
                      6: #include "../h/filsys.h"
                      7: #include "../h/dir.h"
                      8: #include "../h/vm.h"
                      9: #include <a.out.h>
                     10: #include "saio.h"
                     11: #include <sys/reboot.h>
                     12: 
                     13: /*
                     14:  * Boot program... arguments passed in r10 and r11 determine
                     15:  * whether boot stops to ask for system name and which device
                     16:  * boot comes from.
                     17:  */
                     18: 
                     19: /* Types in r10 specifying major device */
                     20: char   devname[][2] = {
                     21:        'h','p',        /* 0 = hp */
                     22:        0,0,            /* 1 = ht */
                     23:        'u','p',        /* 2 = up */
                     24:        'h','k',        /* 3 = hk */
                     25:        0,0,            /* 4 = sw */
                     26:        0,0,            /* 5 = tm */
                     27:        0,0,            /* 6 = ts */
                     28:        0,0,            /* 7 = mt */
                     29:        0,0,            /* 8 = tu */
                     30:        'r','a',        /* 9 = ra */
                     31: };
                     32: 
                     33: char line[100] = "xx(0,0)vmunix";
                     34: 
                     35: int    retry = 0;
                     36: 
                     37: main()
                     38: {
                     39:        register howto, devtype;        /* howto=r11, devtype=r10 */
                     40:        int io;
                     41: 
                     42: #ifdef lint
                     43:        howto = 0; devtype = 0;
                     44: #endif
                     45:        printf("\nBoot\n");
                     46: #ifdef JUSTASK
                     47:        howto = RB_ASKNAME|RB_SINGLE;
                     48: #else
                     49:        if ((howto&RB_ASKNAME)==0) {
                     50:                if (devtype>=0 && devtype<sizeof(devname)/2
                     51:                    && devname[devtype][0]) {
                     52:                        line[0] = devname[devtype][0];
                     53:                        line[1] = devname[devtype][1];
                     54:                } else
                     55:                        howto = RB_SINGLE|RB_ASKNAME;
                     56:        }
                     57: #endif
                     58:        for (;;) {
                     59:                if (howto & RB_ASKNAME) {
                     60:                        printf(": ");
                     61:                        gets(line);
                     62:                } else
                     63:                        printf(": %s\n", line);
                     64:                io = open(line, 0);
                     65:                if (io >= 0)
                     66:                        copyunix(howto, io);
                     67:                if (++retry > 2)
                     68:                        howto = RB_SINGLE|RB_ASKNAME;
                     69:        }
                     70: }
                     71: 
                     72: /*ARGSUSED*/
                     73: copyunix(howto, io)
                     74:        register howto, io;
                     75: {
                     76:        struct exec x;
                     77:        register int i;
                     78:        char *addr;
                     79: 
                     80:        i = read(io, (char *)&x, sizeof x);
                     81:        if (i != sizeof x || x.a_magic != 0410)
                     82:                _stop("Bad format\n");
                     83:        printf("%d", x.a_text);
                     84:        if (read(io, (char *)0, x.a_text) != x.a_text)
                     85:                goto shread;
                     86:        addr = (char *)x.a_text;
                     87:        while ((int)addr & CLOFSET)
                     88:                *addr++ = 0;
                     89:        printf("+%d", x.a_data);
                     90:        if (read(io, addr, x.a_data) != x.a_data)
                     91:                goto shread;
                     92:        addr += x.a_data;
                     93:        printf("+%d", x.a_bss);
                     94:        x.a_bss += 128*512;     /* slop */
                     95:        for (i = 0; i < x.a_bss; i++)
                     96:                *addr++ = 0;
                     97:        x.a_entry &= 0x7fffffff;
                     98:        printf(" start 0x%x\n", x.a_entry);
                     99:        (*((int (*)()) x.a_entry))();
                    100:        _exit();
                    101: shread:
                    102:        _stop("Short read\n");
                    103: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.