Annotation of 42BSD/sys/stand/boot.c, revision 1.1

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

unix.superglobalmegacorp.com

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