Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/dreamcast/dev/maple Added subunit scan.



details:   https://anonhg.NetBSD.org/src/rev/13e1a14d7500
branches:  trunk
changeset: 503251:13e1a14d7500
user:      marcus <marcus%NetBSD.org@localhost>
date:      Sat Feb 03 23:25:51 2001 +0000

description:
Added subunit scan.

diffstat:

 sys/arch/dreamcast/dev/maple/maple.c    |  96 ++++++++++++++++++++++++--------
 sys/arch/dreamcast/dev/maple/maplevar.h |   4 +-
 2 files changed, 73 insertions(+), 27 deletions(-)

diffs (174 lines):

diff -r 6b46111307a6 -r 13e1a14d7500 sys/arch/dreamcast/dev/maple/maple.c
--- a/sys/arch/dreamcast/dev/maple/maple.c      Sat Feb 03 23:24:30 2001 +0000
+++ b/sys/arch/dreamcast/dev/maple/maple.c      Sat Feb 03 23:25:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: maple.c,v 1.4 2001/01/31 00:14:30 thorpej Exp $        */
+/*     $NetBSD: maple.c,v 1.5 2001/02/03 23:25:51 marcus Exp $ */
 
 /*-
  * Copyright (c) 2001 Marcus Comstedt
@@ -55,7 +55,7 @@
 #include <dreamcast/dev/maple/maplereg.h>
 
 
-#define MAPLE_CALLOUT_TICKS 1
+#define MAPLE_CALLOUT_TICKS 2
 
 /*
  * Function declarations.
@@ -197,7 +197,7 @@
 maple_scanbus(sc)
        struct maple_softc *sc;
 {
-       int p;
+       int p, s;
 
        maple_polling = 1;
 
@@ -215,20 +215,58 @@
            ;
 
          for (p = 0; p < MAPLE_PORTS; p++)
-           if ((sc->sc_rxbuf[p][0][0] & 0xff) == MAPLE_RESPONSE_DEVINFO) {
+           if ((sc->sc_rxbuf[p][0][0] & 0xff) == MAPLE_RESPONSE_DEVINFO)
+
+             sc->sc_port_units[p] = ((sc->sc_rxbuf[p][0][0]>>16)&0x1f)|1;
+
+           else
+
+             sc->sc_port_units[p] = 0;
+
+
+         maple_begin_txbuf(sc);
 
-             u_int32_t *to_swap;
-             int i;
+         for (p = 0; p < MAPLE_PORTS; p++) {
+           for (s = 0; s < MAPLE_SUBUNITS; s++) {
+             if (sc->sc_port_units[p] & (1<<s))
+               maple_write_command(sc, p, s, MAPLE_COMMAND_DEVINFO, 0, NULL);
+           }
+         }
+
+         if (maple_end_txbuf(sc)) {
+
+           MAPLE_DMAADDR = sc->sc_txbuf_phys;
+           MAPLE_STATE = 1;
+           while (MAPLE_STATE != 0)
+             ;
 
-             bcopy(sc->sc_rxbuf[p][0]+1,
-                   (to_swap = &sc->sc_unit[p][0].devinfo.di_func),
-                   sizeof(struct maple_devinfo));
+           for (p = 0; p < MAPLE_PORTS; p++)
+             for (s = 0; s < MAPLE_SUBUNITS; s++)
+               if (sc->sc_port_units[p] & (1<<s)) {
+
+                 if ((sc->sc_rxbuf[p][s][0] & 0xff) ==
+                     MAPLE_RESPONSE_DEVINFO) {
 
-             for (i = 0; i < 4; i++, to_swap++)
-               *to_swap = ntohl(*to_swap);
+                   u_int32_t *to_swap;
+                   int i;
+                   
+                   bcopy(sc->sc_rxbuf[p][s]+1,
+                         (to_swap = &sc->sc_unit[p][s].devinfo.di_func),
+                         sizeof(struct maple_devinfo));
+                   
+                   for (i = 0; i < 4; i++, to_swap++)
+                     *to_swap = ntohl(*to_swap);
+                   
+                   maple_attach_dev(sc, p, s);
 
-             maple_attach_dev(sc, p, 0);
-           }
+                 } else {
+
+                   printf("%s: no response from port %d subunit %d\n",
+                          sc->sc_dev.dv_xname, p, s);
+                 }
+               }
+           
+         }
 
        }
 
@@ -240,7 +278,7 @@
 maple_send_commands(sc)
        struct maple_softc *sc;
 {
-       int p;
+       int p, s;
 
        if (sc->maple_commands_pending || MAPLE_STATE != 0)
          return;
@@ -249,11 +287,15 @@
 
        for (p = 0; p < MAPLE_PORTS; p++) {
 
-         if (sc->sc_unit[p][0].getcond_callback != NULL) {
+         for (s = 0; s < MAPLE_SUBUNITS; s++) {
+
+           if (sc->sc_unit[p][s].getcond_callback != NULL) {
 
-           u_int32_t func = ntohl(sc->sc_unit[p][0].getcond_func);
+             u_int32_t func = ntohl(sc->sc_unit[p][s].getcond_func);
+             
+             maple_write_command(sc, p, s, MAPLE_COMMAND_GETCOND, 1, &func);
 
-           maple_write_command(sc, p, 0, MAPLE_COMMAND_GETCOND, 1, &func);
+           }
 
          }
 
@@ -272,20 +314,22 @@
 maple_check_responses(sc)
        struct maple_softc *sc;
 {
-       int p;
+       int p, s;
 
        if (!sc->maple_commands_pending || MAPLE_STATE != 0)
          return;
 
        for (p = 0; p < MAPLE_PORTS; p++) {
-         struct maple_unit * u = &sc->sc_unit[p][0];
-         if (u->getcond_callback != NULL &&
-             (sc->sc_rxbuf[p][0][0] & 0xff) == MAPLE_RESPONSE_DATATRF &&
-             (sc->sc_rxbuf[p][0][0]>>24) >= 1 &&
-             htonl(sc->sc_rxbuf[p][0][1]) == u->getcond_func) {
-           (*u->getcond_callback)(u->getcond_data,
-                                  (void *)(sc->sc_rxbuf[p][0]+2),
-                                  ((sc->sc_rxbuf[p][0][0]>>22)&1020)-4);
+         for (s = 0; s < MAPLE_SUBUNITS; s++) {
+           struct maple_unit * u = &sc->sc_unit[p][s];
+           if (u->getcond_callback != NULL &&
+               (sc->sc_rxbuf[p][s][0] & 0xff) == MAPLE_RESPONSE_DATATRF &&
+               (sc->sc_rxbuf[p][s][0]>>24) >= 1 &&
+               htonl(sc->sc_rxbuf[p][s][1]) == u->getcond_func) {
+             (*u->getcond_callback)(u->getcond_data,
+                                    (void *)(sc->sc_rxbuf[p][s]+2),
+                                    ((sc->sc_rxbuf[p][s][0]>>22)&1020)-4);
+           }
          }
        }
 
diff -r 6b46111307a6 -r 13e1a14d7500 sys/arch/dreamcast/dev/maple/maplevar.h
--- a/sys/arch/dreamcast/dev/maple/maplevar.h   Sat Feb 03 23:24:30 2001 +0000
+++ b/sys/arch/dreamcast/dev/maple/maplevar.h   Sat Feb 03 23:25:51 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: maplevar.h,v 1.2 2001/01/21 22:45:58 marcus Exp $ */
+/* $NetBSD: maplevar.h,v 1.3 2001/02/03 23:25:51 marcus Exp $ */
 /*-
  * Copyright (c) 2001 Marcus Comstedt
  * All rights reserved.
@@ -39,6 +39,8 @@
        struct callout maple_callout_ch;
        int maple_commands_pending;
 
+       int sc_port_units[MAPLE_PORTS];
+
        struct maple_unit sc_unit[MAPLE_PORTS][MAPLE_SUBUNITS];
 
        u_int32_t *sc_txbuf;    /* start of allocated transmit buffer */



Home | Main Index | Thread Index | Old Index