Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/macppc/dev Sync with mac68k.



details:   https://anonhg.NetBSD.org/src/rev/78d511f4b9ee
branches:  trunk
changeset: 500827:78d511f4b9ee
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Tue Dec 19 02:50:11 2000 +0000

description:
Sync with mac68k.

diffstat:

 sys/arch/macppc/dev/adb.c        |   22 +---
 sys/arch/macppc/dev/adb_direct.c |   42 ++++++--
 sys/arch/macppc/dev/adbvar.h     |   28 +-----
 sys/arch/macppc/dev/akbd.c       |   64 +++---------
 sys/arch/macppc/dev/ams.c        |  187 +++++++++++++-------------------------
 5 files changed, 124 insertions(+), 219 deletions(-)

diffs (truncated from 702 to 300 lines):

diff -r 12237a7326b9 -r 78d511f4b9ee sys/arch/macppc/dev/adb.c
--- a/sys/arch/macppc/dev/adb.c Tue Dec 19 01:59:21 2000 +0000
+++ b/sys/arch/macppc/dev/adb.c Tue Dec 19 02:50:11 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adb.c,v 1.6 1999/08/16 06:28:09 tsubai Exp $   */
+/*     $NetBSD: adb.c,v 1.7 2000/12/19 02:50:11 tsubai Exp $   */
 
 /*-
  * Copyright (C) 1994  Bradley A. Grantham
@@ -162,8 +162,8 @@
 
 int
 adbprint(args, name)
-        void *args;
-        const char *name;
+       void *args;
+       const char *name;
 {
        struct adb_attach_args *aa_args = (struct adb_attach_args *)args;
        int rv = UNCONF;
@@ -172,7 +172,7 @@
                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);
+               printf("%s addr %d: ", name, aa_args->adbaddr);
                switch(aa_args->origaddr) {
 #ifdef DIAGNOSTIC
                case 0:
@@ -226,17 +226,7 @@
 #endif /* DIAGNOSTIC */
                }
        } else          /* a device matched and was configured */
-                printf(" addr %d: ", aa_args->origaddr);
-
-       return (rv);
-}
+                printf(" addr %d: ", aa_args->adbaddr);
 
-void
-extdms_complete(buffer, compdata, cmd)
-       caddr_t buffer, compdata;
-       int cmd;
-{
-       long *p = (long *)compdata;
-
-       *p= -1;
+       return rv;
 }
diff -r 12237a7326b9 -r 78d511f4b9ee sys/arch/macppc/dev/adb_direct.c
--- a/sys/arch/macppc/dev/adb_direct.c  Tue Dec 19 01:59:21 2000 +0000
+++ b/sys/arch/macppc/dev/adb_direct.c  Tue Dec 19 02:50:11 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adb_direct.c,v 1.14 2000/06/08 22:10:45 tsubai Exp $   */
+/*     $NetBSD: adb_direct.c,v 1.15 2000/12/19 02:50:11 tsubai Exp $   */
 
 /* From: adb_direct.c 2.02 4/18/97 jpw */
 
@@ -1609,7 +1609,6 @@
        }
 }
 
-
 /*
  * adb_op_sync
  *
@@ -1624,19 +1623,41 @@
 int
 adb_op_sync(Ptr buffer, Ptr compRout, Ptr data, short command)
 {
+       int tmout;
        int result;
        volatile int flag = 0;
 
        result = adb_op(buffer, (void *)adb_op_comprout,
            (void *)&flag, command);    /* send command */
-       if (result == 0)                /* send ok? */
-               while (0 == flag)
-                       /* wait for compl. routine */;
+       if (result == 0) {              /* send ok? */
+               /*
+                * Total time to wait is calculated as follows:
+                *  - Tlt (stop to start time): 260 usec
+                *  - start bit: 100 usec
+                *  - up to 8 data bytes: 64 * 100 usec = 6400 usec
+                *  - stop bit (with SRQ): 140 usec
+                * Total: 6900 usec
+                *
+                * This is the total time allowed by the specification.  Any
+                * device that doesn't conform to this will fail to operate
+                * properly on some Apple systems.  In spite of this we
+                * double the time to wait; some Cuda-based apparently
+                * queues some commands and allows the main CPU to continue
+                * processing (radical concept, eh?).  To be safe, allow
+                * time for two complete ADB transactions to occur.
+                */
+               for (tmout = 13800; !flag && tmout >= 10; tmout -= 10)
+                       delay(10);
+               if (!flag && tmout > 0)
+                       delay(tmout);
+
+               if (!flag)
+                       result = -2;
+       }
 
        return result;
 }
 
-
 /*
  * adb_op_comprout
  *
@@ -2137,14 +2158,13 @@
        volatile int flag = 0;
        int result;
        u_char output[16];
-       extern void adb_op_comprout();
 
        output[0] = 0x03;       /* 3-byte message */
        output[1] = 0x01;       /* to pram/rtc device */
        output[2] = 0x01;       /* cuda autopoll */
        output[3] = 0x01;
-       result = send_adb_cuda(output, output, adb_op_comprout,
-               (void *)&flag, 0);
+       result = send_adb_cuda(output, output, adb_op_comprout, (void *)&flag,
+                              0);
        if (result != 0)        /* exit if not sent */
                return;
 
