Annotation of 43BSDTahoe/sys/tahoestand/boot.c, revision 1.1

1.1     ! root        1: /*     boot.c  7.2     89/05/24        */
        !             2: 
        !             3: #include "machine/mtpr.h"
        !             4: 
        !             5: #include "param.h"
        !             6: #include "inode.h"
        !             7: #include "fs.h"
        !             8: #include "vm.h"
        !             9: #include "saio.h"
        !            10: #include "reboot.h"
        !            11: 
        !            12: #include <a.out.h>
        !            13: 
        !            14: /*
        !            15:  * Boot program... arguments passed in r10 and r11 determine
        !            16:  * whether boot stops to ask for system name and which device
        !            17:  * boot comes from.
        !            18:  */
        !            19: 
        !            20: /*#define      DEV_DFLT        1               /* vd/dk */
        !            21: #define        DEV_DFLT        2               /* hd */
        !            22: 
        !            23: char line[100];
        !            24: 
        !            25: extern unsigned opendev;
        !            26: extern unsigned bootdev;
        !            27: 
        !            28: main()
        !            29: {
        !            30:        register char *cp;              /* skip r12 */
        !            31:        register u_int howto, devtype;  /* howto=r11, devtype=r10 */
        !            32:        int io = 0, retry, type;
        !            33: 
        !            34: #ifdef lint
        !            35:        howto = 0; devtype = 0;
        !            36: #endif
        !            37:        if ((devtype & B_MAGICMASK) != B_DEVMAGIC)
        !            38:                devtype = DEV_DFLT << B_TYPESHIFT;      /* unit, partition 0 */
        !            39:        bootdev = devtype;
        !            40: #ifdef JUSTASK
        !            41:        howto = RB_ASKNAME|RB_SINGLE;
        !            42: #else
        !            43:        if ((howto & RB_ASKNAME) == 0) {
        !            44:                type = (devtype >> B_TYPESHIFT) & B_TYPEMASK;
        !            45:                if ((unsigned)type < ndevs && devsw[type].dv_name)
        !            46:                        strcpy(line, UNIX);
        !            47:                else
        !            48:                        howto |= RB_SINGLE|RB_ASKNAME;
        !            49:        }
        !            50: #endif
        !            51:        for (retry = 0;;) {
        !            52:                if (io >= 0)
        !            53:                        printf("\nBoot");
        !            54:                if (howto & RB_ASKNAME) {
        !            55:                        printf(": ");
        !            56:                        gets(line);
        !            57:                        if (line[0] == 0) {
        !            58:                                strcpy(line, UNIX);
        !            59:                                printf(": %s\n", line);
        !            60:                        }
        !            61:                } else
        !            62:                        printf(": %s\n", line);
        !            63:                io = open(line, 0);
        !            64:                if (io >= 0) {
        !            65:                        copyunix(howto, opendev, io);
        !            66:                        close(io);
        !            67:                        howto |= RB_SINGLE|RB_ASKNAME;
        !            68:                }
        !            69:                if (++retry > 2)
        !            70:                        howto |= RB_SINGLE|RB_ASKNAME;
        !            71:        }
        !            72: }
        !            73: 
        !            74: /*ARGSUSED*/
        !            75: copyunix(howto, devtype, io)
        !            76:        register io, howto, devtype;    /* NOTE ORDER */
        !            77: {
        !            78:        register int esym;              /* must be r9 */
        !            79:        register int i;
        !            80:        register char *addr;
        !            81:        struct exec x;
        !            82: 
        !            83:        if (read(io, (char *)&x, sizeof(x)) != sizeof(x) || N_BADMAG(x)) {
        !            84:                printf("bad magic #\n");
        !            85:                return;
        !            86:        }
        !            87:        printf("%ld", x.a_text);
        !            88:        if (x.a_magic == ZMAGIC && lseek(io, 0x400, 0) == -1)
        !            89:                goto shread;
        !            90:        if (read(io, (char *)RELOC, x.a_text) != x.a_text)
        !            91:                goto shread;
        !            92:        addr = (char *)(x.a_text + RELOC);
        !            93:        if (x.a_magic == ZMAGIC || x.a_magic == NMAGIC)
        !            94:                while ((int)addr & CLOFSET)
        !            95:                        *addr++ = 0;
        !            96:        printf("+%ld", x.a_data);
        !            97:        if (read(io, addr, x.a_data) != x.a_data)
        !            98:                goto shread;
        !            99:        addr += x.a_data;
        !           100:        printf("+%ld", x.a_bss);
        !           101:        if (howto & RB_KDB && x.a_syms) {
        !           102:                for (i = 0; i < x.a_bss; i++)
        !           103:                        *addr++ = 0;
        !           104:                *(int *)addr = x.a_syms;                /* symbol table size */
        !           105:                addr += sizeof (int);
        !           106:                printf("[+%ld", x.a_syms);
        !           107:                if (read(io, addr, x.a_syms) != x.a_syms)
        !           108:                        goto shread;
        !           109:                addr += x.a_syms;
        !           110:                if (read(io, addr, sizeof (int)) != sizeof (int))
        !           111:                        goto shread;
        !           112:                i = *(int *)addr - sizeof (int);        /* string table size */
        !           113:                addr += sizeof (int);
        !           114:                printf("+%d]", i);
        !           115:                if (read(io, addr, i) != i)
        !           116:                        goto shread;
        !           117:                addr += i;
        !           118:                esym = roundup((int)addr, sizeof (int));
        !           119:                x.a_bss = 0;
        !           120:        } else
        !           121:                howto &= ~RB_KDB;
        !           122:        x.a_bss += 32*1024;     /* slop */
        !           123:        for (i = 0; i < x.a_bss; i++)
        !           124:                *addr++ = 0;
        !           125:        x.a_entry &= 0x1fffffff;
        !           126:        printf(" start 0x%lx\n", x.a_entry);
        !           127:        mtpr(PADC, 0);          /* Purge data cache */
        !           128:        mtpr(PACC, 0);          /* Purge code cache */
        !           129:        mtpr(DCR, 1);           /* Enable data cache */
        !           130:        (*((int (*)()) x.a_entry))();
        !           131:        return;
        !           132: shread:
        !           133:        printf("short read\n");
        !           134:        return;
        !           135: }

unix.superglobalmegacorp.com

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