Annotation of Net2/arch/amiga/dev/kbd.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. All advertising materials mentioning features or use of this software
                     14:  *    must display the following acknowledgement:
                     15:  *     This product includes software developed by the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
                     33:  *     kbd.c
                     34:  */
                     35: 
                     36: #include "ite.h"
                     37: 
                     38: #if NITE > 0
                     39: #include "sys/param.h"
                     40: #include "sys/systm.h"
                     41: #include "sys/ioctl.h"
                     42: #include "sys/tty.h"
                     43: #include "sys/proc.h"
                     44: #include "sys/conf.h"
                     45: #include "sys/file.h"
                     46: #include "sys/uio.h"
                     47: #include "sys/kernel.h"
                     48: #include "sys/syslog.h"
                     49: 
                     50: #include "device.h"
                     51: #include "kbdreg.h"
                     52: #include "itevar.h"
                     53: #include "machine/cpu.h"
                     54: 
                     55: #include "../amiga/custom.h"
                     56: #include "../amiga/cia.h"
                     57: 
                     58: void
                     59: kbdenable ()
                     60: {
                     61:   int s = spltty();
                     62: 
                     63:   /* collides with external ints from SCSI, watch out for this when
                     64:      enabling/disabling interrupts there !! */
                     65:   custom.intena = INTF_SETCLR | INTF_PORTS;
                     66:   ciaa.icr = (1<<7) | (1<<3);  /* SP interrupt enable */
                     67:   ciaa.cra &= ~(1<<6);         /* serial line == input */
                     68:   
                     69:   splx (s);
                     70: }
                     71: 
                     72: 
                     73: int
                     74: kbdintr ()
                     75: {
                     76:   /* THIS CLEARS ALL INTERRUPTS FROM CIAA! Will need a special cia
                     77:      interrupt handler to be able to use the ciaa timers besides driving
                     78:      the keyboard !! */
                     79:   u_char ints = ciaa.icr;
                     80:   u_char c, in;
                     81:  
                     82:   if (! (ints & (1<<3)))
                     83:     return 0;
                     84:     
                     85:   in = ciaa.sdr;
                     86:   /* ack */
                     87:   ciaa.cra |= (1 << 6);        /* serial line output */
                     88:   /* wait 85 microseconds */
                     89:   DELAY(85);
                     90:   ciaa.cra &= ~(1 << 6);
                     91: 
                     92:   c = ~in;     /* keyboard data is inverted */
                     93: 
                     94:   /* process the character. 
                     95:   
                     96:      Should implement RAW mode for X11 later here !! */
                     97:   c = (c >> 1) | (c << 7);     /* rotate right once */
                     98: 
                     99:   itefilter (c, ITEFILT_TTY);
                    100: }
                    101: 
                    102: 
                    103: int
                    104: kbdbell()
                    105: {
                    106: 
                    107:  /* not yet.. */
                    108: 
                    109: }
                    110: 
                    111: 
                    112: int
                    113: kbdgetcn ()
                    114: {
                    115:   int s = spltty ();
                    116:   u_char ints, c, in;
                    117: 
                    118:   /* this is very very nasty... */
                    119:   while (! (ciaa.icr & (1<<3))) ;
                    120: 
                    121:   in = ciaa.sdr;
                    122:   c = ~in;
                    123:   
                    124:   /* ack */
                    125:   ciaa.cra |= (1 << 6);        /* serial line output */
                    126:   ciaa.sdr = 0xff;             /* ack */
                    127:   /* wait 85 microseconds */
                    128:   DELAY(85);    /* XXXX only works as long as DELAY doesn't use a timer and waits.. */
                    129:   ciaa.cra &= ~(1 << 6);
                    130:   ciaa.sdr = in;
                    131: 
                    132:   splx (s);
                    133:   c = (c >> 1) | (c << 7);
                    134:   return c;
                    135: }
                    136: 
                    137: #endif

unix.superglobalmegacorp.com

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