Annotation of researchv9/jerq/src/lib/sys/kbd.c, revision 1.1.1.2

1.1       root        1: #include <jerq.h>
1.1.1.2 ! root        2: #include <queue.h>
1.1       root        3: #include <kbd.h>
                      4: #include <setup.h>
                      5: 
1.1.1.2 ! root        6: int    kbdrepeat;
        !             7: int    rptcount;
        !             8: int    kbdstatus;
1.1       root        9: 
                     10: /*
1.1.1.2 ! root       11:  * All characters with high bits set are used to index this table to yield
        !            12:  * the generated character. This makes TAB==^I, etc, and removes the silly
        !            13:  * mappings like ^@==0xba instead of NUL.  However, ^, is still NUL.
        !            14:  * For now, shifted keys are the same as unshifted, if mapped in this table;
        !            15:  * for example shift RETURN is RETURN.  This may change....
        !            16:  * Characters that 'cannot happen' are mapped to 'X'==0x58, to ferret out bugs.
        !            17:  * Break is well known as 0x80, disconnect as 0x81.
        !            18:  * This map is done at interrupt level time, so is always applied.
1.1       root       19:  */
1.1.1.2 ! root       20: unsigned char defkeymap[]={
        !            21: /*80*/ 0x58,   0x58,   0x58,   0x58,   0x58,   0x58,   0x58,   0x58,
        !            22:        0x58,   0x58,   0x58,   0x58,   0x58,   0x58,   0x8e,   0x81,
        !            23: /*90*/ 0x90,   0x91,   0x92,   0x93,   0x94,   0x95,   0x96,   0x97,
        !            24:        0x98,   0x99,   0x9a,   0x9b,   0x58,   0x58,   0x58,   0x58,
        !            25: /*A0*/ 0x58,   0xa1,   0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,
        !            26:        0x58,   0x58,   0x58,   0x58,   0x58,   0x58,   0xae,   0x80,
        !            27: /*B0*/ 0xb0,   0xb1,   0xb2,   0xb3,   0xb4,   0xb5,   0x0a,   0xb7,
        !            28:        0xb8,   0xb9,   0x00,   0xbb,   0x1e,   0xbd,   0x60,   0x1f,
        !            29: /*C0*/ 0xc0,   0xc1,   0xc2,   0xc3,   0xc4,   0x58,   0xc6,   0x0d,
        !            30:        0xc8,   0xc9,   0xca,   0xcb,   0xcc,   0xcd,   0xce,   0xcf,
        !            31: /*D0*/ 0x09,   0x08,   0xd2,   0xd3,   0xd4,   0xd5,   0xd6,   0xd7,
        !            32:        0x58,   0x58,   0x58,   0x58,   0x58,   0x58,   0x7f,   0x58,
        !            33: /*E0*/ 0x58,   0x58,   0xe2,   0x1b,   0x58,   0xe5,   0x58,   0x0d,
        !            34:        0xe8,   0xe9,   0xea,   0xeb,   0xec,   0xed,   0xee,   0xef,
        !            35: /*F0*/ 0x09,   0x08,   0xb2,   0x1b,   0x58,   0xf5,   0x0a,   0x58,
        !            36:        0x58,   0x58,   0x58,   0x58,   0x58,   0x58,   0x7f,   0x58,
1.1       root       37: };
                     38: 
                     39: kbdchar()
                     40: {
                     41:        return qgetc(&KBDQUEUE);
                     42: }
                     43: kbdinit()
                     44: {
                     45:        /* init the keyboard */
1.1.1.2 ! root       46:        DUART->b_cmnd=RESET_RECV|DIS_TX|DIS_RX;
        !            47:        DUART->b_cmnd=RESET_TRANS;
        !            48:        DUART->b_cmnd=RESET_ERR;
        !            49:        DUART->b_cmnd=RESET_MR;
        !            50:        DUART->mr1_2b=CHAR_ERR|PAR_ENB|EVN_PAR|CBITS8;
        !            51:        DUART->mr1_2b=NRML_MOD|ONEP000SB;
        !            52:        DUART->b_sr_csr=BD4800BPS;
        !            53:        DUART->b_cmnd=RESET_MR|ENB_TX|ENB_RX;
        !            54:        DUART->scc_ropbc=0x08; /* set output pins for kbd tx port*/
1.1       root       55:        /* turn chirps on/off depending on BRAM */
1.1.1.2 ! root       56:        if(VALKEYTONE)
        !            57:                kbdstatus=0;    /* no chirp */
1.1       root       58:        else
1.1.1.2 ! root       59:                kbdstatus=TTY_CHIRP;    /* chirp, chirp */
        !            60:        DUART->b_data=kbdstatus|0x02; /* request status */
1.1       root       61: }
1.1.1.2 ! root       62: auto2(){
        !            63:        register unsigned s, c;
        !            64:        s=DUART->b_sr_csr;
        !            65:        c=DUART->b_data;
        !            66:        if(s&(FRM_ERR|OVR_RUN)) 
1.1       root       67:                return;
1.1.1.2 ! root       68:        if(s&PAR_ERR){  /* control word: caps lock or repeat */
        !            69:                checkbram();
        !            70:                VALCAPS=(c&0x04)? 0 : 1; /* set the caps lock flag */
        !            71:                setbram();
        !            72:                if(c&0x10)      /* turn repeat off */
        !            73:                        kbdrepeat=rptcount=0;
        !            74:                else            /* the next character is to be repeated */
        !            75:                        kbdrepeat=RPTON;
1.1       root       76:                /*
1.1.1.2 ! root       77:                 * Don't actually set the repeat bit until the character
        !            78:                 * after the control code
        !            79:                 */
        !            80:        }else{          /* ordinary character */
        !            81:                rptcount=0;     /* new char so restart repeat timer */
        !            82:                if(c&0x80)
        !            83:                        c=defkeymap[c&0x7f];
        !            84:                if(c==0x8E)     /* SHIFT-SETUP; show what's up */
        !            85:                        KBDQUEUE.state |= QPRIORITY;
1.1       root       86:                qputc(&KBDQUEUE, (int)c);
1.1.1.2 ! root       87:                KBDQUEUE.state &= ~QPRIORITY;
        !            88:                if((kbdrepeat&RPTMASK) == RPTON){
        !            89:                        kbdrepeat=RPTHAVECHR|RPTON;
        !            90:                        kbdrepeat|=c;
1.1       root       91:                }
                     92:        }
                     93: }
1.1.1.2 ! root       94: kbdrpt(){
        !            95:        qputc(&KBDQUEUE, kbdrepeat&0xff);
1.1       root       96: }

unix.superglobalmegacorp.com

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