Annotation of 43BSDReno/sys/hp300/swapgeneric.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1982, 1986 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution is only permitted until one year after the first shipment
                      6:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
                      7:  * binary forms are permitted provided that: (1) source distributions retain
                      8:  * this entire copyright notice and comment, and (2) distributions including
                      9:  * binaries display the following acknowledgement:  This product includes
                     10:  * software developed by the University of California, Berkeley and its
                     11:  * contributors'' in the documentation or other materials provided with the
                     12:  * distribution and in all advertising materials mentioning features or use
                     13:  * of this software.  Neither the name of the University nor the names of
                     14:  * its contributors may be used to endorse or promote products derived from
                     15:  * this software without specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  *
                     20:  *     @(#)swapgeneric.c       7.1 (Berkeley) 5/8/90
                     21:  */
                     22: 
                     23: #include "pte.h"
                     24: 
                     25: #include "param.h"
                     26: #include "conf.h"
                     27: #include "buf.h"
                     28: #include "vm.h"
                     29: #include "systm.h"
                     30: #include "reboot.h"
                     31: 
                     32: #include "../hpdev/device.h"
                     33: 
                     34: /*
                     35:  * Generic configuration;  all in one
                     36:  */
                     37: dev_t  rootdev = NODEV;
                     38: dev_t  argdev = NODEV;
                     39: dev_t  dumpdev = NODEV;
                     40: int    nswap;
                     41: struct swdevt swdevt[] = {
                     42:        { -1,   1,      0 },
                     43:        { 0,    0,      0 },
                     44: };
                     45: long   dumplo;
                     46: int    dmmin, dmmax, dmtext;
                     47: 
                     48: extern struct driver rddriver;
                     49: extern struct driver sddriver;
                     50: extern struct hp_ctlr hp_cinit[];
                     51: extern struct hp_device hp_dinit[];
                     52: 
                     53: struct genericconf {
                     54:        caddr_t gc_driver;
                     55:        char    *gc_name;
                     56:        dev_t   gc_root;
                     57: } genericconf[] = {
                     58:        { (caddr_t)&rddriver,   "rd",   makedev(2, 0),  },
                     59:        { (caddr_t)&sddriver,   "sd",   makedev(4, 0),  },
                     60:        { 0 },
                     61: };
                     62: 
                     63: setconf()
                     64: {
                     65:        register struct hp_ctlr *hc;
                     66:        register struct hp_device *hd;
                     67:        register struct genericconf *gc;
                     68:        register char *cp;
                     69:        int unit, swaponroot = 0;
                     70: 
                     71:        if (rootdev != NODEV)
                     72:                goto doswap;
                     73:        unit = 0;
                     74:        if (boothowto & RB_ASKNAME) {
                     75:                char name[128];
                     76: retry:
                     77:                printf("root device? ");
                     78:                gets(name);
                     79:                for (gc = genericconf; gc->gc_driver; gc++)
                     80:                        if (gc->gc_name[0] == name[0] &&
                     81:                            gc->gc_name[1] == name[1])
                     82:                                goto gotit;
                     83:                printf("use one of:");
                     84:                for (gc = genericconf; gc->gc_driver; gc++)
                     85:                        printf(" %s%%d", gc->gc_name);
                     86:                printf("\n");
                     87:                goto retry;
                     88: gotit:
                     89:                if (*++cp < '0' || *cp > '9') {
                     90:                        printf("bad/missing unit number\n");
                     91:                        goto retry;
                     92:                }
                     93:                while (*cp >= '0' && *cp <= '9')
                     94:                        unit = 10 * unit + *cp++ - '0';
                     95:                if (*cp == '*')
                     96:                        swaponroot++;
                     97:                goto found;
                     98:        }
                     99:        for (gc = genericconf; gc->gc_driver; gc++) {
                    100:                for (hd = hp_dinit; hd->hp_driver; hd++) {
                    101:                        if (hd->hp_alive == 0)
                    102:                                continue;
                    103:                        if (hd->hp_unit == 0 && hd->hp_driver ==
                    104:                            (struct driver *)gc->gc_driver) {
                    105:                                printf("root on %s0\n", hd->hp_driver->d_name);
                    106:                                goto found;
                    107:                        }
                    108:                }
                    109:        }
                    110:        printf("no suitable root\n");
                    111:        asm("stop #0x2700");
                    112: found:
                    113:        gc->gc_root = makedev(major(gc->gc_root), unit*8);
                    114:        rootdev = gc->gc_root;
                    115: doswap:
                    116:        swdevt[0].sw_dev = argdev = dumpdev =
                    117:            makedev(major(rootdev), minor(rootdev)+1);
                    118:        /* swap size and dumplo set during autoconfigure */
                    119:        if (swaponroot)
                    120:                rootdev = dumpdev;
                    121: }
                    122: 
                    123: gets(cp)
                    124:        char *cp;
                    125: {
                    126:        register char *lp;
                    127:        register c;
                    128: 
                    129:        lp = cp;
                    130:        for (;;) {
                    131:                cnputc(c = cngetc());
                    132:                switch (c) {
                    133:                case '\n':
                    134:                case '\r':
                    135:                        *lp++ = '\0';
                    136:                        return;
                    137:                case '\b':
                    138:                case '\177':
                    139:                        if (lp > cp) {
                    140:                                lp--;
                    141:                                cnputc(' ');
                    142:                                cnputc('\b');
                    143:                        }
                    144:                        continue;
                    145:                case '#':
                    146:                        lp--;
                    147:                        if (lp < cp)
                    148:                                lp = cp;
                    149:                        continue;
                    150:                case '@':
                    151:                case 'u'&037:
                    152:                        lp = cp;
                    153:                        cnputc('\n');
                    154:                        continue;
                    155:                default:
                    156:                        *lp++ = c;
                    157:                }
                    158:        }
                    159: }

unix.superglobalmegacorp.com

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