New ADB "bus" interface:
o Separate ms and kbd drivers o aed device for compatibility o debug message cleanup in hardware direct support (from scottr)
This commit is contained in:
parent
df7e58ed2e
commit
2055d846f9
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: GENERIC,v 1.79 1998/07/01 14:49:07 scottr Exp $
|
||||
# $NetBSD: GENERIC,v 1.80 1998/10/23 01:16:22 ender Exp $
|
||||
#
|
||||
# GENERIC
|
||||
|
||||
|
@ -133,7 +133,10 @@ nubus0 at mainbus?
|
|||
# Console Devices
|
||||
|
||||
# Apple Desktop Bus interface
|
||||
adb0 at obio? # ADB event device
|
||||
adb0 at obio?
|
||||
aed* at adb? # ADB event device
|
||||
kbd* at adb? # ADB keyboard
|
||||
ms* at adb? # ADB mouse
|
||||
|
||||
# Basic frame buffer support
|
||||
intvid0 at obio? # Internal video hardware
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.mac68k,v 1.85 1998/10/22 04:36:50 scottr Exp $
|
||||
# $NetBSD: files.mac68k,v 1.86 1998/10/23 01:16:22 ender Exp $
|
||||
|
||||
# mac68k-specific configuration info
|
||||
|
||||
|
@ -26,14 +26,25 @@ device nubus { }
|
|||
attach nubus at mainbus
|
||||
file arch/mac68k/nubus/nubus.c nubus
|
||||
|
||||
device adb
|
||||
device adb { }
|
||||
attach adb at obio_norm
|
||||
file arch/mac68k/dev/adb.c adb
|
||||
file arch/mac68k/dev/adbsys.c
|
||||
file arch/mac68k/dev/adbsysasm.s
|
||||
file arch/mac68k/dev/adb_direct.c
|
||||
file arch/mac68k/dev/pm_direct.c
|
||||
|
||||
device aed
|
||||
attach aed at adb
|
||||
file arch/mac68k/dev/aed.c aed needs-flag
|
||||
|
||||
device kbd
|
||||
attach kbd at adb
|
||||
file arch/mac68k/dev/kbd.c kbd needs-flag
|
||||
|
||||
device ms
|
||||
attach ms at adb
|
||||
file arch/mac68k/dev/ms.c ms needs-flag
|
||||
|
||||
device asc
|
||||
attach asc at obio_norm
|
||||
file arch/mac68k/obio/asc.c asc needs-flag
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $NetBSD: adb.c,v 1.24 1998/08/11 20:07:59 briggs Exp $ */
|
||||
/* $NetBSD: adb.c,v 1.25 1998/10/23 01:16:23 ender Exp $ */
|
||||
|
||||
/*-
|
||||
/*
|
||||
* Copyright (C) 1994 Bradley A. Grantham
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -10,7 +10,7 @@
|
|||
* 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
|
||||
e* notice, this list of conditions and the following disclaimer in the
|
||||
* 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:
|
||||
|
@ -42,58 +42,39 @@ e* notice, this list of conditions and the following disclaimer in the
|
|||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/keyboard.h>
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <mac68k/mac68k/macrom.h>
|
||||
#include <mac68k/dev/adbvar.h>
|
||||
#include <mac68k/dev/itevar.h>
|
||||
#include <mac68k/dev/kbdvar.h>
|
||||
|
||||
#include "aed.h" /* ADB Event Device for compatibility */
|
||||
|
||||
/*
|
||||
* Function declarations.
|
||||
*/
|
||||
static int adbmatch __P((struct device *, struct cfdata *, void *));
|
||||
static void adbattach __P((struct device *, struct device *, void *));
|
||||
static int adbprint __P((void *, const char *));
|
||||
|
||||
extern void adb_jadbproc __P((void));
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
int adb_polling = 0; /* Are we polling? (Debugger mode) */
|
||||
int adb_initted = 0; /* adb_init() has completed successfully */
|
||||
int adb_initted = 0; /* adb_init() has completed successfully */
|
||||
#ifdef ADB_DEBUG
|
||||
int adb_debug = 0; /* Output debugging messages */
|
||||
#endif /* ADB_DEBUG */
|
||||
|
||||
extern struct mac68k_machine_S mac68k_machine;
|
||||
extern int adbHardware;
|
||||
extern char *adbHardwareDescr[];
|
||||
|
||||
/*
|
||||
* Local variables.
|
||||
* Driver definition.
|
||||
*/
|
||||
|
||||
/* External keyboard translation matrix */
|
||||
extern unsigned char keyboard[128][3];
|
||||
|
||||
/* Event queue definitions */
|
||||
#if !defined(ADB_MAX_EVENTS)
|
||||
#define ADB_MAX_EVENTS 200 /* Maximum events to be kept in queue */
|
||||
/* maybe should be higher for slower macs? */
|
||||
#endif /* !defined(ADB_MAX_EVENTS) */
|
||||
static adb_event_t adb_evq[ADB_MAX_EVENTS]; /* ADB event queue */
|
||||
static int adb_evq_tail = 0; /* event queue tail */
|
||||
static int adb_evq_len = 0; /* event queue length */
|
||||
|
||||
/* ADB device state information */
|
||||
static int adb_isopen = 0; /* Are we queuing events for adb_read? */
|
||||
static struct selinfo adb_selinfo; /* select() info */
|
||||
static struct proc *adb_ioproc = NULL; /* process to wakeup */
|
||||
|
||||
/* Key repeat parameters */
|
||||
static int adb_rptdelay = 20; /* ticks before auto-repeat */
|
||||
static int adb_rptinterval = 6; /* ticks between auto-repeat */
|
||||
static int adb_repeating = -1; /* key that is auto-repeating */
|
||||
static adb_event_t adb_rptevent;/* event to auto-repeat */
|
||||
|
||||
/* Mouse button state */
|
||||
static int adb_ms_buttons = 0;
|
||||
|
||||
/* Driver definition. -- This should probably be a bus... */
|
||||
struct cfattach adb_ca = {
|
||||
sizeof(struct device), adbmatch, adbattach
|
||||
};
|
||||
|
@ -119,498 +100,151 @@ adbattach(parent, dev, aux)
|
|||
struct device *parent, *dev;
|
||||
void *aux;
|
||||
{
|
||||
printf(" (ADB event device)\n");
|
||||
adb_init();
|
||||
ADBDataBlock adbdata;
|
||||
struct adb_attach_args aa_args;
|
||||
int totaladbs;
|
||||
int adbindex, adbaddr;
|
||||
|
||||
#ifdef MRG_ADB
|
||||
/*
|
||||
* Even if serial console only, some models require the
|
||||
* ADB in order to get the date/time and do soft power.
|
||||
*/
|
||||
if ((mac68k_machine.serial_console & 0x03)) {
|
||||
printf(": using serial console");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mrg_romready()) {
|
||||
printf(": no ROM ADB driver in this kernel for this machine");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf("adb: call mrg_initadbintr\n");
|
||||
#endif
|
||||
|
||||
mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf("adb: returned from mrg_initadbintr\n");
|
||||
#endif
|
||||
|
||||
/* ADBReInit pre/post-processing */
|
||||
JADBProc = adb_jadbproc;
|
||||
|
||||
/* Initialize ADB */
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf("adb: calling ADBAlternateInit.\n");
|
||||
#endif
|
||||
|
||||
ADBAlternateInit();
|
||||
printf(" (mrg) ");
|
||||
#else
|
||||
ADBReInit();
|
||||
printf(" (direct, %s)", adbHardwareDescr[adbHardware]);
|
||||
#endif /* MRG_ADB */
|
||||
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf("adb: done with ADBReInit\n");
|
||||
#endif
|
||||
|
||||
totaladbs = CountADBs();
|
||||
|
||||
printf(": %d targets\n", totaladbs);
|
||||
|
||||
#if NAED > 0
|
||||
/* ADB event device for compatibility */
|
||||
aa_args.origaddr = 0;
|
||||
aa_args.adbaddr = 0;
|
||||
aa_args.handler_id = 0;
|
||||
(void)config_found(dev, &aa_args, adbprint);
|
||||
#endif
|
||||
|
||||
/* for each ADB device */
|
||||
for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
|
||||
/* Get the ADB information */
|
||||
adbaddr = GetIndADB(&adbdata, adbindex);
|
||||
|
||||
aa_args.origaddr = adbdata.origADBAddr;
|
||||
aa_args.adbaddr = adbaddr;
|
||||
aa_args.handler_id = adbdata.devType;
|
||||
|
||||
(void)config_found(dev, &aa_args, adbprint);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
adb_enqevent(event)
|
||||
adb_event_t *event;
|
||||
|
||||
int
|
||||
adbprint(args, name)
|
||||
void *args;
|
||||
const char *name;
|
||||
{
|
||||
int s;
|
||||
struct adb_attach_args *aa_args = (struct adb_attach_args *)args;
|
||||
int rv = UNCONF;
|
||||
|
||||
s = spladb();
|
||||
if (name) { /* no configured device matched */
|
||||
rv = UNSUPP; /* most ADB device types are unsupported */
|
||||
|
||||
/* print out what kind of ADB device we have found */
|
||||
printf("%s addr %d: ", name, aa_args->origaddr);
|
||||
switch(aa_args->origaddr) {
|
||||
#ifdef DIAGNOSTIC
|
||||
if (adb_evq_tail < 0 || adb_evq_tail >= ADB_MAX_EVENTS)
|
||||
panic("adb: event queue tail is out of bounds");
|
||||
|
||||
if (adb_evq_len < 0 || adb_evq_len > ADB_MAX_EVENTS)
|
||||
panic("adb: event queue len is out of bounds");
|
||||
#endif
|
||||
|
||||
if (adb_evq_len == ADB_MAX_EVENTS) {
|
||||
splx(s);
|
||||
return; /* Oh, well... */
|
||||
}
|
||||
adb_evq[(adb_evq_len + adb_evq_tail) % ADB_MAX_EVENTS] =
|
||||
*event;
|
||||
adb_evq_len++;
|
||||
|
||||
selwakeup(&adb_selinfo);
|
||||
if (adb_ioproc)
|
||||
psignal(adb_ioproc, SIGIO);
|
||||
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
adb_handoff(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
if (adb_isopen && !adb_polling) {
|
||||
adb_enqevent(event);
|
||||
} else {
|
||||
if (event->def_addr == 2)
|
||||
ite_intr(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
adb_autorepeat(keyp)
|
||||
void *keyp;
|
||||
{
|
||||
int key = (int)keyp;
|
||||
|
||||
adb_rptevent.bytes[0] |= 0x80;
|
||||
microtime(&adb_rptevent.timestamp);
|
||||
adb_handoff(&adb_rptevent); /* do key up */
|
||||
|
||||
adb_rptevent.bytes[0] &= 0x7f;
|
||||
microtime(&adb_rptevent.timestamp);
|
||||
adb_handoff(&adb_rptevent); /* do key down */
|
||||
|
||||
if (adb_repeating == key) {
|
||||
timeout(adb_autorepeat, keyp, adb_rptinterval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
adb_dokeyupdown(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
int adb_key;
|
||||
|
||||
if (event->def_addr == 2) {
|
||||
adb_key = event->u.k.key & 0x7f;
|
||||
if (!(event->u.k.key & 0x80) &&
|
||||
keyboard[event->u.k.key & 0x7f][0] != 0) {
|
||||
/* ignore shift & control */
|
||||
if (adb_repeating != -1) {
|
||||
untimeout(adb_autorepeat,
|
||||
(void *)adb_rptevent.u.k.key);
|
||||
}
|
||||
adb_rptevent = *event;
|
||||
adb_repeating = adb_key;
|
||||
timeout(adb_autorepeat,
|
||||
(void *)adb_key, adb_rptdelay);
|
||||
} else {
|
||||
if (adb_repeating != -1) {
|
||||
adb_repeating = -1;
|
||||
untimeout(adb_autorepeat,
|
||||
(void *)adb_rptevent.u.k.key);
|
||||
}
|
||||
adb_rptevent = *event;
|
||||
}
|
||||
}
|
||||
adb_handoff(event);
|
||||
}
|
||||
|
||||
void
|
||||
adb_keymaybemouse(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
static int optionkey_down = 0;
|
||||
adb_event_t new_event;
|
||||
|
||||
if (event->u.k.key == ADBK_KEYDOWN(ADBK_OPTION)) {
|
||||
optionkey_down = 1;
|
||||
} else if (event->u.k.key == ADBK_KEYUP(ADBK_OPTION)) {
|
||||
/* key up */
|
||||
optionkey_down = 0;
|
||||
if (adb_ms_buttons & 0xfe) {
|
||||
adb_ms_buttons &= 1;
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = adb_ms_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
}
|
||||
} else if (optionkey_down) {
|
||||
#ifdef ALTXBUTTONS
|
||||
if (event->u.k.key == ADBK_KEYDOWN(ADBK_1)) {
|
||||
adb_ms_buttons |= 1; /* left down */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = adb_ms_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
} else if (event->u.k.key == ADBK_KEYUP(ADBK_1)) {
|
||||
adb_ms_buttons &= ~1; /* left up */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = adb_ms_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
} else
|
||||
#endif
|
||||
if (event->u.k.key == ADBK_KEYDOWN(ADBK_LEFT)
|
||||
#ifdef ALTXBUTTONS
|
||||
|| event->u.k.key == ADBK_KEYDOWN(ADBK_2)
|
||||
#endif
|
||||
) {
|
||||
adb_ms_buttons |= 2; /* middle down */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = adb_ms_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
} else if (event->u.k.key == ADBK_KEYUP(ADBK_LEFT)
|
||||
#ifdef ALTXBUTTONS
|
||||
|| event->u.k.key == ADBK_KEYUP(ADBK_2)
|
||||
#endif
|
||||
) {
|
||||
adb_ms_buttons &= ~2; /* middle up */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = adb_ms_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
} else if (event->u.k.key == ADBK_KEYDOWN(ADBK_RIGHT)
|
||||
#ifdef ALTXBUTTONS
|
||||
|| event->u.k.key == ADBK_KEYDOWN(ADBK_3)
|
||||
#endif
|
||||
) {
|
||||
adb_ms_buttons |= 4; /* right down */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = adb_ms_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
} else if (event->u.k.key == ADBK_KEYUP(ADBK_RIGHT)
|
||||
#ifdef ALTXBUTTONS
|
||||
|| event->u.k.key == ADBK_KEYUP(ADBK_3)
|
||||
#endif
|
||||
) {
|
||||
adb_ms_buttons &= ~4; /* right up */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = adb_ms_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
} else if (ADBK_MODIFIER(event->u.k.key)) {
|
||||
/* ctrl, shift, cmd */
|
||||
adb_dokeyupdown(event);
|
||||
} else if (!(event->u.k.key & 0x80)) {
|
||||
/* key down */
|
||||
new_event = *event;
|
||||
|
||||
/* send option-down */
|
||||
new_event.u.k.key = ADBK_KEYDOWN(ADBK_OPTION);
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
|
||||
/* send key-down */
|
||||
new_event.u.k.key = event->bytes[0];
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
|
||||
/* send key-up */
|
||||
new_event.u.k.key =
|
||||
ADBK_KEYUP(ADBK_KEYVAL(event->bytes[0]));
|
||||
microtime(&new_event.timestamp);
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
adb_dokeyupdown(&new_event);
|
||||
|
||||
/* send option-up */
|
||||
new_event.u.k.key = ADBK_KEYUP(ADBK_OPTION);
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
microtime(&new_event.timestamp);
|
||||
adb_dokeyupdown(&new_event);
|
||||
} else {
|
||||
/* option-keyup -- do nothing. */
|
||||
}
|
||||
} else {
|
||||
adb_dokeyupdown(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
adb_processevent(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
adb_event_t new_event;
|
||||
int i, button_bit, max_byte, mask, buttons;
|
||||
|
||||
new_event = *event;
|
||||
buttons = 0;
|
||||
|
||||
switch (event->def_addr) {
|
||||
case ADBADDR_KBD:
|
||||
new_event.u.k.key = event->bytes[0];
|
||||
new_event.bytes[1] = 0xff;
|
||||
adb_keymaybemouse(&new_event);
|
||||
if (event->bytes[1] != 0xff) {
|
||||
new_event.u.k.key = event->bytes[1];
|
||||
new_event.bytes[0] = event->bytes[1];
|
||||
new_event.bytes[1] = 0xff;
|
||||
adb_keymaybemouse(&new_event);
|
||||
}
|
||||
break;
|
||||
case ADBADDR_MS:
|
||||
/*
|
||||
* This should handle both plain ol' Apple mice and mice
|
||||
* that claim to support the Extended Apple Mouse Protocol.
|
||||
*/
|
||||
max_byte = event->byte_count;
|
||||
button_bit = 1;
|
||||
switch (event->hand_id) {
|
||||
case ADBMS_USPEED:
|
||||
case ADBMS_UCONTOUR:
|
||||
/* MicroSpeed mouse and Contour Mouse */
|
||||
if (max_byte == 4)
|
||||
buttons = (~event->bytes[2]) & 0xff;
|
||||
else
|
||||
buttons = (event->bytes[0] & 0x80) ? 0 : 1;
|
||||
case 0:
|
||||
printf("ADB event device");
|
||||
rv = UNCONF;
|
||||
break;
|
||||
case ADBMS_MSA3:
|
||||
/* Mouse Systems A3 mouse */
|
||||
if (max_byte == 3)
|
||||
buttons = (~event->bytes[2]) & 0x07;
|
||||
else
|
||||
buttons = (event->bytes[0] & 0x80) ? 0 : 1;
|
||||
case ADBADDR_SECURE:
|
||||
printf("security dongle (%d)", aa_args->handler_id);
|
||||
break;
|
||||
#endif
|
||||
case ADBADDR_MAP:
|
||||
printf("mapped device (%d)", aa_args->handler_id);
|
||||
rv = UNCONF;
|
||||
break;
|
||||
case ADBADDR_REL:
|
||||
printf("relative positioning device (%d)",
|
||||
aa_args->handler_id);
|
||||
rv = UNCONF;
|
||||
break;
|
||||
#ifdef DIAGNOSTIC
|
||||
case ADBADDR_ABS:
|
||||
switch (aa_args->handler_id) {
|
||||
case ADB_ARTPAD:
|
||||
printf("WACOM ArtPad II");
|
||||
break;
|
||||
default:
|
||||
printf("absolute positioning device (%d)",
|
||||
aa_args->handler_id);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ADBADDR_DATATX:
|
||||
printf("data transfer device (modem?) (%d)",
|
||||
aa_args->handler_id);
|
||||
break;
|
||||
case ADBADDR_MISC:
|
||||
switch (aa_args->handler_id) {
|
||||
case ADB_POWERKEY:
|
||||
printf("Sophisticated Circuits PowerKey");
|
||||
break;
|
||||
default:
|
||||
printf("misc. device (remote control?) (%d)",
|
||||
aa_args->handler_id);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Classic Mouse Protocol (up to 2 buttons) */
|
||||
for (i = 0; i < 2; i++, button_bit <<= 1)
|
||||
/* 0 when button down */
|
||||
if (!(event->bytes[i] & 0x80))
|
||||
buttons |= button_bit;
|
||||
else
|
||||
buttons &= ~button_bit;
|
||||
/* Extended Protocol (up to 6 more buttons) */
|
||||
for (mask = 0x80; i < max_byte;
|
||||
i += (mask == 0x80), button_bit <<= 1) {
|
||||
/* 0 when button down */
|
||||
if (!(event->bytes[i] & mask))
|
||||
buttons |= button_bit;
|
||||
else
|
||||
buttons &= ~button_bit;
|
||||
mask = ((mask >> 4) & 0xf)
|
||||
| ((mask & 0xf) << 4);
|
||||
}
|
||||
printf("unknown type device, (handler %d)",
|
||||
aa_args->handler_id);
|
||||
break;
|
||||
#endif /* DIAGNOSTIC */
|
||||
}
|
||||
new_event.u.m.buttons = adb_ms_buttons | buttons;
|
||||
new_event.u.m.dx = ((signed int) (event->bytes[1] & 0x3f)) -
|
||||
((event->bytes[1] & 0x40) ? 64 : 0);
|
||||
new_event.u.m.dy = ((signed int) (event->bytes[0] & 0x3f)) -
|
||||
((event->bytes[0] & 0x40) ? 64 : 0);
|
||||
adb_dokeyupdown(&new_event);
|
||||
break;
|
||||
default: /* God only knows. */
|
||||
adb_dokeyupdown(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
adbopen(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
register int unit;
|
||||
int error = 0;
|
||||
int s;
|
||||
|
||||
unit = minor(dev);
|
||||
if (unit != 0 || !adb_initted)
|
||||
return (ENXIO);
|
||||
|
||||
s = spladb();
|
||||
if (adb_isopen) {
|
||||
splx(s);
|
||||
return (EBUSY);
|
||||
}
|
||||
adb_evq_tail = 0;
|
||||
adb_evq_len = 0;
|
||||
adb_isopen = 1;
|
||||
adb_ioproc = p;
|
||||
splx(s);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
adbclose(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
int s = spladb();
|
||||
|
||||
adb_isopen = 0;
|
||||
adb_ioproc = NULL;
|
||||
splx(s);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
adbread(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
int s, error;
|
||||
int willfit;
|
||||
int total;
|
||||
int firstmove;
|
||||
int moremove;
|
||||
|
||||
if (uio->uio_resid < sizeof(adb_event_t))
|
||||
return (EMSGSIZE); /* close enough. */
|
||||
|
||||
s = spladb();
|
||||
if (adb_evq_len == 0) {
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
willfit = howmany(uio->uio_resid, sizeof(adb_event_t));
|
||||
total = (adb_evq_len < willfit) ? adb_evq_len : willfit;
|
||||
|
||||
firstmove = (adb_evq_tail + total > ADB_MAX_EVENTS)
|
||||
? (ADB_MAX_EVENTS - adb_evq_tail) : total;
|
||||
|
||||
error = uiomove((caddr_t) & adb_evq[adb_evq_tail],
|
||||
firstmove * sizeof(adb_event_t), uio);
|
||||
if (error) {
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
moremove = total - firstmove;
|
||||
|
||||
if (moremove > 0) {
|
||||
error = uiomove((caddr_t) & adb_evq[0],
|
||||
moremove * sizeof(adb_event_t), uio);
|
||||
if (error) {
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
adb_evq_tail = (adb_evq_tail + total) % ADB_MAX_EVENTS;
|
||||
adb_evq_len -= total;
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
adbwrite(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
adbioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
switch (cmd) {
|
||||
case ADBIOC_DEVSINFO: {
|
||||
adb_devinfo_t *di;
|
||||
ADBDataBlock adbdata;
|
||||
int totaldevs;
|
||||
int adbaddr;
|
||||
int i;
|
||||
|
||||
di = (void *)data;
|
||||
|
||||
/* Initialize to no devices */
|
||||
for (i = 0; i < 16; i++)
|
||||
di->dev[i].addr = -1;
|
||||
|
||||
totaldevs = CountADBs();
|
||||
for (i = 1; i <= totaldevs; i++) {
|
||||
adbaddr = GetIndADB(&adbdata, i);
|
||||
di->dev[adbaddr].addr = adbaddr;
|
||||
di->dev[adbaddr].default_addr = adbdata.origADBAddr;
|
||||
di->dev[adbaddr].handler_id = adbdata.devType;
|
||||
}
|
||||
|
||||
/* Must call ADB Manager to get devices now */
|
||||
break;
|
||||
}
|
||||
|
||||
case ADBIOC_GETREPEAT:{
|
||||
adb_rptinfo_t *ri;
|
||||
|
||||
ri = (void *)data;
|
||||
ri->delay_ticks = adb_rptdelay;
|
||||
ri->interval_ticks = adb_rptinterval;
|
||||
break;
|
||||
}
|
||||
|
||||
case ADBIOC_SETREPEAT:{
|
||||
adb_rptinfo_t *ri;
|
||||
|
||||
ri = (void *)data;
|
||||
adb_rptdelay = ri->delay_ticks;
|
||||
adb_rptinterval = ri->interval_ticks;
|
||||
break;
|
||||
}
|
||||
|
||||
case ADBIOC_RESET:
|
||||
adb_init();
|
||||
break;
|
||||
|
||||
case ADBIOC_LISTENCMD:{
|
||||
adb_listencmd_t *lc;
|
||||
|
||||
lc = (void *)data;
|
||||
}
|
||||
|
||||
default:
|
||||
return (EINVAL);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
adbpoll(dev, events, p)
|
||||
dev_t dev;
|
||||
int events;
|
||||
struct proc *p;
|
||||
{
|
||||
int s, revents;
|
||||
|
||||
revents = events & (POLLOUT | POLLWRNORM);
|
||||
|
||||
if ((events & (POLLIN | POLLRDNORM)) == 0)
|
||||
return (revents);
|
||||
|
||||
s = spladb();
|
||||
if (adb_evq_len > 0)
|
||||
revents |= events & (POLLIN | POLLRDNORM);
|
||||
else
|
||||
selrecord(p, &adb_selinfo);
|
||||
splx(s);
|
||||
|
||||
return (revents);
|
||||
} else /* a device matched and was configured */
|
||||
printf(" addr %d: ", aa_args->origaddr);
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: adb_direct.c,v 1.15 1998/08/12 05:42:44 scottr Exp $ */
|
||||
/* $NetBSD: adb_direct.c,v 1.16 1998/10/23 01:16:23 ender Exp $ */
|
||||
|
||||
/* From: adb_direct.c 2.02 4/18/97 jpw */
|
||||
|
||||
|
@ -72,12 +72,18 @@
|
|||
#include <machine/adbsys.h> /* required for adbvar.h */
|
||||
|
||||
#include <mac68k/mac68k/macrom.h>
|
||||
#include <mac68k/dev/adb_direct.h>
|
||||
#include <mac68k/dev/adbvar.h>
|
||||
#define printf_intr printf
|
||||
#else /* !__NetBSD__, i.e. Mac OS */
|
||||
#include "via.h" /* for macos based testing */
|
||||
/* #define ADB_DEBUG */ /* more verbose for testing */
|
||||
|
||||
/* Types of ADB hardware that we support */
|
||||
#define ADB_HW_UNKNOWN 0x0 /* don't know */
|
||||
#define ADB_HW_II 0x1 /* Mac II series */
|
||||
#define ADB_HW_IISI 0x2 /* Mac IIsi series */
|
||||
#define ADB_HW_PB 0x3 /* PowerBook series */
|
||||
#define ADB_HW_CUDA 0x4 /* Machines with a Cuda chip */
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -94,32 +100,25 @@
|
|||
#define vSR_INT 0x04
|
||||
#define vSR_OUT 0x10
|
||||
|
||||
/* types of adb hardware that we (will eventually) support */
|
||||
#define ADB_HW_UNKNOWN 0x01 /* don't know */
|
||||
#define ADB_HW_II 0x02 /* Mac II series */
|
||||
#define ADB_HW_IISI 0x03 /* Mac IIsi series */
|
||||
#define ADB_HW_PB 0x04 /* PowerBook series */
|
||||
#define ADB_HW_CUDA 0x05 /* Machines with a Cuda chip */
|
||||
|
||||
/* the type of ADB action that we are currently preforming */
|
||||
#define ADB_ACTION_NOTREADY 0x01 /* has not been initialized yet */
|
||||
#define ADB_ACTION_IDLE 0x02 /* the bus is currently idle */
|
||||
#define ADB_ACTION_OUT 0x03 /* sending out a command */
|
||||
#define ADB_ACTION_IN 0x04 /* receiving data */
|
||||
#define ADB_ACTION_POLLING 0x05 /* polling - II only */
|
||||
#define ADB_ACTION_NOTREADY 0x1 /* has not been initialized yet */
|
||||
#define ADB_ACTION_IDLE 0x2 /* the bus is currently idle */
|
||||
#define ADB_ACTION_OUT 0x3 /* sending out a command */
|
||||
#define ADB_ACTION_IN 0x4 /* receiving data */
|
||||
#define ADB_ACTION_POLLING 0x5 /* polling - II only */
|
||||
|
||||
/*
|
||||
* These describe the state of the ADB bus itself, although they
|
||||
* don't necessarily correspond directly to ADB states.
|
||||
* Note: these are not really used in the IIsi code.
|
||||
*/
|
||||
#define ADB_BUS_UNKNOWN 0x01 /* we don't know yet - all models */
|
||||
#define ADB_BUS_IDLE 0x02 /* bus is idle - all models */
|
||||
#define ADB_BUS_CMD 0x03 /* starting a command - II models */
|
||||
#define ADB_BUS_ODD 0x04 /* the "odd" state - II models */
|
||||
#define ADB_BUS_EVEN 0x05 /* the "even" state - II models */
|
||||
#define ADB_BUS_ACTIVE 0x06 /* active state - IIsi models */
|
||||
#define ADB_BUS_ACK 0x07 /* currently ACKing - IIsi models */
|
||||
#define ADB_BUS_UNKNOWN 0x1 /* we don't know yet - all models */
|
||||
#define ADB_BUS_IDLE 0x2 /* bus is idle - all models */
|
||||
#define ADB_BUS_CMD 0x3 /* starting a command - II models */
|
||||
#define ADB_BUS_ODD 0x4 /* the "odd" state - II models */
|
||||
#define ADB_BUS_EVEN 0x5 /* the "even" state - II models */
|
||||
#define ADB_BUS_ACTIVE 0x6 /* active state - IIsi models */
|
||||
#define ADB_BUS_ACK 0x7 /* currently ACKing - IIsi models */
|
||||
|
||||
/*
|
||||
* Shortcuts for setting or testing the VIA bit states.
|
||||
|
@ -208,6 +207,17 @@ struct adbCommand {
|
|||
u_int ack_only; /* 1 for no special processing */
|
||||
};
|
||||
|
||||
/*
|
||||
* Text representations of each hardware class
|
||||
*/
|
||||
char *adbHardwareDescr[MAX_ADB_HW + 1] = {
|
||||
"unknown",
|
||||
"II series",
|
||||
"IIsi series",
|
||||
"PowerBook",
|
||||
"Cuda",
|
||||
};
|
||||
|
||||
/*
|
||||
* A few variables that we need and their initial values.
|
||||
*/
|
||||
|
@ -258,10 +268,7 @@ int tickle_serial = 0; /* the last packet tickled */
|
|||
int adb_cuda_serial = 0; /* the current packet */
|
||||
|
||||
extern struct mac68k_machine_S mac68k_machine;
|
||||
|
||||
#if 0
|
||||
int zshard __P((int));
|
||||
#endif
|
||||
extern int ite_polling; /* Are we polling? (Debugger mode) */
|
||||
|
||||
void pm_setup_adb __P((void));
|
||||
void pm_check_adb_devices __P((int));
|
||||
|
@ -272,7 +279,9 @@ void pm_init_adb_device __P((void));
|
|||
/*
|
||||
* The following are private routines.
|
||||
*/
|
||||
#ifdef ADB_DEBUG
|
||||
void print_single __P((u_char *));
|
||||
#endif
|
||||
void adb_intr __P((void));
|
||||
void adb_intr_II __P((void));
|
||||
void adb_intr_IIsi __P((void));
|
||||
|
@ -305,6 +314,7 @@ int adb_prog_switch_disable __P((void));
|
|||
/* we should create this and it will be the public version */
|
||||
int send_adb __P((u_char *, void *, void *));
|
||||
|
||||
#ifdef ADB_DEBUG
|
||||
/*
|
||||
* print_single
|
||||
* Diagnostic display routine. Displays the hex values of the
|
||||
|
@ -334,6 +344,7 @@ print_single(thestring)
|
|||
printf_intr(" 0x%02x", thestring[x + 1]);
|
||||
printf_intr("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
adb_cuda_tickle(void)
|
||||
|
@ -365,7 +376,8 @@ adb_cuda_tickle(void)
|
|||
* called when when an adb interrupt happens
|
||||
*
|
||||
* Cuda version of adb_intr
|
||||
* TO DO: do we want to add some zshard calls in here?
|
||||
* TO DO: do we want to add some calls to intr_dispatch() here to
|
||||
* grab serial interrupts?
|
||||
*/
|
||||
void
|
||||
adb_intr_cuda(void)
|
||||
|
@ -572,11 +584,17 @@ switch_start:
|
|||
break;
|
||||
|
||||
case ADB_ACTION_NOTREADY:
|
||||
printf_intr("adb: not yet initialized\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: not yet initialized\n");
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
printf_intr("intr: unknown ADB state\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("intr: unknown ADB state\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */
|
||||
|
@ -694,11 +712,7 @@ adb_intr_II(void)
|
|||
ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */
|
||||
|
||||
delay(ADB_DELAY); /* yuck (don't remove) */
|
||||
#if 0
|
||||
zshard(0); /* grab any serial interrupts */
|
||||
#else
|
||||
(void)intr_dispatch(0x70);
|
||||
#endif
|
||||
(void)intr_dispatch(0x70); /* grab any serial interrupts */
|
||||
|
||||
if (ADB_INTR_IS_ON)
|
||||
intr_on = 1; /* save for later */
|
||||
|
@ -745,11 +759,7 @@ switch_start:
|
|||
adbActionState = ADB_ACTION_IN;
|
||||
}
|
||||
delay(ADB_DELAY);
|
||||
#if 0
|
||||
zshard(0); /* grab any serial interrupts */
|
||||
#else
|
||||
(void)intr_dispatch(0x70);
|
||||
#endif
|
||||
(void)intr_dispatch(0x70); /* grab any serial interrupts */
|
||||
goto switch_start;
|
||||
break;
|
||||
case ADB_ACTION_IDLE:
|
||||
|
@ -1013,13 +1023,20 @@ switch_start:
|
|||
break;
|
||||
|
||||
default:
|
||||
printf_intr("strange state!!! (0x%x)\n", adbBusState);
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug) {
|
||||
printf_intr("strange state!!! (0x%x)\n",
|
||||
adbBusState);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf_intr("adb: unknown ADB state (during intr)\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: unknown ADB state (during intr)\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */
|
||||
|
@ -1234,11 +1251,7 @@ switch_start:
|
|||
ADB_SET_STATE_ACKON(); /* start ACK to ADB chip */
|
||||
delay(ADB_DELAY); /* delay */
|
||||
ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */
|
||||
#if 0
|
||||
zshard(0); /* grab any serial interrupts */
|
||||
#else
|
||||
(void)intr_dispatch(0x70);
|
||||
#endif
|
||||
(void)intr_dispatch(0x70); /* grab any serial interrupts */
|
||||
break;
|
||||
|
||||
case ADB_ACTION_IN:
|
||||
|
@ -1252,11 +1265,7 @@ switch_start:
|
|||
ADB_SET_STATE_ACKON(); /* start ACK to ADB chip */
|
||||
delay(ADB_DELAY); /* delay */
|
||||
ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */
|
||||
#if 0
|
||||
zshard(0); /* grab any serial interrupts */
|
||||
#else
|
||||
(void)intr_dispatch(0x70);
|
||||
#endif
|
||||
(void)intr_dispatch(0x70); /* grab any serial interrupts */
|
||||
|
||||
if (1 == ending) { /* end of message? */
|
||||
ADB_SET_STATE_INACTIVE(); /* signal end of frame */
|
||||
|
@ -1304,11 +1313,7 @@ switch_start:
|
|||
adbActionState = ADB_ACTION_OUT; /* set next state */
|
||||
|
||||
delay(ADB_DELAY); /* delay */
|
||||
#if 0
|
||||
zshard(0); /* grab any serial interrupts */
|
||||
#else
|
||||
(void)intr_dispatch(0x70);
|
||||
#endif
|
||||
(void)intr_dispatch(0x70); /* grab any serial interrupts */
|
||||
|
||||
if (ADB_INTR_IS_ON) { /* ADB intr low during
|
||||
* write */
|
||||
|
@ -1349,21 +1354,13 @@ switch_start:
|
|||
adbWriteDelay = 1; /* must retry when done with
|
||||
* read */
|
||||
delay(ADB_DELAY); /* delay */
|
||||
#if 0
|
||||
zshard(0); /* grab any serial interrupts */
|
||||
#else
|
||||
(void)intr_dispatch(0x70);
|
||||
#endif
|
||||
(void)intr_dispatch(0x70); /* grab any serial interrupts */
|
||||
goto switch_start; /* process next state right
|
||||
* now */
|
||||
break;
|
||||
}
|
||||
delay(ADB_DELAY); /* required delay */
|
||||
#if 0
|
||||
zshard(0); /* grab any serial interrupts */
|
||||
#else
|
||||
(void)intr_dispatch(0x70);
|
||||
#endif
|
||||
(void)intr_dispatch(0x70); /* grab any serial interrupts */
|
||||
|
||||
if (adbOutputBuffer[0] == adbSentChars) { /* check for done */
|
||||
if (0 == adb_cmd_result(adbOutputBuffer)) { /* do we expect data
|
||||
|
@ -1400,11 +1397,17 @@ switch_start:
|
|||
break;
|
||||
|
||||
case ADB_ACTION_NOTREADY:
|
||||
printf_intr("adb: not yet initialized\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: not yet initialized\n");
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
printf_intr("intr: unknown ADB state\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("intr: unknown ADB state\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */
|
||||
|
@ -1548,7 +1551,10 @@ adb_pass_up(struct adbCommand *in)
|
|||
/*u_char *comprout = 0;*/
|
||||
|
||||
if (adbInCount >= ADB_QUEUE) {
|
||||
printf_intr("adb: ring buffer overflow\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: ring buffer overflow\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1646,7 +1652,7 @@ adb_pass_up(struct adbCommand *in)
|
|||
* If the debugger is running, call upper half manually.
|
||||
* Otherwise, trigger a soft interrupt to handle the rest later.
|
||||
*/
|
||||
if (adb_polling)
|
||||
if (ite_polling)
|
||||
adb_soft_intr();
|
||||
else
|
||||
setsoftadb();
|
||||
|
@ -1864,8 +1870,12 @@ adb_hw_setup(void)
|
|||
for (i = 0; i < 30; i++) {
|
||||
delay(ADB_DELAY);
|
||||
adb_hw_setup_IIsi(send_string);
|
||||
printf_intr("adb: cleanup: ");
|
||||
print_single(send_string);
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug) {
|
||||
printf_intr("adb: cleanup: ");
|
||||
print_single(send_string);
|
||||
}
|
||||
#endif
|
||||
delay(ADB_DELAY);
|
||||
if (ADB_INTR_IS_OFF)
|
||||
break;
|
||||
|
@ -2175,11 +2185,18 @@ adb_reinit(void)
|
|||
/* enable the programmer's switch, if we have one */
|
||||
adb_prog_switch_enable();
|
||||
|
||||
if (0 == ADBNumDevices) /* tell user if no devices found */
|
||||
printf_intr("adb: no devices found\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug) {
|
||||
if (0 == ADBNumDevices) /* tell user if no devices found */
|
||||
printf_intr("adb: no devices found\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
adbStarting = 0; /* not starting anymore */
|
||||
printf_intr("adb: ADBReInit complete\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: ADBReInit complete\n");
|
||||
#endif
|
||||
|
||||
if (adbHardware == ADB_HW_CUDA)
|
||||
timeout((void *)adb_cuda_tickle, 0, ADB_TICKLE_TICKS);
|
||||
|
@ -2372,7 +2389,10 @@ adb_setup_hw_type(void)
|
|||
case 52: /* Centris 610 */
|
||||
case 53: /* Quadra 610 */
|
||||
adbHardware = ADB_HW_II;
|
||||
printf_intr("adb: using II series hardware support\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: using II series hardware support\n");
|
||||
#endif
|
||||
break;
|
||||
case 18: /* IIsi */
|
||||
case 20: /* Quadra 900 - not sure if IIsi or not */
|
||||
|
@ -2385,7 +2405,10 @@ adb_setup_hw_type(void)
|
|||
case 48: /* IIvx */
|
||||
case 62: /* Performa 460/465/467 */
|
||||
adbHardware = ADB_HW_IISI;
|
||||
printf_intr("adb: using IIsi series hardware support\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: using IIsi series hardware support\n");
|
||||
#endif
|
||||
break;
|
||||
case 21: /* PowerBook 170 */
|
||||
case 25: /* PowerBook 140 */
|
||||
|
@ -2398,7 +2421,10 @@ adb_setup_hw_type(void)
|
|||
case 115: /* PowerBook 150 */
|
||||
adbHardware = ADB_HW_PB;
|
||||
pm_setup_adb();
|
||||
printf_intr("adb: using PowerBook 100-series hardware support\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: using PowerBook 100-series hardware support\n");
|
||||
#endif
|
||||
break;
|
||||
case 29: /* PowerBook Duo 210 */
|
||||
case 32: /* PowerBook Duo 230 */
|
||||
|
@ -2409,7 +2435,10 @@ adb_setup_hw_type(void)
|
|||
case 103: /* PowerBook Duo 280c */
|
||||
adbHardware = ADB_HW_PB;
|
||||
pm_setup_adb();
|
||||
printf_intr("adb: using PowerBook Duo-series and PowerBook 500-series hardware support\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: using PowerBook Duo-series and PowerBook 500-series hardware support\n");
|
||||
#endif
|
||||
break;
|
||||
case 49: /* Color Classic */
|
||||
case 56: /* LC 520 */
|
||||
|
@ -2423,12 +2452,19 @@ adb_setup_hw_type(void)
|
|||
case 98: /* LC 630, Performa 630, Quadra 630 */
|
||||
case 99: /* Performa 580(?)/588 */
|
||||
adbHardware = ADB_HW_CUDA;
|
||||
printf_intr("adb: using Cuda series hardware support\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf_intr("adb: using Cuda series hardware support\n");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
adbHardware = ADB_HW_UNKNOWN;
|
||||
printf_intr("adb: hardware type unknown for this machine\n");
|
||||
printf_intr("adb: ADB support is disabled\n");
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug) {
|
||||
printf_intr("adb: hardware type unknown for this machine\n");
|
||||
printf_intr("adb: ADB support is disabled\n");
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: adbsysasm.s,v 1.6 1997/11/07 07:38:12 scottr Exp $ */
|
||||
/* $NetBSD: adbsysasm.s,v 1.7 1998/10/23 01:16:23 ender Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994 Bradley A. Grantham
|
||||
|
@ -34,48 +34,36 @@
|
|||
* ADB subsystem routines in assembly
|
||||
*/
|
||||
|
||||
/* This routine is called when a device has sent us some data. */
|
||||
/* This routine is called when a keyboard has sent us some data. */
|
||||
/* (provided it has been set up with SetADBInfo) */
|
||||
.global _adb_asmcomplete
|
||||
.global _adb_complete
|
||||
_adb_asmcomplete:
|
||||
.global _adb_kbd_asmcomplete
|
||||
.global _kbd_adbcomplete
|
||||
_adb_kbd_asmcomplete:
|
||||
moveml #0xc0c0, sp@- | save scratch regs
|
||||
movl d0, sp@- /* ADB command byte */
|
||||
movl a2, sp@- /* data area pointer */
|
||||
/* a1 is the pointer to this routine itself. */
|
||||
movl a0, sp@- /* device data buffer */
|
||||
jbsr _adb_complete
|
||||
jbsr _kbd_adbcomplete
|
||||
addl #12, sp /* pop params */
|
||||
moveml sp@+, #0x0303 | restore scratch regs
|
||||
rts
|
||||
|
||||
/* This routine is called when an A3 mouse has sent us some data. */
|
||||
/* This routine is called when a mouse has sent us some data. */
|
||||
/* (provided it has been set up with SetADBInfo) */
|
||||
.global _adb_msa3_asmcomplete
|
||||
_adb_msa3_asmcomplete:
|
||||
.global _adb_ms_asmcomplete
|
||||
.global _ms_adbcomplete
|
||||
_adb_ms_asmcomplete:
|
||||
moveml #0xc0c0, sp@- | save scratch regs
|
||||
movl d0, sp@- /* ADB command byte */
|
||||
movl a2, sp@- /* data area pointer */
|
||||
/* a1 is the pointer to this routine itself. */
|
||||
movl a0, sp@- /* device data buffer */
|
||||
jbsr _adb_msa3_complete
|
||||
jbsr _ms_adbcomplete
|
||||
addl #12, sp /* pop params */
|
||||
moveml sp@+, #0x0303 | restore scratch regs
|
||||
rts
|
||||
|
||||
/* This routine is called when a Mouseman (non-EMP) mouse has sent
|
||||
* us some data. (provided it has been set up with SetADBInfo) */
|
||||
.global _adb_mm_nonemp_asmcomplete
|
||||
_adb_mm_nonemp_asmcomplete:
|
||||
moveml #0xc0c0, sp@- | save scratch regs
|
||||
movl d0, sp@- /* ADB command byte */
|
||||
movl a2, sp@- /* data area pointer */
|
||||
/* a1 is the pointer to this routine itself. */
|
||||
movl a0, sp@- /* device data buffer */
|
||||
jbsr _adb_mm_nonemp_complete
|
||||
addl #12, sp /* pop params */
|
||||
moveml sp@+, #0x0303 | restore scratch regs
|
||||
rts
|
||||
|
||||
_adb_jadbprochello:
|
||||
.asciz "adb: hello from adbproc\n"
|
||||
|
@ -84,14 +72,14 @@ _adb_jadbprochello:
|
|||
|
||||
.global _adb_jadbproc
|
||||
_adb_jadbproc:
|
||||
#if defined(MRG_DEBUG) && 0
|
||||
#if defined(ADB_DEBUG) && 0
|
||||
moveml #0xc0c0, sp@- | save scratch regs
|
||||
movl _adb_jadbprochello, sp@-
|
||||
jbsr _printf
|
||||
addl #4, sp /* pop params */
|
||||
moveml sp@+, #0x0303 | restore scratch regs
|
||||
#endif
|
||||
/* Don't do anything; adb_init fixes dev info for us. */
|
||||
/* Don't do anything; adbattach fixes dev info for us. */
|
||||
rts
|
||||
|
||||
/* ADBOp's completion routine used by extdms_init() in adbsys.c. */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $NetBSD: adbvar.h,v 1.10 1998/02/23 03:11:26 scottr Exp $ */
|
||||
/* $NetBSD: adbvar.h,v 1.11 1998/10/23 01:16:23 ender Exp $ */
|
||||
|
||||
/*-
|
||||
/*
|
||||
* Copyright (C) 1994 Bradley A. Grantham
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -32,6 +32,15 @@
|
|||
|
||||
#include <machine/adbsys.h>
|
||||
|
||||
/*
|
||||
* Arguments used to attach a device to the Apple Desktop Bus
|
||||
*/
|
||||
struct adb_attach_args {
|
||||
unsigned char origaddr;
|
||||
unsigned char adbaddr;
|
||||
unsigned char handler_id;
|
||||
};
|
||||
|
||||
typedef struct adb_trace_xlate_s {
|
||||
int params;
|
||||
char *string;
|
||||
|
@ -50,11 +59,6 @@ extern int adb_debug;
|
|||
|
||||
/* adb.c */
|
||||
void adb_enqevent __P((adb_event_t *event));
|
||||
void adb_handoff __P((adb_event_t *event));
|
||||
void adb_autorepeat __P((void *keyp));
|
||||
void adb_dokeyupdown __P((adb_event_t *event));
|
||||
void adb_keymaybemouse __P((adb_event_t *event));
|
||||
void adb_processevent __P((adb_event_t *event));
|
||||
int adbopen __P((dev_t dev, int flag, int mode, struct proc *p));
|
||||
int adbclose __P((dev_t dev, int flag, int mode, struct proc *p));
|
||||
int adbread __P((dev_t dev, struct uio *uio, int flag));
|
||||
|
@ -63,24 +67,18 @@ int adbioctl __P((dev_t , int , caddr_t , int , struct proc *));
|
|||
int adbpoll __P((dev_t dev, int events, struct proc *p));
|
||||
|
||||
/* adbsysasm.s */
|
||||
void adb_asmcomplete __P((void));
|
||||
void adb_msa3_asmcomplete __P((void));
|
||||
void adb_mm_nonemp_asmcomplete __P((void));
|
||||
void adb_kbd_asmcomplete __P((void));
|
||||
void adb_ms_asmcomplete __P((void));
|
||||
void extdms_complete __P((void));
|
||||
|
||||
/* adbsys.c */
|
||||
void adb_complete __P((caddr_t buffer, caddr_t data_area, int adb_command));
|
||||
void adb_msa3_complete __P((caddr_t buffer, caddr_t data_area, int adb_command));
|
||||
void adb_mm_nonemp_complete __P((caddr_t buffer, caddr_t data_area, int adb_command));
|
||||
void extdms_init __P((int));
|
||||
|
||||
#ifndef MRG_ADB
|
||||
/* types of adb hardware that we (will eventually) support */
|
||||
#define ADB_HW_UNKNOWN 0x01 /* don't know */
|
||||
#define ADB_HW_II 0x02 /* Mac II series */
|
||||
#define ADB_HW_IISI 0x03 /* Mac IIsi series */
|
||||
#define ADB_HW_PB 0x04 /* PowerBook series */
|
||||
#define ADB_HW_CUDA 0x05 /* Machines with a Cuda chip */
|
||||
#define ADB_HW_UNKNOWN 0x0 /* don't know */
|
||||
#define ADB_HW_II 0x1 /* Mac II series */
|
||||
#define ADB_HW_IISI 0x2 /* Mac IIsi series */
|
||||
#define ADB_HW_PB 0x3 /* PowerBook series */
|
||||
#define ADB_HW_CUDA 0x4 /* Machines with a Cuda chip */
|
||||
#define MAX_ADB_HW 4 /* Number of ADB hardware types */
|
||||
|
||||
/* adb_direct.c */
|
||||
int adb_poweroff __P((void));
|
||||
|
|
|
@ -0,0 +1,599 @@
|
|||
/* $Id: aed.c,v 1.1 1998/10/23 01:16:23 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1994 Bradley A. Grantham
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 Bradley A. Grantham.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#include "opt_adb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/keyboard.h>
|
||||
|
||||
#include <mac68k/mac68k/macrom.h>
|
||||
#include <mac68k/dev/adbvar.h>
|
||||
#include <mac68k/dev/aedvar.h>
|
||||
#include <mac68k/dev/itevar.h>
|
||||
#include <mac68k/dev/kbdvar.h>
|
||||
|
||||
/*
|
||||
* Function declarations.
|
||||
*/
|
||||
static int aedmatch __P((struct device *, struct cfdata *, void *));
|
||||
static void aedattach __P((struct device *, struct device *, void *));
|
||||
static void aed_emulate_mouse __P((adb_event_t *event));
|
||||
static void aed_kbdrpt __P((void *kstate));
|
||||
static void aed_dokeyupdown __P((adb_event_t *event));
|
||||
static void aed_handoff __P((adb_event_t *event));
|
||||
static void aed_enqevent __P((adb_event_t *event));
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
extern int ite_polling; /* Are we polling? (Debugger mode) */
|
||||
|
||||
/*
|
||||
* Local variables.
|
||||
*/
|
||||
static struct aed_softc *aed_sc = NULL;
|
||||
static int aed_options = 0 | AED_MSEMUL;
|
||||
|
||||
/* Driver definition */
|
||||
struct cfattach aed_ca = {
|
||||
sizeof(struct aed_softc), aedmatch, aedattach
|
||||
};
|
||||
|
||||
extern struct cfdriver aed_cd;
|
||||
|
||||
static int
|
||||
aedmatch(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
|
||||
static int aed_matched = 0;
|
||||
|
||||
/* Allow only one instance. */
|
||||
if ((aa_args->origaddr == 0) && (!aed_matched)) {
|
||||
aed_matched = 1;
|
||||
return (1);
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
aedattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
|
||||
struct aed_softc *sc = (struct aed_softc *)self;
|
||||
|
||||
sc->origaddr = aa_args->origaddr;
|
||||
sc->adbaddr = aa_args->adbaddr;
|
||||
sc->handler_id = aa_args->handler_id;
|
||||
|
||||
sc->sc_evq_tail = 0;
|
||||
sc->sc_evq_len = 0;
|
||||
|
||||
sc->sc_rptdelay = 20;
|
||||
sc->sc_rptinterval = 6;
|
||||
sc->sc_repeating = -1; /* not repeating */
|
||||
|
||||
/* Pull in the options flags. */
|
||||
sc->sc_options = (sc->sc_dev.dv_cfdata->cf_flags | aed_options);
|
||||
|
||||
sc->sc_ioproc = NULL;
|
||||
|
||||
sc->sc_buttons = 0;
|
||||
|
||||
sc->sc_open = 0;
|
||||
|
||||
aed_sc = sc;
|
||||
|
||||
printf("ADB Event device\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a keyboard ADB event, record the keycode and call the key
|
||||
* repeat handler, optionally passing the event through the mouse
|
||||
* button emulation handler first. Pass mouse events directly to
|
||||
* the handoff function.
|
||||
*/
|
||||
void
|
||||
aed_input(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
adb_event_t new_event = *event;
|
||||
|
||||
switch (event->def_addr) {
|
||||
case ADBADDR_KBD:
|
||||
if (aed_sc->sc_options & AED_MSEMUL)
|
||||
aed_emulate_mouse(&new_event);
|
||||
else
|
||||
aed_dokeyupdown(&new_event);
|
||||
break;
|
||||
case ADBADDR_MS:
|
||||
aed_handoff(&new_event);
|
||||
break;
|
||||
default: /* God only knows. */
|
||||
#ifdef DIAGNOSTIC
|
||||
panic("aed: received event from unsupported device!\n");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Handles mouse button emulation via the keyboard. If the emulation
|
||||
* modifier key is down, left and right arrows will generate 2nd and
|
||||
* 3rd mouse button events while the 1, 2, and 3 keys will generate
|
||||
* the corresponding mouse button event.
|
||||
*/
|
||||
static void
|
||||
aed_emulate_mouse(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
static int emulmodkey_down = 0;
|
||||
adb_event_t new_event;
|
||||
|
||||
if (event->u.k.key == ADBK_KEYDOWN(ADBK_OPTION)) {
|
||||
emulmodkey_down = 1;
|
||||
} else if (event->u.k.key == ADBK_KEYUP(ADBK_OPTION)) {
|
||||
/* key up */
|
||||
emulmodkey_down = 0;
|
||||
if (aed_sc->sc_buttons & 0xfe) {
|
||||
aed_sc->sc_buttons &= 1;
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = aed_sc->sc_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_handoff(&new_event);
|
||||
}
|
||||
} else if (emulmodkey_down) {
|
||||
switch(event->u.k.key) {
|
||||
#ifdef ALTXBUTTONS
|
||||
case ADBK_KEYDOWN(ADBK_1):
|
||||
aed_sc->sc_buttons |= 1; /* left down */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = aed_sc->sc_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_handoff(&new_event);
|
||||
break;
|
||||
case ADBK_KEYUP(ADBK_1):
|
||||
aed_c->sc_buttons &= ~1; /* left up */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = aed_sc->sc_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_handoff(&new_event);
|
||||
break;
|
||||
#endif
|
||||
case ADBK_KEYDOWN(ADBK_LEFT):
|
||||
#ifdef ALTXBUTTONS
|
||||
case ADBK_KEYDOWN(ADBK_2):
|
||||
#endif
|
||||
aed_sc->sc_buttons |= 2; /* middle down */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = aed_sc->sc_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_handoff(&new_event);
|
||||
break;
|
||||
case ADBK_KEYUP(ADBK_LEFT):
|
||||
#ifdef ALTXBUTTONS
|
||||
case ADBK_KEYUP(ADBK_2):
|
||||
#endif
|
||||
aed_sc->sc_buttons &= ~2; /* middle up */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = aed_sc->sc_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_handoff(&new_event);
|
||||
break;
|
||||
case ADBK_KEYDOWN(ADBK_RIGHT):
|
||||
#ifdef ALTXBUTTONS
|
||||
case ADBK_KEYDOWN(ADBK_3):
|
||||
#endif
|
||||
aed_sc->sc_buttons |= 4; /* right down */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = aed_sc->sc_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_handoff(&new_event);
|
||||
break;
|
||||
case ADBK_KEYUP(ADBK_RIGHT):
|
||||
case ADBK_KEYUP(ADBK_3):
|
||||
aed_sc->sc_buttons &= ~4; /* right up */
|
||||
new_event.def_addr = ADBADDR_MS;
|
||||
new_event.u.m.buttons = aed_sc->sc_buttons;
|
||||
new_event.u.m.dx = new_event.u.m.dy = 0;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_handoff(&new_event);
|
||||
break;
|
||||
case ADBK_KEYVAL(ADBK_SHIFT):
|
||||
case ADBK_KEYVAL(ADBK_CONTROL):
|
||||
case ADBK_KEYVAL(ADBK_FLOWER):
|
||||
/* ctrl, shift, cmd */
|
||||
aed_dokeyupdown(event);
|
||||
break;
|
||||
default:
|
||||
if (event->u.k.key & 0x80)
|
||||
/* ignore keyup */
|
||||
break;
|
||||
|
||||
/* key down */
|
||||
new_event = *event;
|
||||
|
||||
/* send option-down */
|
||||
new_event.u.k.key = ADBK_KEYDOWN(ADBK_OPTION);
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_dokeyupdown(&new_event);
|
||||
|
||||
/* send key-down */
|
||||
new_event.u.k.key = event->bytes[0];
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_dokeyupdown(&new_event);
|
||||
|
||||
/* send key-up */
|
||||
new_event.u.k.key =
|
||||
ADBK_KEYUP(ADBK_KEYVAL(event->bytes[0]));
|
||||
microtime(&new_event.timestamp);
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
aed_dokeyupdown(&new_event);
|
||||
|
||||
/* send option-up */
|
||||
new_event.u.k.key = ADBK_KEYUP(ADBK_OPTION);
|
||||
new_event.bytes[0] = new_event.u.k.key;
|
||||
microtime(&new_event.timestamp);
|
||||
aed_dokeyupdown(&new_event);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
aed_dokeyupdown(event);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Keyboard autorepeat timeout function. Sends key up/down events
|
||||
* for the repeating key and schedules the next call at sc_rptinterval
|
||||
* ticks in the future.
|
||||
*/
|
||||
static void
|
||||
aed_kbdrpt(kstate)
|
||||
void *kstate;
|
||||
{
|
||||
struct aed_softc *aed_sc = (struct aed_softc *)kstate;
|
||||
|
||||
aed_sc->sc_rptevent.bytes[0] |= 0x80;
|
||||
microtime(&aed_sc->sc_rptevent.timestamp);
|
||||
aed_handoff(&aed_sc->sc_rptevent); /* do key up */
|
||||
|
||||
aed_sc->sc_rptevent.bytes[0] &= 0x7f;
|
||||
microtime(&aed_sc->sc_rptevent.timestamp);
|
||||
aed_handoff(&aed_sc->sc_rptevent); /* do key down */
|
||||
|
||||
if (aed_sc->sc_repeating == aed_sc->sc_rptevent.u.k.key) {
|
||||
timeout(aed_kbdrpt, kstate, aed_sc->sc_rptinterval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cancels the currently repeating key event if there is one, schedules
|
||||
* a new repeating key event if needed, and hands the event off to the
|
||||
* appropriate subsystem.
|
||||
*/
|
||||
static void
|
||||
aed_dokeyupdown(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
int kbd_key;
|
||||
|
||||
kbd_key = ADBK_KEYVAL(event->u.k.key);
|
||||
if (ADBK_PRESS(event->u.k.key) && keyboard[kbd_key][0] != 0) {
|
||||
/* ignore shift & control */
|
||||
if (aed_sc->sc_repeating != -1) {
|
||||
untimeout(aed_kbdrpt, (void *)aed_sc);
|
||||
}
|
||||
aed_sc->sc_rptevent = *event;
|
||||
aed_sc->sc_repeating = kbd_key;
|
||||
timeout(aed_kbdrpt, (void *)aed_sc, aed_sc->sc_rptdelay);
|
||||
} else {
|
||||
if (aed_sc->sc_repeating != -1) {
|
||||
aed_sc->sc_repeating = -1;
|
||||
untimeout(aed_kbdrpt, (void *)aed_sc);
|
||||
}
|
||||
aed_sc->sc_rptevent = *event;
|
||||
}
|
||||
aed_handoff(event);
|
||||
}
|
||||
|
||||
/*
|
||||
* Place the event in the event queue if a requesting device is open
|
||||
* and we are not polling, otherwise, pass it up to the console driver.
|
||||
*/
|
||||
static void
|
||||
aed_handoff(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
if (aed_sc->sc_open && !ite_polling)
|
||||
aed_enqevent(event);
|
||||
else {
|
||||
if (event->def_addr == 2)
|
||||
ite_intr(event);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Place the event in the event queue and wakeup any waiting processes.
|
||||
*/
|
||||
static void
|
||||
aed_enqevent(event)
|
||||
adb_event_t *event;
|
||||
{
|
||||
int s;
|
||||
|
||||
s = spladb();
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (aed_sc->sc_evq_tail < 0 || aed_sc->sc_evq_tail >= AED_MAX_EVENTS)
|
||||
panic("adb: event queue tail is out of bounds");
|
||||
|
||||
if (aed_sc->sc_evq_len < 0 || aed_sc->sc_evq_len > AED_MAX_EVENTS)
|
||||
panic("adb: event queue len is out of bounds");
|
||||
#endif
|
||||
|
||||
if (aed_sc->sc_evq_len == AED_MAX_EVENTS) {
|
||||
splx(s);
|
||||
return; /* Oh, well... */
|
||||
}
|
||||
aed_sc->sc_evq[(aed_sc->sc_evq_len + aed_sc->sc_evq_tail) %
|
||||
AED_MAX_EVENTS] = *event;
|
||||
aed_sc->sc_evq_len++;
|
||||
|
||||
selwakeup(&aed_sc->sc_selinfo);
|
||||
if (aed_sc->sc_ioproc)
|
||||
psignal(aed_sc->sc_ioproc, SIGIO);
|
||||
|
||||
splx(s);
|
||||
}
|
||||
|
||||
int
|
||||
aedopen(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
int unit;
|
||||
int error = 0;
|
||||
int s;
|
||||
|
||||
unit = minor(dev);
|
||||
|
||||
if (unit != 0)
|
||||
return (ENXIO);
|
||||
|
||||
s = spladb();
|
||||
if (aed_sc->sc_open) {
|
||||
splx(s);
|
||||
return (EBUSY);
|
||||
}
|
||||
aed_sc->sc_evq_tail = 0;
|
||||
aed_sc->sc_evq_len = 0;
|
||||
aed_sc->sc_open = 1;
|
||||
aed_sc->sc_ioproc = p;
|
||||
splx(s);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
aedclose(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
int s = spladb();
|
||||
|
||||
aed_sc->sc_open = 0;
|
||||
aed_sc->sc_ioproc = NULL;
|
||||
splx(s);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
aedread(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
int s, error;
|
||||
int willfit;
|
||||
int total;
|
||||
int firstmove;
|
||||
int moremove;
|
||||
|
||||
if (uio->uio_resid < sizeof(adb_event_t))
|
||||
return (EMSGSIZE); /* close enough. */
|
||||
|
||||
s = spladb();
|
||||
if (aed_sc->sc_evq_len == 0) {
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
willfit = howmany(uio->uio_resid, sizeof(adb_event_t));
|
||||
total = (aed_sc->sc_evq_len < willfit) ? aed_sc->sc_evq_len : willfit;
|
||||
|
||||
firstmove = (aed_sc->sc_evq_tail + total > AED_MAX_EVENTS)
|
||||
? (AED_MAX_EVENTS - aed_sc->sc_evq_tail) : total;
|
||||
|
||||
error = uiomove((caddr_t) & aed_sc->sc_evq[aed_sc->sc_evq_tail],
|
||||
firstmove * sizeof(adb_event_t), uio);
|
||||
if (error) {
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
moremove = total - firstmove;
|
||||
|
||||
if (moremove > 0) {
|
||||
error = uiomove((caddr_t) & aed_sc->sc_evq[0],
|
||||
moremove * sizeof(adb_event_t), uio);
|
||||
if (error) {
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
aed_sc->sc_evq_tail = (aed_sc->sc_evq_tail + total) % AED_MAX_EVENTS;
|
||||
aed_sc->sc_evq_len -= total;
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
aedwrite(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
aedioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
switch (cmd) {
|
||||
case ADBIOC_DEVSINFO: {
|
||||
adb_devinfo_t *di;
|
||||
ADBDataBlock adbdata;
|
||||
int totaldevs;
|
||||
int adbaddr;
|
||||
int i;
|
||||
|
||||
di = (void *)data;
|
||||
|
||||
/* Initialize to no devices */
|
||||
for (i = 0; i < 16; i++)
|
||||
di->dev[i].addr = -1;
|
||||
|
||||
totaldevs = CountADBs();
|
||||
for (i = 1; i <= totaldevs; i++) {
|
||||
adbaddr = GetIndADB(&adbdata, i);
|
||||
di->dev[adbaddr].addr = adbaddr;
|
||||
di->dev[adbaddr].default_addr = adbdata.origADBAddr;
|
||||
di->dev[adbaddr].handler_id = adbdata.devType;
|
||||
}
|
||||
|
||||
/* Must call ADB Manager to get devices now */
|
||||
break;
|
||||
}
|
||||
|
||||
case ADBIOC_GETREPEAT:{
|
||||
adb_rptinfo_t *ri;
|
||||
|
||||
ri = (void *)data;
|
||||
ri->delay_ticks = aed_sc->sc_rptdelay;
|
||||
ri->interval_ticks = aed_sc->sc_rptinterval;
|
||||
break;
|
||||
}
|
||||
|
||||
case ADBIOC_SETREPEAT:{
|
||||
adb_rptinfo_t *ri;
|
||||
|
||||
ri = (void *) data;
|
||||
aed_sc->sc_rptdelay = ri->delay_ticks;
|
||||
aed_sc->sc_rptinterval = ri->interval_ticks;
|
||||
break;
|
||||
}
|
||||
|
||||
case ADBIOC_RESET:
|
||||
/* Do nothing for now */
|
||||
break;
|
||||
|
||||
case ADBIOC_LISTENCMD:{
|
||||
adb_listencmd_t *lc;
|
||||
|
||||
lc = (void *)data;
|
||||
}
|
||||
|
||||
default:
|
||||
return (EINVAL);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
aedpoll(dev, events, p)
|
||||
dev_t dev;
|
||||
int events;
|
||||
struct proc *p;
|
||||
{
|
||||
int s, revents;
|
||||
|
||||
revents = events & (POLLOUT | POLLWRNORM);
|
||||
|
||||
if ((events & (POLLIN | POLLRDNORM)) == 0)
|
||||
return (revents);
|
||||
|
||||
s = spladb();
|
||||
if (aed_sc->sc_evq_len > 0)
|
||||
revents |= events & (POLLIN | POLLRDNORM);
|
||||
else
|
||||
selrecord(p, &aed_sc->sc_selinfo);
|
||||
splx(s);
|
||||
|
||||
return (revents);
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/* $NetBSD: aedvar.h,v 1.1 1998/10/23 01:16:23 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1994 Bradley A. Grantham
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 Bradley A. Grantham.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#include <machine/adbsys.h>
|
||||
|
||||
/* Event queue definitions */
|
||||
#ifndef AED_MAX_EVENTS
|
||||
#define AED_MAX_EVENTS 200 /* Maximum events to be kept in queue */
|
||||
/* maybe should be higher for slower macs? */
|
||||
#endif /* AED_MAX_EVENTS */
|
||||
|
||||
struct aed_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
/* ADB info */
|
||||
u_char origaddr; /* ADB device type (ADBADDR_AED) */
|
||||
u_char adbaddr; /* current ADB address */
|
||||
u_char handler_id; /* type of device */
|
||||
|
||||
/* ADB event queue */
|
||||
adb_event_t sc_evq[AED_MAX_EVENTS]; /* the queue */
|
||||
int sc_evq_tail; /* event queue tail pointer */
|
||||
int sc_evq_len; /* event queue length */
|
||||
|
||||
/* Keyboard repeat state */
|
||||
int sc_rptdelay; /* ticks before auto-repeat */
|
||||
int sc_rptinterval; /* ticks between auto-repeat */
|
||||
int sc_repeating; /* key that is auto-repeating */
|
||||
adb_event_t sc_rptevent; /* event to auto-repeat */
|
||||
|
||||
int sc_buttons; /* mouse button state */
|
||||
|
||||
struct selinfo sc_selinfo; /* select() info */
|
||||
struct proc * sc_ioproc; /* process to wakeup */
|
||||
|
||||
int sc_open; /* Are we queuing events? */
|
||||
int sc_options; /* config options */
|
||||
};
|
||||
|
||||
/* Options */
|
||||
#define AED_MSEMUL 0x1 /* emulate mouse buttons */
|
||||
|
||||
void aed_input __P((adb_event_t *event));
|
||||
int aedopen __P((dev_t dev, int flag, int mode, struct proc *p));
|
||||
int aedclose __P((dev_t dev, int flag, int mode, struct proc *p));
|
||||
int aedread __P((dev_t dev, struct uio *uio, int flag));
|
||||
int aedwrite __P((dev_t dev, struct uio *uio, int flag));
|
||||
int aedioctl __P((dev_t , int , caddr_t , int , struct proc *));
|
||||
int aedpoll __P((dev_t dev, int events, struct proc *p));
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ite.c,v 1.44 1998/07/01 14:49:08 scottr Exp $ */
|
||||
/* $NetBSD: ite.c,v 1.45 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
|
@ -165,9 +165,9 @@ static int bell_freq = 1880; /* frequency */
|
|||
static int bell_length = 10; /* duration */
|
||||
static int bell_volume = 100; /* volume */
|
||||
|
||||
/* For polled ADB mode */
|
||||
/* For polled kbd mode */
|
||||
int ite_polling = 0;
|
||||
static int polledkey;
|
||||
extern int adb_polling;
|
||||
|
||||
extern u_int32_t mac68k_vidphys;
|
||||
|
||||
|
@ -894,7 +894,7 @@ ite_pollforchar()
|
|||
s = splhigh();
|
||||
|
||||
polledkey = -1;
|
||||
adb_polling = 1;
|
||||
ite_polling = 1;
|
||||
|
||||
/* pretend we're VIA interrupt dispatcher */
|
||||
while (polledkey == -1) {
|
||||
|
@ -910,7 +910,7 @@ ite_pollforchar()
|
|||
}
|
||||
}
|
||||
|
||||
adb_polling = 0;
|
||||
ite_polling = 0;
|
||||
|
||||
splx(s);
|
||||
|
||||
|
@ -1214,7 +1214,7 @@ ite_intr(adb_event_t * event)
|
|||
str[1] = '\0';
|
||||
break;
|
||||
}
|
||||
if (adb_polling)
|
||||
if (ite_polling)
|
||||
polledkey = str[0];
|
||||
else
|
||||
for (s = str; *s; s++)
|
||||
|
|
|
@ -0,0 +1,415 @@
|
|||
/* $Id: kbd.c,v 1.1 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1998 Colin Wood
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 Colin Wood.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
|
||||
#include <mac68k/mac68k/macrom.h>
|
||||
#include <mac68k/dev/adbvar.h>
|
||||
#include <mac68k/dev/aedvar.h>
|
||||
#include <mac68k/dev/itevar.h>
|
||||
#include <mac68k/dev/kbdvar.h>
|
||||
#include <mac68k/dev/msvar.h>
|
||||
|
||||
/*
|
||||
* Function declarations.
|
||||
*/
|
||||
static int kbdmatch __P((struct device *, struct cfdata *, void *));
|
||||
static void kbdattach __P((struct device *, struct device *, void *));
|
||||
void kbd_adbcomplete __P((caddr_t buffer, caddr_t data_area, int adb_command));
|
||||
static void kbd_processevent __P((adb_event_t *event, struct kbd_softc *));
|
||||
#ifdef notyet
|
||||
static u_char getleds __P((int));
|
||||
static int setleds __P((struct kbd_softc *, u_char));
|
||||
static void blinkleds __P((struct kbd_softc *));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables.
|
||||
*/
|
||||
static volatile int kbd_done; /* Did ADBOp() complete? */
|
||||
|
||||
/* Driver definition. */
|
||||
struct cfattach kbd_ca = {
|
||||
sizeof(struct kbd_softc), kbdmatch, kbdattach
|
||||
};
|
||||
|
||||
extern struct cfdriver kbd_cd;
|
||||
|
||||
static int
|
||||
kbdmatch(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
|
||||
|
||||
if (aa_args->origaddr == ADBADDR_KBD)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
kbdattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
ADBSetInfoBlock adbinfo;
|
||||
struct kbd_softc *sc = (struct kbd_softc *)self;
|
||||
struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
|
||||
int count, error;
|
||||
short cmd;
|
||||
u_char buffer[9];
|
||||
|
||||
sc->origaddr = aa_args->origaddr;
|
||||
sc->adbaddr = aa_args->adbaddr;
|
||||
sc->handler_id = aa_args->handler_id;
|
||||
|
||||
sc->sc_leds = (u_int8_t)0x00; /* initially off */
|
||||
|
||||
adbinfo.siServiceRtPtr = (Ptr)adb_kbd_asmcomplete;
|
||||
adbinfo.siDataAreaAddr = (caddr_t)sc;
|
||||
|
||||
switch (sc->handler_id) {
|
||||
case ADB_STDKBD:
|
||||
printf("standard keyboard\n");
|
||||
break;
|
||||
case ADB_ISOKBD:
|
||||
printf("standard keyboard (ISO layout)\n");
|
||||
break;
|
||||
case ADB_EXTKBD:
|
||||
kbd_done = 0;
|
||||
cmd = (((sc->adbaddr << 4) & 0xf0) | 0x0d ); /* talk R1 */
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&kbd_done, cmd);
|
||||
|
||||
/* Wait until done, but no more than 2 secs */
|
||||
count = 40000;
|
||||
while (!kbd_done && count-- > 0)
|
||||
delay(50);
|
||||
|
||||
/* Ignore Logitech MouseMan/Trackman pseudo keyboard */
|
||||
if (kbd_done && buffer[1] == 0x9a && buffer[2] == 0x20) {
|
||||
printf("Mouseman (non-EMP) pseudo keyboard\n");
|
||||
adbinfo.siServiceRtPtr = (Ptr)0;
|
||||
adbinfo.siDataAreaAddr = (Ptr)0;
|
||||
} else if (kbd_done && buffer[1] == 0x9a && buffer[2] == 0x21) {
|
||||
printf("Trackman (non-EMP) pseudo keyboard\n");
|
||||
adbinfo.siServiceRtPtr = (Ptr)0;
|
||||
adbinfo.siDataAreaAddr = (Ptr)0;
|
||||
} else {
|
||||
printf("extended keyboard\n");
|
||||
#ifdef notyet
|
||||
blinkleds(sc);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ADB_EXTISOKBD:
|
||||
printf("extended keyboard (ISO layout)\n");
|
||||
#ifdef notyet
|
||||
blinkleds(sc);
|
||||
#endif
|
||||
break;
|
||||
case ADB_KBDII:
|
||||
printf("keyboard II\n");
|
||||
break;
|
||||
case ADB_ISOKBDII:
|
||||
printf("keyboard II (ISO layout)\n");
|
||||
break;
|
||||
case ADB_PBKBD:
|
||||
printf("PowerBook keyboard\n");
|
||||
break;
|
||||
case ADB_PBISOKBD:
|
||||
printf("PowerBook keyboard (ISO layout)\n");
|
||||
break;
|
||||
case ADB_ADJKPD:
|
||||
printf("adjustable keypad\n");
|
||||
break;
|
||||
case ADB_ADJKBD:
|
||||
printf("adjustable keyboard\n");
|
||||
break;
|
||||
case ADB_ADJISOKBD:
|
||||
printf("adjustable keyboard (ISO layout)\n");
|
||||
break;
|
||||
case ADB_ADJJAPKBD:
|
||||
printf("adjustable keyboard (Japanese layout)\n");
|
||||
break;
|
||||
case ADB_PBEXTISOKBD:
|
||||
printf("PowerBook extended keyboard (ISO layout)\n");
|
||||
break;
|
||||
case ADB_PBEXTJAPKBD:
|
||||
printf("PowerBook extended keyboard (Japanese layout)\n");
|
||||
break;
|
||||
case ADB_PBEXTKBD:
|
||||
printf("PowerBook extended keyboard\n");
|
||||
break;
|
||||
case ADB_DESIGNKBD:
|
||||
printf("extended keyboard\n");
|
||||
#ifdef notyet
|
||||
blinkleds(sc);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
printf("mapped device (%d)\n", sc->handler_id);
|
||||
break;
|
||||
}
|
||||
error = SetADBInfo(&adbinfo, sc->adbaddr);
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf("kbd: returned %d from SetADBInfo\n", error);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle putting the keyboard data received from the ADB into
|
||||
* an ADB event record.
|
||||
*/
|
||||
void
|
||||
kbd_adbcomplete(buffer, data_area, adb_command)
|
||||
caddr_t buffer;
|
||||
caddr_t data_area;
|
||||
int adb_command;
|
||||
{
|
||||
adb_event_t event;
|
||||
struct kbd_softc *ksc;
|
||||
int adbaddr;
|
||||
#ifdef ADB_DEBUG
|
||||
int i;
|
||||
|
||||
if (adb_debug)
|
||||
printf("adb: transaction completion\n");
|
||||
#endif
|
||||
|
||||
adbaddr = (adb_command & 0xf0) >> 4;
|
||||
ksc = (struct kbd_softc *)data_area;
|
||||
|
||||
event.addr = adbaddr;
|
||||
event.hand_id = ksc->handler_id;
|
||||
event.def_addr = ksc->origaddr;
|
||||
event.byte_count = buffer[0];
|
||||
memcpy(event.bytes, buffer + 1, event.byte_count);
|
||||
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug) {
|
||||
printf("kbd: from %d at %d (org %d) %d:", event.addr,
|
||||
event.hand_id, event.def_addr, buffer[0]);
|
||||
for (i = 1; i <= buffer[0]; i++)
|
||||
printf(" %x", buffer[i]);
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
microtime(&event.timestamp);
|
||||
|
||||
kbd_processevent(&event, ksc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a keyboard ADB event, record the keycodes and call the key
|
||||
* repeat handler, optionally passing the event through the mouse
|
||||
* button emulation handler first.
|
||||
*/
|
||||
static void
|
||||
kbd_processevent(event, ksc)
|
||||
adb_event_t *event;
|
||||
struct kbd_softc *ksc;
|
||||
{
|
||||
adb_event_t new_event;
|
||||
|
||||
new_event = *event;
|
||||
new_event.u.k.key = event->bytes[0];
|
||||
new_event.bytes[1] = 0xff;
|
||||
aed_input(&new_event);
|
||||
if (event->bytes[1] != 0xff) {
|
||||
new_event.u.k.key = event->bytes[1];
|
||||
new_event.bytes[0] = event->bytes[1];
|
||||
new_event.bytes[1] = 0xff;
|
||||
aed_input(&new_event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef notyet
|
||||
/*
|
||||
* Get the actual hardware LED state and convert it to softc format.
|
||||
*/
|
||||
static u_char
|
||||
getleds(addr)
|
||||
int addr;
|
||||
{
|
||||
short cmd;
|
||||
u_char buffer[9], leds;
|
||||
|
||||
leds = 0x00; /* all off */
|
||||
buffer[0] = 0;
|
||||
kbd_done = 0;
|
||||
|
||||
/* talk R2 */
|
||||
cmd = ((addr & 0xf) << 4) | 0x0c | 0x02;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&kbd_done, cmd);
|
||||
while (!kbd_done)
|
||||
/* busy-wait until done */ ;
|
||||
|
||||
if (buffer[0] > 0)
|
||||
leds = ~(buffer[2]) & 0x07;
|
||||
|
||||
return (leds);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the keyboard LED's.
|
||||
*
|
||||
* Automatically translates from ioctl/softc format to the
|
||||
* actual keyboard register format
|
||||
*/
|
||||
static int
|
||||
setleds(ksc, leds)
|
||||
struct kbd_softc *ksc;
|
||||
u_char leds;
|
||||
{
|
||||
int addr;
|
||||
short cmd;
|
||||
u_char buffer[9];
|
||||
|
||||
if ((leds & 0x07) == (ksc->sc_leds & 0x07))
|
||||
return (0);
|
||||
|
||||
addr = (int)ksc->adbaddr;
|
||||
buffer[0] = 0;
|
||||
kbd_done = 0;
|
||||
|
||||
/* talk R2 */
|
||||
cmd = ((addr & 0xf) << 4) | 0x0c | 0x02;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&kbd_done, cmd);
|
||||
while (!kbd_done)
|
||||
/* busy-wait until done */ ;
|
||||
|
||||
if (buffer[0] == 0)
|
||||
return (EIO);
|
||||
|
||||
leds = ~leds & 0x07;
|
||||
buffer[2] &= 0xf8;
|
||||
buffer[2] |= leds;
|
||||
|
||||
/* listen R2 */
|
||||
cmd = ((addr & 0xf) << 4) | 0x08 | 0x02;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&kbd_done, cmd);
|
||||
while (!kbd_done)
|
||||
/* busy-wait until done */ ;
|
||||
|
||||
/* talk R2 */
|
||||
cmd = ((addr & 0xf) << 4) | 0x0c | 0x02;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&kbd_done, cmd);
|
||||
while (!kbd_done)
|
||||
/* busy-wait until done */ ;
|
||||
|
||||
if (buffer[0] == 0)
|
||||
return (EIO);
|
||||
|
||||
ksc->sc_leds = ~((u_int8_t)buffer[2]) & 0x07;
|
||||
|
||||
if ((buffer[2] & 0xf8) != leds)
|
||||
return (EIO);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Toggle all of the LED's on and off, just for show.
|
||||
*/
|
||||
static void
|
||||
blinkleds(ksc)
|
||||
struct kbd_softc *ksc;
|
||||
{
|
||||
int addr, i;
|
||||
u_char blinkleds, origleds;
|
||||
|
||||
addr = (int)ksc->adbaddr;
|
||||
origleds = getleds(addr);
|
||||
blinkleds = LED_NUMLOCK | LED_CAPSLOCK | LED_SCROLL_LOCK;
|
||||
|
||||
(void)setleds(ksc, blinkleds);
|
||||
|
||||
for (i = 0; i < 10000; i++)
|
||||
delay(50);
|
||||
|
||||
/* make sure that we restore the LED settings */
|
||||
i = 10;
|
||||
do {
|
||||
(void)setleds(ksc, (u_char)0x00);
|
||||
} while (setleds(ksc, (u_char)0x00) && (i-- > 0));
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int
|
||||
kbdioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct kbd_softc *ksc;
|
||||
int error = 0;
|
||||
|
||||
ksc = kbd_cd.cd_devs[minor(dev)];
|
||||
|
||||
switch (cmd) {
|
||||
case KIOCTYPE: /* Get keyboard type */
|
||||
*(u_int8_t *)data = ksc->handler_id;
|
||||
case KIOCSLED:
|
||||
error = setleds(ksc, *(u_char *)data);
|
||||
break;
|
||||
case KIOCGLED:
|
||||
*(u_int8_t *)data = ksc->sc_leds;
|
||||
break;
|
||||
default:
|
||||
error = (EINVAL);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: adb_direct.h,v 1.1 1997/04/08 03:16:19 scottr Exp $ */
|
||||
/* $Id: kbdvar.h,v 1.1 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 John P. Wittkoski
|
||||
* Copyright (C) 1998 Colin Wood
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -14,7 +14,7 @@
|
|||
* 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 John P. Wittkoski.
|
||||
* This product includes software developed by Colin Wood.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
|
@ -29,25 +29,31 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/* From: adb_direct.h 1.4 10/23/96 jpw */
|
||||
|
||||
#ifndef _MAC68K_KBDVAR_H_
|
||||
#define _MAC68K_KBDVAR_H_
|
||||
|
||||
#include <machine/adbsys.h>
|
||||
|
||||
/*
|
||||
* These are public declarations that other routines may need.
|
||||
* State info, per keyboard instance.
|
||||
*/
|
||||
struct kbd_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
/* types of adb hardware that we (will eventually) support */
|
||||
#define ADB_HW_UNKNOWN 0x01 /* don't know */
|
||||
#define ADB_HW_II 0x02 /* Mac II series */
|
||||
#define ADB_HW_IISI 0x03 /* Mac IIsi series */
|
||||
#define ADB_HW_PB 0x04 /* PowerBook series */
|
||||
#define ADB_HW_CUDA 0x05 /* Machines with a Cuda chip */
|
||||
/* ADB info */
|
||||
u_int8_t origaddr; /* ADB device type (ADBADDR_KBD) */
|
||||
u_int8_t adbaddr; /* current ADB address */
|
||||
u_int8_t handler_id; /* type of keyboard */
|
||||
|
||||
int adb_poweroff __P((void));
|
||||
int CountADBs __P((void));
|
||||
void ADBReInit __P((void));
|
||||
int GetIndADB __P((ADBDataBlock *info, int index));
|
||||
int GetADBInfo __P((ADBDataBlock *info, int adbAddr));
|
||||
int SetADBInfo __P((ADBSetInfoBlock *info, int adbAddr));
|
||||
int ADBOp __P((Ptr buffer, Ptr compRout, Ptr data, short commandNum));
|
||||
int adb_read_date_time __P((unsigned long *));
|
||||
int adb_set_date_time __P((unsigned long));
|
||||
u_int8_t sc_leds; /* current LED state */
|
||||
};
|
||||
|
||||
/* LED register bits, inverse of actual register value */
|
||||
#define LED_NUMLOCK 0x1
|
||||
#define LED_CAPSLOCK 0x2
|
||||
#define LED_SCROLL_LOCK 0x4
|
||||
|
||||
void kbd_adbcomplete __P((caddr_t buffer, caddr_t data_area, int adb_command));
|
||||
|
||||
#endif /* _MAC68K_KBDVAR_H_ */
|
|
@ -0,0 +1,546 @@
|
|||
/* $Id: ms.c,v 1.1 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1998 Colin Wood
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 Colin Wood.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/keyboard.h>
|
||||
|
||||
#include <mac68k/mac68k/macrom.h>
|
||||
#include <mac68k/dev/adbvar.h>
|
||||
#include <mac68k/dev/aedvar.h>
|
||||
#include <mac68k/dev/msvar.h>
|
||||
#include <mac68k/dev/itevar.h>
|
||||
|
||||
/*
|
||||
* Function declarations.
|
||||
*/
|
||||
static int msmatch __P((struct device *, struct cfdata *, void *));
|
||||
static void msattach __P((struct device *, struct device *, void *));
|
||||
static void ems_init __P((struct ms_softc *));
|
||||
static void ms_processevent __P((adb_event_t *event, struct ms_softc *));
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
extern int kbd_polling; /* Are we polling (Debugger mode)? from kbd.c */
|
||||
|
||||
/*
|
||||
* Local variables.
|
||||
*/
|
||||
static volatile int extdms_done; /* Did ADBOp() complete? */
|
||||
|
||||
|
||||
/* Driver definition. */
|
||||
struct cfattach ms_ca = {
|
||||
sizeof(struct ms_softc), msmatch, msattach
|
||||
};
|
||||
|
||||
extern struct cfdriver ms_cd;
|
||||
|
||||
static int
|
||||
msmatch(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct adb_attach_args * aa_args = (struct adb_attach_args *)aux;
|
||||
|
||||
if (aa_args->origaddr == ADBADDR_MS)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
msattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
ADBSetInfoBlock adbinfo;
|
||||
struct ms_softc *sc = (struct ms_softc *)self;
|
||||
struct adb_attach_args * aa_args = (struct adb_attach_args *)aux;
|
||||
int error;
|
||||
|
||||
sc->origaddr = aa_args->origaddr;
|
||||
sc->adbaddr = aa_args->adbaddr;
|
||||
sc->handler_id = aa_args->handler_id;
|
||||
|
||||
sc->sc_class = MSCLASS_MOUSE;
|
||||
sc->sc_buttons = 1;
|
||||
sc->sc_res = 100;
|
||||
sc->sc_devid[0] = 0;
|
||||
sc->sc_devid[4] = 0;
|
||||
|
||||
adbinfo.siServiceRtPtr = (Ptr)adb_ms_asmcomplete;
|
||||
adbinfo.siDataAreaAddr = (caddr_t)sc;
|
||||
|
||||
ems_init(sc);
|
||||
|
||||
/* print out the type of mouse we have */
|
||||
switch (sc->handler_id) {
|
||||
case ADBMS_100DPI:
|
||||
printf("%d-button, %d dpi mouse\n", sc->sc_buttons,
|
||||
sc->sc_res);
|
||||
break;
|
||||
case ADBMS_200DPI:
|
||||
sc->sc_res = 200;
|
||||
printf("%d-button, %d dpi mouse\n", sc->sc_buttons,
|
||||
sc->sc_res);
|
||||
break;
|
||||
case ADBMS_MSA3:
|
||||
printf("Mouse Systems A3 mouse, %d-button, %d dpi\n",
|
||||
sc->sc_buttons, sc->sc_res);
|
||||
break;
|
||||
case ADBMS_USPEED:
|
||||
printf("MicroSpeed mouse, default parameters\n");
|
||||
break;
|
||||
case ADBMS_EXTENDED:
|
||||
if (sc->sc_devid[0] == '\0') {
|
||||
printf("Logitech ");
|
||||
switch (sc->sc_class) {
|
||||
case MSCLASS_MOUSE:
|
||||
printf("MouseMan (non-EMP) mouse");
|
||||
break;
|
||||
case MSCLASS_TRACKBALL:
|
||||
printf("TrackMan (non-EMP) trackball");
|
||||
break;
|
||||
default:
|
||||
printf("non-EMP relative positioning device");
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
} else {
|
||||
printf("EMP ");
|
||||
switch (sc->sc_class) {
|
||||
case MSCLASS_TABLET:
|
||||
printf("tablet");
|
||||
break;
|
||||
case MSCLASS_MOUSE:
|
||||
printf("mouse");
|
||||
break;
|
||||
case MSCLASS_TRACKBALL:
|
||||
printf("trackball");
|
||||
break;
|
||||
default:
|
||||
printf("unknown device");
|
||||
break;
|
||||
}
|
||||
printf(" <%s> %d-button, %d dpi\n", sc->sc_devid,
|
||||
sc->sc_buttons, sc->sc_res);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("relative positioning device (mouse?) (%d)\n",
|
||||
sc->handler_id);
|
||||
break;
|
||||
}
|
||||
error = SetADBInfo(&adbinfo, sc->adbaddr);
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf("ms: returned %d from SetADBInfo\n", error);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize extended mouse support -- probes devices as described
|
||||
* in Inside Macintosh: Devices, Chapter 5 "ADB Manager".
|
||||
*
|
||||
* Extended Mouse Protocol is documented in TechNote HW1:
|
||||
* "ADB - The Untold Story: Space Aliens Ate My Mouse"
|
||||
*
|
||||
* Supports: Extended Mouse Protocol, MicroSpeed Mouse Deluxe,
|
||||
* Mouse Systems A^3 Mouse, Logitech non-EMP MouseMan
|
||||
*/
|
||||
void
|
||||
ems_init(sc)
|
||||
struct ms_softc * sc;
|
||||
{
|
||||
int adbaddr, count;
|
||||
short cmd;
|
||||
u_char buffer[9];
|
||||
|
||||
adbaddr = sc->adbaddr;
|
||||
if (sc->origaddr != ADBADDR_MS)
|
||||
return;
|
||||
if (sc->handler_id == ADBMS_USPEED) {
|
||||
/* Found MicroSpeed Mouse Deluxe Mac */
|
||||
cmd = ((adbaddr<<4)&0xF0)|0x9; /* listen 1 */
|
||||
|
||||
/*
|
||||
* To setup the MicroSpeed, it appears that we can
|
||||
* send the following command to the mouse and then
|
||||
* expect data back in the form:
|
||||
* buffer[0] = 4 (bytes)
|
||||
* buffer[1], buffer[2] as std. mouse
|
||||
* buffer[3] = buffer[4] = 0xff when no buttons
|
||||
* are down. When button N down, bit N is clear.
|
||||
* buffer[4]'s locking mask enables a
|
||||
* click to toggle the button down state--sort of
|
||||
* like the "Easy Access" shift/control/etc. keys.
|
||||
* buffer[3]'s alternative speed mask enables using
|
||||
* different speed when the corr. button is down
|
||||
*/
|
||||
buffer[0] = 4;
|
||||
buffer[1] = 0x00; /* Alternative speed */
|
||||
buffer[2] = 0x00; /* speed = maximum */
|
||||
buffer[3] = 0x10; /* enable extended protocol,
|
||||
* lower bits = alt. speed mask
|
||||
* = 0000b
|
||||
*/
|
||||
buffer[4] = 0x07; /* Locking mask = 0000b,
|
||||
* enable buttons = 0111b
|
||||
*/
|
||||
extdms_done = 0;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, cmd);
|
||||
while (!extdms_done)
|
||||
/* busy wait until done */;
|
||||
|
||||
sc->sc_buttons = 3;
|
||||
sc->sc_res = 200;
|
||||
return;
|
||||
}
|
||||
if ((sc->handler_id == ADBMS_100DPI) ||
|
||||
(sc->handler_id == ADBMS_200DPI)) {
|
||||
/* found a mouse */
|
||||
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
|
||||
|
||||
extdms_done = 0;
|
||||
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, cmd);
|
||||
|
||||
/* Wait until done, but no more than 2 secs */
|
||||
count = 40000;
|
||||
while (!extdms_done && count-- > 0)
|
||||
delay(50);
|
||||
|
||||
if (!extdms_done) {
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug)
|
||||
printf("adb: extdms_init timed out\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* Attempt to initialize Extended Mouse Protocol */
|
||||
buffer[2] = '\004'; /* make handler ID 4 */
|
||||
extdms_done = 0;
|
||||
cmd = (cmd & 0xf3) | 0x08; /* listen command */
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, cmd);
|
||||
while (!extdms_done)
|
||||
/* busy wait until done */;
|
||||
|
||||
/*
|
||||
* Check to see if successful, if not
|
||||
* try to initialize it as other types
|
||||
*/
|
||||
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
|
||||
extdms_done = 0;
|
||||
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, cmd);
|
||||
while (!extdms_done)
|
||||
/* busy wait until done */;
|
||||
|
||||
if (buffer[2] == ADBMS_EXTENDED) {
|
||||
sc->handler_id = ADBMS_EXTENDED;
|
||||
extdms_done = 0;
|
||||
/* talk register 1 */
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, (adbaddr << 4) | 0xd);
|
||||
while (!extdms_done)
|
||||
/* busy-wait until done */;
|
||||
if (buffer[0] == 8) {
|
||||
/* we have a true EMP device */
|
||||
sc->sc_class = buffer[7];
|
||||
sc->sc_buttons = buffer[8];
|
||||
sc->sc_res = (int)*(short *)&buffer[5];
|
||||
bcopy(&(buffer[1]), sc->sc_devid, 4);
|
||||
} else if (buffer[1] == 0x9a &&
|
||||
((buffer[2] == 0x20) || (buffer[2] == 0x21))) {
|
||||
/*
|
||||
* Set up non-EMP Mouseman/Trackman to put
|
||||
* button bits in 3rd byte instead of sending
|
||||
* via pseudo keyboard device.
|
||||
*/
|
||||
extdms_done = 0;
|
||||
/* listen register 1 */
|
||||
buffer[0]=2;
|
||||
buffer[1]=0x00;
|
||||
buffer[2]=0x81;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
||||
while (!extdms_done)
|
||||
/* busy-wait until done */;
|
||||
extdms_done = 0;
|
||||
/* listen register 1 */
|
||||
buffer[0]=2;
|
||||
buffer[1]=0x01;
|
||||
buffer[2]=0x81;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
||||
while (!extdms_done)
|
||||
/* busy-wait until done */;
|
||||
extdms_done = 0;
|
||||
/* listen register 1 */
|
||||
buffer[0]=2;
|
||||
buffer[1]=0x02;
|
||||
buffer[2]=0x81;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
||||
while (!extdms_done)
|
||||
/* busy-wait until done */;
|
||||
extdms_done = 0;
|
||||
/* listen register 1 */
|
||||
buffer[0]=2;
|
||||
buffer[1]=0x03;
|
||||
buffer[2]=0x38;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
||||
while (!extdms_done)
|
||||
/* busy-wait until done */;
|
||||
sc->sc_buttons = 3;
|
||||
sc->sc_res = 400;
|
||||
if (buffer[2] == 0x21)
|
||||
sc->sc_class = MSCLASS_TRACKBALL;
|
||||
else
|
||||
sc->sc_class = MSCLASS_MOUSE;
|
||||
} else
|
||||
/* unknown device? */;
|
||||
} else {
|
||||
/* Attempt to initialize as an A3 mouse */
|
||||
buffer[2] = 0x03; /* make handler ID 3 */
|
||||
extdms_done = 0;
|
||||
cmd = (cmd & 0xf3) | 0x08; /* listen command */
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, cmd);
|
||||
while (!extdms_done)
|
||||
/* busy wait until done */;
|
||||
|
||||
/*
|
||||
* Check to see if successful, if not
|
||||
* try to initialize it as other types
|
||||
*/
|
||||
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
|
||||
extdms_done = 0;
|
||||
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, cmd);
|
||||
while (!extdms_done)
|
||||
/* busy wait until done */;
|
||||
|
||||
if (buffer[2] == ADBMS_MSA3) {
|
||||
sc->handler_id = ADBMS_MSA3;
|
||||
/* Initialize as above */
|
||||
cmd = ((adbaddr << 4) & 0xF0) | 0xA;
|
||||
/* listen 2 */
|
||||
buffer[0] = 3;
|
||||
buffer[1] = 0x00;
|
||||
/* Irrelevant, buffer has 0x77 */
|
||||
buffer[2] = 0x07;
|
||||
/*
|
||||
* enable 3 button mode = 0111b,
|
||||
* speed = normal
|
||||
*/
|
||||
extdms_done = 0;
|
||||
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
||||
(Ptr)&extdms_done, cmd);
|
||||
while (!extdms_done)
|
||||
/* busy wait until done */;
|
||||
sc->sc_buttons = 3;
|
||||
sc->sc_res = 300;
|
||||
} else {
|
||||
/* No special support for this mouse */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle putting the mouse data received from the ADB into
|
||||
* an ADB event record.
|
||||
*/
|
||||
void
|
||||
ms_adbcomplete(buffer, data_area, adb_command)
|
||||
caddr_t buffer;
|
||||
caddr_t data_area;
|
||||
int adb_command;
|
||||
{
|
||||
adb_event_t event;
|
||||
struct ms_softc *msc;
|
||||
int adbaddr;
|
||||
#ifdef ADB_DEBUG
|
||||
int i;
|
||||
|
||||
if (adb_debug)
|
||||
printf("adb: transaction completion\n");
|
||||
#endif
|
||||
|
||||
adbaddr = (adb_command & 0xf0) >> 4;
|
||||
msc = (struct ms_softc *)data_area;
|
||||
|
||||
if ((msc->handler_id == ADBMS_EXTENDED) && (msc->sc_devid[0] == 0)) {
|
||||
/* massage the data to look like EMP data */
|
||||
if ((buffer[3] & 0x04) == 0x04)
|
||||
buffer[1] &= 0x7f;
|
||||
else
|
||||
buffer[1] |= 0x80;
|
||||
if ((buffer[3] & 0x02) == 0x02)
|
||||
buffer[2] &= 0x7f;
|
||||
else
|
||||
buffer[2] |= 0x80;
|
||||
if ((buffer[3] & 0x01) == 0x01)
|
||||
buffer[3] = 0x00;
|
||||
else
|
||||
buffer[3] = 0x80;
|
||||
}
|
||||
|
||||
event.addr = adbaddr;
|
||||
event.hand_id = msc->handler_id;
|
||||
event.def_addr = msc->origaddr;
|
||||
event.byte_count = buffer[0];
|
||||
memcpy(event.bytes, buffer + 1, event.byte_count);
|
||||
|
||||
#ifdef ADB_DEBUG
|
||||
if (adb_debug) {
|
||||
printf("ms: from %d at %d (org %d) %d:", event.addr,
|
||||
event.hand_id, event.def_addr, buffer[0]);
|
||||
for (i = 1; i <= buffer[0]; i++)
|
||||
printf(" %x", buffer[i]);
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
microtime(&event.timestamp);
|
||||
|
||||
ms_processevent(&event, msc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a mouse ADB event, record the button settings, calculate the
|
||||
* x- and y-axis motion, and handoff the event to the appropriate subsystem.
|
||||
*/
|
||||
static void
|
||||
ms_processevent(event, msc)
|
||||
adb_event_t *event;
|
||||
struct ms_softc *msc;
|
||||
{
|
||||
adb_event_t new_event;
|
||||
int i, button_bit, max_byte, mask, buttons;
|
||||
|
||||
new_event = *event;
|
||||
buttons = 0;
|
||||
|
||||
/*
|
||||
* This should handle both plain ol' Apple mice and mice
|
||||
* that claim to support the Extended Apple Mouse Protocol.
|
||||
*/
|
||||
max_byte = event->byte_count;
|
||||
button_bit = 1;
|
||||
switch (event->hand_id) {
|
||||
case ADBMS_USPEED:
|
||||
/* MicroSpeed mouse */
|
||||
if (max_byte == 4)
|
||||
buttons = (~event->bytes[2]) & 0xff;
|
||||
else
|
||||
buttons = (event->bytes[0] & 0x80) ? 0 : 1;
|
||||
break;
|
||||
case ADBMS_MSA3:
|
||||
/* Mouse Systems A3 mouse */
|
||||
if (max_byte == 3)
|
||||
buttons = (~event->bytes[2]) & 0x07;
|
||||
else
|
||||
buttons = (event->bytes[0] & 0x80) ? 0 : 1;
|
||||
break;
|
||||
default:
|
||||
/* Classic Mouse Protocol (up to 2 buttons) */
|
||||
for (i = 0; i < 2; i++, button_bit <<= 1)
|
||||
/* 0 when button down */
|
||||
if (!(event->bytes[i] & 0x80))
|
||||
buttons |= button_bit;
|
||||
else
|
||||
buttons &= ~button_bit;
|
||||
/* Extended Protocol (up to 6 more buttons) */
|
||||
for (mask = 0x80; i < max_byte;
|
||||
i += (mask == 0x80), button_bit <<= 1) {
|
||||
/* 0 when button down */
|
||||
if (!(event->bytes[i] & mask))
|
||||
buttons |= button_bit;
|
||||
else
|
||||
buttons &= ~button_bit;
|
||||
mask = ((mask >> 4) & 0xf)
|
||||
| ((mask & 0xf) << 4);
|
||||
}
|
||||
break;
|
||||
}
|
||||
new_event.u.m.buttons = msc->sc_mb | buttons;
|
||||
new_event.u.m.dx = ((signed int) (event->bytes[1] & 0x3f)) -
|
||||
((event->bytes[1] & 0x40) ? 64 : 0);
|
||||
new_event.u.m.dy = ((signed int) (event->bytes[0] & 0x3f)) -
|
||||
((event->bytes[0] & 0x40) ? 64 : 0);
|
||||
|
||||
aed_input(&new_event);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
msioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct ms_softc *msc;
|
||||
|
||||
msc = ms_cd.cd_devs[minor(dev)];
|
||||
|
||||
switch (cmd) {
|
||||
default:
|
||||
return (EINVAL);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,64 @@
|
|||
/* $Id: msvar.h,v 1.1 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1998 Colin Wood
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 Colin Wood.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _MAC68K_MSVAR_H_
|
||||
#define _MAC68K_MSVAR_H_
|
||||
|
||||
/*
|
||||
* State info, per mouse instance.
|
||||
*/
|
||||
struct ms_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
/* ADB info */
|
||||
u_int8_t origaddr; /* ADB device type (ADBADDR_MS) */
|
||||
u_int8_t adbaddr; /* current ADB address */
|
||||
u_int8_t handler_id; /* type of mouse */
|
||||
|
||||
/* Extended Mouse Protocol info, faked for non-EMP mice */
|
||||
u_int8_t sc_class; /* mouse class (mouse, trackball) */
|
||||
u_int8_t sc_buttons; /* number of buttons */
|
||||
u_int32_t sc_res; /* mouse resolution (dpi) */
|
||||
char sc_devid[5]; /* device indentifier */
|
||||
|
||||
int sc_mb; /* current button state */
|
||||
};
|
||||
|
||||
/* EMP device classes */
|
||||
#define MSCLASS_TABLET 0
|
||||
#define MSCLASS_MOUSE 1
|
||||
#define MSCLASS_TRACKBALL 2
|
||||
|
||||
void ms_adbcomplete __P((caddr_t buffer, caddr_t data_area, int adb_command));
|
||||
void ms_handoff __P((adb_event_t *event, struct ms_softc *));
|
||||
|
||||
#endif /* _MAC68K_MSVAR_H_ */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pm_direct.c,v 1.6 1998/08/12 05:42:44 scottr Exp $ */
|
||||
/* $NetBSD: pm_direct.c,v 1.7 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Takashi Hamada
|
||||
|
@ -220,6 +220,7 @@ struct adbCommand {
|
|||
};
|
||||
extern void adb_pass_up __P((struct adbCommand *));
|
||||
|
||||
extern int ite_polling; /* Are we polling? (Debugger mode) */
|
||||
|
||||
#if 0
|
||||
/*
|
||||
|
@ -1028,9 +1029,9 @@ pm_adb_op(buffer, compRout, data, command)
|
|||
packet.cmd = command;
|
||||
packet.unsol = 0;
|
||||
packet.ack_only = 1;
|
||||
adb_polling = 1;
|
||||
ite_polling = 1;
|
||||
adb_pass_up(&packet);
|
||||
adb_polling = 0;
|
||||
ite_polling = 0;
|
||||
}
|
||||
|
||||
rval = pmgrop(&pmdata);
|
||||
|
@ -1102,9 +1103,9 @@ pm_adb_get_TALK_result(pmdata)
|
|||
packet.compData = adbCompData;
|
||||
packet.unsol = 0;
|
||||
packet.ack_only = 0;
|
||||
adb_polling = 1;
|
||||
ite_polling = 1;
|
||||
adb_pass_up(&packet);
|
||||
adb_polling = 0;
|
||||
ite_polling = 0;
|
||||
|
||||
adbWaiting = 0;
|
||||
adbBuffer = (long)0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: adbsys.h,v 1.11 1998/08/11 20:07:59 briggs Exp $ */
|
||||
/* $NetBSD: adbsys.h,v 1.12 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1993, 1994 Allen K. Briggs, Chris P. Caputo,
|
||||
|
@ -161,6 +161,4 @@ typedef struct adb_listencmd_s{
|
|||
} adb_listencmd_t;
|
||||
#define ADBIOC_LISTENCMD _IOW('A', 133, adb_listencmd_t)
|
||||
|
||||
void adb_init __P((void));
|
||||
|
||||
#endif /* _ADBSYS_MACHINE_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: autoconf.c,v 1.47 1998/07/05 22:29:52 jonathan Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.48 1998/10/23 01:16:24 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -64,7 +64,6 @@
|
|||
#include <dev/cons.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/adbsys.h>
|
||||
#include <machine/viareg.h>
|
||||
|
||||
#include <dev/scsipi/scsi_all.h>
|
||||
|
@ -94,7 +93,7 @@ configure()
|
|||
extern int cold;
|
||||
|
||||
mrg_init(); /* Init Mac ROM Glue */
|
||||
startrtclock(); /* start before adb_init() */
|
||||
startrtclock(); /* start before ADB attached */
|
||||
|
||||
if (config_rootfound("mainbus", "mainbus") == NULL)
|
||||
panic("No mainbus found!");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: conf.c,v 1.45 1998/10/10 02:00:54 thorpej Exp $ */
|
||||
/* $NetBSD: conf.c,v 1.46 1998/10/23 01:16:25 ender Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -90,6 +90,7 @@ struct bdevsw bdevsw[] =
|
|||
int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
|
||||
|
||||
#define NADB 1 /* #include "adb.h" */
|
||||
#include "aed.h"
|
||||
#include "asc.h"
|
||||
#include "bpfilter.h"
|
||||
#include "ch.h"
|
||||
|
@ -102,11 +103,15 @@ int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
|
|||
#include "ss.h"
|
||||
#include "tun.h"
|
||||
#include "uk.h"
|
||||
#if 0
|
||||
#include "wskbd.h"
|
||||
#include "wsmouse.h"
|
||||
#endif
|
||||
#include "zsc.h"
|
||||
#include "zstty.h"
|
||||
#include "scsibus.h"
|
||||
|
||||
cdev_decl(adb);
|
||||
cdev_decl(aed);
|
||||
cdev_decl(asc);
|
||||
cdev_decl(bpf);
|
||||
cdev_decl(ccd);
|
||||
|
@ -117,11 +122,13 @@ cdev_decl(fd);
|
|||
cdev_decl(grf);
|
||||
cdev_decl(ipl);
|
||||
cdev_decl(ite);
|
||||
cdev_decl(kbd);
|
||||
cdev_decl(log);
|
||||
cdev_decl(md);
|
||||
#define mmread mmrw
|
||||
#define mmwrite mmrw
|
||||
cdev_decl(mm);
|
||||
cdev_decl(ms);
|
||||
#define ptcioctl ptyioctl
|
||||
#define ptctty ptytty
|
||||
cdev_decl(ptc);
|
||||
|
@ -136,6 +143,10 @@ cdev_decl(sw);
|
|||
cdev_decl(tun);
|
||||
cdev_decl(uk);
|
||||
cdev_decl(vnd);
|
||||
#if 0
|
||||
cdev_decl(wskbd);
|
||||
cdev_decl(wsmouse);
|
||||
#endif
|
||||
cdev_decl(zs);
|
||||
cdev_decl(zsc);
|
||||
cdev_decl(scsibus);
|
||||
|
@ -167,7 +178,7 @@ struct cdevsw cdevsw[] =
|
|||
cdev_disk_init(NCCD,ccd), /* 20: concatenated disk driver */
|
||||
cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-device */
|
||||
cdev_bpftun_init(NBPFILTER,bpf),/* 22: Berkeley packet filter */
|
||||
cdev_mouse_init(NADB,adb), /* 23: ADB event interface */
|
||||
cdev_mouse_init(NAED,aed), /* 23: ADB event device */
|
||||
cdev_bpftun_init(NTUN,tun), /* 24: network tunnel */
|
||||
cdev_lkm_init(NLKM,lkm), /* 25: loadable module driver */
|
||||
cdev_lkm_dummy(), /* 26 */
|
||||
|
@ -184,6 +195,11 @@ struct cdevsw cdevsw[] =
|
|||
cdev_se_init(NSE, se), /* 37: SCSI ethernet */
|
||||
cdev_rnd_init(NRND, rnd), /* 38: random source pseudo-device */
|
||||
cdev_scsibus_init(NSCSIBUS,scsibus), /* 39: SCSI bus */
|
||||
#if 0
|
||||
cdev_mouse_init(NWSKBD, wskbd), /* 40: wscons keyboard driver */
|
||||
cdev_mouse_init(NWSMOUSE,
|
||||
wsmouse), /* 41: wscons mouse driver */
|
||||
#endif
|
||||
};
|
||||
int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
|
||||
|
||||
|
@ -265,6 +281,8 @@ static int chrtoblktab[] = {
|
|||
/* 37 */ NODEV,
|
||||
/* 38 */ NODEV,
|
||||
/* 39 */ NODEV,
|
||||
/* 40 */ NODEV,
|
||||
/* 41 */ NODEV,
|
||||
};
|
||||
|
||||
dev_t
|
||||
|
|
Loading…
Reference in New Issue