Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arc/dev Moved from /cvsroot/syssrc/sys/arch/pica/de...



details:   https://anonhg.NetBSD.org/src/rev/dd0111bba11c
branches:  trunk
changeset: 480972:dd0111bba11c
user:      soda <soda%NetBSD.org@localhost>
date:      Sun Jan 23 20:08:13 2000 +0000

description:
Moved from /cvsroot/syssrc/sys/arch/pica/dev/pccons.c,v

diffstat:

 sys/arch/arc/dev/pccons.c |  2220 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 2220 insertions(+), 0 deletions(-)

diffs (truncated from 2224 to 300 lines):

diff -r dde48f2cadb7 -r dd0111bba11c sys/arch/arc/dev/pccons.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/dev/pccons.c Sun Jan 23 20:08:13 2000 +0000
@@ -0,0 +1,2220 @@
+/*     $NetBSD: pccons.c,v 1.12 2000/01/23 20:08:13 soda Exp $ */
+
+/*-
+ * Copyright (c) 1993, 1994, 1995 Charles M. Hannum.  All rights reserved.
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz and Don Ahn.
+ *
+ * Copyright (c) 1994 Charles M. Hannum.
+ * Copyright (c) 1992, 1993 Erik Forsberg.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)pccons.c    5.11 (Berkeley) 5/21/91
+ */
+
+/*
+ * code to work keyboard & display for PC-style console
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/tty.h>
+#include <sys/uio.h>
+#include <sys/callout.h>
+#include <sys/syslog.h>
+#include <sys/vnode.h>
+#include <sys/device.h>
+#include <sys/file.h>
+#include <sys/poll.h>
+
+#include <dev/cons.h>
+
+#include <machine/cpu.h>
+#include <machine/pio.h>
+#include <machine/autoconf.h>
+#include <machine/bus.h>
+#include <machine/display.h>
+#include <machine/pccons.h>
+#include <pica/pica/pica.h>
+
+#ifdef notyet
+#include <dev/isa/isavar.h>
+#endif
+#include <machine/kbdreg.h>
+
+#define        XFREE86_BUG_COMPAT
+
+#ifndef BEEP_FREQ
+#define BEEP_FREQ 1600
+#endif
+#ifndef BEEP_TIME
+#define BEEP_TIME (hz/5)
+#endif
+
+#define PCBURST 128
+
+static u_short *Crtat;                 /* pointer to backing store */
+static u_short *crtat;                 /* pointer to current char */
+static u_char async, kernel, polling;  /* Really, you don't want to know. */
+static u_char lock_state = 0x00,       /* all off */
+             old_lock_state = 0xff,
+             typematic_rate = 0xff,    /* don't update until set by user */
+             old_typematic_rate = 0xff;
+static u_short cursor_shape = 0xffff,  /* don't update until set by user */
+              old_cursor_shape = 0xffff;
+int pc_xmode = 0;
+
+/*
+ *  Keyboard output queue.
+ */
+int    kb_oq_put = 0;
+int    kb_oq_get = 0;
+u_char kb_oq[8];
+
+#define        PCUNIT(x)       (minor(x))
+
+static struct video_state {
+       int     cx, cy;         /* escape parameters */
+       int     row, col;       /* current cursor position */
+       int     nrow, ncol, nchr;       /* current screen geometry */
+       u_char  state;          /* parser state */
+#define        VSS_ESCAPE      1
+#define        VSS_EBRACE      2
+#define        VSS_EPARAM      3
+       char    so;             /* in standout mode? */
+       char    color;          /* color or mono display */
+       char    at;             /* normal attributes */
+       char    so_at;          /* standout attributes */
+} vs;
+
+struct pc_softc {
+       struct  device sc_dev;
+       struct  tty *sc_tty;
+};
+
+struct pms_softc {             /* driver status information */
+       struct device sc_dev;
+
+       struct clist sc_q;
+       struct selinfo sc_rsel;
+       u_char sc_state;        /* mouse driver state */
+#define        PMS_OPEN        0x01    /* device is open */
+#define        PMS_ASLP        0x02    /* waiting for mouse data */
+       u_char sc_status;       /* mouse button status */
+       int sc_x, sc_y;         /* accumulated motion in the X,Y axis */
+};
+
+int pcmatch __P((struct device *, void *, void *));
+void pcattach __P((struct device *, struct device *, void *));
+int pcintr __P((void *));
+
+struct cfattach pc_ca = {
+       sizeof(struct pc_softc), pcmatch, pcattach
+};
+
+extern struct cfdriver pc_cd;
+
+int pmsprobe __P((struct device *, void *, void *));
+void pmsattach __P((struct device *, struct device *, void *));
+int pmsintr __P((void *));
+
+struct cfattach pms_ca = {
+       sizeof(struct pms_softc), pmsprobe, pmsattach
+};
+
+#define        PMSUNIT(dev)    (minor(dev))
+
+#define        COL             80
+#define        ROW             25
+#define        CHR             2
+
+/*
+ * DANGER WIL ROBINSON -- the values of SCROLL, NUM, CAPS, and ALT are
+ * important.
+ */
+#define        SCROLL          0x0001  /* stop output */
+#define        NUM             0x0002  /* numeric shift  cursors vs. numeric */
+#define        CAPS            0x0004  /* caps shift -- swaps case of letter */
+#define        SHIFT           0x0008  /* keyboard shift */
+#define        CTL             0x0010  /* control shift  -- allows ctl function */
+#define        ASCII           0x0020  /* ascii code for this key */
+#define        ALTGR           0x0040  /* alt graphic */
+#define        ALT             0x0080  /* alternate shift -- alternate chars */
+#define        FUNC            0x0100  /* function key */
+#define        KP              0x0200  /* Keypad keys */
+#define        NONE            0x0400  /* no function */
+
+static unsigned int addr_6845 = MONO_BASE;
+
+char *sget __P((void));
+void sput __P((u_char *, int));
+
+void   pcstart();
+int    pcparam();
+char   partab[];
+
+extern pcopen(dev_t, int, int, struct proc *);
+
+#define        KBD_DELAY \
+               DELAY(10);
+
+static inline int
+kbd_wait_output()
+{
+       u_int i;
+
+       for (i = 100000; i; i--)
+               if ((inb(KBSTATP) & KBS_IBF) == 0) {
+                       KBD_DELAY;
+                       return 1;
+               }
+       return 0;
+}
+
+static inline int
+kbd_wait_input()
+{
+       u_int i;
+
+       for (i = 100000; i; i--)
+               if ((inb(KBSTATP) & KBS_DIB) != 0) {
+                       KBD_DELAY;
+                       return 1;
+               }
+       return 0;
+}
+
+static inline void
+kbd_flush_input()
+{
+       u_char c;
+
+       while (c = inb(KBSTATP) & 0x03)
+               if ((c & KBS_DIB) == KBS_DIB) {
+                       /* XXX - delay is needed to prevent some keyboards from
+                          wedging when the system boots */
+                       delay(6);
+                       (void) inb(KBDATAP);
+               }
+}
+
+
+#if 1
+/*
+ * Get the current command byte.
+ */
+static u_char
+kbc_get8042cmd()
+{
+
+       if (!kbd_wait_output())
+               return -1;
+       outb(KBCMDP, K_RDCMDBYTE);
+       if (!kbd_wait_input())
+               return -1;
+       return inb(KBDATAP);
+}
+#endif
+
+/*
+ * Pass command byte to keyboard controller (8042).
+ */
+static int
+kbc_put8042cmd(val)
+       u_char val;
+{
+
+       if (!kbd_wait_output())
+               return 0;
+       outb(KBCMDP, K_LDCMDBYTE);
+       if (!kbd_wait_output())
+               return 0;
+       outb(KBOUTP, val);
+       return 1;
+}
+
+/*
+ * Pass command to keyboard itself
+ */
+int
+kbd_cmd(val, polling)
+       u_char val;
+       u_char polling;
+{
+       u_int retries = 3;
+       register u_int i;
+
+       if(!polling) {
+               i = spltty();
+               if(kb_oq_get == kb_oq_put) {
+                       outb(KBOUTP, val);
+               }
+               kb_oq[kb_oq_put] = val;
+               kb_oq_put = (kb_oq_put + 1) & 7;
+               splx(i);
+               return(1);
+       }
+       else do {
+               if (!kbd_wait_output())
+                       return 0;



Home | Main Index | Thread Index | Old Index