1: #
   2: /*
   3:  */
   4: 
   5: #include "../param.h"
   6: #include "../seg.h"
   7: #include "../buf.h"
   8: #include "../conf.h"
   9: 
  10: /*
  11:  * Address and structure of the
  12:  * KL-11 console device registers.
  13:  */
  14: struct
  15: {
  16:     int rsr;
  17:     int rbr;
  18:     int xsr;
  19:     int xbr;
  20: };
  21: 
  22: /*
  23:  * In case console is off,
  24:  * panicstr contains argument to last
  25:  * call to panic.
  26:  */
  27: 
  28: char    *panicstr;
  29: 
  30: /*
  31:  * Scaled down version of C Library printf.
  32:  * Only %s %l %d (==%l) %o are recognized.
  33:  * Used to print diagnostic information
  34:  * directly on console tty.
  35:  * Since it is not interrupt driven,
  36:  * all system activities are pretty much
  37:  * suspended.
  38:  * Printf should not be used for chit-chat.
  39:  */
  40: printf(fmt,x1,x2,x3,x4,x5,x6,x7,x8,x9,xa,xb,xc)
  41: char fmt[];
  42: {
  43:     register char *s;
  44:     register *adx, c;
  45: 
  46:     adx = &x1;
  47: loop:
  48:     while((c = *fmt++) != '%') {
  49:         if(c == '\0')
  50:             return;
  51:         putchar(c);
  52:     }
  53:     c = *fmt++;
  54:     if(c == 'd' || c == 'l' || c == 'o')
  55:         printn(*adx, c=='o'? 8: 10);
  56:     if(c == 's') {
  57:         s = *adx;
  58:         while(c = *s++)
  59:             putchar(c);
  60:     }
  61:     adx++;
  62:     goto loop;
  63: }
  64: 
  65: /*
  66:  * Print an unsigned integer in base b.
  67:  */
  68: printn(n, b)
  69: {
  70:     register a;
  71: 
  72:     if(a = ldiv(n, b))
  73:         printn(a, b);
  74:     putchar(lrem(n, b) + '0');
  75: }
  76: 
  77: /*
  78:  * Print a character on console.
  79:  * Attempts to save and restore device
  80:  * status.
  81:  * If the switches are 0, all
  82:  * printing is inhibited.
  83:  */
  84: putchar(c)
  85: {
  86:     register rc, s;
  87: 
  88:     rc = c;
  89:     if(SW->integ == 0)
  90:         return;
  91:     while((KL->xsr&0200) == 0)
  92:         ;
  93:     if(rc == 0)
  94:         return;
  95:     s = KL->xsr;
  96:     KL->xsr = 0;
  97:     KL->xbr = rc;
  98:     if(rc == '\n') {
  99:         putchar('\r');
 100:         putchar(0177);
 101:         putchar(0177);
 102:     }
 103:     putchar(0);
 104:     KL->xsr = s;
 105: }
 106: 
 107: /*
 108:  * Panic is called on unresolvable
 109:  * fatal errors.
 110:  * It syncs, prints "panic: mesg" and
 111:  * then loops.
 112:  */
 113: panic(s)
 114: char *s;
 115: {
 116:     panicstr = s;
 117:     update();
 118:     printf("panic: %s\n", s);
 119:     for(;;)
 120:         idle();
 121: }
 122: 
 123: /*
 124:  * prdev prints a warning message of the
 125:  * form "mesg on dev x/y".
 126:  * x and y are the major and minor parts of
 127:  * the device argument.
 128:  */
 129: prdev(str, dev)
 130: {
 131: 
 132:     printf("%s on dev %l/%l\n", str, dev.d_major, dev.d_minor);
 133: }
 134: 
 135: /*
 136:  * deverr prints a diagnostic from
 137:  * a device driver.
 138:  * It prints the device, block number,
 139:  * and an octal word (usually some error
 140:  * status register) passed as argument.
 141:  */
 142: deverror(bp, o1, o2)
 143: int *bp;
 144: {
 145:     register *rbp;
 146: 
 147:     rbp = bp;
 148:     prdev("err", rbp->b_dev);
 149:     printf("bn%l er%o %o\n", rbp->b_blkno, o1, o2);
 150: }

Defined functions

deverror defined in line 142; used 6 times
prdev defined in line 129; used 5 times
printf defined in line 40; used 9 times
printn defined in line 68; used 2 times
putchar defined in line 84; used 7 times

Defined variables

panicstr defined in line 28; used 1 times
Last modified: 1975-07-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 844
Valid CSS Valid XHTML 1.0 Strict