Add and use macros to build ADB FLUSH, LISTEN, and TALK commands.

This commit is contained in:
scottr 2000-03-19 07:37:58 +00:00
parent 893f3574fb
commit 4f29e4d330
6 changed files with 47 additions and 54 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: adb_direct.c,v 1.40 2000/03/18 08:07:50 scottr Exp $ */
/* $NetBSD: adb_direct.c,v 1.41 2000/03/19 07:37:58 scottr Exp $ */
/* From: adb_direct.c 2.02 4/18/97 jpw */
@ -810,7 +810,7 @@ switch_start:
}
#endif
adbLastDevice = (adbInputBuffer[1] & 0xf0) >> 4;
adbLastDevice = ADB_CMDADDR(adbInputBuffer[1]);
if (adbInputBuffer[0] == 1 && !adbWaiting) { /* SRQ!!!*/
#ifdef ADB_DEBUG
@ -824,8 +824,7 @@ switch_start:
adbLastDevice);
#endif
adbOutputBuffer[0] = 1;
adbOutputBuffer[1] =
((adbLastDevice & 0x0f) << 4) | 0x0c;
adbOutputBuffer[1] = ADBTALK(adbLastDevice, 0);
adbSentChars = 0; /* nothing sent yet */
adbActionState = ADB_ACTION_POLLING; /* set next state */
@ -997,7 +996,8 @@ switch_start:
} else {
/* send talk to last device instead */
adbOutputBuffer[0] = 1;
adbOutputBuffer[1] = (adbOutputBuffer[1] & 0xf0) | 0x0c;
adbOutputBuffer[1] =
ADBTALK(ADB_CMDADDR(adbOutputBuffer[1]), 0);
adbSentChars = 0; /* nothing sent yet */
adbActionState = ADB_ACTION_IDLE; /* set next state */
@ -1670,7 +1670,7 @@ adb_pass_up(struct adbCommand *in)
if (adbStarting)
return;
/* get device's comp. routine and data area */
if (-1 == get_adb_info(&block, ((cmd & 0xf0) >> 4)))
if (-1 == get_adb_info(&block, ADB_CMDADDR(cmd)))
return;
}
}
@ -2148,11 +2148,10 @@ adb_reinit(void)
/* initial scan through the devices */
for (i = 1; i < 16; i++) {
command = ((int)(i & 0xf) << 4) | 0xf; /* talk R3 */
command = ADBTALK(i, 3);
result = adb_op_sync((Ptr)send_string, (Ptr)0,
(Ptr)0, (short)command);
/* anything come back? */
if (send_string[0] != 0) {
/* check for valid device handler */
switch (send_string[2]) {
@ -2201,12 +2200,12 @@ adb_reinit(void)
#endif
/* send TALK R3 to address */
command = ((int)(device & 0xf) << 4) | 0xf;
command = ADBTALK(device, 3);
adb_op_sync((Ptr)send_string, (Ptr)0,
(Ptr)0, (short)command);
/* move device to higher address */
command = ((int)(device & 0xf) << 4) | 0xb;
command = ADBLISTEN(device, 3);
send_string[0] = 2;
send_string[1] = (u_char)(saveptr | 0x60);
send_string[2] = 0xfe;
@ -2215,7 +2214,7 @@ adb_reinit(void)
delay(500);
/* send TALK R3 - anthing at new address? */
command = ((int)(saveptr & 0xf) << 4) | 0xf;
command = ADBTALK(saveptr, 3);
adb_op_sync((Ptr)send_string, (Ptr)0,
(Ptr)0, (short)command);
delay(500);
@ -2229,7 +2228,7 @@ adb_reinit(void)
}
/* send TALK R3 - anything at old address? */
command = ((int)(device & 0xf) << 4) | 0xf;
command = ADBTALK(device, 3);
result = adb_op_sync((Ptr)send_string, (Ptr)0,
(Ptr)0, (short)command);
if (send_string[0] != 0) {
@ -2291,7 +2290,7 @@ adb_reinit(void)
printf_intr("moving back...\n");
#endif
/* move old device back */
command = ((int)(saveptr & 0xf) << 4) | 0xb;
command = ADBLISTEN(saveptr, 3);
send_string[0] = 2;
send_string[1] = (u_char)(device | 0x60);
send_string[2] = 0xfe;

View File

@ -1,4 +1,4 @@
/* $NetBSD: adbsys.c,v 1.42 1999/11/07 08:08:10 scottr Exp $ */
/* $NetBSD: adbsys.c,v 1.43 2000/03/19 07:44:58 scottr Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -65,7 +65,7 @@ adb_complete(buffer, data_area, adb_command)
printf("adb: transaction completion\n");
#endif
adbaddr = (adb_command & 0xf0) >> 4;
adbaddr = ADB_CMDADDR(adb_command);
error = GetADBInfo(&adbdata, adbaddr);
#ifdef ADB_DEBUG
if (adb_debug)
@ -110,7 +110,7 @@ adb_msa3_complete(buffer, data_area, adb_command)
printf("adb: transaction completion\n");
#endif
adbaddr = (adb_command & 0xf0) >> 4;
adbaddr = ADB_CMDADDR(adb_command);
error = GetADBInfo(&adbdata, adbaddr);
#ifdef ADB_DEBUG
if (adb_debug)
@ -156,7 +156,7 @@ adb_mm_nonemp_complete(buffer, data_area, adb_command)
printf("adb: transaction completion\n");
#endif
adbaddr = (adb_command & 0xf0) >> 4;
adbaddr = ADB_CMDADDR(adb_command);
error = GetADBInfo(&adbdata, adbaddr);
#ifdef ADB_DEBUG
if (adb_debug)
@ -228,7 +228,7 @@ extdms_init(totaladbs)
(adbdata.devType == ADBMS_USPEED ||
adbdata.devType == ADBMS_UCONTOUR)) {
/* Found MicroSpeed Mouse Deluxe Mac or Contour Mouse */
cmd = ((adbaddr<<4)&0xF0)|0x9; /* listen 1 */
cmd = ADBLISTEN(adbaddr, 1);
/*
* To setup the MicroSpeed or the Contour, it appears
@ -264,10 +264,8 @@ extdms_init(totaladbs)
(adbdata.devType == ADBMS_100DPI ||
adbdata.devType == ADBMS_200DPI)) {
/* found a mouse */
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
cmd = ADBTALK(adbaddr, 3);
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
@ -287,7 +285,7 @@ extdms_init(totaladbs)
/* Attempt to initialize Extended Mouse Protocol */
buffer[2] = '\004'; /* make handler ID 4 */
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x08; /* listen command */
cmd = ADBLISTEN(adbaddr, 3);
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -297,9 +295,8 @@ extdms_init(totaladbs)
* Check to see if successful, if not
* try to initialize it as other types
*/
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
cmd = ADBTALK(adbaddr, 3);
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -309,7 +306,7 @@ extdms_init(totaladbs)
/* Attempt to initialize as an A3 mouse */
buffer[2] = 0x03; /* make handler ID 3 */
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x08; /* listen command */
cmd = ADBLISTEN(adbaddr, 3);
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -319,9 +316,8 @@ extdms_init(totaladbs)
* Check to see if successful, if not
* try to initialize it as other types
*/
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
cmd = ADBTALK(adbaddr, 3);
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -329,7 +325,7 @@ extdms_init(totaladbs)
if (buffer[2] == ADBMS_MSA3) {
/* Initialize as above */
cmd = ((adbaddr << 4) & 0xF0) | 0xA;
cmd = ADBLISTEN(adbaddr, 2);
/* listen 2 */
buffer[0] = 3;
buffer[1] = 0x00;

View File

@ -1,4 +1,4 @@
/* $NetBSD: adbvar.h,v 1.17 1999/11/07 08:22:50 scottr Exp $ */
/* $NetBSD: adbvar.h,v 1.18 2000/03/19 07:44:58 scottr Exp $ */
/*
* Copyright (C) 1994 Bradley A. Grantham
@ -87,6 +87,11 @@ void extdms_complete __P((void));
#define ADB_HW_IOP 0x5 /* Machines with an IOP */
#define MAX_ADB_HW 5 /* Number of ADB hardware types */
#define ADB_CMDADDR(cmd) ((u_int8_t)(cmd & 0xf0) >> 4)
#define ADBFLUSH(dev) ((((u_int8_t)dev & 0x0f) << 4) | 0x01)
#define ADBLISTEN(dev, reg) ((((u_int8_t)dev & 0x0f) << 4) | 0x08 | reg)
#define ADBTALK(dev, reg) ((((u_int8_t)dev & 0x0f) << 4) | 0x0c | reg)
#ifndef MRG_ADB
/* adb_direct.c */
int adb_poweroff __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: akbd.c,v 1.6 2000/02/17 02:07:07 ender Exp $ */
/* $NetBSD: akbd.c,v 1.7 2000/03/19 07:37:58 scottr Exp $ */
/*
* Copyright (C) 1998 Colin Wood
@ -161,7 +161,7 @@ akbdattach(parent, self, aux)
break;
case ADB_EXTKBD:
kbd_done = 0;
cmd = (((sc->adbaddr << 4) & 0xf0) | 0x0d ); /* talk R1 */
cmd = ADBTALK(sc->adbaddr, 1);
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&kbd_done, cmd);
@ -278,7 +278,7 @@ kbd_adbcomplete(buffer, data_area, adb_command)
printf("adb: transaction completion\n");
#endif
adbaddr = (adb_command & 0xf0) >> 4;
adbaddr = ADB_CMDADDR(adb_command);
ksc = (struct akbd_softc *)data_area;
event.addr = adbaddr;
@ -356,8 +356,7 @@ getleds(addr)
buffer[0] = 0;
kbd_done = 0;
/* talk R2 */
cmd = ((addr & 0xf) << 4) | 0x0c | 0x02;
cmd = ADBTALK(addr, 2);
ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&kbd_done, cmd);
while (!kbd_done)
/* busy-wait until done */ ;
@ -390,8 +389,7 @@ setleds(ksc, leds)
buffer[0] = 0;
kbd_done = 0;
/* talk R2 */
cmd = ((addr & 0xf) << 4) | 0x0c | 0x02;
cmd = ADBTALK(addr, 2);
ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&kbd_done, cmd);
while (!kbd_done)
/* busy-wait until done */ ;
@ -403,14 +401,13 @@ setleds(ksc, leds)
buffer[2] &= 0xf8;
buffer[2] |= leds;
/* listen R2 */
cmd = ((addr & 0xf) << 4) | 0x08 | 0x02;
cmd = ADBLISTEN(addr, 2);
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;
cmd = ADBTALK(addr, 2);
ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&kbd_done, cmd);
while (!kbd_done)
/* busy-wait until done */ ;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ams.c,v 1.6 2000/02/14 07:01:46 scottr Exp $ */
/* $NetBSD: ams.c,v 1.7 2000/03/19 07:37:58 scottr Exp $ */
/*
* Copyright (C) 1998 Colin Wood
@ -230,7 +230,7 @@ ems_init(sc)
if (sc->handler_id == ADBMS_USPEED ||
sc->handler_id == ADBMS_UCONTOUR) {
/* Found MicroSpeed Mouse Deluxe Mac or Contour Mouse */
cmd = ((adbaddr<<4)&0xF0)|0x9; /* listen 1 */
cmd = ADBLISTEN(adbaddr, 1);
/*
* To setup the MicroSpeed or the Contour, it appears
@ -269,10 +269,8 @@ ems_init(sc)
if ((sc->handler_id == ADBMS_100DPI) ||
(sc->handler_id == ADBMS_200DPI)) {
/* found a mouse */
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
cmd = ADBTALK(adbaddr, 3);
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
@ -292,7 +290,7 @@ ems_init(sc)
/* Attempt to initialize Extended Mouse Protocol */
buffer[2] = '\004'; /* make handler ID 4 */
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x08; /* listen command */
cmd = ADBLISTEN(adbaddr, 3);
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -302,9 +300,8 @@ ems_init(sc)
* Check to see if successful, if not
* try to initialize it as other types
*/
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
cmd = ADBTALK(adbaddr, 3);
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -379,7 +376,7 @@ ems_init(sc)
/* Attempt to initialize as an A3 mouse */
buffer[2] = 0x03; /* make handler ID 3 */
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x08; /* listen command */
cmd = ADBLISTEN(adbaddr, 3);
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -389,9 +386,8 @@ ems_init(sc)
* Check to see if successful, if not
* try to initialize it as other types
*/
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
cmd = ADBTALK(adbaddr, 3);
extdms_done = 0;
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
(Ptr)&extdms_done, cmd);
while (!extdms_done)
@ -400,7 +396,7 @@ ems_init(sc)
if (buffer[2] == ADBMS_MSA3) {
sc->handler_id = ADBMS_MSA3;
/* Initialize as above */
cmd = ((adbaddr << 4) & 0xF0) | 0xA;
cmd = ADBLISTEN(adbaddr, 2);
/* listen 2 */
buffer[0] = 3;
buffer[1] = 0x00;
@ -444,7 +440,7 @@ ms_adbcomplete(buffer, data_area, adb_command)
printf("adb: transaction completion\n");
#endif
adbaddr = (adb_command & 0xf0) >> 4;
adbaddr = ADB_CMDADDR(adb_command);
amsc = (struct ams_softc *)data_area;
if ((amsc->handler_id == ADBMS_EXTENDED) && (amsc->sc_devid[0] == 0)) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pm_direct.c,v 1.10 1999/11/07 00:12:56 scottr Exp $ */
/* $NetBSD: pm_direct.c,v 1.11 2000/03/19 07:37:58 scottr Exp $ */
/*
* Copyright (C) 1997 Takashi Hamada
@ -1164,7 +1164,7 @@ pm_adb_poll_next_device_pm1(pmdata)
/* find another existent ADB device to poll */
for (i = 1; i < 16; i++) {
ndid = (((pmdata->data[3] & 0xf0) >> 4) + i) & 0xf;
ndid = (ADB_CMDADDR(pmdata->data[3]) + i) & 0xf;
bendid <<= ndid;
if ((pm_existent_ADB_devices & bendid) != 0)
break;