1: /*
   2:  * Copyright (c) 1982, 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)swapgeneric.c	7.1 (Berkeley) 6/6/86
   7:  */
   8: 
   9: #include "mba.h"
  10: 
  11: #include "pte.h"
  12: 
  13: #include "param.h"
  14: #include "conf.h"
  15: #include "buf.h"
  16: #include "vm.h"
  17: #include "systm.h"
  18: #include "reboot.h"
  19: 
  20: #include "cons.h"
  21: #include "mtpr.h"
  22: #include "../vaxmba/mbareg.h"
  23: #include "../vaxmba/mbavar.h"
  24: #include "../vaxuba/ubareg.h"
  25: #include "../vaxuba/ubavar.h"
  26: 
  27: /*
  28:  * Generic configuration;  all in one
  29:  */
  30: dev_t   rootdev = NODEV;
  31: dev_t   argdev = NODEV;
  32: dev_t   dumpdev = NODEV;
  33: int nswap;
  34: struct  swdevt swdevt[] = {
  35:     { -1,   1,  0 },
  36:     { 0,    0,  0 },
  37: };
  38: long    dumplo;
  39: int dmmin, dmmax, dmtext;
  40: 
  41: extern  struct mba_driver hpdriver;
  42: extern  struct uba_driver scdriver;
  43: extern  struct uba_driver hkdriver;
  44: extern  struct uba_driver idcdriver;
  45: extern  struct uba_driver hldriver;
  46: extern  struct uba_driver udadriver;
  47: 
  48: struct  genericconf {
  49:     caddr_t gc_driver;
  50:     char    *gc_name;
  51:     dev_t   gc_root;
  52: } genericconf[] = {
  53:     { (caddr_t)&hpdriver,   "hp",   makedev(0, 0),  },
  54:     { (caddr_t)&scdriver,   "up",   makedev(2, 0),  },
  55:     { (caddr_t)&udadriver,  "ra",   makedev(9, 0),  },
  56:     { (caddr_t)&idcdriver,  "rb",   makedev(11, 0), },
  57:     { (caddr_t)&hldriver,   "rl",   makedev(14, 0), },
  58:     { (caddr_t)&hkdriver,   "hk",   makedev(3, 0),  },
  59:     { (caddr_t)&hkdriver,   "rk",   makedev(3, 0),  },
  60:     { 0 },
  61: };
  62: 
  63: setconf()
  64: {
  65:     register struct mba_device *mi;
  66:     register struct uba_device *ui;
  67:     register struct genericconf *gc;
  68:     int unit, swaponroot = 0;
  69: 
  70:     if (rootdev != NODEV)
  71:         goto doswap;
  72:     if (boothowto & RB_ASKNAME) {
  73:         char name[128];
  74: retry:
  75:         printf("root device? ");
  76:         gets(name);
  77:         for (gc = genericconf; gc->gc_driver; gc++)
  78:             if (gc->gc_name[0] == name[0] &&
  79:                 gc->gc_name[1] == name[1])
  80:                 goto gotit;
  81:         goto bad;
  82: gotit:
  83:         if (name[3] == '*') {
  84:             name[3] = name[4];
  85:             swaponroot++;
  86:         }
  87:         if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) {
  88:             unit = name[2] - '0';
  89:             goto found;
  90:         }
  91:         printf("bad/missing unit number\n");
  92: bad:
  93:         printf("use hp%%d, up%%d, ra%%d, rb%%d, rl%%d or hk%%d\n");
  94:         goto retry;
  95:     }
  96:     unit = 0;
  97:     for (gc = genericconf; gc->gc_driver; gc++) {
  98:         for (mi = mbdinit; mi->mi_driver; mi++) {
  99:             if (mi->mi_alive == 0)
 100:                 continue;
 101:             if (mi->mi_unit == 0 && mi->mi_driver ==
 102:                 (struct mba_driver *)gc->gc_driver) {
 103:                 printf("root on %s0\n",
 104:                     mi->mi_driver->md_dname);
 105:                 goto found;
 106:             }
 107:         }
 108:         for (ui = ubdinit; ui->ui_driver; ui++) {
 109:             if (ui->ui_alive == 0)
 110:                 continue;
 111:             if (ui->ui_unit == 0 && ui->ui_driver ==
 112:                 (struct uba_driver *)gc->gc_driver) {
 113:                 printf("root on %s0\n",
 114:                     ui->ui_driver->ud_dname);
 115:                 goto found;
 116:             }
 117:         }
 118:     }
 119:     printf("no suitable root\n");
 120:     asm("halt");
 121: found:
 122:     gc->gc_root = makedev(major(gc->gc_root), unit*8);
 123:     rootdev = gc->gc_root;
 124: doswap:
 125:     swdevt[0].sw_dev = argdev = dumpdev =
 126:         makedev(major(rootdev), minor(rootdev)+1);
 127:     /* swap size and dumplo set during autoconfigure */
 128:     if (swaponroot)
 129:         rootdev = dumpdev;
 130: }
 131: 
 132: getchar()
 133: {
 134:     register c;
 135: 
 136:     while ((mfpr(RXCS)&RXCS_DONE) == 0)
 137:         ;
 138:     c = mfpr(RXDB)&0177;
 139:     if (c == '\r')
 140:         c = '\n';
 141:     cnputc(c);
 142:     return (c);
 143: }
 144: 
 145: gets(cp)
 146:     char *cp;
 147: {
 148:     register char *lp;
 149:     register c;
 150: 
 151:     lp = cp;
 152:     for (;;) {
 153:         c = getchar() & 0177;
 154:         switch (c) {
 155:         case '\n':
 156:         case '\r':
 157:             *lp++ = '\0';
 158:             return;
 159:         case '\b':
 160:         case '#':
 161:         case '\177':
 162:             lp--;
 163:             if (lp < cp)
 164:                 lp = cp;
 165:             continue;
 166:         case '@':
 167:         case 'u'&037:
 168:             lp = cp;
 169:             cnputc('\n');
 170:             continue;
 171:         default:
 172:             *lp++ = c;
 173:         }
 174:     }
 175: }

Defined functions

getchar defined in line 132; used 1 times
gets defined in line 145; used 1 times
  • in line 76
setconf defined in line 63; used 1 times

Defined variables

argdev defined in line 31; used 1 times
dmmax defined in line 39; never used
dmmin defined in line 39; never used
dmtext defined in line 39; never used
dumpdev defined in line 32; used 2 times
dumplo defined in line 38; never used
genericconf defined in line 52; used 2 times
nswap defined in line 33; never used
rootdev defined in line 30; used 5 times
swdevt defined in line 34; used 1 times

Defined struct's

genericconf defined in line 48; used 2 times
  • in line 67(2)
Last modified: 1986-06-07
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1054
Valid CSS Valid XHTML 1.0 Strict