Wsdisplay and wskbd are supported as a console device.
This commit is contained in:
parent
e7d4e16bdf
commit
5a30c20715
|
@ -2,7 +2,7 @@
|
|||
# Distribution kernel (any model) kernel config file
|
||||
|
||||
#
|
||||
# $NetBSD: GENERIC,v 1.3 1999/10/18 09:42:12 enami Exp $
|
||||
# $NetBSD: GENERIC,v 1.4 1999/10/24 08:37:28 takemura Exp $
|
||||
#
|
||||
include "arch/hpcmips/conf/std.hpcmips"
|
||||
|
||||
|
@ -86,7 +86,7 @@ options WSDISPLAY_DEFAULTSCREENS=4
|
|||
# Workstation Console attachments
|
||||
fb* at mainbus0
|
||||
wsdisplay* at fb?
|
||||
#wskbd* at pckbd? mux 1
|
||||
wskbd* at vrkiu? mux 1
|
||||
#wsmouse* at pms? mux 0
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.hpcmips,v 1.1.1.1 1999/09/16 12:23:19 takemura Exp $
|
||||
# $NetBSD: files.hpcmips,v 1.2 1999/10/24 08:37:28 takemura Exp $
|
||||
|
||||
# maxpartitions must be first item in files.${ARCH}.
|
||||
maxpartitions 8
|
||||
|
@ -103,9 +103,10 @@ device vrbcu
|
|||
attach vrbcu at vrip
|
||||
file arch/hpcmips/vr/bcu_vrip.c vrbcu
|
||||
|
||||
device vrkiu
|
||||
device vrkiu: wskbddev
|
||||
attach vrkiu at vrip
|
||||
file arch/hpcmips/vr/vrkiu.c vrkiu
|
||||
file arch/hpcmips/vr/vrkiu.c vrkiu needs-flag
|
||||
file dev/pckbc/wskbdmap_mfii.c vrkiu
|
||||
|
||||
device vrpmu
|
||||
attach vrpmu at vrip
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fb.c,v 1.2 1999/09/26 10:22:10 takemura Exp $ */
|
||||
/* $NetBSD: fb.c,v 1.3 1999/10/24 08:37:29 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
|
@ -63,7 +63,7 @@
|
|||
static const char _copyright[] __attribute__ ((unused)) =
|
||||
"Copyright (c) 19999 Shin Takemura. All rights reserved.";
|
||||
static const char _rcsid[] __attribute__ ((unused)) =
|
||||
"$Id: fb.c,v 1.2 1999/09/26 10:22:10 takemura Exp $";
|
||||
"$Id: fb.c,v 1.3 1999/10/24 08:37:29 takemura Exp $";
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -81,13 +81,13 @@ static const char _rcsid[] __attribute__ ((unused)) =
|
|||
#include <machine/autoconf.h>
|
||||
#include <machine/bootinfo.h>
|
||||
|
||||
#include <arch/hpcmips/dev/fbvar.h>
|
||||
|
||||
#include <dev/rcons/raster.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wscons_raster.h>
|
||||
#include <dev/wscons/wsdisplayvar.h>
|
||||
|
||||
#include <arch/hpcmips/dev/fbvar.h>
|
||||
|
||||
#define FBDEBUG
|
||||
#ifdef FBDEBUG
|
||||
int fb_debug = 1;
|
||||
|
@ -157,7 +157,9 @@ struct wsdisplay_accessops fb_accessops = {
|
|||
0 /* load_font */
|
||||
};
|
||||
|
||||
static int fbconsole, fb_console_type;
|
||||
struct fb_devconfig fb_console_dc;
|
||||
struct wsscreen_descr fb_console_screen;
|
||||
|
||||
/*
|
||||
* function bodies
|
||||
|
@ -194,13 +196,11 @@ fbattach(parent, self, aux)
|
|||
struct fb_softc *sc = (struct fb_softc *)self;
|
||||
struct mainbus_attach_args *ma = aux;
|
||||
struct wsemuldisplaydev_attach_args wa;
|
||||
int console;
|
||||
|
||||
/* avoid warning */
|
||||
console = (int)ma->ma_iot;
|
||||
ma->ma_iot = ma->ma_iot;
|
||||
|
||||
console = 0;
|
||||
if (console) {
|
||||
if (fbconsole) {
|
||||
sc->sc_dc = &fb_console_dc;
|
||||
sc->nscreens = 1;
|
||||
} else {
|
||||
|
@ -221,7 +221,7 @@ fbattach(parent, self, aux)
|
|||
|
||||
printf("\n");
|
||||
|
||||
wa.console = 0;
|
||||
wa.console = fbconsole;
|
||||
wa.scrdata = &fb_screenlist;
|
||||
wa.accessops = &fb_accessops;
|
||||
wa.accesscookie = sc;
|
||||
|
@ -229,6 +229,49 @@ fbattach(parent, self, aux)
|
|||
config_found(self, &wa, wsemuldisplaydevprint);
|
||||
}
|
||||
|
||||
int
|
||||
fb_cnattach(iot, memt, type, check)
|
||||
bus_space_tag_t iot, memt;
|
||||
int type, check;
|
||||
{
|
||||
long defattr = 0;
|
||||
|
||||
/*
|
||||
We can't probe because we have no real device yet.
|
||||
|
||||
if (check && ! fb_probe(iot, memt))
|
||||
return (ENXIO);
|
||||
*/
|
||||
|
||||
bzero(&fb_console_dc, sizeof(struct fb_devconfig));
|
||||
if (fb_getdevconfig(&fb_console_dc) != 0) {
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
fb_console_screen = fb_stdscreen;
|
||||
fb_console_screen.nrows = fb_console_dc.dc_rcons.rc_maxrow;
|
||||
fb_console_screen.ncols = fb_console_dc.dc_rcons.rc_maxcol;
|
||||
|
||||
wsdisplay_cnattach(&fb_console_screen, &fb_console_dc.dc_rcons,
|
||||
0, 0, defattr);
|
||||
|
||||
fbconsole = 1;
|
||||
fb_console_type = type;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void fb_cons_test_xxx(char a);
|
||||
|
||||
void
|
||||
fb_cons_test_xxx(char a)
|
||||
{
|
||||
static int col = 0;
|
||||
fb_console_screen.textops->putchar(&fb_console_dc.dc_rcons,
|
||||
0, col++, a, 0);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
fb_getdevconfig(dc)
|
||||
struct fb_devconfig *dc;
|
||||
|
@ -295,9 +338,6 @@ fb_getdevconfig(dc)
|
|||
rcp->rc_ccolp = &rcp->rc_ccol;
|
||||
rcons_init(rcp, 34, 80);
|
||||
|
||||
fb_stdscreen.nrows = dc->dc_rcons.rc_maxrow;
|
||||
fb_stdscreen.ncols = dc->dc_rcons.rc_maxcol;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -309,7 +349,16 @@ fb_ioctl(v, cmd, data, flag, p)
|
|||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
DPRINTF(("%s(%d): fb_ioctl()\n", __FILE__, __LINE__));
|
||||
switch (cmd) {
|
||||
case WSKBDIO_BELL:
|
||||
return (0);
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINTF(("%s(%d): fb_ioctl(%ld, %lx)\n",
|
||||
__FILE__, __LINE__, cmd, (u_long)data));
|
||||
break;
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fbvar.h,v 1.1.1.1 1999/09/16 12:23:19 takemura Exp $ */
|
||||
/* $NetBSD: fbvar.h,v 1.2 1999/10/24 08:37:30 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
|
@ -54,3 +54,6 @@ struct fb_softc {
|
|||
struct fb_devconfig *sc_dc; /* device configuration */
|
||||
int nscreens;
|
||||
};
|
||||
|
||||
int fb_cnattach(bus_space_tag_t iot, bus_space_tag_t memt,
|
||||
int type, int check);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vr.c,v 1.2 1999/10/16 12:27:55 shin Exp $ */
|
||||
/* $NetBSD: vr.c,v 1.3 1999/10/24 08:37:30 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
|
@ -51,6 +51,7 @@
|
|||
#include <mips/mips/mips_mcclock.h> /* mcclock CPUspeed estimation */
|
||||
|
||||
#include <hpcmips/vr/vr.h>
|
||||
#include <hpcmips/vr/vripreg.h>
|
||||
#include <hpcmips/vr/rtcreg.h>
|
||||
#include <hpcmips/hpcmips/machdep.h> /* XXXjrs replace with vectors */
|
||||
#include <machine/bootinfo.h>
|
||||
|
@ -68,6 +69,21 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include "fb.h"
|
||||
#include "vrkiu.h"
|
||||
#if NFB > 0 || NVRKIU > 0
|
||||
#include <dev/rcons/raster.h>
|
||||
#include <dev/wscons/wsdisplayvar.h>
|
||||
#endif
|
||||
|
||||
#if NFB > 0
|
||||
#include <arch/hpcmips/dev/fbvar.h>
|
||||
#endif
|
||||
|
||||
#if NFB > 0
|
||||
#include <arch/hpcmips/vr/vrkiuvar.h>
|
||||
#endif
|
||||
|
||||
void vr_init __P((void));
|
||||
void vr_os_init __P((void));
|
||||
void vr_bus_reset __P((void));
|
||||
|
@ -162,7 +178,7 @@ vr_bus_reset()
|
|||
void
|
||||
vr_cons_init()
|
||||
{
|
||||
#if NCOM > 0
|
||||
#if NCOM > 0 || NFB > 0 || NVRKIU > 0
|
||||
extern bus_space_tag_t system_bus_iot;
|
||||
extern bus_space_tag_t mb_bus_space_init __P((void));
|
||||
#endif
|
||||
|
@ -181,6 +197,24 @@ vr_cons_init()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if NFB > 0
|
||||
mb_bus_space_init(); /* At this time, not initialized yet */
|
||||
if(fb_cnattach(system_bus_iot, 0x0c000000, 0, 0)) {
|
||||
printf("%s(%d): can't init fb console", __FILE__, __LINE__);
|
||||
} else {
|
||||
goto find_keyboard;
|
||||
}
|
||||
#endif
|
||||
|
||||
find_keyboard:
|
||||
#if NVRKIU > 0
|
||||
if (vrkiu_cnattach(system_bus_iot, VRIP_KIU_ADDR)) {
|
||||
printf("%s(%d): can't init vrkiu as console",
|
||||
__FILE__, __LINE__);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/* $NetBSD: vrkiu.c,v 1.1.1.1 1999/09/16 12:23:33 takemura Exp $ */
|
||||
/* $NetBSD: vrkiu.c,v 1.2 1999/10/24 08:37:30 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 SASAKI Takesi
|
||||
* Copyright (c) 1999 SASAKI Takesi All rights reserved.
|
||||
* Copyright (c) 1999 TAKEMRUA, Shin All rights reserved.
|
||||
* Copyright (c) 1999 PocketBSD Project. All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is a part of the PocketBSD.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -58,6 +56,12 @@
|
|||
#include <hpcmips/vr/vrkiureg.h>
|
||||
#include <hpcmips/vr/icureg.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wskbdvar.h>
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsksymvar.h>
|
||||
#include <dev/pckbc/wskbdmap_mfii.h>
|
||||
|
||||
#ifdef VRKIUDEBUG
|
||||
int vrkiu_debug = 0;
|
||||
#define DPRINTF(arg) if (vrkiu_debug) printf arg;
|
||||
|
@ -65,22 +69,84 @@ int vrkiu_debug = 0;
|
|||
#define DPRINTF(arg)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* structure and data types
|
||||
*/
|
||||
struct vrkiu_chip {
|
||||
bus_space_tag_t kc_iot;
|
||||
bus_space_handle_t kc_ioh;
|
||||
unsigned short kc_scandata[KIU_NSCANLINE/2];
|
||||
int kc_polling;
|
||||
u_int kc_type;
|
||||
int kc_data;
|
||||
|
||||
int kc_sft:1, kc_alt:1, kc_ctrl:1;
|
||||
|
||||
struct vrkiu_softc* kc_sc; /* back link */
|
||||
};
|
||||
|
||||
struct vrkiu_softc {
|
||||
struct device sc_dev;
|
||||
struct vrkiu_chip *sc_chip;
|
||||
struct vrkiu_chip sc_chip_body;
|
||||
int sc_enabled;
|
||||
struct device *sc_wskbddev;
|
||||
|
||||
void *sc_handler;
|
||||
#define NKEYBUF 32
|
||||
unsigned char keybuf[NKEYBUF];
|
||||
int keybufhead, keybuftail;
|
||||
};
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
static int vrkiumatch __P((struct device *, struct cfdata *, void *));
|
||||
static void vrkiuattach __P((struct device *, struct device *, void *));
|
||||
|
||||
static void vrkiu_write __P((struct vrkiu_softc *, int, unsigned short));
|
||||
static unsigned short vrkiu_read __P((struct vrkiu_softc *, int));
|
||||
|
||||
int vrkiu_intr __P((void *));
|
||||
|
||||
static void detect_key __P((struct vrkiu_softc *));
|
||||
static void process_key __P((struct vrkiu_softc *, int, int));
|
||||
static int vrkiu_init(struct vrkiu_chip*, bus_space_tag_t, bus_space_handle_t);
|
||||
static void vrkiu_write __P((struct vrkiu_chip *, int, unsigned short));
|
||||
static unsigned short vrkiu_read __P((struct vrkiu_chip *, int));
|
||||
static int vrkiu_is_console(bus_space_tag_t, bus_space_handle_t);
|
||||
static void detect_key __P((struct vrkiu_chip *));
|
||||
|
||||
static struct vrkiu_softc *the_vrkiu = NULL; /* XXX: kludge!! */
|
||||
|
||||
/* wskbd accessopts */
|
||||
int vrkiu_enable __P((void *, int));
|
||||
void vrkiu_set_leds __P((void *, int));
|
||||
int vrkiu_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
|
||||
|
||||
/* consopts */
|
||||
void vrkiu_cngetc __P((void*, u_int*, int*));
|
||||
void vrkiu_cnpollc __P((void *, int));
|
||||
|
||||
/*
|
||||
* global/static data
|
||||
*/
|
||||
struct cfattach vrkiu_ca = {
|
||||
sizeof(struct vrkiu_softc), vrkiumatch, vrkiuattach
|
||||
};
|
||||
|
||||
static struct vrkiu_softc *the_vrkiu = NULL; /* XXX: kludge!! */
|
||||
const struct wskbd_accessops vrkiu_accessops = {
|
||||
vrkiu_enable,
|
||||
vrkiu_set_leds,
|
||||
vrkiu_ioctl,
|
||||
};
|
||||
|
||||
const struct wskbd_consops vrkiu_consops = {
|
||||
vrkiu_cngetc,
|
||||
vrkiu_cnpollc,
|
||||
};
|
||||
|
||||
const struct wskbd_mapdata vrkiu_keymapdata = {
|
||||
pckbd_keydesctab,
|
||||
KB_US,
|
||||
};
|
||||
|
||||
struct vrkiu_chip *vrkiu_consdata = NULL;
|
||||
|
||||
/* XXX: This tranlation table may depend on each machine.
|
||||
Should I build it in? */
|
||||
|
@ -111,195 +177,79 @@ static char keytrans[] = {
|
|||
#define KP 0x0200 /* Keypad keys */
|
||||
#define NONE 0x0400 /* no function */
|
||||
|
||||
#define CODE_SIZE 4 /* Use a max of 4 for now... */
|
||||
/*
|
||||
* utilities
|
||||
*/
|
||||
static inline void
|
||||
vrkiu_write(chip, port, val)
|
||||
struct vrkiu_chip *chip;
|
||||
int port;
|
||||
unsigned short val;
|
||||
{
|
||||
bus_space_write_2(chip->kc_iot, chip->kc_ioh, port, val);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
u_short type;
|
||||
char unshift[CODE_SIZE];
|
||||
char shift[CODE_SIZE];
|
||||
char ctl[CODE_SIZE];
|
||||
} Scan_def;
|
||||
static inline unsigned short
|
||||
vrkiu_read(chip, port)
|
||||
struct vrkiu_chip *chip;
|
||||
int port;
|
||||
{
|
||||
return bus_space_read_2(chip->kc_iot, chip->kc_ioh, port);
|
||||
}
|
||||
|
||||
#if !defined(PCCONS_REAL_BS)
|
||||
#define PCCONS_REAL_BS 1
|
||||
#endif
|
||||
#if !defined(CAPS_IS_CONTROL)
|
||||
#define CAPS_IS_CONTROL 1
|
||||
#endif
|
||||
#if !defined(CAPS_ADD_CONTROL)
|
||||
#define CAPS_ADD_CONTROL 0
|
||||
#endif
|
||||
static inline int
|
||||
vrkiu_is_console(iot, ioh)
|
||||
bus_space_tag_t iot;
|
||||
bus_space_handle_t ioh;
|
||||
{
|
||||
if (vrkiu_consdata &&
|
||||
vrkiu_consdata->kc_iot == iot &&
|
||||
vrkiu_consdata->kc_ioh == ioh) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static Scan_def scan_codes[] = {
|
||||
{ NONE, "", "", "" }, /* 0 unused */
|
||||
{ ASCII,"\033", "\033", "\033" }, /* 1 ESCape */
|
||||
{ ASCII,"1", "!", "!" }, /* 2 1 */
|
||||
{ ASCII,"2", "@", "\000" }, /* 3 2 */
|
||||
{ ASCII,"3", "#", "#" }, /* 4 3 */
|
||||
{ ASCII,"4", "$", "$" }, /* 5 4 */
|
||||
{ ASCII,"5", "%", "%" }, /* 6 5 */
|
||||
{ ASCII,"6", "^", "\036" }, /* 7 6 */
|
||||
{ ASCII,"7", "&", "&" }, /* 8 7 */
|
||||
{ ASCII,"8", "*", "\010" }, /* 9 8 */
|
||||
{ ASCII,"9", "(", "(" }, /* 10 9 */
|
||||
{ ASCII,"0", ")", ")" }, /* 11 0 */
|
||||
{ ASCII,"-", "_", "\037" }, /* 12 - */
|
||||
{ ASCII,"=", "+", "+" }, /* 13 = */
|
||||
#ifndef PCCONS_REAL_BS
|
||||
{ ASCII,"\177", "\177", "\010" }, /* 14 backspace */
|
||||
#else
|
||||
{ ASCII,"\010", "\010", "\177" }, /* 14 backspace */
|
||||
#endif
|
||||
{ ASCII,"\t", "\177\t", "\t" }, /* 15 tab */
|
||||
{ ASCII,"q", "Q", "\021" }, /* 16 q */
|
||||
{ ASCII,"w", "W", "\027" }, /* 17 w */
|
||||
{ ASCII,"e", "E", "\005" }, /* 18 e */
|
||||
{ ASCII,"r", "R", "\022" }, /* 19 r */
|
||||
{ ASCII,"t", "T", "\024" }, /* 20 t */
|
||||
{ ASCII,"y", "Y", "\031" }, /* 21 y */
|
||||
{ ASCII,"u", "U", "\025" }, /* 22 u */
|
||||
{ ASCII,"i", "I", "\011" }, /* 23 i */
|
||||
{ ASCII,"o", "O", "\017" }, /* 24 o */
|
||||
{ ASCII,"p", "P", "\020" }, /* 25 p */
|
||||
{ ASCII,"[", "{", "\033" }, /* 26 [ */
|
||||
{ ASCII,"]", "}", "\035" }, /* 27 ] */
|
||||
{ ASCII,"\r", "\r", "\n" }, /* 28 return */
|
||||
#if CAPS_IS_CONTROL == 1 && CAPS_ADD_CONTROL == 0
|
||||
{ CAPS, "", "", "" }, /* 29 caps */
|
||||
#else
|
||||
{ CTL, "", "", "" }, /* 29 control */
|
||||
#endif
|
||||
{ ASCII,"a", "A", "\001" }, /* 30 a */
|
||||
{ ASCII,"s", "S", "\023" }, /* 31 s */
|
||||
{ ASCII,"d", "D", "\004" }, /* 32 d */
|
||||
{ ASCII,"f", "F", "\006" }, /* 33 f */
|
||||
{ ASCII,"g", "G", "\007" }, /* 34 g */
|
||||
{ ASCII,"h", "H", "\010" }, /* 35 h */
|
||||
{ ASCII,"j", "J", "\n" }, /* 36 j */
|
||||
{ ASCII,"k", "K", "\013" }, /* 37 k */
|
||||
{ ASCII,"l", "L", "\014" }, /* 38 l */
|
||||
{ ASCII,";", ":", ";" }, /* 39 ; */
|
||||
{ ASCII,"'", "\"", "'" }, /* 40 ' */
|
||||
{ ASCII,"`", "~", "`" }, /* 41 ` */
|
||||
{ SHIFT,"", "", "" }, /* 42 shift */
|
||||
{ ASCII,"\\", "|", "\034" }, /* 43 \ */
|
||||
{ ASCII,"z", "Z", "\032" }, /* 44 z */
|
||||
{ ASCII,"x", "X", "\030" }, /* 45 x */
|
||||
{ ASCII,"c", "C", "\003" }, /* 46 c */
|
||||
{ ASCII,"v", "V", "\026" }, /* 47 v */
|
||||
{ ASCII,"b", "B", "\002" }, /* 48 b */
|
||||
{ ASCII,"n", "N", "\016" }, /* 49 n */
|
||||
{ ASCII,"m", "M", "\r" }, /* 50 m */
|
||||
{ ASCII,",", "<", "<" }, /* 51 , */
|
||||
{ ASCII,".", ">", ">" }, /* 52 . */
|
||||
{ ASCII,"/", "?", "\037" }, /* 53 / */
|
||||
{ SHIFT,"", "", "" }, /* 54 shift */
|
||||
{ KP, "*", "*", "*" }, /* 55 kp * */
|
||||
{ ALT, "", "", "" }, /* 56 alt */
|
||||
{ ASCII," ", " ", "\000" }, /* 57 space */
|
||||
#if CAPS_IS_CONTROL == 1 || CAPS_ADD_CONTROL == 1
|
||||
{ CTL, "", "", "" }, /* 58 control */
|
||||
#else
|
||||
{ CAPS, "", "", "" }, /* 58 caps */
|
||||
#endif
|
||||
{ FUNC, "\033[M", "\033[Y", "\033[k" }, /* 59 f1 */
|
||||
{ FUNC, "\033[N", "\033[Z", "\033[l" }, /* 60 f2 */
|
||||
{ FUNC, "\033[O", "\033[a", "\033[m" }, /* 61 f3 */
|
||||
{ FUNC, "\033[P", "\033[b", "\033[n" }, /* 62 f4 */
|
||||
{ FUNC, "\033[Q", "\033[c", "\033[o" }, /* 63 f5 */
|
||||
{ FUNC, "\033[R", "\033[d", "\033[p" }, /* 64 f6 */
|
||||
{ FUNC, "\033[S", "\033[e", "\033[q" }, /* 65 f7 */
|
||||
{ FUNC, "\033[T", "\033[f", "\033[r" }, /* 66 f8 */
|
||||
{ FUNC, "\033[U", "\033[g", "\033[s" }, /* 67 f9 */
|
||||
{ FUNC, "\033[V", "\033[h", "\033[t" }, /* 68 f10 */
|
||||
{ NUM, "", "", "" }, /* 69 num lock */
|
||||
{ SCROLL,"", "", "" }, /* 70 scroll lock */
|
||||
{ KP, "7", "\033[H", "7" }, /* 71 kp 7 */
|
||||
{ KP, "8", "\033[A", "8" }, /* 72 kp 8 */
|
||||
{ KP, "9", "\033[I", "9" }, /* 73 kp 9 */
|
||||
{ KP, "-", "-", "-" }, /* 74 kp - */
|
||||
{ KP, "4", "\033[D", "4" }, /* 75 kp 4 */
|
||||
{ KP, "5", "\033[E", "5" }, /* 76 kp 5 */
|
||||
{ KP, "6", "\033[C", "6" }, /* 77 kp 6 */
|
||||
{ KP, "+", "+", "+" }, /* 78 kp + */
|
||||
{ KP, "1", "\033[F", "1" }, /* 79 kp 1 */
|
||||
{ KP, "2", "\033[B", "2" }, /* 80 kp 2 */
|
||||
{ KP, "3", "\033[G", "3" }, /* 81 kp 3 */
|
||||
{ KP, "0", "\033[L", "0" }, /* 82 kp 0 */
|
||||
{ KP, ".", "\177", "." }, /* 83 kp . */
|
||||
{ NONE, "", "", "" }, /* 84 0 */
|
||||
{ NONE, "100", "", "" }, /* 85 0 */
|
||||
{ NONE, "101", "", "" }, /* 86 0 */
|
||||
{ FUNC, "\033[W", "\033[i", "\033[u" }, /* 87 f11 */
|
||||
{ FUNC, "\033[X", "\033[j", "\033[v" }, /* 88 f12 */
|
||||
{ NONE, "102", "", "" }, /* 89 0 */
|
||||
{ NONE, "103", "", "" }, /* 90 0 */
|
||||
{ NONE, "", "", "" }, /* 91 0 */
|
||||
{ ASCII,"\177", "\177", "\010" }, /* 92 del */
|
||||
{ NONE, "", "", "" }, /* 93 0 */
|
||||
{ NONE, "", "", "" }, /* 94 0 */
|
||||
{ NONE, "", "", "" }, /* 95 0 */
|
||||
{ NONE, "", "", "" }, /* 96 0 */
|
||||
{ NONE, "", "", "" }, /* 97 0 */
|
||||
{ NONE, "", "", "" }, /* 98 0 */
|
||||
{ NONE, "", "", "" }, /* 99 0 */
|
||||
{ NONE, "", "", "" }, /* 100 */
|
||||
{ NONE, "", "", "" }, /* 101 */
|
||||
{ NONE, "", "", "" }, /* 102 */
|
||||
{ NONE, "", "", "" }, /* 103 */
|
||||
{ NONE, "", "", "" }, /* 104 */
|
||||
{ NONE, "", "", "" }, /* 105 */
|
||||
{ NONE, "", "", "" }, /* 106 */
|
||||
{ NONE, "", "", "" }, /* 107 */
|
||||
{ NONE, "", "", "" }, /* 108 */
|
||||
{ NONE, "", "", "" }, /* 109 */
|
||||
{ NONE, "", "", "" }, /* 110 */
|
||||
{ NONE, "", "", "" }, /* 111 */
|
||||
{ NONE, "", "", "" }, /* 112 */
|
||||
{ NONE, "", "", "" }, /* 113 */
|
||||
{ NONE, "", "", "" }, /* 114 */
|
||||
{ NONE, "", "", "" }, /* 115 */
|
||||
{ NONE, "", "", "" }, /* 116 */
|
||||
{ NONE, "", "", "" }, /* 117 */
|
||||
{ NONE, "", "", "" }, /* 118 */
|
||||
{ NONE, "", "", "" }, /* 119 */
|
||||
{ NONE, "", "", "" }, /* 120 */
|
||||
{ NONE, "", "", "" }, /* 121 */
|
||||
{ NONE, "", "", "" }, /* 122 */
|
||||
{ NONE, "", "", "" }, /* 123 */
|
||||
{ NONE, "", "", "" }, /* 124 */
|
||||
{ NONE, "", "", "" }, /* 125 */
|
||||
{ NONE, "", "", "" }, /* 126 */
|
||||
{ NONE, "", "", "" }, /* 127 */
|
||||
};
|
||||
/*
|
||||
* initialize device
|
||||
*/
|
||||
static int
|
||||
vrkiu_init(chip, iot, ioh)
|
||||
struct vrkiu_chip* chip;
|
||||
bus_space_tag_t iot;
|
||||
bus_space_handle_t ioh;
|
||||
{
|
||||
memset(chip, 0, sizeof(struct vrkiu_chip));
|
||||
chip->kc_iot = iot;
|
||||
chip->kc_ioh = ioh;
|
||||
chip->kc_polling = 0;
|
||||
|
||||
/* XXX: Make these queue obsolute, or move these into vrkiu_softc */
|
||||
/* set KIU */
|
||||
vrkiu_write(chip, KIURST, 1); /* reset */
|
||||
vrkiu_write(chip, KIUSCANLINE, 0); /* 96keys */
|
||||
vrkiu_write(chip, KIUWKS, 0x18a4); /* XXX: scan timing! */
|
||||
vrkiu_write(chip, KIUWKI, 450);
|
||||
vrkiu_write(chip, KIUSCANREP, 0x8023);
|
||||
/* KEYEN | STPREP = 2 | ATSTP | ATSCAN */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* probe
|
||||
*/
|
||||
static int
|
||||
vrkiumatch(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
return 1; /* XXX */
|
||||
}
|
||||
|
||||
static inline void
|
||||
vrkiu_write(sc, port, val)
|
||||
struct vrkiu_softc *sc;
|
||||
int port;
|
||||
unsigned short val;
|
||||
{
|
||||
bus_space_write_2(sc->sc_iot, sc->sc_ioh, port, val);
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
vrkiu_read(sc, port)
|
||||
struct vrkiu_softc *sc;
|
||||
int port;
|
||||
{
|
||||
return bus_space_read_2(sc->sc_iot, sc->sc_ioh, port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* attach
|
||||
*/
|
||||
static void
|
||||
vrkiuattach(parent, self, aux)
|
||||
struct device *parent;
|
||||
|
@ -308,6 +258,8 @@ vrkiuattach(parent, self, aux)
|
|||
{
|
||||
struct vrkiu_softc *sc = (struct vrkiu_softc *)self;
|
||||
struct vrip_attach_args *va = aux;
|
||||
struct wskbddev_attach_args wa;
|
||||
int isconsole;
|
||||
|
||||
bus_space_tag_t iot = va->va_iot;
|
||||
bus_space_handle_t ioh;
|
||||
|
@ -317,18 +269,14 @@ vrkiuattach(parent, self, aux)
|
|||
return;
|
||||
}
|
||||
|
||||
sc->sc_iot = iot;
|
||||
sc->sc_ioh = ioh;
|
||||
|
||||
/* set KIU */
|
||||
vrkiu_write(sc, KIURST, 1); /* reset */
|
||||
vrkiu_write(sc, KIUSCANLINE, 0); /* 96keys */
|
||||
vrkiu_write(sc, KIUWKS, 0x18a4); /* XXX: scan timing! */
|
||||
vrkiu_write(sc, KIUWKI, 450);
|
||||
vrkiu_write(sc, KIUSCANREP, 0x8023);
|
||||
/* KEYEN | STPREP = 2 | ATSTP | ATSCAN */
|
||||
|
||||
the_vrkiu = sc;
|
||||
isconsole = vrkiu_is_console(iot, ioh);
|
||||
if (isconsole) {
|
||||
sc->sc_chip = vrkiu_consdata;
|
||||
} else {
|
||||
sc->sc_chip = &sc->sc_chip_body;
|
||||
vrkiu_init(sc->sc_chip, iot, ioh);
|
||||
}
|
||||
sc->sc_chip->kc_sc = sc;
|
||||
|
||||
if (!(sc->sc_handler =
|
||||
vrip_intr_establish(va->va_vc, va->va_intr, IPL_TTY,
|
||||
|
@ -340,6 +288,13 @@ vrkiuattach(parent, self, aux)
|
|||
vrip_intr_setmask2(va->va_vc, sc->sc_handler, KIUINT_KDATRDY, 1);
|
||||
|
||||
printf("\n");
|
||||
|
||||
wa.console = isconsole;
|
||||
wa.keymap = &vrkiu_keymapdata;
|
||||
wa.accessops = &vrkiu_accessops;
|
||||
wa.accesscookie = sc;
|
||||
|
||||
sc->sc_wskbddev = config_found(self, &wa, wskbddevprint);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -347,91 +302,71 @@ vrkiu_intr(arg)
|
|||
void *arg;
|
||||
{
|
||||
struct vrkiu_softc *sc = arg;
|
||||
/* When key scan finisshed, this entry is called. */
|
||||
detect_key(sc);
|
||||
DPRINTF(("%d", vrkiu_read(sc, KIUINT) & 7));
|
||||
|
||||
vrkiu_write(sc, KIUINT, 0x7); /* Clear all interrupt */
|
||||
/* When key scan finisshed, this entry is called. */
|
||||
DPRINTF(("%s(%d): vrkiu_intr: %d\n",
|
||||
__FILE__, __LINE__,
|
||||
vrkiu_read(sc->sc_chip, KIUINT) & 7));
|
||||
|
||||
detect_key(sc->sc_chip);
|
||||
|
||||
vrkiu_write(sc->sc_chip, KIUINT, 0x7); /* Clear all interrupt */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
detect_key(sc)
|
||||
struct vrkiu_softc *sc;
|
||||
detect_key(chip)
|
||||
struct vrkiu_chip* chip;
|
||||
{
|
||||
int i, k;
|
||||
|
||||
DPRINTF(("[detect_key():begin read]"));
|
||||
int i, j, modified, mask;
|
||||
unsigned short scandata[KIU_NSCANLINE/2];
|
||||
|
||||
for (i = 0; i < KIU_NSCANLINE / 2; i++) {
|
||||
k = vrkiu_read(sc, KIUDATP + i * 2) ^ sc->keystat[i];
|
||||
sc->keystat[i] = vrkiu_read(sc, KIUDATP + i * 2);
|
||||
while (k) {
|
||||
int n, m;
|
||||
n = ffs(k) - 1;
|
||||
if (n < 0) {
|
||||
break;
|
||||
}
|
||||
k ^= 1 << n;
|
||||
m = n + i * 16;
|
||||
if (keytrans[m] < 0) {
|
||||
printf("vrkiu: Unkown scan code 0x%02x\n", m);
|
||||
continue;
|
||||
}
|
||||
/* XXX: scanbuf may overflow! */
|
||||
process_key(sc, keytrans[m],
|
||||
!((sc->keystat[i] & (1 << n))));
|
||||
}
|
||||
/* XXX: The order of keys can be a problem.
|
||||
If CTRL and normal key are pushed simultaneously,
|
||||
normal key can be entered in queue first.
|
||||
Same problem would occur in key break. */
|
||||
scandata[i] = vrkiu_read(chip, KIUDATP + i * 2);
|
||||
}
|
||||
/* TODO: Enter scancode into the queue as long as the key pressed */
|
||||
|
||||
}
|
||||
DPRINTF(("%s(%d): detect_key():", __FILE__, __LINE__));
|
||||
|
||||
static void
|
||||
process_key(sc, k, brk)
|
||||
struct vrkiu_softc *sc;
|
||||
int k, brk;
|
||||
{
|
||||
char *p;
|
||||
extern struct tty biconsdev_tty[];
|
||||
|
||||
switch (scan_codes[k].type) {
|
||||
case ALT:
|
||||
sc->k_alt = brk ? 0 : 1;
|
||||
break;
|
||||
case SHIFT:
|
||||
sc->k_sft = brk ? 0 : 1;
|
||||
break;
|
||||
case CTL:
|
||||
sc->k_ctrl = brk ? 0 : 1;
|
||||
break;
|
||||
case ASCII:
|
||||
if (!brk) {
|
||||
if (sc->k_ctrl) {
|
||||
p = scan_codes[k].ctl;
|
||||
} else if (sc->k_sft) {
|
||||
p = scan_codes[k].shift;
|
||||
} else {
|
||||
p = scan_codes[k].unshift;
|
||||
}
|
||||
sc->keybuf[sc->keybufhead++] =
|
||||
sc->k_alt ? (*p | 0x80) : *p;
|
||||
/* XXX: multi byte key! */
|
||||
if (sc->keybufhead >= NKEYBUF) {
|
||||
sc->keybufhead = 0;
|
||||
}
|
||||
(*linesw[0].l_rint)(sc->k_alt ? (*p | 0x80) : *p,
|
||||
&biconsdev_tty [0]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Ignored */
|
||||
if (chip->kc_polling) {
|
||||
chip->kc_type = WSCONS_EVENT_ALL_KEYS_UP;
|
||||
}
|
||||
|
||||
for (i = 0; i < KIU_NSCANLINE / 2; i++) {
|
||||
modified = scandata[i] ^ chip->kc_scandata[i];
|
||||
mask = 1;
|
||||
for (j = 0; j < 16; j++) {
|
||||
/* XXX: The order of keys can be a problem.
|
||||
If CTRL and normal key are pushed simultaneously,
|
||||
normal key can be entered in queue first.
|
||||
Same problem would occur in key break. */
|
||||
if (modified & mask) {
|
||||
int key, type;
|
||||
key = i * 16 + j;
|
||||
if (keytrans[key] < 0) {
|
||||
printf("vrkiu: Unkown scan code 0x%02x\n", key);
|
||||
continue;
|
||||
}
|
||||
type = (scandata[i] & mask) ?
|
||||
WSCONS_EVENT_KEY_DOWN :
|
||||
WSCONS_EVENT_KEY_UP;
|
||||
DPRINTF(("(%d,%d)=%s%d ", i, j,
|
||||
(scandata[i] & mask) ? "v" : "^",
|
||||
keytrans[key]));
|
||||
if (chip->kc_polling) {
|
||||
chip->kc_type = type;
|
||||
chip->kc_data = keytrans[key];
|
||||
} else {
|
||||
wskbd_input(chip->kc_sc->sc_wskbddev,
|
||||
type,
|
||||
keytrans[key]);
|
||||
}
|
||||
}
|
||||
mask <<= 1;
|
||||
}
|
||||
chip->kc_scandata[i] = scandata[i];
|
||||
}
|
||||
DPRINTF(("\n"));
|
||||
}
|
||||
|
||||
/* called from biconsdev.c */
|
||||
|
@ -445,7 +380,7 @@ vrkiu_getc()
|
|||
}
|
||||
|
||||
while (the_vrkiu->keybuftail == the_vrkiu->keybufhead) {
|
||||
detect_key(the_vrkiu);
|
||||
detect_key(vrkiu_consdata);
|
||||
}
|
||||
ret = the_vrkiu->keybuf[the_vrkiu->keybuftail++];
|
||||
if (the_vrkiu->keybuftail >= NKEYBUF) {
|
||||
|
@ -454,3 +389,133 @@ vrkiu_getc()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
vrkiu_enable(scx, on)
|
||||
void *scx;
|
||||
int on;
|
||||
{
|
||||
struct vrkiu_softc *sc = scx;
|
||||
|
||||
if (on) {
|
||||
if (sc->sc_enabled)
|
||||
return (EBUSY);
|
||||
sc->sc_enabled = 1;
|
||||
} else {
|
||||
if (sc->sc_chip == vrkiu_consdata)
|
||||
return (EBUSY);
|
||||
sc->sc_enabled = 0;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
vrkiu_set_leds(scx, leds)
|
||||
void *scx;
|
||||
int leds;
|
||||
{
|
||||
/*struct pckbd_softc *sc = scx;
|
||||
*/
|
||||
|
||||
DPRINTF(("%s(%d): vrkiu_set_leds() not implemented\n",
|
||||
__FILE__, __LINE__));
|
||||
}
|
||||
|
||||
int
|
||||
vrkiu_ioctl(scx, cmd, data, flag, p)
|
||||
void *scx;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
/*struct vrkiu_softc *sc = scx;
|
||||
*/
|
||||
|
||||
switch (cmd) {
|
||||
case WSKBDIO_GTYPE:
|
||||
/*
|
||||
* XXX, fix me !
|
||||
*/
|
||||
*(int *)data = WSKBD_TYPE_PC_XT;
|
||||
return 0;
|
||||
case WSKBDIO_SETLEDS:
|
||||
DPRINTF(("%s(%d): no LED\n", __FILE__, __LINE__));
|
||||
return 0;
|
||||
case WSKBDIO_GETLEDS:
|
||||
DPRINTF(("%s(%d): no LED\n", __FILE__, __LINE__));
|
||||
*(int *)data = 0;
|
||||
return (0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* console support routines
|
||||
*/
|
||||
int
|
||||
vrkiu_cnattach(iot, iobase)
|
||||
bus_space_tag_t iot;
|
||||
int iobase;
|
||||
{
|
||||
static struct vrkiu_chip vrkiu_consdata_body;
|
||||
bus_space_handle_t ioh;
|
||||
|
||||
if (vrkiu_consdata) {
|
||||
panic("vrkiu is already attached as the console");
|
||||
}
|
||||
if (bus_space_map(iot, iobase, 1, 0, &ioh)) {
|
||||
printf("%s(%d): can't map bus space\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (vrkiu_init(&vrkiu_consdata_body, iot, ioh) != 0) {
|
||||
DPRINTF(("%s(%d): vrkiu_init() failed\n", __FILE__, __LINE__));
|
||||
return -1;
|
||||
}
|
||||
vrkiu_consdata = &vrkiu_consdata_body;
|
||||
|
||||
wskbd_cnattach(&vrkiu_consops, vrkiu_consdata, &vrkiu_keymapdata);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
vrkiu_cngetc(chipx, type, data)
|
||||
void *chipx;
|
||||
u_int *type;
|
||||
int *data;
|
||||
{
|
||||
struct vrkiu_chip* chip = chipx;
|
||||
int s;
|
||||
|
||||
if (!chip->kc_polling) {
|
||||
printf("%s(%d): kiu is not polled\n", __FILE__, __LINE__);
|
||||
while (1);
|
||||
}
|
||||
|
||||
s = splimp();
|
||||
if (chip->kc_type == WSCONS_EVENT_ALL_KEYS_UP) {
|
||||
detect_key(chip);
|
||||
}
|
||||
*type = chip->kc_type;
|
||||
*data = chip->kc_data;
|
||||
chip->kc_type = WSCONS_EVENT_ALL_KEYS_UP;
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
vrkiu_cnpollc(chipx, on)
|
||||
void *chipx;
|
||||
int on;
|
||||
{
|
||||
struct vrkiu_chip* chip = chipx;
|
||||
int s = splimp();
|
||||
|
||||
chip->kc_polling = on;
|
||||
|
||||
splx(s);
|
||||
|
||||
DPRINTF(("%s(%d): vrkiu polling %s\n",
|
||||
__FILE__, __LINE__, on ? "ON" : "OFF"));
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
/* $NetBSD: vrkiuvar.h,v 1.1.1.1 1999/09/16 12:23:33 takemura Exp $ */
|
||||
/* $NetBSD: vrkiuvar.h,v 1.2 1999/10/24 08:37:30 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 SASAKI Takesi
|
||||
* Copyright (c) 1999 SASAKI Takesi All rights reserved.
|
||||
* Copyright (c) 1999 PocketBSD Project. All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is a part of the PocketBSD.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -37,18 +34,5 @@
|
|||
*
|
||||
*/
|
||||
|
||||
struct vrkiu_softc {
|
||||
struct device sc_dev;
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
void *sc_handler;
|
||||
unsigned short keystat[12]; /* key status */
|
||||
|
||||
int k_sft:1, k_alt:1, k_ctrl:1;
|
||||
|
||||
#define NKEYBUF 32
|
||||
unsigned char keybuf[NKEYBUF];
|
||||
int keybufhead, keybuftail;
|
||||
};
|
||||
|
||||
extern int vrkiu_getc __P((void));
|
||||
extern int vrkiu_cnattach __P((bus_space_tag_t iot, int iobase));
|
||||
|
|
Loading…
Reference in New Issue