Annotation of researchv9/sys/boot/stand/boot.c, revision 1.1.1.1

1.1       root        1: #include <sys/reboot.h>
                      2: #include <machine/sunromvec.h>
                      3: 
                      4: /*
                      5:  * Boot program... argument from monitor determines
                      6:  * whether boot stops to ask for system name and which device
                      7:  * boot comes from.
                      8:  */
                      9: 
                     10: int (*readfile())();
                     11: 
                     12: char aline[100];
                     13: 
                     14: char bunix[] = "unix"; /* and room to patch to whatever */
                     15: 
                     16: main()
                     17: {
                     18:        register struct bootparam *bp;
                     19:        register char *arg;
                     20:        register int howto;
                     21:        register int io;
                     22:        int (*go2)();
                     23: 
                     24:        bp = *(romp->v_bootparam);              /* S-2: via romvec */
                     25: 
                     26:        arg = bp->bp_argv[0];
                     27:        howto = bootflags(bp->bp_argv[1]);
                     28:        if ((howto&RB_ASKNAME)==0) {
                     29:                register char *s, *p;
                     30: 
                     31:                for (s = arg, p = aline; *s; s++, p++)
                     32:                        *p = *s;
                     33:                
                     34:                /*
                     35:                 * If no file name given, default to "unix"
                     36:                 * We only do this if we aren't asking for input
                     37:                 */
                     38:                for (s = aline; *s;)
                     39:                        if (*s++ == ')')
                     40:                                break;
                     41:                if (*s == '\0') {
                     42:                        for (p = bunix; *p;)
                     43:                                *s++ = *p++;
                     44:                        *s = '\0';
                     45:                }
                     46:        }
                     47:        for (;;) {
                     48:                if (howto & RB_ASKNAME) {
                     49:                        printf("Boot: ");
                     50:                        gets(aline);
                     51:                        if (*aline == 0)
                     52:                                continue;       /* Null input - try again */
                     53:                        parseparam(aline, howto, bp);
                     54:                } else
                     55:                        printf("Boot: %s\n", aline);
                     56:                io = open(aline, 0);
                     57:                if (io >= 0) {
                     58:                        go2 = readfile(io, 1);
                     59:                        if (!(howto & RB_ASKNAME))  {
                     60:                                _exitto(go2);
                     61:                                /*NOTREACHED*/ ;
                     62:                        }
                     63:                        if ((int)go2 != -1)
                     64:                                (*go2)(arg);
                     65:                } else {
                     66:                        printf("boot failed\n");
                     67:                        if (!(howto & RB_ASKNAME))
                     68:                                _stop((char *) 0);
                     69:                }
                     70:        }
                     71: }
                     72: 
                     73: 
                     74: struct bootf {
                     75:        char    let;
                     76:        short   bit;
                     77: } bootf[] = {
                     78:        'a',    RB_ASKNAME,
                     79:        's',    RB_SINGLE,
                     80:        'i',    0,
                     81:        'h',    RB_HALT,
                     82:        0,      0,
                     83: };
                     84: 
                     85: /*
                     86:  * Parse the boot line to determine boot flags 
                     87:  */
                     88: bootflags(cp)
                     89:        register char *cp;
                     90: {
                     91:        register int i, boothowto = 0;
                     92: 
                     93:        if (*cp++ == '-')
                     94:        do {
                     95:                for (i = 0; bootf[i].let; i++) {
                     96:                        if (*cp == bootf[i].let) {
                     97:                                boothowto |= bootf[i].bit;
                     98:                                break;
                     99:                        }
                    100:                }
                    101:                cp++;
                    102:        } while (bootf[i].let && *cp);
                    103:        return (boothowto);
                    104: }
                    105:  
                    106: /*
                    107:  * Parse the boot line and put it in bootparam.  Stuff in -a -s or -as if
                    108:  * s/he only typed one argument and if they were in effect before.
                    109:  */
                    110: parseparam(line, defaults, bp)
                    111:        register char *line;
                    112:        int defaults;
                    113:        register struct bootparam *bp;
                    114: {
                    115:        register int narg = 0, i;
                    116:        register char *cp = bp->bp_strings;
                    117: 
                    118:        while(*line) {
                    119:                if (narg == 1)          /* terminate line for open */
                    120:                        *line++ = 0;
                    121:                while (*line == ' ')
                    122:                        line++;
                    123:                if (*line)
                    124:                        bp->bp_argv[narg++] = cp;
                    125:                while (*line != ' ' && *line != 0)
                    126:                        *cp++ = *line++;
                    127:                *cp++ = 0;
                    128:        };
                    129:        bp->bp_argv[narg] = 0;
                    130:        /*
                    131:         * Stuff in default switches
                    132:         */
                    133:        if (narg == 1 && defaults) {
                    134:                bp->bp_argv[narg++] = cp;
                    135:                *cp++ = '-';
                    136:                for (i = 0; bootf[i].let; i++) {
                    137:                        if (defaults & bootf[i].bit)
                    138:                                *cp++ = bootf[i].let;
                    139:                }
                    140:                *cp = 0;
                    141:                bp->bp_argv[narg] = 0;
                    142:        }
                    143: }

unix.superglobalmegacorp.com

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