@@ -2154,7 +2174,6 @@
 void
 adb_restart()
 {
-       volatile int flag = 0;
        int result;
        u_char output[16];
 
@@ -2165,8 +2184,7 @@
                output[0] = 0x02;       /* 2 byte message */
                output[1] = 0x01;       /* to pram/rtc/soft-power device */
                output[2] = 0x11;       /* restart */
-               result = send_adb_cuda((u_char *)output, (u_char *)0,
-                                      (void *)0, (void *)0, (int)0);
+               result = send_adb_cuda(output, NULL, NULL, NULL, 0);
                if (result != 0)        /* exit if not sent */
                        return;
                while (1);              /* not return */
diff -r 12237a7326b9 -r 78d511f4b9ee sys/arch/macppc/dev/adbvar.h
--- a/sys/arch/macppc/dev/adbvar.h      Tue Dec 19 01:59:21 2000 +0000
+++ b/sys/arch/macppc/dev/adbvar.h      Tue Dec 19 02:50:11 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adbvar.h,v 1.3 2000/06/08 22:10:46 tsubai Exp $        */
+/*     $NetBSD: adbvar.h,v 1.4 2000/12/19 02:50:11 tsubai Exp $        */
 
 /*-
  * Copyright (C) 1994  Bradley A. Grantham
@@ -83,28 +83,6 @@
        char *sc_regbase;
 };
 
-
-/* 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));
-int    adbwrite __P((dev_t dev, struct uio *uio, int flag));
-int    adbioctl __P((dev_t , int , caddr_t , int , struct proc *));
-int    adbpoll __P((dev_t dev, int events, struct proc *p));
-
-/* 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));
-void   extdms_complete __P((caddr_t, caddr_t, int));
-
 /* 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 */
@@ -117,7 +95,6 @@
 #define ADBLISTEN(dev, reg)    ((((u_int8_t)(dev) & 0x0f) << 4) | 0x08 | (reg))
 #define ADBTALK(dev, reg)      ((((u_int8_t)(dev) & 0x0f) << 4) | 0x0c | (reg))
 
-/* adb_direct.c */
 int    adb_poweroff __P((void));
 int    CountADBs __P((void));
 void   ADBReInit __P((void));
@@ -127,3 +104,6 @@
 int    ADBOp __P((Ptr buffer, Ptr compRout, Ptr data, short commandNum));
 int    adb_read_date_time __P((unsigned long *t));
 int    adb_set_date_time __P((unsigned long t));
+
+int    adb_op_sync __P((Ptr, Ptr, Ptr, short));
+void   adb_op_comprout __P((caddr_t, caddr_t, int));
diff -r 12237a7326b9 -r 78d511f4b9ee sys/arch/macppc/dev/akbd.c
--- a/sys/arch/macppc/dev/akbd.c        Tue Dec 19 01:59:21 2000 +0000
+++ b/sys/arch/macppc/dev/akbd.c        Tue Dec 19 02:50:11 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: akbd.c,v 1.10 2000/09/01 16:00:38 tsubai Exp $ */
+/*     $NetBSD: akbd.c,v 1.11 2000/12/19 02:50:11 tsubai Exp $ */
 
 /*
  * Copyright (C) 1998  Colin Wood
@@ -52,7 +52,6 @@
 #include <macppc/dev/aedvar.h>
 #include <macppc/dev/akbdmap.h>
 #include <macppc/dev/akbdvar.h>
-#include <macppc/dev/amsvar.h>
 
 #include "aed.h"
 
@@ -69,11 +68,6 @@
 static void    blinkleds __P((struct akbd_softc *));
 #endif
 
-/*
- * Local variables.
- */
-static volatile int kbd_done;  /* Did ADBOp() complete? */
-
 /* Driver definition. */
 struct cfattach akbd_ca = {
        sizeof(struct akbd_softc), akbdmatch, akbdattach
@@ -132,7 +126,7 @@
        ADBSetInfoBlock adbinfo;
        struct akbd_softc *sc = (struct akbd_softc *)self;
        struct adb_attach_args *aa_args = (struct adb_attach_args *)aux;
-       int count, error;
+       int error, kbd_done;
        short cmd;
        u_char buffer[9];
        struct wskbddev_attach_args a;
@@ -154,15 +148,9 @@
                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);
+               cmd = ADBTALK(sc->adbaddr, 1);
+               kbd_done =
+                   (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd) == 0);
 
                /* Ignore Logitech MouseMan/Trackman pseudo keyboard */
                if (kbd_done && buffer[1] == 0x9a && buffer[2] == 0x20) {
@@ -241,7 +229,7 @@
        error = SetADBInfo(&adbinfo, sc->adbaddr);
 #ifdef ADB_DEBUG
        if (adb_debug)
-               printf("kbd: returned %d from SetADBInfo\n", error);
+               printf("akbd: returned %d from SetADBInfo\n", error);
 #endif
 
        a.console = akbd_is_console;
@@ -273,7 +261,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;
@@ -284,7 +272,7 @@
 
 #ifdef ADB_DEBUG
        if (adb_debug) {
-               printf("kbd: from %d at %d (org %d) %d:", event.addr,
+               printf("akbd: 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]);
@@ -341,15 +329,11 @@
 
        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)
+       cmd = ADBTALK(addr, 2);
+       if (adb_op_sync((Ptr)buffer, (Ptr)0, (Ptr)0, cmd) == 0 &&
+           buffer[0] > 0)



Home | Main Index | Thread Index | Old Index