Annotation of cci/d/ioex/cp.c, revision 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[charcnt] = 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:        time = 0xff0000;
        !           116:        r12 = ((long)&cpin) & 0xffffff;
        !           117:        asm("mtpr r12,$CPMDCB");
        !           118: 
        !           119:        r11 = (long)(&cpin.cp_hdr.cp_unit);
        !           120:        while (time-- && !(cpin.cp_hdr.cp_unit & CPDONE)) { 
        !           121:                asm("mtpr r11,$0x1c");                  /* mtpr r11,$PDCS */
        !           122:                }
        !           123:        if (!(cpin.cp_hdr.cp_unit & CPDONE)) cp_hlt();  /* Time out */
        !           124: }
        !           125: 
        !           126: 
        !           127: /*     Poll CP on write
        !           128: */
        !           129: cp_poll(c)
        !           130: char c;
        !           131: {      register long r12, r11, time;
        !           132: 
        !           133:        time = 200000;
        !           134:        r12 = ((long)&cpout) & 0xffffff;
        !           135:        asm("mtpr r12,$CPMDCB");
        !           136:        asm("mtpr r12,$CPMDCB");
        !           137: 
        !           138:        r11 = (long)(&cpout.cp_hdr.cp_unit);
        !           139:        while (time-- && !(cpout.cp_hdr.cp_unit & CPDONE)) { 
        !           140:                asm("mtpr r11,$0x1c");                  /* mtpr r11,$PDCS */
        !           141:                }
        !           142:        if (!(cpout.cp_hdr.cp_unit & CPDONE)) cp_hlt(); /* Time out */
        !           143:        if (c== '\n') putchar('\r');
        !           144: }
        !           145: 
        !           146: cp_hlt()
        !           147: {
        !           148:        asm("movl $0xeeeeeeee,r0");
        !           149:        asm("movl $0xeeeeeeee,r1");
        !           150:        asm("movl $0xeeeeeeee,r2");
        !           151:        asm("halt");
        !           152: }
        !           153: 

unix.superglobalmegacorp.com

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