Annotation of cci/d/pits/bio.c, revision 1.1.1.1

1.1       root        1: 
                      2: #include "definitions"
                      3: #define LINE   80
                      4: #define CRTN   0x0d
                      5: #define EOL    '.'
                      6: 
                      7: /*     I/O ROUTINES TO CPU2 CONSOLE    */
                      8: 
                      9: writec(c)
                     10: char c;
                     11: {
                     12:        putchar(c);
                     13: }
                     14: 
                     15: writes(s)
                     16: char *s;
                     17: {
                     18:        putstr(s);
                     19: }
                     20: 
                     21: writeh(ix)     /* 32 bits HEX */
                     22: long ix;
                     23: {      register long count, mask, indx;
                     24:        char c, str[9];
                     25: 
                     26:        if (ix==0) { writec('0'); return; }
                     27:        indx = 0; count = 28;
                     28:        mask = 0xf0000000;
                     29:        str[8]='\0';
                     30:        while (mask)  {
                     31:                c = ( (ix&mask) >> count )&0xf;
                     32:                count -= 4;
                     33:                if (indx==0) mask = 0xf000000;
                     34:                        else mask = mask >> 4;
                     35:                if ((c>=0)&&(c<=9)) c=c+'0';
                     36:                        else c=c+'7';
                     37:                str[indx++] = c;
                     38:                }
                     39:        /* replace leading 0 with space */
                     40:        for (indx=0; indx<8; indx++) {
                     41:                if (str[indx]!='0') break;
                     42:                        /* esle str[indx]=' '; */
                     43:                }
                     44:        writes(&str[indx]);
                     45: }
                     46: 
                     47: /*     Function to write a 32_bit decimal to Console
                     48: */
                     49: writed(ix)
                     50: long ix;
                     51: {      char c;
                     52:        register long div, lead0;
                     53: 
                     54:        if (ix==0) { writec('0'); return; }
                     55:        if (ix<0) { writec('-'); ix = (~ix)+1; }
                     56:        lead0 = 1;
                     57:        div = 1000000000;
                     58:        while (div) {
                     59:                c = (ix/div)+'0';
                     60:                ix = ix%div;            /* Mod */
                     61:                div /= 10;
                     62:                if ((c=='0')&&(lead0)) c=' ';
                     63:                        else lead0 = 0;
                     64:                if (c != ' ') writec(c);
                     65:                }
                     66: }
                     67: 
                     68: /*     Function read 1 char from Console
                     69: */
                     70: char readc()
                     71: {      char c, rdchar();
                     72: 
                     73:        writec(c = rdchar());
                     74:        return(c);
                     75: }
                     76: 
                     77: /*     This function read a string of characters.
                     78:        calling sequence : nochar = reads(s);
                     79:        input argument   : char *s;
                     80:        return value     : no. of char read; excluding NULL or CR.
                     81: */
                     82: reads(s)
                     83: char *s;
                     84: {      register long ix;
                     85: 
                     86:        for(ix=0;;ix++) {
                     87:                *s = readc();
                     88:                if ((*s==NULL)||(*s==CR)) 
                     89:                        { *s = NULL; break; }
                     90:                     else s++;
                     91:                }
                     92:        return(ix);
                     93: }
                     94: 
                     95: 
                     96: /*     This function read a string of HEX digit and
                     97:        convert it to integer value.
                     98:        calling sequence : stat = readh(ix);
                     99:        input parameter  : long *ix;
                    100:        return value     : (stat < 0) if error else (stat = 0);
                    101: */
                    102: /*
                    103: readh(ix)      
                    104: long *ix;
                    105: {      char line[ALINE], *getnum(), *del;
                    106:        int nochar;
                    107: 
                    108:        if ( (nochar = reads(line)) > 8 ) return(-1);
                    109:        if ( (del = getnum(line,ix,del,HEX)) < 0 ) return(-1);
                    110:                else return(0);
                    111: }
                    112: 
                    113: */
                    114: 
                    115: 
                    116: 
                    117: 
                    118: /*     This function read a string of DEC digit and
                    119:        convert it to integer value.
                    120:        calling sequence : stat = readd(ix);
                    121:        input parameter  : long *ix;
                    122:        return value     : (stat < 0) if error else (stat = 0);
                    123: */
                    124: 
                    125: /*
                    126: readd(ix)      
                    127: long *ix;
                    128: {      char line[ALINE], *getnum(), *del;
                    129:        int nochar;
                    130: 
                    131:        if ( (nochar = reads(line)) > 11 ) return(-1);
                    132:        if ( (del = getnum(line,ix,del,DEC)) < 0 ) return(-1);
                    133:                else return(0);
                    134: }
                    135: */
                    136: echo(c)                /* routine to get a test number, validate it 
                    137:                   and set bits in a flag word.           */
                    138: 
                    139: int c;
                    140: 
                    141: {
                    142: 
                    143: #define ALL 00
                    144: #define VDDC 03
                    145: #define VIOC 05
                    146: #define MT 06
                    147: 
                    148: int flag, valid;
                    149: 
                    150: flag = 0;
                    151: valid = 1;
                    152: 
                    153: while (valid){ 
                    154:        c = readc();
                    155:        switch(c){
                    156:        case '0':
                    157:                flag |= ALL;
                    158:                valid = 0;
                    159:                break;
                    160:        case '1':
                    161:                flag |= MT;
                    162:                valid = 0;
                    163:                break;
                    164:        case '2':
                    165:                flag |= VIOC;
                    166:                valid = 0;
                    167:                break;
                    168:        case '3':
                    169:                flag |= VDDC;
                    170:                valid = 0;
                    171:                break;
                    172:        default:
                    173:                writes(" invalid test number\n");
                    174:                writes("\nRe-enter test number : ");
                    175:                valid = 1;
                    176:                break;
                    177:                }
                    178:        }
                    179: c = flag;
                    180: return(c);
                    181: }
                    182: getcont(c)     /* routine to get controller number */
                    183: int c;
                    184: {
                    185: int valid, cont;
                    186: valid = 1;
                    187: writes("\n\nController number [0-3] : ");
                    188: while(valid){
                    189:        c = readc();
                    190:        switch(c){
                    191:        case '0':
                    192:                cont = 0;
                    193:                valid = 0;
                    194:                break;
                    195:        case '1':
                    196:                cont = 1;
                    197:                valid = 0;
                    198:                break;
                    199:        case '2':
                    200:                cont = 2;
                    201:                valid = 0;
                    202:                break;
                    203:        case '3':
                    204:                cont = 3;
                    205:                valid = 0;
                    206:                break;
                    207:        default:
                    208:                writes(" invalid controller number\n");
                    209:                writes("\nRe-enter controller number : ");
                    210:                valid = 1;
                    211:                break;
                    212:                }
                    213:        }
                    214: return(cont);
                    215: }
                    216: gettype(c)     /* routine to get type of disk */
                    217: int c;
                    218: {
                    219: int valid, type;
                    220: valid = 1;
                    221: writes("\n\nDisk type [0 = fsd, 1 = smd, 2 = xfd] : ");
                    222: while(valid){
                    223:        c = readc();
                    224:        switch(c){
                    225:        case '0':
                    226:                type = 0;
                    227:                valid = 0;
                    228:                break;  
                    229:        case '1':
                    230:                type = 1;
                    231:                valid = 0;
                    232:                break;
                    233:        case '2':
                    234:                type = 2;
                    235:                valid = 0;
                    236:                break;
                    237:        default:
                    238:                writes(" invalid disk type\n");
                    239:                writes("\nRe-enter disk type : ");
                    240:                valid = 1;
                    241:                break;
                    242:                }
                    243:        }
                    244: return(type);
                    245: }
                    246:        /**********************************************************
                    247:        Hex input routine, call fill and validates the characters
                    248:        in the character buffer. Then returns the HEX value back to 
                    249:        the calling routine.
                    250:        **********************************************************/
                    251: gethex() 
                    252: {
                    253:        char s[LINE];
                    254:        int k[1],i,n;
                    255:        n=0x0;
                    256:        fill(s,k);                      /* Fill s[] */ 
                    257:        for (i=0;i<k[0];++i) {
                    258:          if (s[i] >= 'a' && s[i] <= 'f')
                    259:         n=0x10*n+s[i]-'W';
                    260:         if (s[i] >= 'A' && s[i] <= 'F')
                    261:         n=0x10*n+s[i]-'7';
                    262:         if (s[i] >= '0' && s[i] <= '9')
                    263:         n=0x10*n+s[i]-'0';
                    264:         if ((s[i] < '0' ) || (s[i] > '9' && s[i] < 'A') || (s[i]  > 'F' 
                    265:             && s[i] < 'a') || (s[i] > 'f')) 
                    266:         {
                    267:         writes("\nInvalid hex digit: "); writec(s[i]); writes(" (ignored)");
                    268:         }
                    269:        }
                    270:        return(n);
                    271: }
                    272:        /****************************************************
                    273:        This routine fills a character buffer with characters
                    274:        that are input on the console.
                    275:        ****************************************************/
                    276: fill(s,k)
                    277: char s[];
                    278: int k[];
                    279: {
                    280:        char c;
                    281:        int i;
                    282:        k[0]=0;
                    283:        for (i=0;(c=readc())!=CRTN;++i)
                    284:        {
                    285:        if (k[0]>LINE - 1) break;
                    286:        if (c==EOL)        break;
                    287:        s[i]=c;
                    288:        ++k[0];
                    289:        }
                    290: }

unix.superglobalmegacorp.com

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