Annotation of cci/d/mem/cp.c, revision 1.1.1.1

1.1       root        1: /*     Console Processor Interface     */
                      2: /*     Tahoe version, Nov. 1982        */
                      3: 
                      4: /****************************************/
                      5: /*                                     */
                      6: /*     Reduced DCB layout for byte     */
                      7: /*     communication.                  */
                      8: /*                                     */
                      9: /****************************************/
                     10: 
                     11: asm(".set CPMDCB,21");
                     12: asm(".set DC_OFF,2");
                     13: asm(".set DC_ON,1");
                     14: asm(".set MME,9");
                     15: asm(".set DCR,27");
                     16: asm(".set PDCS,28");
                     17: asm(".set CTL_SW,0x41b");  /* Addr of switches to turn on Cache, MME, Fault */
                     18: long tmp_lw;
                     19: 
                     20: 
                     21: #define        CPBUFLEN 200            /* Output buffer length */
                     22: struct cphdr
                     23: {
                     24:        char    cp_unit;        /* Done bit & unit # */
                     25:        char    cp_comm;        /* Command */
                     26:        short   cp_count;       /* Counter (when relevant) */
                     27: };
                     28: 
                     29: struct cpdcb_o                 /* Output structure */
                     30: {
                     31:        struct  cphdr   cp_hdr;
                     32:        char    cp_buf[CPBUFLEN]; /* Buffer for output or 'stty' */
                     33: };
                     34: 
                     35: struct cpdcb_i                 /* Structure for input */
                     36: {
                     37:        struct  cphdr   cp_hdr;
                     38:        char    cpi_buf[4];     /* Buffer for input */
                     39: };
                     40: 
                     41: #define        CPDONE  0x80            /* 'Done' bit in cp_unit */
                     42: #define        CPTAKE  0x40            /* CP 'ack' to this cpdcb */
                     43: 
                     44:                /* Values for 'unit' */
                     45: #define        CPUNIT  0               /* The CP itself */
                     46: #define        CPCONS  1               /* Console line */
                     47: #define        CPREMOT 2               /* Remote line */
                     48: 
                     49:                /* Values for 'command' */
                     50: #define        CPRESET 0
                     51: #define        CPWRITE 1
                     52: #define        CPREAD  2
                     53: #define        CPSTTY  3
                     54: #define        CPBOOT  4
                     55: 
                     56: 
                     57: /*     Put a char to CPU2 console */
                     58: 
                     59: #define NCHAR  1
                     60: 
                     61: long cpbuf_sz = 1;             /* Buffer size   */
                     62: long charcnt = 0;
                     63: struct cpdcb_o cpout;                  /* DCB for output */
                     64: struct cpdcb_i cpin;                   /* DCB for input */
                     65: 
                     66: asm(".set HISR,0x410");
                     67: 
                     68: putstr(str)
                     69: char *str;
                     70: {      long c_cnt;
                     71: 
                     72:        cpout.cp_hdr.cp_unit = CPCONS;          /* Reset done bit */
                     73:        cpout.cp_hdr.cp_comm = CPWRITE;         /* Set command */
                     74:        for(c_cnt=0;;c_cnt++) {
                     75:                cpout.cp_buf[c_cnt] = *str++;
                     76:                if (cpout.cp_buf[c_cnt]=='\n') {
                     77:                         c_cnt++;
                     78:                         cpout.cp_buf[c_cnt]='\r';
                     79:                         }
                     80:                if (cpout.cp_buf[c_cnt]=='\0') break;
                     81:        }
                     82:        if (c_cnt) {
                     83:                cpout.cp_hdr.cp_count = c_cnt;
                     84:                cp_poll('\0'); }
                     85: }
                     86: 
                     87: putchar(c)
                     88: {
                     89:        cpout.cp_hdr.cp_unit = CPCONS;          /* Reset done bit */
                     90:        cpout.cp_hdr.cp_comm = CPWRITE;         /* Set command */
                     91:        cpout.cp_buf[0] = c;
                     92:        cpout.cp_hdr.cp_count = 1;
                     93:        cp_poll(c);
                     94: }
                     95: 
                     96: 
                     97: char rdchar()
                     98: {
                     99: register long  r12;
                    100:        cpin.cp_hdr.cp_unit = CPCONS;           /* Reset done bit */
                    101:        cpin.cp_hdr.cp_comm = CPREAD;           /* Set command */
                    102:        cpin.cp_hdr.cp_count = 1;
                    103:        cp_pollr();
                    104:        r12 = (long)(&cpin.cpi_buf[0]);
                    105:        asm("mtpr r12,$0x1c");                  /* mtpr r11,$PDCS */
                    106:        return(cpin.cpi_buf[0] & 0x7f);
                    107: }
                    108: 
                    109: 
                    110: /*     Poll CP on read
                    111: */
                    112: cp_pollr()
                    113: {      register long r12, r11, time;
                    114: 
                    115:        r12 = ((long)&cpin) & 0xffffff;
                    116:        asm("mtpr r12,$CPMDCB");
                    117: 
                    118:        r11 = (long)(&cpin.cp_hdr.cp_unit);
                    119:        while (!(cpin.cp_hdr.cp_unit & CPDONE)) { 
                    120:                asm("mtpr r11,$0x1c");                  /* mtpr r11,$PDCS */
                    121:                }
                    122:        if (!(cpin.cp_hdr.cp_unit & CPDONE)) cp_hlt();  /* Time out */
                    123: }
                    124: 
                    125: 
                    126: /*     Poll CP on write
                    127: */
                    128: cp_poll(c)
                    129: char c;
                    130: {      register long r12, r11, time;
                    131: 
                    132:        time = 200000;
                    133:        r12 = ((long)&cpout) & 0xffffff;
                    134:        asm("mtpr r12,$CPMDCB");
                    135: 
                    136:        r11 = (long)(&cpout.cp_hdr.cp_unit);
                    137:        while (time-- && !(cpout.cp_hdr.cp_unit & CPDONE)) { 
                    138:                asm("mtpr r11,$0x1c");                  /* mtpr r11,$PDCS */
                    139:                }
                    140:        if (!(cpout.cp_hdr.cp_unit & CPDONE)) cp_hlt(); /* Time out */
                    141:        if (c== '\n') putchar('\r');
                    142: }
                    143: 
                    144: cp_hlt()
                    145: {
                    146:        asm("movl $0xeeeeeeee,r0");
                    147:        asm("movl $0xeeeeeeee,r1");
                    148:        asm("movl $0xeeeeeeee,r2");
                    149:        asm("halt");
                    150: }
                    151: 

unix.superglobalmegacorp.com

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