Annotation of cci/d/event/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: 
        !            64: asm(".set HISR,0x410");
        !            65: 
        !            66: putstr(str)
        !            67: char *str;
        !            68: {      long c_cnt;
        !            69:        struct cpdcb_o cpout;                   /* DCB for output */
        !            70: 
        !            71:        cpout.cp_hdr.cp_unit = CPCONS;          /* Reset done bit */
        !            72:        cpout.cp_hdr.cp_comm = CPWRITE;         /* Set command */
        !            73:        for(c_cnt=0;;c_cnt++) {
        !            74:                cpout.cp_buf[c_cnt] = *str++;
        !            75:                if (cpout.cp_buf[c_cnt]=='\n') {
        !            76:                         c_cnt++;
        !            77:                         cpout.cp_buf[c_cnt]='\r';
        !            78:                         }
        !            79:                if (cpout.cp_buf[c_cnt]=='\0') break;
        !            80:        }
        !            81:        if (c_cnt) {
        !            82:                cpout.cp_hdr.cp_count = c_cnt;
        !            83:                cp_poll(&cpout,'\0');
        !            84:                /* cp_poll('\0'); */ }
        !            85: }
        !            86: 
        !            87: putchar(c)
        !            88: {
        !            89:        struct cpdcb_o cpout;                   /* DCB for output */
        !            90: 
        !            91:        cpout.cp_hdr.cp_unit = CPCONS;          /* Reset done bit */
        !            92:        cpout.cp_hdr.cp_comm = CPWRITE;         /* Set command */
        !            93:        cpout.cp_buf[charcnt] = c;
        !            94:        cpout.cp_hdr.cp_count = 1;
        !            95:        cp_poll(&cpout,c);
        !            96:        /* cp_poll(c); */
        !            97: }
        !            98: 
        !            99: cp_poll(cpout,c)
        !           100: struct cpdcb_o *cpout;
        !           101: char c;
        !           102: {      register long time, r11, r10;
        !           103: 
        !           104:        time = 0x1ff0000;
        !           105:        r10 = (long)cpout;
        !           106:        r10 &= 0xffffff;
        !           107:        asm("mtpr r10,$CPMDCB");
        !           108:        tmp_lw = (long)(&cpout->cp_hdr.cp_unit);
        !           109: 
        !           110:        r11 = (long)(&cpout->cp_hdr.cp_unit);
        !           111:        while (time-- && !(cpout->cp_hdr.cp_unit & CPDONE)) { 
        !           112:                asm("mtpr r11,$0x1c");                  /* mtpr r11,$PDCS */
        !           113:                }
        !           114:        if (!(cpout->cp_hdr.cp_unit & CPDONE)) cp_hlt();        /* Time out */
        !           115:        if (c== '\n') putchar('\r');
        !           116: }
        !           117: 
        !           118: cp_hlt()
        !           119: {
        !           120:        asm("movl $0xeeeeeeee,r0");
        !           121:        asm("movl $0xeeeeeeee,r1");
        !           122:        asm("movl $0xeeeeeeee,r2");
        !           123:        asm("halt");
        !           124: }
        !           125: 

unix.superglobalmegacorp.com

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