Subject: Re: mmem woes
To: None <port-dreamcast@netbsd.org>
From: ITOH Yasufumi <itohy@netbsd.org>
List: port-dreamcast
Date: 02/09/2003 11:17:54
logix@foobar.franken.de writes:

> mapleA1: ping response -1
> mapleA1: remove
> mapleA1: detaching func 1
> mmem0 detached

Mmm, the device does not respond at all for pinging (by GETCOND command).
Does this change help?
-- 
ITOH Yasufumi

Index: maple.c
===================================================================
RCS file: /cvsroot/src/sys/arch/dreamcast/dev/maple/maple.c,v
retrieving revision 1.23
diff -p -u -r1.23 maple.c
--- maple.c	2003/01/01 01:28:29	1.23
+++ maple.c	2003/02/09 02:11:06
@@ -957,15 +957,45 @@ maple_unit_ping(struct maple_softc *sc)
 {
 	struct maple_unit *u;
 	struct maple_func *fn;
+#define MAPLE_MEMCARD_PING_HACK
+#ifdef MAPLE_MEMCARD_PING_HACK
+	static u_int32_t memcard_ping_arg[2] = {
+		0x02000000,	/* htonl(MAPLE_FUNC(MAPLE_FN_MEMCARD)) */
+		0		/* pt (1 byte) and unused 3 bytes */
+	};
+#endif
 
 	if ((u = TAILQ_FIRST(&sc->sc_pingq)) != NULL) {
 		KASSERT(u->u_queuestat == MAPLE_QUEUE_PING);
 		maple_remove_from_queues(sc, u);
 		if (u->u_dma_stat == MAPLE_DMA_IDLE && u->u_noping == 0) {
-			fn = &u->u_func[u->u_ping_func];
-			fn->f_work = htonl(MAPLE_FUNC(u->u_ping_func));
-			maple_write_command(sc, u, MAPLE_COMMAND_GETCOND,
-			    1, &fn->f_work);
+#ifdef MAPLE_MEMCARD_PING_HACK
+			if (u->u_ping_func == MAPLE_FN_MEMCARD) {
+				/*
+				 * Some of 3rd party Memory cards do not
+				 * property implement Maple bus command set,
+				 * and do not respond at all for GETCOND.
+				 *
+				 * A correct device shall return 
+				 * MAPLE_RESPONSE_BADCMD (-3) for
+				 * unrecognized commands.
+				 *
+				 * (BTW, Sega Visual Memory returns
+				 *  MAPLE_RESPONSE_BADFUNC (-2) for
+				 *  unrecognized commands.  Weird. :-)
+				 */
+				maple_write_command(sc, u,
+				    MAPLE_COMMAND_GETMINFO,
+				    2, memcard_ping_arg);
+			} else
+#endif
+			{
+				fn = &u->u_func[u->u_ping_func];
+				fn->f_work = htonl(MAPLE_FUNC(u->u_ping_func));
+				maple_write_command(sc, u,
+				    MAPLE_COMMAND_GETCOND,
+				    1, &fn->f_work);
+			}
 			u->u_dma_stat = MAPLE_DMA_PING;
 			/* u->u_dma_func = XXX; */
 		} else {