Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mac68k/dev Add and use macros to build ADB FLUSH, L...



details:   https://anonhg.NetBSD.org/src/rev/a8005b6f96e1
branches:  trunk
changeset: 483819:a8005b6f96e1
user:      scottr <scottr%NetBSD.org@localhost>
date:      Sun Mar 19 07:37:58 2000 +0000

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

diffstat:

 sys/arch/mac68k/dev/adb_direct.c |  25 ++++++++++++-------------
 sys/arch/mac68k/dev/adbsys.c     |  26 +++++++++++---------------
 sys/arch/mac68k/dev/adbvar.h     |   7 ++++++-
 sys/arch/mac68k/dev/akbd.c       |  17 +++++++----------
 sys/arch/mac68k/dev/ams.c        |  22 +++++++++-------------
 sys/arch/mac68k/dev/pm_direct.c  |   4 ++--
 6 files changed, 47 insertions(+), 54 deletions(-)

diffs (truncated from 399 to 300 lines):

diff -r 112ee576b617 -r a8005b6f96e1 sys/arch/mac68k/dev/adb_direct.c
--- a/sys/arch/mac68k/dev/adb_direct.c  Sun Mar 19 06:31:17 2000 +0000
+++ b/sys/arch/mac68k/dev/adb_direct.c  Sun Mar 19 07:37:58 2000 +0000
@@ -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 @@
                        }
 #endif
 
-                       adbLastDevice = (adbInputBuffer[1] & 0xf0) >> 4;
+                       adbLastDevice = ADB_CMDADDR(adbInputBuffer[1]);
                        
                        if (adbInputBuffer[0] == 1 && !adbWaiting) {    /* SRQ!!!*/
 #ifdef ADB_DEBUG
@@ -824,8 +824,7 @@
                                            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 @@
                        } 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 @@
                        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 @@
 
        /* 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 @@
 #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 @@
                        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 @@
                        }
 
                        /* 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 @@
                                        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;
diff -r 112ee576b617 -r a8005b6f96e1 sys/arch/mac68k/dev/adbsys.c
--- a/sys/arch/mac68k/dev/adbsys.c      Sun Mar 19 06:31:17 2000 +0000
+++ b/sys/arch/mac68k/dev/adbsys.c      Sun Mar 19 07:37:58 2000 +0000
@@ -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 @@
                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 @@
                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 @@
                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 @@
                    (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 @@
                    (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 @@
                        /* 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 @@
                         * 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 @@
                                /* 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 @@
                                 * 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 @@
                                        
                                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;
diff -r 112ee576b617 -r a8005b6f96e1 sys/arch/mac68k/dev/adbvar.h
--- a/sys/arch/mac68k/dev/adbvar.h      Sun Mar 19 06:31:17 2000 +0000
+++ b/sys/arch/mac68k/dev/adbvar.h      Sun Mar 19 07:37:58 2000 +0000
@@ -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 @@
 #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));
diff -r 112ee576b617 -r a8005b6f96e1 sys/arch/mac68k/dev/akbd.c
--- a/sys/arch/mac68k/dev/akbd.c        Sun Mar 19 06:31:17 2000 +0000
+++ b/sys/arch/mac68k/dev/akbd.c        Sun Mar 19 07:37:58 2000 +0000
@@ -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 @@
                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 @@
                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 @@
        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 @@
        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 @@
        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 */ ;
diff -r 112ee576b617 -r a8005b6f96e1 sys/arch/mac68k/dev/ams.c
--- a/sys/arch/mac68k/dev/ams.c Sun Mar 19 06:31:17 2000 +0000
+++ b/sys/arch/mac68k/dev/ams.c Sun Mar 19 07:37:58 2000 +0000
@@ -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 $   */
 



Home | Main Index | Thread Index | Old Index