summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ieee1394/fwnode.c264
-rw-r--r--sys/dev/ieee1394/fwnodereg.h26
-rw-r--r--sys/dev/ieee1394/fwnodevar.h32
-rw-r--r--sys/dev/ieee1394/fwohci.c1885
-rw-r--r--sys/dev/ieee1394/fwohcireg.h254
-rw-r--r--sys/dev/ieee1394/fwohcivar.h285
-rw-r--r--sys/dev/ieee1394/ieee1394reg.h221
-rw-r--r--sys/dev/ieee1394/ieee1394var.h137
-rw-r--r--sys/dev/std/ieee1212.c583
-rw-r--r--sys/dev/std/ieee1212reg.h82
-rw-r--r--sys/dev/std/ieee1212var.h41
11 files changed, 2290 insertions, 1520 deletions
diff --git a/sys/dev/ieee1394/fwnode.c b/sys/dev/ieee1394/fwnode.c
index 4e822217f45..583bc3cbbd6 100644
--- a/sys/dev/ieee1394/fwnode.c
+++ b/sys/dev/ieee1394/fwnode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fwnode.c,v 1.3 2002/10/12 01:09:44 krw Exp $ */
+/* $OpenBSD: fwnode.c,v 1.4 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: fwnode.c,v 1.13 2002/04/03 04:15:59 jmc Exp $ */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-#ifdef __KERNEL_RCSID
+#ifdef __KERNEL_RCSID
__KERNEL_RCSID(0, "$NetBSD: fwnode.c,v 1.13 2002/04/03 04:15:59 jmc Exp $");
#endif
@@ -59,7 +59,9 @@ __KERNEL_RCSID(0, "$NetBSD: fwnode.c,v 1.13 2002/04/03 04:15:59 jmc Exp $");
#include <dev/ieee1394/ieee1394var.h>
#include <dev/ieee1394/fwnodevar.h>
-static const char * const ieee1394_speeds[] = { IEEE1394_SPD_STRINGS };
+#if 0
+const char * const ieee1394_speeds[] = { IEEE1394_SPD_STRINGS };
+#endif
#ifdef __NetBSD__
int fwnode_match(struct device *, struct cfdata *, void *);
@@ -70,18 +72,31 @@ void fwnode_attach(struct device *, struct device *, void *);
int fwnode_detach(struct device *, int);
void fwnode_configrom_input(struct ieee1394_abuf *, int);
int fwnode_print(void *, const char *);
-#ifdef FWNODE_DEBUG
-void fwnode_dump_rom(struct fwnode_softc *,u_int32_t *, u_int32_t);
-#endif
+#ifdef FWNODE_DEBUG
+void fwnode_dump_rom(struct fwnode_softc *, u_int32_t *, u_int32_t);
+#endif /* FWNODE_DEBUG */
-#ifdef FWNODE_DEBUG
-#define DPRINTF(x) if (fwnodedebug) printf x
-#define DPRINTFN(n,x) if (fwnodedebug>(n)) printf x
-int fwnodedebug = 1;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
+#ifdef FWNODE_DEBUG
+#include <sys/syslog.h>
+extern int log_open;
+int fwnode_oldlog;
+#define DPRINTF(x) if (fwnodedebug) do { \
+ fwnode_oldlog = log_open; log_open = 1; \
+ addlog x; log_open = fwnode_oldlog; \
+} while (0)
+#define DPRINTFN(n,x) if (fwnodedebug>(n)) do { \
+ fwnode_oldlog = log_open; log_open = 1; \
+ addlog x; log_open = fwnode_oldlog; \
+} while (0)
+#define MPRINTF(x,y) DPRINTF(("%s[%d]: %s 0x%08x\n", \
+ __func__, __LINE__, (x), (u_int32_t)(y)))
+
+int fwnodedebug = 0;
+#else /* FWNODE_DEBUG */
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#define MPRINTF(x,y)
+#endif /* ! FWNODE_DEBUG */
#ifdef __OpenBSD__
struct cfdriver fwnode_cd = {
@@ -103,10 +118,10 @@ fwnode_match(struct device *parent, void *match, void *aux)
#endif
{
struct ieee1394_attach_args *fwa = aux;
-
+
if (strcmp(fwa->name, "fwnode") == 0)
- return 1;
- return 0;
+ return (1);
+ return (0);
}
void
@@ -116,28 +131,32 @@ fwnode_attach(struct device *parent, struct device *self, void *aux)
struct ieee1394_softc *psc = (struct ieee1394_softc *)parent;
struct ieee1394_attach_args *fwa = aux;
struct ieee1394_abuf *ab;
-
+
#ifdef M_ZERO
- ab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK|M_ZERO);
+ MALLOC(ab, struct ieee1394_abuf *, sizeof(*ab),
+ M_1394DATA, M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("MALLOC(1394DATA)", ab);
#else
- ab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK);
- bzero(ab, sizeof(struct ieee1394_abuf));
+ MALLOC(ab, struct ieee1394_abuf *, sizeof(*ab), M_1394DATA, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(1394DATA)", ab);
+ bzero(ab, sizeof(*ab));
#endif
ab->ab_data = malloc(4, M_1394DATA, M_WAITOK);
+ //MPRINTF_OLD("malloc(1394DATA)", ab->ab_data);
ab->ab_data[0] = 0;
-
+
sc->sc_sc1394.sc1394_node_id = fwa->nodeid;
memcpy(sc->sc_sc1394.sc1394_guid, fwa->uid, 8);
sc->sc1394_read = fwa->read;
sc->sc1394_write = fwa->write;
sc->sc1394_inreg = fwa->inreg;
sc->sc1394_unreg = fwa->unreg;
-
+
/* XXX. Fix the fw code to use the generic routines. */
sc->sc_sc1394.sc1394_ifinreg = psc->sc1394_ifinreg;
sc->sc_sc1394.sc1394_ifoutput = psc->sc1394_ifoutput;
-
- printf(" Node %d: UID %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
+
+ printf(" Node %d: UID %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
sc->sc_sc1394.sc1394_node_id,
sc->sc_sc1394.sc1394_guid[0], sc->sc_sc1394.sc1394_guid[1],
sc->sc_sc1394.sc1394_guid[2], sc->sc_sc1394.sc1394_guid[3],
@@ -155,20 +174,27 @@ fwnode_attach(struct device *parent, struct device *self, void *aux)
int
fwnode_detach(struct device *self, int flags)
{
- struct fwnode_softc *sc = (struct fwnode_softc *)self;
+ struct fwnode_softc *sc = (struct fwnode_softc *)self;
struct device **children;
-
+
if (sc->sc_children) {
children = sc->sc_children;
- while (*children++)
+ while (*children != NULL) {
config_detach(*children, 0);
+ children++;
+ }
free(sc->sc_children, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", sc->sc_children);
+ sc->sc_children = NULL;
}
-
+
if (sc->sc_sc1394.sc1394_configrom &&
- sc->sc_sc1394.sc1394_configrom_len)
+ sc->sc_sc1394.sc1394_configrom_len) {
free(sc->sc_sc1394.sc1394_configrom, M_1394DATA);
-
+ //MPRINTF_OLD("free(1394DATA)", sc->sc_sc1394.sc1394_configrom);
+ sc->sc_sc1394.sc1394_configrom = NULL;
+ }
+
if (sc->sc_configrom)
p1212_free(sc->sc_configrom);
return 0;
@@ -204,12 +230,20 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
if (rcode != IEEE1394_RCODE_COMPLETE) {
DPRINTF(("Aborting configrom input, rcode: %d\n", rcode));
-#ifdef FWNODE_DEBUG
+#ifdef FWNODE_DEBUG
fwnode_dump_rom(sc, ab->ab_data, ab->ab_retlen);
-#endif
- if (cc != NULL) free(cc, M_1394DATA);
+#endif /* FWNODE_DEBUG */
+ if (cc != NULL) {
+ FREE(cc, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", cc);
+ cc = NULL; /* XXX */
+ }
free(ab->ab_data, M_1394DATA);
- free(ab, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL;
+ FREE(ab, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", ab);
+ ab = NULL; /* XXX */
return;
}
@@ -217,57 +251,51 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
DPRINTF(("%s: config rom short read. Expected :%d, received: "
"%d. Not attaching\n", sc->sc_sc1394.sc1394_dev.dv_xname,
ab->ab_length, ab->ab_retlen));
-/* if (cc != NULL) free(cc, M_1394DATA); */
free(ab->ab_data, M_1394DATA);
- free(ab, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL;
+ FREE(ab, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", ab);
+ ab = NULL; /* XXX */
return;
- }
+ }
if (ab->ab_retlen % 4) {
DPRINTF(("%s: configrom read of invalid length: %d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, ab->ab_retlen));
-/* if (cc != NULL) free(cc, M_1394DATA); */
free(ab->ab_data, M_1394DATA);
- free(ab, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL;
+ FREE(ab, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", ab);
+ ab = NULL; /* XXX */
return;
}
-
+
ab->ab_retlen = ab->ab_retlen / 4;
-/*
- DPRINTF(("ab_length:%d/0x%02x ab_retlen:%d/0x%02x ab_data0:0x%08x\n",
- ab->ab_length, ab->ab_length, ab->ab_retlen, ab->ab_retlen,
- ab->ab_data[0], ab->ab_data[0]));
- */
if (cc != NULL) {
cc->cc_buf[cc->cc_num++] = ab->ab_data[0];
-/* free(ab->ab_data, M_1394DATA); */
ab->ab_data[0] = 0;
-/* wakeup(&cc->cc_num); DPRINTF(("wakeup %d\n", cc->cc_num)); */
-/* if (test != 0) { */
if (cc->cc_num < cc->cc_retlen) {
-/* free(cc, M_1394DATA); */
-/* free(ab, M_1394DATA); */
ab->ab_addr = CSR_BASE + CSR_CONFIG_ROM +
cc->cc_num * 4;
ab->ab_length = 4;
ab->ab_retlen = 0;
ab->ab_cb = fwnode_configrom_input;
ab->ab_cbarg = cc;
-/* DPRINTF(("re-submitting %d\n", cc->cc_num)); */
sc->sc1394_read(ab);
-/* DPRINTF(("re-submitted %d\n", cc->cc_num)); */
return;
} else {
free(ab->ab_data, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL;
ab->ab_data = &cc->cc_buf[0];
ab->ab_retlen = cc->cc_retlen;
ab->ab_length = cc->cc_retlen * 4;
- free(cc, M_1394DATA);
- cc = NULL;
+ FREE(cc, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", cc);
+ cc = NULL; /* XXX */
ab->ab_cbarg = NULL;
-#ifdef FWNODE_DEBUG
-/* fwnode_dump_rom(sc, ab->ab_data, ab->ab_retlen); */
-#endif
}
}
@@ -275,42 +303,48 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
DPRINTF(("%s: configrom parse error\n",
sc->sc_sc1394.sc1394_dev.dv_xname));
free(ab->ab_data, M_1394DATA);
- free(ab, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL; /* XXX */
+ FREE(ab, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", ab);
+ ab = NULL; /* XXX */
return;
}
-/*
- DPRINTF(("ab_length:%d/0x%02x ab_retlen:%d/0x%02x ab_data0:0x%08x\n",
- ab->ab_length, ab->ab_length, ab->ab_retlen, ab->ab_retlen,
- ab->ab_data[0], ab->ab_data[0]));
- */
#ifdef DIAGNOSTIC
if (ab->ab_retlen < (ab->ab_length / 4))
panic("Configrom shrank during iscomplete check?");
#endif
-
+
if (ab->ab_retlen > (ab->ab_length / 4)) {
if (cc != NULL) { /* Should never occur here */
DPRINTF(("%s: cbarg not NULL\n",
sc->sc_sc1394.sc1394_dev.dv_xname));
-/* free(cc, M_1394DATA); */
free(ab->ab_data, M_1394DATA);
- free(ab, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL; /* XXX */
+ FREE(ab, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", ab);
+ ab = NULL; /* XXX */
return;
}
free(ab->ab_data, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL; /* XXX */
if (ab->ab_length == 4) { /* reread whole rom */
#ifdef M_ZERO
- ab->ab_data = malloc(ab->ab_retlen * 4, M_1394DATA,
+ ab->ab_data = malloc(ab->ab_retlen * 4, M_1394DATA,
M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("malloc(1394DATA)",ab->ab_data);
#else
ab->ab_data = malloc(ab->ab_retlen * 4,
M_1394DATA, M_WAITOK);
+ //MPRINTF_OLD("malloc(1394DATA)",ab->ab_data);
bzero(ab->ab_data, ab->ab_retlen * 4);
#endif
-
+
ab->ab_addr = CSR_BASE + CSR_CONFIG_ROM;
ab->ab_length = ab->ab_retlen * 4;
ab->ab_retlen = 0;
@@ -322,43 +356,36 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
" - 0x%08x\n", sc->sc_sc1394.sc1394_dev.dv_xname,
ab->ab_retlen, ab->ab_retlen, ab->ab_data[0]));
-#ifdef M_ZERO
+#ifdef M_ZERO
cbuf = malloc(ab->ab_retlen * 4, M_1394DATA,
M_WAITOK|M_ZERO);
- cc = malloc(sizeof(struct cfgrom_cbarg), M_1394DATA,
- M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("malloc(1394DATA)", cbuf);
+ MALLOC(cc, struct cfgrom_cbarg *, sizeof(*cc),
+ M_1394DATA, M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("MALLOC(1394DATA)", cc);
#else
cbuf = malloc(ab->ab_retlen * 4, M_1394DATA, M_WAITOK);
+ //MPRINTF_OLD("malloc(1394DATA)", cbuf);
bzero(cbuf, ab->ab_retlen * 4);
- cc = malloc(sizeof(struct cfgrom_cbarg), M_1394DATA,
- M_WAITOK);
- bzero(cc, sizeof(struct cfgrom_cbarg));
+ MALLOC(cc, struct cfgrom_cbarg *, sizeof(*cc),
+ M_1394DATA, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(1394DATA)", cc);
+ bzero(cc, sizeof(*cc));
#endif
cc->cc_type = 0x31333934;
cc->cc_retlen = ab->ab_retlen;
-/* cc->cc_num = i; */
cc->cc_num = 0;
cc->cc_buf = cbuf;
ab->ab_data = malloc(4, M_1394DATA, M_WAITOK);
+ //MPRINTF_OLD("malloc(1394DATA)", ab->ab_data);
ab->ab_data[0] = 0;
-/* ab->ab_addr = CSR_BASE + CSR_CONFIG_ROM + i * 4; */
ab->ab_addr = CSR_BASE + CSR_CONFIG_ROM;
ab->ab_length = 4;
ab->ab_retlen = 0;
ab->ab_cb = fwnode_configrom_input;
ab->ab_cbarg = cc;
-/* splx(s); */
-/* DPRINTF(("submitting %d\n", cc->cc_num)); */
sc->sc1394_read(ab);
-/* DPRINTF(("submitted %d\n", cc->cc_num)); */
-#if 0
- s = tsleep(&cc->cc_num, PRIBIO, "cfgrom_wait", 1 * hz);
- DPRINTF(("returned %d\n", cc->cc_num));
- free(cc, M_1394DATA);
- if (s == EWOULDBLOCK) break;
- free(ab, M_1394DATA);
-#endif
}
return;
} else {
@@ -366,15 +393,17 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
sc->sc_sc1394.sc1394_configrom_len = ab->ab_retlen;
sc->sc_sc1394.sc1394_configrom = ab->ab_data;
ab->ab_data = NULL;
-
- free(ab, M_1394DATA);
-
- /*
+
+ FREE(ab, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", ab);
+ ab = NULL; /* XXX */
+
+ /*
* Set P1212_ALLOW_DEPENDENT_INFO_OFFSET_TYPE and
* P1212_ALLOW_DEPENDENT_INFO_IMMED_TYPE as some protocols
- * such as SBP2 need it.
+ * such as SBP2 need it.
*/
-
+
val = P1212_ALLOW_DEPENDENT_INFO_OFFSET_TYPE;
val |= P1212_ALLOW_DEPENDENT_INFO_IMMED_TYPE;
val |= P1212_ALLOW_VENDOR_DIRECTORY_TYPE;
@@ -383,28 +412,31 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
sc->sc_sc1394.sc1394_configrom_len, val);
if ((sc->sc_configrom == NULL) ||
(sc->sc_configrom->len != IEEE1394_BUSINFO_LEN)) {
-#ifdef FWNODE_DEBUG
+#ifdef FWNODE_DEBUG
DPRINTF(("Parse error with config rom\n"));
- fwnode_dump_rom(sc, sc->sc_sc1394.sc1394_configrom,
+ fwnode_dump_rom(sc, sc->sc_sc1394.sc1394_configrom,
sc->sc_sc1394.sc1394_configrom_len);
-#endif
+#endif /* FWNODE_DEBUG */
if (sc->sc_configrom)
p1212_free(sc->sc_configrom);
free(sc->sc_sc1394.sc1394_configrom, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", sc->sc_sc1394.sc1394_configrom);
sc->sc_sc1394.sc1394_configrom = NULL;
sc->sc_sc1394.sc1394_configrom_len = 0;
return;
}
-
+
val = htonl(IEEE1394_SIGNATURE);
if (memcmp(sc->sc_configrom->name, &val, 4)) {
-#ifdef FWNODE_DEBUG
+#ifdef FWNODE_DEBUG
DPRINTF(("Invalid signature found in bus info block: "
"%s\n", sc->sc_configrom->name));
- fwnode_dump_rom(sc, sc->sc_sc1394.sc1394_configrom,
+ fwnode_dump_rom(sc, sc->sc_sc1394.sc1394_configrom,
sc->sc_sc1394.sc1394_configrom_len);
-#endif
+#endif /* FWNODE_DEBUG */
p1212_free(sc->sc_configrom);
+ free(sc->sc_sc1394.sc1394_configrom, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", sc->sc_sc1394.sc1394_configrom);
sc->sc_sc1394.sc1394_configrom = NULL;
sc->sc_sc1394.sc1394_configrom_len = 0;
return;
@@ -415,14 +447,16 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
sc->sc_sc1394.sc1394_link_speed =
IEEE1394_GET_LINK_SPD(ntohl(sc->sc_configrom->data[0]));
printf("%s: Link Speed: %s, max_rec: %d bytes\n",
- sc->sc_sc1394.sc1394_dev.dv_xname,
+ sc->sc_sc1394.sc1394_dev.dv_xname,
ieee1394_speeds[sc->sc_sc1394.sc1394_link_speed],
IEEE1394_MAX_REC(sc->sc_sc1394.sc1394_max_receive));
-#ifdef FWNODE_DEBUG
- fwnode_dump_rom(sc, sc->sc_sc1394.sc1394_configrom,
- sc->sc_sc1394.sc1394_configrom_len);
- p1212_print(sc->sc_configrom->root);
-#endif
+#ifdef FWNODE_DEBUG
+ if (fwnodedebug) {
+ fwnode_dump_rom(sc, sc->sc_sc1394.sc1394_configrom,
+ sc->sc_sc1394.sc1394_configrom_len);
+ p1212_print(sc->sc_configrom->root);
+ }
+#endif /* FWNODE_DEBUG */
sc->sc_children = p1212_match_units(&sc->sc_sc1394.sc1394_dev,
sc->sc_configrom->root, fwnode_print);
}
@@ -433,25 +467,25 @@ fwnode_print(void *aux, const char *pnp)
{
if (pnp)
printf("Unknown device at %s", pnp);
-
+
return UNCONF;
}
-#ifdef FWNODE_DEBUG
+#ifdef FWNODE_DEBUG
void
fwnode_dump_rom(struct fwnode_softc *sc, u_int32_t *t, u_int32_t len)
{
int i;
- printf("%s: Config rom dump:\n", sc->sc_sc1394.sc1394_dev.dv_xname);
+ DPRINTF(("%s: Config rom dump:\n", sc->sc_sc1394.sc1394_dev.dv_xname));
for (i = 0; i < len; i++) {
if ((i % 4) == 0) {
if (i)
- printf("\n");
- printf("%s: 0x%02hx: ",
- sc->sc_sc1394.sc1394_dev.dv_xname, (short)(4 * i));
+ DPRINTF(("\n"));
+ DPRINTF(("%s: 0x%02hx: ",
+ sc->sc_sc1394.sc1394_dev.dv_xname, (short)(4 * i)));
}
- printf("0x%08x ", ntohl(t[i]));
+ DPRINTF(("0x%08x ", ntohl(t[i])));
}
- printf("\n");
+ DPRINTF(("\n"));
}
-#endif
+#endif /* FWNODE_DEBUG */
diff --git a/sys/dev/ieee1394/fwnodereg.h b/sys/dev/ieee1394/fwnodereg.h
index d6788a498da..e2a1026ff1d 100644
--- a/sys/dev/ieee1394/fwnodereg.h
+++ b/sys/dev/ieee1394/fwnodereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fwnodereg.h,v 1.1 2002/06/25 17:11:49 itojun Exp $ */
+/* $OpenBSD: fwnodereg.h,v 1.2 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: fwnodereg.h,v 1.1 2001/05/01 04:46:23 jmc Exp $ */
/*
@@ -37,23 +37,23 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_IEEE1394_FWNODEREG_H
-#define _DEV_IEEE1394_FWNODEREG_H
+#ifndef _DEV_IEEE1394_FWNODEREG_H
+#define _DEV_IEEE1394_FWNODEREG_H
-#define DEVTYPE_UNKNOWN 0x0
-#define DEVTYPE_SBP2 0x1
+#define DEVTYPE_UNKNOWN 0x0
+#define DEVTYPE_SBP2 0x1
-#define DEVSPEC_UNKNOWN 0x0
-#define DEVSPEC_SCSI2 0x1
+#define DEVSPEC_UNKNOWN 0x0
+#define DEVSPEC_SCSI2 0x1
-#define FWNODE_ENABLED 0x0001
+#define FWNODE_ENABLED 0x0001
-#ifndef FALSE
-#define FALSE 0
+#ifndef FALSE
+#define FALSE 0
#endif
-#ifndef TRUE
-#define TRUE 1
+#ifndef TRUE
+#define TRUE 1
#endif
-#endif /* _DEV_IEEE1394_FWNODEREG_H */
+#endif /* _DEV_IEEE1394_FWNODEREG_H */
diff --git a/sys/dev/ieee1394/fwnodevar.h b/sys/dev/ieee1394/fwnodevar.h
index 9660ab80a8a..6cf353b11dc 100644
--- a/sys/dev/ieee1394/fwnodevar.h
+++ b/sys/dev/ieee1394/fwnodevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fwnodevar.h,v 1.1 2002/06/25 17:11:49 itojun Exp $ */
+/* $OpenBSD: fwnodevar.h,v 1.2 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: fwnodevar.h,v 1.4 2002/02/27 05:02:25 jmc Exp $ */
/*
@@ -37,22 +37,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_IEEE1394_FWNODEVAR_H
-#define _DEV_IEEE1394_FWNODEVAR_H
+#ifndef _DEV_IEEE1394_FWNODEVAR_H
+#define _DEV_IEEE1394_FWNODEVAR_H
-struct fwnode_softc {
- struct ieee1394_softc sc_sc1394;
-
- int sc_flags;
-
- int (*sc1394_read)(struct ieee1394_abuf *);
- int (*sc1394_write)(struct ieee1394_abuf *);
- int (*sc1394_inreg)(struct ieee1394_abuf *, int);
- int (*sc1394_unreg)(struct ieee1394_abuf *, int);
-
- struct device **sc_children;
+typedef struct fwnode_softc {
+ struct ieee1394_softc sc_sc1394;
+ int sc_flags;
+ int (*sc1394_read) (struct ieee1394_abuf *);
+ int (*sc1394_write)(struct ieee1394_abuf *);
+ int (*sc1394_inreg)(struct ieee1394_abuf *, int);
+ int (*sc1394_unreg)(struct ieee1394_abuf *, int);
+ struct device **sc_children;
+ struct p1212_rom *sc_configrom;
+} fwnode_softc;
- struct p1212_rom *sc_configrom;
-};
-
-#endif /* _DEV_IEEE1394_FWNODEVAR_H */
+#endif /* _DEV_IEEE1394_FWNODEVAR_H */
diff --git a/sys/dev/ieee1394/fwohci.c b/sys/dev/ieee1394/fwohci.c
index 30ddb2787ca..05116581f96 100644
--- a/sys/dev/ieee1394/fwohci.c
+++ b/sys/dev/ieee1394/fwohci.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: fwohci.c,v 1.4 2002/10/12 02:03:46 krw Exp $ */
+/* $OpenBSD: fwohci.c,v 1.5 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: fwohci.c,v 1.54 2002/03/29 05:06:42 jmc Exp $ */
-/*-
+/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -18,8 +18,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@@ -50,14 +50,14 @@
*/
#include <sys/cdefs.h>
-#ifdef __KERNEL_RCSID
+#ifdef __KERNEL_RCSID
__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.54 2002/03/29 05:06:42 jmc Exp $");
#endif
-#define DOUBLEBUF 1
-#define NO_THREAD 0
+#define DOUBLEBUF 0
+#define NO_THREAD 0
-#ifdef __NetBSD__
+#ifdef __NetBSD__
#include "opt_inet.h"
#endif
@@ -65,7 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.54 2002/03/29 05:06:42 jmc Exp $");
#include <sys/systm.h>
#include <sys/kthread.h>
#include <sys/socket.h>
-#ifdef __NetBSD__
+#ifdef __NetBSD__
#include <sys/callout.h>
#else
#include <sys/timeout.h>
@@ -74,11 +74,11 @@ __KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.54 2002/03/29 05:06:42 jmc Exp $");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
-#ifdef __OpenBSD__
+#ifdef __OpenBSD__
#include <sys/endian.h>
#endif
-#if __NetBSD_Version__ >= 105010000 || !defined(__NetBSD__)
+#if __NetBSD_Version__ >= 105010000 || !defined(__NetBSD__)
#include <uvm/uvm_extern.h>
#else
#include <vm/vm.h>
@@ -93,21 +93,23 @@ __KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.54 2002/03/29 05:06:42 jmc Exp $");
#include <dev/ieee1394/ieee1394var.h>
#include <dev/ieee1394/fwohcivar.h>
-static const char * const ieee1394_speeds[] = { IEEE1394_SPD_STRINGS };
+const char * const ieee1394_speeds[] = { IEEE1394_SPD_STRINGS };
#if 0
-int fwohci_dnamem_alloc(struct fwohci_softc *sc, int size,
+int fwohci_dmamem_alloc(struct fwohci_softc *sc, int size,
int alignment, bus_dmamap_t *mapp, caddr_t *kvap, int flags);
#endif
void fwohci_create_event_thread(void *);
void fwohci_thread_init(void *);
void fwohci_event_thread(struct fwohci_softc *);
+void fwohci_event_dispatch(struct fwohci_softc *);
void fwohci_hw_init(struct fwohci_softc *);
void fwohci_power(int, void *);
void fwohci_shutdown(void *);
int fwohci_desc_alloc(struct fwohci_softc *);
+void fwohci_desc_free(struct fwohci_softc *);
struct fwohci_desc *fwohci_desc_get(struct fwohci_softc *, int);
void fwohci_desc_put(struct fwohci_softc *, struct fwohci_desc *, int);
@@ -120,8 +122,8 @@ int fwohci_buf_alloc(struct fwohci_softc *, struct fwohci_buf *);
void fwohci_buf_free(struct fwohci_softc *, struct fwohci_buf *);
void fwohci_buf_init_rx(struct fwohci_softc *);
void fwohci_buf_start_rx(struct fwohci_softc *);
-void fwohci_buf_stop_tx(struct fwohci_softc *);
void fwohci_buf_stop_rx(struct fwohci_softc *);
+void fwohci_buf_stop_tx(struct fwohci_softc *);
void fwohci_buf_next(struct fwohci_softc *, struct fwohci_ctx *);
int fwohci_buf_pktget(struct fwohci_softc *, struct fwohci_buf **,
caddr_t *, int);
@@ -137,6 +139,8 @@ void fwohci_phy_input(struct fwohci_softc *, struct fwohci_pkt *);
int fwohci_handler_set(struct fwohci_softc *, int, u_int32_t, u_int32_t,
int (*)(struct fwohci_softc *, void *, struct fwohci_pkt *), void *);
+int fwohci_block_handler_set(struct fwohci_softc *, int, u_int32_t, u_int32_t,
+ int, int (*)(struct fwohci_softc *, void *, struct fwohci_pkt *), void *);
void fwohci_arrq_input(struct fwohci_softc *, struct fwohci_ctx *);
void fwohci_arrs_input(struct fwohci_softc *, struct fwohci_ctx *);
@@ -184,28 +188,45 @@ int fwohci_inreg(struct ieee1394_abuf *, int);
int fwohci_unreg(struct ieee1394_abuf *, int);
int fwohci_parse_input(struct fwohci_softc *, void *,
struct fwohci_pkt *);
-#ifdef __NetBSD__
+#ifdef __NetBSD__
int fwohci_submatch(struct device *, struct cfdata *, void *);
#else
int fwohci_submatch(struct device *, void *, void *);
#endif
u_int16_t fwohci_crc16(u_int32_t *, int);
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
void fwohci_show_intr(struct fwohci_softc *, u_int32_t);
void fwohci_show_phypkt(struct fwohci_softc *, u_int32_t);
/* 1 is normal debug, 2 is verbose debug, 3 is complete (packet dumps). */
-#define DPRINTF(x) if (fwdebug) printf x
-#define DPRINTFN(n,x) if (fwdebug>(n)) printf x
-int fwdebug = 1;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
-
-#ifdef __OpenBSD__
+#include <sys/syslog.h>
+extern int log_open;
+int fwohci_oldlog;
+#define DPRINTF(x) if (fwohcidebug) do { \
+ fwohci_oldlog = log_open; log_open = 1; \
+ addlog x; log_open = fwohci_oldlog; \
+} while (0)
+#define DPRINTFN(n,x) if (fwohcidebug>(n)) do { \
+ fwohci_oldlog = log_open; log_open = 1; \
+ addlog x; log_open = fwohci_oldlog; \
+} while (0)
+#define MPRINTF(x,y) DPRINTF(("%s[%d]: %s 0x%08x\n", \
+ __func__, __LINE__, (x), (u_int32_t)(y)))
+
+int fwohcidebug = 0;
+int fwintr = 0;
+caddr_t fwptr = 0;
+int fwlen = 0;
+struct fwohci_buf *fwbuf = NULL;
+#else /* FWOHCI_DEBUG */
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#define MPRINTF(x,y)
+#endif /* ! FWOHCI_DEBUG */
+
+#ifdef __OpenBSD__
struct cfdriver fwohci_cd = {
NULL, "fwohci", DV_DULL
};
@@ -220,7 +241,7 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
int error;
#endif
-#ifdef __NetBSD__
+#ifdef __NetBSD__
evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ev,
sc->sc_sc1394.sc1394_dev.dv_xname, "intr");
@@ -231,7 +252,7 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
#endif
/*
- * Wait for reset completion
+ * Wait for reset completion.
*/
for (i = 0; i < OHCI_LOOP; i++) {
val = OHCI_CSR_READ(sc, OHCI_REG_HCControlClear);
@@ -240,7 +261,8 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
DELAY(10);
}
- /* What dialect of OHCI is this device?
+ /*
+ * What dialect of OHCI is this device ?
*/
val = OHCI_CSR_READ(sc, OHCI_REG_Version);
printf("%s: OHCI %u.%u", sc->sc_sc1394.sc1394_dev.dv_xname,
@@ -260,7 +282,8 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
sc->sc_sc1394.sc1394_guid[4], sc->sc_sc1394.sc1394_guid[5],
sc->sc_sc1394.sc1394_guid[6], sc->sc_sc1394.sc1394_guid[7]);
- /* Get the maximum link speed and receive size
+ /*
+ * Get the maximum link speed and receive size.
*/
val = OHCI_CSR_READ(sc, OHCI_REG_BusOptions);
sc->sc_sc1394.sc1394_link_speed =
@@ -271,8 +294,9 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
} else {
printf(", unknown speed %u", sc->sc_sc1394.sc1394_link_speed);
}
-
- /* MaxRec is encoded as log2(max_rec_octets)-1
+
+ /*
+ * MaxRec is encoded as log2(max_rec_octets)-1
*/
sc->sc_sc1394.sc1394_max_receive =
1 << (OHCI_BITVAL(val, OHCI_BusOptions_MaxRec) + 1);
@@ -290,26 +314,29 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
}
sc->sc_isoctx = i;
printf(", %d iso_ctx", sc->sc_isoctx);
-
+
printf("\n");
#if 0
- error = fwohci_dnamem_alloc(sc, OHCI_CONFIG_SIZE,
+ error = fwohci_dmamem_alloc(sc, OHCI_CONFIG_SIZE,
OHCI_CONFIG_ALIGNMENT, &sc->sc_configrom_map,
(caddr_t *) &sc->sc_configrom, BUS_DMA_WAITOK|BUS_DMA_COHERENT);
return error;
#endif
- sc->sc_dying = 0;
+ MALLOC(sc->sc_dying, int *, sizeof(int), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", sc->sc_dying);
+ DPRINTF(("%s: sc_dying 0x%08x\n", __func__, (u_int32_t)sc->sc_dying));
+ *sc->sc_dying = 0;
sc->sc_nodeid = 0xffff; /* invalid */
-#ifdef __NetBSD__
+#ifdef __NetBSD__
kthread_create(fwohci_create_event_thread, sc);
#else
if (initproc == NULL)
kthread_create_deferred(fwohci_create_event_thread, sc);
- else /* late binding, threads
- already running */
+ else
+ /* Late binding, threads already running. */
fwohci_create_event_thread(sc);
#endif
@@ -329,7 +356,7 @@ fwohci_if_setiso(struct device *self, u_int32_t channel, u_int32_t tag,
}
s = splnet();
- retval = fwohci_handler_set(sc, IEEE1394_TCODE_STREAM_DATA,
+ retval = fwohci_handler_set(sc, IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK,
channel, tag, fwohci_if_input_iso, handler);
splx(s);
@@ -348,45 +375,92 @@ int
fwohci_intr(void *arg)
{
struct fwohci_softc * const sc = arg;
+#if 1
int progress = 0;
+#else
+ int progress = (sc->sc_intmask != 0);
+#endif
u_int32_t intmask, iso;
+ splassert(IPL_BIO);
+
+#ifdef FWOHCI_DEBUG
+ //DPRINTFN(3,("%s: in(%d)\n", __func__, fwintr));
+ fwintr++;
+#endif /* FWOHCI_DEBUG */
+
+#if 1
for (;;) {
+#endif
intmask = OHCI_CSR_READ(sc, OHCI_REG_IntEventClear);
/*
* On a bus reset, everything except bus reset gets
- * cleared. That can't get cleared until the selfid
+ * cleared. That can't get cleared until the selfid
* phase completes (which happens outside the
* interrupt routines). So if just a bus reset is left
* in the mask and it's already in the sc_intmask,
* just return.
*/
- if ((intmask == 0) ||
+ if ((intmask == 0xffffffff) || (intmask == 0) ||
(progress && (intmask == OHCI_Int_BusReset) &&
- (sc->sc_intmask & OHCI_Int_BusReset))) {
- if (progress)
+ (sc->sc_intmask & OHCI_Int_BusReset))) {
+
+ if (intmask == 0xffffffff)
+ config_detach(((struct device *)sc)
+ ->dv_parent, 0);
+
+ if (progress) {
+#if NO_THREAD
+ fwohci_event_dispatch(sc);
+#else /* NO_THREAD */
wakeup(fwohci_event_thread);
- return progress;
+#endif /* NO_THREAD */
+ }
+
+#ifdef FWOHCI_DEBUG
+ --fwintr;
+ //DPRINTFN(3,("%s: out(%d)\n", __func__, fwintr));
+#endif /* FWOHCI_DEBUG */
+
+ return (progress);
}
+#if 1
+ OHCI_CSR_WRITE(sc, OHCI_REG_IntEventClear,
+ intmask & ~OHCI_Int_BusReset);
+#else
+ DPRINTFN(2,("%s: IntEventClear(0x%08x) IntMaskClear(0x%08x)\n",
+ __func__,
+ intmask & ~OHCI_Int_BusReset,
+ intmask & ~OHCI_Int_BusReset & ~OHCI_Int_MasterEnable));
+ OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskClear,
+ intmask & ~OHCI_Int_BusReset & ~OHCI_Int_MasterEnable);
OHCI_CSR_WRITE(sc, OHCI_REG_IntEventClear,
intmask & ~OHCI_Int_BusReset);
-#ifdef FW_DEBUG
- if (fwdebug > 1)
- fwohci_show_intr(sc, intmask);
#endif
+#ifdef FWOHCI_DEBUG
+ if (fwohcidebug > 1)
+ fwohci_show_intr(sc, intmask);
+#endif /* FWOHCI_DEBUG */
if (intmask & OHCI_Int_BusReset) {
/*
* According to OHCI spec 6.1.1 "busReset",
- * All asynchronous transmit must be stopped before
- * clearing BusReset. Moreover, the BusReset
+ * all asynchronous transmit must be stopped before
+ * clearing BusReset. Moreover, the BusReset
* interrupt bit should not be cleared during the
- * SelfID phase. Thus we turned off interrupt mask
+ * SelfID phase. Thus we turned off interrupt mask
* bit of BusReset instead until SelfID completion
* or SelfID timeout.
*/
+#if 0
+ DPRINTFN(2,("%s: IntMaskSet(0x%08x)"
+ " IntMaskClear(0x%08x)\n", __func__,
+ intmask & ~OHCI_Int_BusReset, OHCI_Int_BusReset));
+ OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskSet,
+ intmask & ~OHCI_Int_BusReset);
+#endif
intmask &= OHCI_Int_SelfIDComplete;
OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskClear,
OHCI_Int_BusReset);
@@ -396,26 +470,39 @@ fwohci_intr(void *arg)
if (intmask & OHCI_Int_IsochTx) {
iso = OHCI_CSR_READ(sc, OHCI_REG_IsoXmitIntEventClear);
+#if 1
OHCI_CSR_WRITE(sc, OHCI_REG_IsoXmitIntEventClear, iso);
+#else
+ OHCI_CSR_WRITE(sc, OHCI_REG_IsoXmitIntEventClear,
+ sc->sc_isotxrst);
+#endif
}
if (intmask & OHCI_Int_IsochRx) {
-#if NO_THREAD
+#if NO_THREAD
int i;
int asyncstream = 0;
-#endif
+#endif /* NO_THREAD */
iso = OHCI_CSR_READ(sc, OHCI_REG_IsoRecvIntEventClear);
+#if 1
OHCI_CSR_WRITE(sc, OHCI_REG_IsoRecvIntEventClear, iso);
-#if NO_THREAD
+#else
+ OHCI_CSR_WRITE(sc, OHCI_REG_IsoRecvIntEventClear,
+ sc->sc_isorxrst);
+#endif
+#if NO_THREAD
for (i = 0; i < sc->sc_isoctx; i++) {
- if ((iso & (1<<i)) && sc->sc_ctx_ir[i] != NULL) {
- if (sc->sc_ctx_ir[i]->fc_type == FWOHCI_CTX_ISO_SINGLE) {
+ if ((iso & (1<<i)) &&
+ sc->sc_ctx_ir[i] != NULL) {
+ if (sc->sc_ctx_ir[i]->fc_type ==
+ FWOHCI_CTX_ISO_SINGLE) {
asyncstream |= (1 << i);
continue;
}
bus_dmamap_sync(sc->sc_dmat,
sc->sc_ddmamap,
- 0, sizeof(struct fwohci_desc) * sc->sc_descsize,
+ 0, sizeof(struct fwohci_desc) *
+ sc->sc_descsize,
BUS_DMASYNC_PREREAD);
sc->sc_isocnt.ev_count++;
@@ -425,19 +512,30 @@ fwohci_intr(void *arg)
if (asyncstream != 0) {
sc->sc_iso |= asyncstream;
} else {
- /* all iso intr is pure isochronous */
+ /* All iso intr is pure isochronous. */
sc->sc_intmask &= ~OHCI_Int_IsochRx;
}
-#else
+#else /* NO_THREAD */
sc->sc_iso |= iso;
-#endif /* NO_THREAD */
+#endif /* NO_THREAD */
}
if (!progress) {
sc->sc_intrcnt.ev_count++;
+#if 1
progress = 1;
+#endif
}
+#if 1
}
+#else
+#ifdef FWOHCI_DEBUG
+ --fwintr;
+ //DPRINTF(("%s: out(%d)\n", __func__, fwintr));
+#endif /* FWOHCI_DEBUG */
+
+ return (progress);
+#endif
}
void
@@ -445,7 +543,7 @@ fwohci_create_event_thread(void *arg)
{
struct fwohci_softc *sc = arg;
-#ifdef __NetBSD__
+#ifdef __NetBSD__
if (kthread_create1(fwohci_thread_init, sc, &sc->sc_event_thread, "%s",
sc->sc_sc1394.sc1394_dev.dv_xname))
#else
@@ -466,7 +564,7 @@ fwohci_thread_init(void *arg)
int i;
/*
- * Allocate descriptors
+ * Allocate descriptors.
*/
if (fwohci_desc_alloc(sc)) {
printf("%s: not enabling interrupts\n",
@@ -475,34 +573,35 @@ fwohci_thread_init(void *arg)
}
/*
- * Enable Link Power
+ * Enable Link Power.
*/
OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet, OHCI_HCControl_LPS);
/*
- * Allocate DMA Context
+ * Allocate DMA Context.
*/
fwohci_ctx_alloc(sc, &sc->sc_ctx_arrq, OHCI_BUF_ARRQ_CNT,
OHCI_CTX_ASYNC_RX_REQUEST, FWOHCI_CTX_ASYNC);
fwohci_ctx_alloc(sc, &sc->sc_ctx_arrs, OHCI_BUF_ARRS_CNT,
OHCI_CTX_ASYNC_RX_RESPONSE, FWOHCI_CTX_ASYNC);
- fwohci_ctx_alloc(sc, &sc->sc_ctx_atrq, 0, OHCI_CTX_ASYNC_TX_REQUEST,
- FWOHCI_CTX_ASYNC);
- fwohci_ctx_alloc(sc, &sc->sc_ctx_atrs, 0, OHCI_CTX_ASYNC_TX_RESPONSE,
- FWOHCI_CTX_ASYNC);
+ fwohci_ctx_alloc(sc, &sc->sc_ctx_atrq, 0,
+ OHCI_CTX_ASYNC_TX_REQUEST, FWOHCI_CTX_ASYNC);
+ fwohci_ctx_alloc(sc, &sc->sc_ctx_atrs, 0,
+ OHCI_CTX_ASYNC_TX_RESPONSE, FWOHCI_CTX_ASYNC);
sc->sc_ctx_ir = malloc(sizeof(sc->sc_ctx_ir[0]) * sc->sc_isoctx,
M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", sc->sc_ctx_ir);
for (i = 0; i < sc->sc_isoctx; i++)
sc->sc_ctx_ir[i] = NULL;
/*
- * Allocate buffer for configuration ROM and SelfID buffer
+ * Allocate buffer for configuration ROM and SelfID buffer.
*/
fwohci_buf_alloc(sc, &sc->sc_buf_cnfrom);
fwohci_buf_alloc(sc, &sc->sc_buf_selfid);
-#ifdef __NetBSD__
+#ifdef __NetBSD__
callout_init(&sc->sc_selfid_callout);
#else
bzero(&sc->sc_selfid_callout, sizeof(sc->sc_selfid_callout));
@@ -513,7 +612,7 @@ fwohci_thread_init(void *arg)
sc->sc_sc1394.sc1394_ifsetiso = fwohci_if_setiso;
/*
- * establish hooks for shutdown and suspend/resume
+ * Establish hooks for shutdown and suspend/resume.
*/
sc->sc_shutdownhook = shutdownhook_establish(fwohci_shutdown, sc);
sc->sc_powerhook = powerhook_establish(fwohci_power, sc);
@@ -524,15 +623,41 @@ fwohci_thread_init(void *arg)
/* Main loop. It's not coming back normally. */
fwohci_event_thread(sc);
+ printf("%s: event thread exited\n", __func__);
+
+ if (sc->sc_uidtbl != NULL) {
+ free(sc->sc_uidtbl, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", sc->sc_uidtbl);
+ sc->sc_uidtbl = NULL;
+ }
+ fwohci_buf_free(sc, &sc->sc_buf_selfid);
+ fwohci_buf_free(sc, &sc->sc_buf_cnfrom);
+
+ free(sc->sc_ctx_ir, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", sc->sc_ctx_ir);
+ sc->sc_ctx_ir = NULL; /* XXX */
+ fwohci_ctx_free(sc, sc->sc_ctx_atrs);
+ fwohci_ctx_free(sc, sc->sc_ctx_atrq);
+ fwohci_ctx_free(sc, sc->sc_ctx_arrs);
+ fwohci_ctx_free(sc, sc->sc_ctx_arrq);
+
+ fwohci_desc_free(sc);
+
+ DPRINTF(("%s: waking up... 0x%08x\n", __func__,
+ (u_int32_t)sc->sc_dying));
+ wakeup(sc->sc_dying);
kthread_exit(0);
}
void
fwohci_event_thread(struct fwohci_softc *sc)
{
- int i, s;
- u_int32_t intmask, iso;
+ int s;
+#if ! NO_THREAD
+ int i;
+ uint32_t intmask, iso;
+#endif /* NO_THREAD */
s = splbio();
@@ -542,29 +667,41 @@ fwohci_event_thread(struct fwohci_softc *sc)
fwohci_hw_init(sc);
- /* Initial Bus Reset */
+ /* Initial Bus Reset. */
fwohci_phy_busreset(sc);
splx(s);
- while (!sc->sc_dying) {
+ while (! *sc->sc_dying) {
+#if ! NO_THREAD
s = splbio();
intmask = sc->sc_intmask;
if (intmask == 0) {
+#endif /* NO_THREAD */
+#if 1
+ tsleep(fwohci_event_thread, PZERO, "fwohciev", 8);
+#else
tsleep(fwohci_event_thread, PZERO, "fwohciev", 0);
+#endif
+#if ! NO_THREAD
splx(s);
continue;
}
sc->sc_intmask = 0;
splx(s);
+ DPRINTFN(2, ("%s: treating interrupts 0x%08x\n", __func__,
+ intmask));
if (intmask & OHCI_Int_BusReset) {
+// s = splbio();
fwohci_buf_stop_tx(sc);
+// splx(s);
if (sc->sc_uidtbl != NULL) {
free(sc->sc_uidtbl, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", sc->sc_uidtbl);
sc->sc_uidtbl = NULL;
}
-#ifdef __NetBSD__
+#ifdef __NetBSD__
callout_reset(&sc->sc_selfid_callout,
OHCI_SELFID_TIMEOUT,
(void (*)(void *))fwohci_phy_busreset, sc);
@@ -574,7 +711,7 @@ fwohci_event_thread(struct fwohci_softc *sc)
timeout_add(&sc->sc_selfid_callout,
OHCI_SELFID_TIMEOUT);
#endif
- sc->sc_nodeid = 0xffff; /* indicate invalid */
+ sc->sc_nodeid = 0xffff; /* Indicate invalid. */
sc->sc_rootid = 0;
sc->sc_irmid = IEEE1394_BCAST_PHY_ID;
}
@@ -585,24 +722,34 @@ fwohci_event_thread(struct fwohci_softc *sc)
OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskSet,
OHCI_Int_BusReset);
splx(s);
-#ifdef __NetBSD__
+#ifdef __NetBSD__
callout_stop(&sc->sc_selfid_callout);
#else
timeout_del(&sc->sc_selfid_callout);
#endif
if (fwohci_selfid_input(sc) == 0) {
+// s = splbio();
fwohci_buf_start_rx(sc);
+// splx(s);
fwohci_uid_collect(sc);
}
}
- if (intmask & OHCI_Int_ReqTxComplete)
+ if (intmask & OHCI_Int_ReqTxComplete) {
+// s = splbio();
fwohci_at_done(sc, sc->sc_ctx_atrq, 0);
- if (intmask & OHCI_Int_RespTxComplete)
+// splx(s);
+ }
+ if (intmask & OHCI_Int_RespTxComplete) {
+// s = splbio();
fwohci_at_done(sc, sc->sc_ctx_atrs, 0);
- if (intmask & OHCI_Int_RQPkt)
+// splx(s);
+ }
+ if (intmask & OHCI_Int_RQPkt) {
fwohci_arrq_input(sc, sc->sc_ctx_arrq);
- if (intmask & OHCI_Int_RSPkt)
+ }
+ if (intmask & OHCI_Int_RSPkt) {
fwohci_arrs_input(sc, sc->sc_ctx_arrs);
+ }
if (intmask & OHCI_Int_IsochRx) {
s = splbio();
iso = sc->sc_iso;
@@ -616,12 +763,125 @@ fwohci_event_thread(struct fwohci_softc *sc)
}
}
}
+#if 0
+ DPRINTF(("%s: IntMaskSet(0x%08x)\n",
+ __func__, intmask & ~OHCI_Int_BusReset));
+ s = splbio();
+// OHCI_CSR_WRITE(sc, OHCI_REG_IntEventClear,
+// intmask & ~OHCI_Int_BusReset);
+ OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskSet,
+ intmask & ~OHCI_Int_BusReset);
+ splx(s);
+#endif
+#endif /* NO_THREAD */
+ }
+}
+
+#if NO_THREAD
+void
+fwohci_event_dispatch(struct fwohci_softc *sc)
+{
+ int i, s;
+ u_int32_t intmask, iso;
+
+ splassert(IPL_BIO);
+ intmask = sc->sc_intmask;
+ if (intmask == 0)
+ return;
+
+ sc->sc_intmask = 0;
+ s = spl0();
+ DPRINTFN(2, ("%s: treating interrupts 0x%08x\n", __func__, intmask));
+
+ if (intmask & OHCI_Int_BusReset) {
+// s = splbio();
+ fwohci_buf_stop_tx(sc);
+// splx(s);
+ if (sc->sc_uidtbl != NULL) {
+ free(sc->sc_uidtbl, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", sc->sc_uidtbl);
+ sc->sc_uidtbl = NULL;
+ }
+
+#ifdef __NetBSD__
+ callout_reset(&sc->sc_selfid_callout,
+ OHCI_SELFID_TIMEOUT,
+ (void (*)(void *))fwohci_phy_busreset, sc);
+#else
+ timeout_set(&sc->sc_selfid_callout,
+ (void (*)(void *))fwohci_phy_busreset, sc);
+ timeout_add(&sc->sc_selfid_callout,
+ OHCI_SELFID_TIMEOUT);
+#endif
+ sc->sc_nodeid = 0xffff; /* Indicate invalid. */
+ sc->sc_rootid = 0;
+ sc->sc_irmid = IEEE1394_BCAST_PHY_ID;
+ }
+ if (intmask & OHCI_Int_SelfIDComplete) {
+ splx(s);
+ OHCI_CSR_WRITE(sc, OHCI_REG_IntEventClear,
+ OHCI_Int_BusReset);
+ OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskSet,
+ OHCI_Int_BusReset);
+ s = spl0();
+#ifdef __NetBSD__
+ callout_stop(&sc->sc_selfid_callout);
+#else
+ timeout_del(&sc->sc_selfid_callout);
+#endif
+ if (fwohci_selfid_input(sc) == 0) {
+// s = splbio();
+ fwohci_buf_start_rx(sc);
+// splx(s);
+ fwohci_uid_collect(sc);
+ }
+ }
+ if (intmask & OHCI_Int_ReqTxComplete) {
+// s = splbio();
+ fwohci_at_done(sc, sc->sc_ctx_atrq, 0);
+// splx(s);
+ }
+ if (intmask & OHCI_Int_RespTxComplete) {
+// s = splbio();
+ fwohci_at_done(sc, sc->sc_ctx_atrs, 0);
+// splx(s);
+ }
+ if (intmask & OHCI_Int_RQPkt) {
+ fwohci_arrq_input(sc, sc->sc_ctx_arrq);
+ }
+ if (intmask & OHCI_Int_RSPkt) {
+ fwohci_arrs_input(sc, sc->sc_ctx_arrs);
+ }
+ if (intmask & OHCI_Int_IsochRx) {
+ splx(s);
+ iso = sc->sc_iso;
+ sc->sc_iso = 0;
+ s = spl0();
+ for (i = 0; i < sc->sc_isoctx; i++) {
+ if ((iso & (1 << i)) &&
+ sc->sc_ctx_ir[i] != NULL) {
+ fwohci_ir_input(sc, sc->sc_ctx_ir[i]);
+ sc->sc_isocnt.ev_count++;
+ }
+ }
}
+#if 0
+ DPRINTF(("%s: IntMaskSet(0x%08x)\n",
+ __func__, intmask & ~OHCI_Int_BusReset));
+ s = splbio();
+// OHCI_CSR_WRITE(sc, OHCI_REG_IntEventClear,
+// intmask & ~OHCI_Int_BusReset);
+ OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskSet, intmask & ~OHCI_Int_BusReset);
+ splx(s);
+#endif
+ splx(s);
}
+#endif /* NO_THREAD */
+
#if 0
int
-fwohci_dnamem_alloc(struct fwohci_softc *sc, int size, int alignment,
+fwohci_dmamem_alloc(struct fwohci_softc *sc, int size, int alignment,
bus_dmamap_t *mapp, caddr_t *kvap, int flags)
{
bus_dma_segment_t segs[1];
@@ -632,6 +892,7 @@ fwohci_dnamem_alloc(struct fwohci_softc *sc, int size, int alignment,
segs, 1, &nsegs, flags);
if (error)
goto cleanup;
+ //MPRINTF_OLD("bus_dmamem_alloc", segs->ds_addr);
steps = 1;
error = bus_dmamem_map(sc->sc_dmat, segs, nsegs, segs[0].ds_len,
@@ -644,6 +905,8 @@ fwohci_dnamem_alloc(struct fwohci_softc *sc, int size, int alignment,
size, flags, mapp);
if (error)
goto cleanup;
+ //MPRINTF_OLD("bus_dmamap_create", mapp);
+
if (error == 0)
error = bus_dmamap_load(sc->sc_dmat, *mapp, *kvap, size, NULL,
flags);
@@ -654,6 +917,7 @@ fwohci_dnamem_alloc(struct fwohci_softc *sc, int size, int alignment,
switch (steps) {
case 1:
bus_dmamem_free(sc->sc_dmat, segs, nsegs);
+ //MPRINTF_OLD("bus_dmamem_free", segs->ds_addr);
}
return error;
@@ -677,6 +941,8 @@ fwohci_hw_init(struct fwohci_softc *sc)
int i;
u_int32_t val;
+ splassert(IPL_BIO);
+
/*
* Software Reset.
*/
@@ -689,18 +955,20 @@ fwohci_hw_init(struct fwohci_softc *sc)
}
OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet, OHCI_HCControl_LPS);
+ DELAY(100000);
/*
- * First, initilize CSRs with undefined value to default settings.
+ * First, initialize CSRs with undefined value to default settings.
*/
val = OHCI_CSR_READ(sc, OHCI_REG_BusOptions);
val |= OHCI_BusOptions_ISC | OHCI_BusOptions_CMC;
-#if 0
+#if 1
val |= OHCI_BusOptions_BMC | OHCI_BusOptions_IRMC;
+ val |= OHCI_BusOptions_PMC;
#else
val &= ~(OHCI_BusOptions_BMC | OHCI_BusOptions_IRMC);
-#endif
val &= ~(OHCI_BusOptions_PMC);
+#endif
OHCI_CSR_WRITE(sc, OHCI_REG_BusOptions, val);
for (i = 0; i < sc->sc_isoctx; i++) {
OHCI_SYNC_RX_DMA_WRITE(sc, i, OHCI_SUBREG_ContextControlClear,
@@ -720,18 +988,32 @@ fwohci_hw_init(struct fwohci_softc *sc)
OHCI_LinkControl_CycleTimerEnable |
OHCI_LinkControl_RcvSelfID | OHCI_LinkControl_RcvPhyPkt);
+#if 0
OHCI_CSR_WRITE(sc, OHCI_REG_ATRetries, 0x00000888); /*XXX*/
+#else
+ OHCI_CSR_WRITE(sc, OHCI_REG_ATRetries, 0xffff0fff); /*XXX*/
+#endif
- /* clear receive filter */
+ /* Clear receive filter. */
OHCI_CSR_WRITE(sc, OHCI_REG_IRMultiChanMaskHiClear, ~0);
OHCI_CSR_WRITE(sc, OHCI_REG_IRMultiChanMaskLoClear, ~0);
OHCI_CSR_WRITE(sc, OHCI_REG_AsynchronousRequestFilterHiSet, 0x80000000);
+ OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet,
+ OHCI_HCControl_ProgramPhyEnable);
+#if 0
OHCI_CSR_WRITE(sc, OHCI_REG_HCControlClear,
- OHCI_HCControl_NoByteSwapData | OHCI_HCControl_APhyEnhanceEnable);
+ OHCI_HCControl_APhyEnhanceEnable);
+#else
+ OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet,
+ OHCI_HCControl_APhyEnhanceEnable);
+#endif
#if BYTE_ORDER == BIG_ENDIAN
OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet,
OHCI_HCControl_NoByteSwapData);
+#else
+ OHCI_CSR_WRITE(sc, OHCI_REG_HCControlClear,
+ OHCI_HCControl_NoByteSwapData);
#endif
OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskClear, ~0);
@@ -749,7 +1031,7 @@ fwohci_hw_init(struct fwohci_softc *sc)
OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet, OHCI_HCControl_LinkEnable);
/*
- * Start the receivers
+ * Start the receivers.
*/
fwohci_buf_start_rx(sc);
}
@@ -770,7 +1052,7 @@ fwohci_power(int why, void *arg)
fwohci_hw_init(sc);
fwohci_phy_busreset(sc);
break;
-#ifdef __NetBSD__
+#ifdef __NetBSD__
case PWR_SOFTSUSPEND:
case PWR_SOFTSTANDBY:
case PWR_SOFTRESUME:
@@ -786,12 +1068,14 @@ fwohci_shutdown(void *arg)
struct fwohci_softc *sc = arg;
u_int32_t val;
-#ifdef __NetBSD__
+ splassert(IPL_BIO);
+
+#ifdef __NetBSD__
callout_stop(&sc->sc_selfid_callout);
#else
timeout_del(&sc->sc_selfid_callout);
#endif
- /* disable all interrupt */
+ /* Disable all interrupt. */
OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskClear, OHCI_Int_MasterEnable);
fwohci_buf_stop_tx(sc);
fwohci_buf_stop_rx(sc);
@@ -806,11 +1090,11 @@ fwohci_shutdown(void *arg)
}
/*
- * COMMON FUNCTIONS
+ * COMMON FUNCTIONS.
*/
/*
- * read the PHY Register.
+ * Read the PHY Register.
*/
u_int8_t
fwohci_phy_read(struct fwohci_softc *sc, u_int8_t reg)
@@ -818,27 +1102,31 @@ fwohci_phy_read(struct fwohci_softc *sc, u_int8_t reg)
int i;
u_int32_t val;
+ splassert(IPL_BIO);
+
OHCI_CSR_WRITE(sc, OHCI_REG_PhyControl,
OHCI_PhyControl_RdReg |
((reg & 0xf) << OHCI_PhyControl_RegAddr_BITPOS));
for (i = 0; i < OHCI_LOOP; i++) {
- if (OHCI_CSR_READ(sc, OHCI_REG_PhyControl) &
- OHCI_PhyControl_RdDone)
+ val = OHCI_CSR_READ(sc, OHCI_REG_PhyControl);
+ if (!(val & OHCI_PhyControl_RdReg) &&
+ (val & OHCI_PhyControl_RdDone))
break;
DELAY(10);
}
- val = OHCI_CSR_READ(sc, OHCI_REG_PhyControl);
return (val & OHCI_PhyControl_RdData) >> OHCI_PhyControl_RdData_BITPOS;
}
/*
- * write the PHY Register.
+ * Write the PHY Register.
*/
void
fwohci_phy_write(struct fwohci_softc *sc, u_int8_t reg, u_int8_t val)
{
int i;
+ splassert(IPL_BIO);
+
OHCI_CSR_WRITE(sc, OHCI_REG_PhyControl, OHCI_PhyControl_WrReg |
((reg & 0xf) << OHCI_PhyControl_RegAddr_BITPOS) |
(val << OHCI_PhyControl_WrData_BITPOS));
@@ -851,7 +1139,7 @@ fwohci_phy_write(struct fwohci_softc *sc, u_int8_t reg, u_int8_t val)
}
/*
- * Initiate Bus Reset
+ * Initiate Bus Reset.
*/
void
fwohci_phy_busreset(struct fwohci_softc *sc)
@@ -859,25 +1147,27 @@ fwohci_phy_busreset(struct fwohci_softc *sc)
int s;
u_int8_t val;
+ splassert(IPL_BIO);
+
s = splbio();
OHCI_CSR_WRITE(sc, OHCI_REG_IntEventClear,
OHCI_Int_BusReset | OHCI_Int_SelfIDComplete);
OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskSet, OHCI_Int_BusReset);
-#ifdef __NetBSD__
+#ifdef __NetBSD__
callout_stop(&sc->sc_selfid_callout);
#else
timeout_del(&sc->sc_selfid_callout);
#endif
val = fwohci_phy_read(sc, 1);
- val = (val & 0x80) | /* preserve RHB (force root) */
- 0x40 | /* Initiate Bus Reset */
- 0x3f; /* default GAP count */
+ val = (val & 0x80) | /* Preserve RHB (force root). */
+ 0x40 | /* Initiate Bus Reset. */
+ 0x3f; /* Default GAP count. */
fwohci_phy_write(sc, 1, val);
splx(s);
}
/*
- * PHY Packet
+ * PHY Packet.
*/
void
fwohci_phy_input(struct fwohci_softc *sc, struct fwohci_pkt *pkt)
@@ -888,7 +1178,7 @@ fwohci_phy_input(struct fwohci_softc *sc, struct fwohci_pkt *pkt)
if (val != ~pkt->fp_hdr[2]) {
if (val == 0 && ((*pkt->fp_trail & 0x001f0000) >> 16) ==
OHCI_CTXCTL_EVENT_BUS_RESET) {
- DPRINTFN(1, ("fwohci_phy_input: BusReset: 0x%08x\n",
+ DPRINTFN(1, ("%s: BusReset: 0x%08x\n", __func__,
pkt->fp_hdr[2]));
} else {
printf("%s: phy packet corrupted (0x%08x, 0x%08x)\n",
@@ -897,10 +1187,10 @@ fwohci_phy_input(struct fwohci_softc *sc, struct fwohci_pkt *pkt)
}
return;
}
-#ifdef FW_DEBUG
- if (fwdebug > 1)
+#ifdef FWOHCI_DEBUG
+ if (fwohcidebug > 1)
fwohci_show_phypkt(sc, val);
-#endif
+#endif /* FWOHCI_DEBUG */
}
/*
@@ -912,7 +1202,7 @@ fwohci_desc_alloc(struct fwohci_softc *sc)
int error, mapsize, dsize;
/*
- * allocate descriptor buffer
+ * Allocate descriptor buffer.
*/
sc->sc_descsize = OHCI_BUF_ARRQ_CNT + OHCI_BUF_ARRS_CNT +
@@ -920,37 +1210,50 @@ fwohci_desc_alloc(struct fwohci_softc *sc)
OHCI_BUF_IR_CNT * sc->sc_isoctx + 2;
dsize = sizeof(struct fwohci_desc) * sc->sc_descsize;
mapsize = howmany(sc->sc_descsize, NBBY);
-#ifdef M_ZERO
+#ifdef M_ZERO
sc->sc_descmap = malloc(mapsize, M_DEVBUF, M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("malloc(DEVBUF)", sc->sc_descmap);
#else
sc->sc_descmap = malloc(mapsize, M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", sc->sc_descmap);
bzero(sc->sc_descmap, mapsize);
#endif
+#if 1 /* XXX Added when reorganizing dmamap stuff... */
+ sc->sc_dnseg = 1;
+#endif
+
+ if ((error = bus_dmamap_create(sc->sc_dmat, dsize, sc->sc_dnseg,
+ dsize, 0, BUS_DMA_WAITOK, &sc->sc_ddmamap)) != 0) {
+ printf("%s: unable to create descriptor buffer DMA map, "
+ "error = %d\n", sc->sc_sc1394.sc1394_dev.dv_xname, error);
+ goto fail_0;
+ }
+ //MPRINTF_OLD("bus_dmamap_create", sc->sc_ddmamap);
+
if ((error = bus_dmamem_alloc(sc->sc_dmat, dsize, PAGE_SIZE, 0,
- &sc->sc_dseg, 1, &sc->sc_dnseg, 0)) != 0) {
+ &sc->sc_dseg, 1, &sc->sc_dnseg, BUS_DMA_WAITOK)) != 0) {
printf("%s: unable to allocate descriptor buffer, error = %d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, error);
- goto fail_0;
+ goto fail_1;
}
+ //MPRINTF_OLD("bus_dmamem_alloc", sc->sc_dseg.ds_addr);
if ((error = bus_dmamem_map(sc->sc_dmat, &sc->sc_dseg, sc->sc_dnseg,
dsize, (caddr_t *)&sc->sc_desc, BUS_DMA_COHERENT | BUS_DMA_WAITOK))
!= 0) {
printf("%s: unable to map descriptor buffer, error = %d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, error);
- goto fail_1;
- }
-
- if ((error = bus_dmamap_create(sc->sc_dmat, dsize, sc->sc_dnseg,
- dsize, 0, BUS_DMA_WAITOK, &sc->sc_ddmamap)) != 0) {
- printf("%s: unable to create descriptor buffer DMA map, "
- "error = %d\n", sc->sc_sc1394.sc1394_dev.dv_xname, error);
goto fail_2;
}
+#if 0
if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_ddmamap, sc->sc_desc,
dsize, NULL, BUS_DMA_WAITOK)) != 0) {
+#else
+ if ((error = bus_dmamap_load_raw(sc->sc_dmat, sc->sc_ddmamap,
+ &sc->sc_dseg, sc->sc_dnseg, dsize, BUS_DMA_WAITOK)) != 0) {
+#endif
printf("%s: unable to load descriptor buffer DMA map, "
"error = %d\n", sc->sc_sc1394.sc1394_dev.dv_xname, error);
goto fail_3;
@@ -959,20 +1262,41 @@ fwohci_desc_alloc(struct fwohci_softc *sc)
return 0;
fail_3:
- bus_dmamap_destroy(sc->sc_dmat, sc->sc_ddmamap);
- fail_2:
bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->sc_desc, dsize);
- fail_1:
+ fail_2:
bus_dmamem_free(sc->sc_dmat, &sc->sc_dseg, sc->sc_dnseg);
+ //MPRINTF_OLD("bus_dmamem_free", sc->sc_dseg.ds_addr);
+ fail_1:
+ bus_dmamap_destroy(sc->sc_dmat, sc->sc_ddmamap);
+ //MPRINTF_OLD("bus_dmamap_destroy", sc->sc_ddmamap);
fail_0:
return error;
}
+void
+fwohci_desc_free(struct fwohci_softc *sc)
+{
+ int dsize = sizeof(struct fwohci_desc) * sc->sc_descsize;
+
+ bus_dmamap_unload(sc->sc_dmat, sc->sc_ddmamap);
+ bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->sc_desc, dsize);
+ bus_dmamem_free(sc->sc_dmat, &sc->sc_dseg, sc->sc_dnseg);
+ //MPRINTF_OLD("bus_dmamem_free", sc->sc_dseg.ds_addr);
+ bus_dmamap_destroy(sc->sc_dmat, sc->sc_ddmamap);
+ //MPRINTF_OLD("bus_dmamap_destroy", sc->sc_ddmamap);
+
+ free(sc->sc_descmap, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", sc->sc_descmap);
+ sc->sc_descmap = NULL; /* XXX */
+}
+
struct fwohci_desc *
fwohci_desc_get(struct fwohci_softc *sc, int ndesc)
{
int i, n;
+ assert(ndesc > 0);
+
for (n = 0; n <= sc->sc_descsize - ndesc; n++) {
for (i = 0; ; i++) {
if (i == ndesc) {
@@ -992,9 +1316,11 @@ fwohci_desc_put(struct fwohci_softc *sc, struct fwohci_desc *fd, int ndesc)
{
int i, n;
+ assert(ndesc > 0);
+
n = fd - sc->sc_desc;
for (i = 0; i < ndesc; i++, n++) {
-#ifdef DIAGNOSTIC
+#ifdef DIAGNOSTIC
if (isclr(sc->sc_descmap, n))
panic("fwohci_desc_put: duplicated free");
#endif
@@ -1003,7 +1329,7 @@ fwohci_desc_put(struct fwohci_softc *sc, struct fwohci_desc *fd, int ndesc)
}
/*
- * Asyncronous/Isochronous Transmit/Receive Context
+ * Asyncronous/Isochronous Transmit/Receive Context.
*/
int
fwohci_ctx_alloc(struct fwohci_softc *sc, struct fwohci_ctx **fcp,
@@ -1017,24 +1343,32 @@ fwohci_ctx_alloc(struct fwohci_softc *sc, struct fwohci_ctx **fcp,
int buf2cnt;
#endif
-#ifdef M_ZERO
- fc = malloc(sizeof(*fc), M_DEVBUF, M_WAITOK|M_ZERO);
+#ifdef M_ZERO
+ MALLOC(fc, struct fwohci_ctx *, sizeof(*fc), M_DEVBUF, M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", fc);
#else
- fc = malloc(sizeof(*fc), M_DEVBUF, M_WAITOK);
+ MALLOC(fc, struct fwohci_ctx *, sizeof(*fc), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", fc);
bzero(fc, sizeof(*fc));
#endif
LIST_INIT(&fc->fc_handler);
TAILQ_INIT(&fc->fc_buf);
fc->fc_ctx = ctx;
-#ifdef M_ZERO
- fc->fc_buffers = fb = malloc(sizeof(*fb) * bufcnt, M_DEVBUF, M_WAITOK|M_ZERO);
+#ifdef M_ZERO
+ fc->fc_buffers = fb = malloc(sizeof(*fb) * bufcnt,
+ M_DEVBUF, M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("malloc(DEVBUF)", fc->fc_buffers);
#else
fc->fc_buffers = fb = malloc(sizeof(*fb) * bufcnt, M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", fc->fc_buffers);
bzero(fb, sizeof(*fb) * bufcnt);
#endif
fc->fc_bufcnt = bufcnt;
+ if (bufcnt == 0) /* Asynchronous transmit... */
+ goto ok;
+
#if DOUBLEBUF
- TAILQ_INIT(&fc->fc_buf2); /* for isochronous */
+ TAILQ_INIT(&fc->fc_buf2); /* For isochronous. */
if (ctxtype == FWOHCI_CTX_ISO_MULTI) {
buf2cnt = bufcnt/2;
bufcnt -= buf2cnt;
@@ -1053,11 +1387,17 @@ fwohci_ctx_alloc(struct fwohci_softc *sc, struct fwohci_ctx **fcp,
fb->fb_desc = fd;
fb->fb_daddr = sc->sc_ddmamap->dm_segs[0].ds_addr +
((caddr_t)fd - (caddr_t)sc->sc_desc);
+ bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_PREWRITE);
fd->fd_flags = OHCI_DESC_INPUT | OHCI_DESC_STATUS |
OHCI_DESC_INTR_ALWAYS | OHCI_DESC_BRANCH;
fd->fd_reqcount = fb->fb_dmamap->dm_segs[0].ds_len;
fd->fd_data = fb->fb_dmamap->dm_segs[0].ds_addr;
TAILQ_INSERT_TAIL(&fc->fc_buf, fb, fb_list);
+ bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_POSTWRITE);
}
#if DOUBLEBUF
if (ctxtype == FWOHCI_CTX_ISO_MULTI) {
@@ -1072,19 +1412,20 @@ fwohci_ctx_alloc(struct fwohci_softc *sc, struct fwohci_ctx **fcp,
fb->fb_daddr = sc->sc_ddmamap->dm_segs[0].ds_addr +
((caddr_t)fd - (caddr_t)sc->sc_desc);
bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
- (caddr_t)fd - (caddr_t)sc->sc_desc, sizeof(struct fwohci_desc),
- BUS_DMASYNC_PREWRITE);
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_PREWRITE);
fd->fd_flags = OHCI_DESC_INPUT | OHCI_DESC_STATUS |
OHCI_DESC_INTR_ALWAYS | OHCI_DESC_BRANCH;
fd->fd_reqcount = fb->fb_dmamap->dm_segs[0].ds_len;
fd->fd_data = fb->fb_dmamap->dm_segs[0].ds_addr;
TAILQ_INSERT_TAIL(&fc->fc_buf2, fb, fb_list);
bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
- (caddr_t)fd - (caddr_t)sc->sc_desc, sizeof(struct fwohci_desc),
- BUS_DMASYNC_POSTWRITE);
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_POSTWRITE);
}
}
#endif /* DOUBLEBUF */
+ ok:
fc->fc_type = ctxtype;
*fcp = fc;
return 0;
@@ -1096,7 +1437,9 @@ fwohci_ctx_alloc(struct fwohci_softc *sc, struct fwohci_ctx **fcp,
fwohci_desc_put(sc, fb->fb_desc, 1);
fwohci_buf_free(sc, fb);
}
- free(fc, M_DEVBUF);
+ FREE(fc, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", fc);
+ fc = NULL; /* XXX */
return error;
}
@@ -1125,16 +1468,20 @@ fwohci_ctx_free(struct fwohci_softc *sc, struct fwohci_ctx *fc)
fwohci_desc_put(sc, fb->fb_desc, 1);
fwohci_buf_free(sc, fb);
}
-#if DOUBLEBUF
+#if DOUBLEBUF
while ((fb = TAILQ_FIRST(&fc->fc_buf2)) != NULL) {
TAILQ_REMOVE(&fc->fc_buf2, fb, fb_list);
if (fb->fb_desc)
fwohci_desc_put(sc, fb->fb_desc, 1);
fwohci_buf_free(sc, fb);
}
-#endif /* DOUBLEBUF */
+#endif /* DOUBLEBUF */
free(fc->fc_buffers, M_DEVBUF);
- free(fc, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", fc->fc_buffers);
+ fc->fc_buffers = NULL; /* XXX */
+ FREE(fc, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", fc);
+ fc = NULL; /* XXX */
}
void
@@ -1145,27 +1492,35 @@ fwohci_ctx_init(struct fwohci_softc *sc, struct fwohci_ctx *fc)
struct fwohci_handler *fh;
int n;
- for (fb = TAILQ_FIRST(&fc->fc_buf); fb != NULL; fb = nfb) {
+ splassert(IPL_BIO);
+
+ TAILQ_FOREACH(fb, &fc->fc_buf, fb_list) {
+ bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_PREWRITE);
nfb = TAILQ_NEXT(fb, fb_list);
fb->fb_off = 0;
fd = fb->fb_desc;
fd->fd_branch = (nfb != NULL) ? (nfb->fb_daddr | 1) : 0;
fd->fd_rescount = fd->fd_reqcount;
+ bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_POSTWRITE);
}
#if DOUBLEBUF
- for (fb = TAILQ_FIRST(&fc->fc_buf2); fb != NULL; fb = nfb) {
+ TAILQ_FOREACH(fb, &fc->fc_buf2, fb_list) {
bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
- (caddr_t)fd - (caddr_t)sc->sc_desc, sizeof(struct fwohci_desc),
- BUS_DMASYNC_PREWRITE);
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_PREWRITE);
nfb = TAILQ_NEXT(fb, fb_list);
fb->fb_off = 0;
fd = fb->fb_desc;
fd->fd_branch = (nfb != NULL) ? (nfb->fb_daddr | 1) : 0;
fd->fd_rescount = fd->fd_reqcount;
bus_dmamap_sync(sc->sc_dmat, sc->sc_ddmamap,
- (caddr_t)fd - (caddr_t)sc->sc_desc, sizeof(struct fwohci_desc),
- BUS_DMASYNC_POSTWRITE);
+ (caddr_t)fd - (caddr_t)sc->sc_desc,
+ sizeof(struct fwohci_desc), BUS_DMASYNC_POSTWRITE);
}
#endif /* DOUBLEBUF */
@@ -1174,6 +1529,7 @@ fwohci_ctx_init(struct fwohci_softc *sc, struct fwohci_ctx *fc)
if (fc->fc_type != FWOHCI_CTX_ASYNC) {
OHCI_SYNC_RX_DMA_WRITE(sc, n, OHCI_SUBREG_CommandPtr,
fb->fb_daddr | 1);
+ MPRINTF("OHCI_SUBREG_CommandPtr(SYNC_RX)", fb->fb_daddr);
OHCI_SYNC_RX_DMA_WRITE(sc, n, OHCI_SUBREG_ContextControlClear,
OHCI_CTXCTL_RX_BUFFER_FILL |
OHCI_CTXCTL_RX_CYCLE_MATCH_ENABLE |
@@ -1192,41 +1548,53 @@ fwohci_ctx_init(struct fwohci_softc *sc, struct fwohci_ctx *fc)
} else {
OHCI_ASYNC_DMA_WRITE(sc, n, OHCI_SUBREG_CommandPtr,
fb->fb_daddr | 1);
+ MPRINTF("OHCI_SUBREG_CommandPtr(ASYNC)", fb->fb_daddr);
}
}
/*
- * DMA data buffer
+ * DMA data buffer.
*/
int
fwohci_buf_alloc(struct fwohci_softc *sc, struct fwohci_buf *fb)
{
int error;
+ if (!fb->fb_nseg)
+ fb->fb_nseg = 1;
+
+ if ((error = bus_dmamap_create(sc->sc_dmat, PAGE_SIZE, fb->fb_nseg,
+ PAGE_SIZE, 0, BUS_DMA_WAITOK, &fb->fb_dmamap)) != 0) {
+ printf("%s: unable to create buffer DMA map, "
+ "error = %d\n", sc->sc_sc1394.sc1394_dev.dv_xname,
+ error);
+ goto fail_0;
+ }
+ //MPRINTF_OLD("bus_dmamap_create", fb->fb_dmamap);
+
if ((error = bus_dmamem_alloc(sc->sc_dmat, PAGE_SIZE, PAGE_SIZE,
PAGE_SIZE, &fb->fb_seg, 1, &fb->fb_nseg, BUS_DMA_WAITOK)) != 0) {
printf("%s: unable to allocate buffer, error = %d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, error);
- goto fail_0;
+ goto fail_1;
}
+ //MPRINTF_OLD("bus_dmamem_alloc", fb->fb_seg.ds_addr);
if ((error = bus_dmamem_map(sc->sc_dmat, &fb->fb_seg,
- fb->fb_nseg, PAGE_SIZE, &fb->fb_buf, BUS_DMA_WAITOK)) != 0) {
+ fb->fb_nseg, PAGE_SIZE, &fb->fb_buf,
+ BUS_DMA_COHERENT | BUS_DMA_WAITOK)) != 0) {
printf("%s: unable to map buffer, error = %d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, error);
- goto fail_1;
- }
-
- if ((error = bus_dmamap_create(sc->sc_dmat, PAGE_SIZE, fb->fb_nseg,
- PAGE_SIZE, 0, BUS_DMA_WAITOK, &fb->fb_dmamap)) != 0) {
- printf("%s: unable to create buffer DMA map, "
- "error = %d\n", sc->sc_sc1394.sc1394_dev.dv_xname,
- error);
goto fail_2;
}
+#if 0
if ((error = bus_dmamap_load(sc->sc_dmat, fb->fb_dmamap,
fb->fb_buf, PAGE_SIZE, NULL, BUS_DMA_WAITOK)) != 0) {
+#else
+ if ((error = bus_dmamap_load_raw(sc->sc_dmat, fb->fb_dmamap,
+ &fb->fb_seg, fb->fb_nseg, PAGE_SIZE, BUS_DMA_WAITOK)) != 0) {
+#endif
printf("%s: unable to load buffer DMA map, "
"error = %d\n", sc->sc_sc1394.sc1394_dev.dv_xname,
error);
@@ -1237,11 +1605,13 @@ fwohci_buf_alloc(struct fwohci_softc *sc, struct fwohci_buf *fb)
bus_dmamap_unload(sc->sc_dmat, fb->fb_dmamap);
fail_3:
- bus_dmamap_destroy(sc->sc_dmat, fb->fb_dmamap);
- fail_2:
bus_dmamem_unmap(sc->sc_dmat, fb->fb_buf, PAGE_SIZE);
- fail_1:
+ fail_2:
bus_dmamem_free(sc->sc_dmat, &fb->fb_seg, fb->fb_nseg);
+ //MPRINTF_OLD("bus_dmamem_free", fb->fb_seg.ds_addr);
+ fail_1:
+ bus_dmamap_destroy(sc->sc_dmat, fb->fb_dmamap);
+ //MPRINTF_OLD("bus_dmamap_destroy", fb->fb_dmamap);
fail_0:
return error;
}
@@ -1251,9 +1621,11 @@ fwohci_buf_free(struct fwohci_softc *sc, struct fwohci_buf *fb)
{
bus_dmamap_unload(sc->sc_dmat, fb->fb_dmamap);
- bus_dmamap_destroy(sc->sc_dmat, fb->fb_dmamap);
bus_dmamem_unmap(sc->sc_dmat, fb->fb_buf, PAGE_SIZE);
bus_dmamem_free(sc->sc_dmat, &fb->fb_seg, fb->fb_nseg);
+ //MPRINTF_OLD("bus_dmamem_free", fb->fb_seg.ds_addr);
+ bus_dmamap_destroy(sc->sc_dmat, fb->fb_dmamap);
+ //MPRINTF_OLD("bus_dmamap_destroy", fb->fb_dmamap);
}
void
@@ -1261,6 +1633,8 @@ fwohci_buf_init_rx(struct fwohci_softc *sc)
{
int i;
+ splassert(IPL_BIO);
+
/*
* Initialize for Asynchronous Receive Queue.
*/
@@ -1281,6 +1655,8 @@ fwohci_buf_start_rx(struct fwohci_softc *sc)
{
int i;
+// splassert(IPL_BIO);
+
OHCI_ASYNC_DMA_WRITE(sc, OHCI_CTX_ASYNC_RX_REQUEST,
OHCI_SUBREG_ContextControlSet, OHCI_CTXCTL_RUN);
OHCI_ASYNC_DMA_WRITE(sc, OHCI_CTX_ASYNC_RX_RESPONSE,
@@ -1297,6 +1673,8 @@ fwohci_buf_stop_tx(struct fwohci_softc *sc)
{
int i;
+// splassert(IPL_BIO);
+
OHCI_ASYNC_DMA_WRITE(sc, OHCI_CTX_ASYNC_TX_REQUEST,
OHCI_SUBREG_ContextControlClear, OHCI_CTXCTL_RUN);
OHCI_ASYNC_DMA_WRITE(sc, OHCI_CTX_ASYNC_TX_RESPONSE,
@@ -1328,6 +1706,8 @@ fwohci_buf_stop_rx(struct fwohci_softc *sc)
{
int i;
+ splassert(IPL_BIO);
+
OHCI_ASYNC_DMA_WRITE(sc, OHCI_CTX_ASYNC_RX_REQUEST,
OHCI_SUBREG_ContextControlClear, OHCI_CTXCTL_RUN);
OHCI_ASYNC_DMA_WRITE(sc, OHCI_CTX_ASYNC_RX_RESPONSE,
@@ -1347,7 +1727,7 @@ fwohci_buf_next(struct fwohci_softc *sc, struct fwohci_ctx *fc)
if (fc->fc_type != FWOHCI_CTX_ISO_MULTI) {
#endif
while ((fb = TAILQ_FIRST(&fc->fc_buf)) != NULL) {
- if (fc->fc_type) {
+ if (fc->fc_type != FWOHCI_CTX_ASYNC) {
if (fb->fb_off == 0)
break;
} else {
@@ -1367,14 +1747,13 @@ fwohci_buf_next(struct fwohci_softc *sc, struct fwohci_ctx *fc)
} else {
struct fwohci_buf_s fctmp;
- /* cleaning buffer */
- for (fb = TAILQ_FIRST(&fc->fc_buf); fb != NULL;
- fb = TAILQ_NEXT(fb, fb_list)) {
+ /* Cleaning buffer. */
+ TAILQ_FOREACH(fb, &fc->fc_buf, fb_list) {
fb->fb_off = 0;
fb->fb_desc->fd_rescount = fb->fb_desc->fd_reqcount;
}
-
- /* rotating buffer */
+
+ /* Rotating buffer. */
fctmp = fc->fc_buf;
fc->fc_buf = fc->fc_buf2;
fc->fc_buf2 = fctmp;
@@ -1383,28 +1762,31 @@ fwohci_buf_next(struct fwohci_softc *sc, struct fwohci_ctx *fc)
}
int
-fwohci_buf_pktget(struct fwohci_softc *sc, struct fwohci_buf **fbp, caddr_t *pp,
- int len)
+fwohci_buf_pktget(struct fwohci_softc *sc, struct fwohci_buf **fbp,
+ caddr_t *pp, int reqlen)
{
struct fwohci_buf *fb;
struct fwohci_desc *fd;
- int bufend;
+ int bufend, len = reqlen;
+#ifdef FWOHCI_DEBUG
+ int i;
+#endif /* FWOHCI_DEBUG */
fb = *fbp;
- again:
+again:
fd = fb->fb_desc;
- DPRINTFN(1, ("fwohci_buf_pktget: desc %ld, off %d, req %d, res %d,"
- " len %d, avail %d\n", (long)(fd - sc->sc_desc), fb->fb_off,
- fd->fd_reqcount, fd->fd_rescount, len,
+ DPRINTFN(1, ("%s: desc %ld, off %d, req %d, res %d, len %d, avail %d",
+ __func__, (long)(fd - sc->sc_desc), fb->fb_off, fd->fd_reqcount,
+ fd->fd_rescount, len,
fd->fd_reqcount - fd->fd_rescount - fb->fb_off));
bufend = fd->fd_reqcount - fd->fd_rescount;
if (fb->fb_off >= bufend) {
- DPRINTFN(5, ("buf %x finish req %d res %d off %d ",
+ DPRINTFN(5, ("\n\tbuf %08x finish req %d res %d off %d",
fb->fb_desc->fd_data, fd->fd_reqcount, fd->fd_rescount,
fb->fb_off));
if (fd->fd_rescount == 0) {
*fbp = fb = TAILQ_NEXT(fb, fb_list);
- if (fb != NULL)
+ if (fb != TAILQ_END(fb))
goto again;
}
return 0;
@@ -1413,6 +1795,15 @@ fwohci_buf_pktget(struct fwohci_softc *sc, struct fwohci_buf **fbp, caddr_t *pp,
len = bufend - fb->fb_off;
bus_dmamap_sync(sc->sc_dmat, fb->fb_dmamap, fb->fb_off, len,
BUS_DMASYNC_POSTREAD);
+
+#ifdef FWOHCI_DEBUG
+ for (i=0; i < (roundup(len, 4) / 4); i++) {
+ if ((i % 8) == 0) DPRINTFN(5, ("\n "));
+ DPRINTFN(5, (" %08x",
+ ((u_int32_t *)(fb->fb_buf + fb->fb_off))[i]));
+ }
+#endif /* FWOHCI_DEBUG */
+ DPRINTF(("\n"));
*pp = fb->fb_buf + fb->fb_off;
fb->fb_off += roundup(len, 4);
return len;
@@ -1426,51 +1817,50 @@ fwohci_buf_input(struct fwohci_softc *sc, struct fwohci_ctx *fc,
struct fwohci_buf *fb;
int len, count, i;
- memset(pkt, 0, sizeof(*pkt));
+ bzero(pkt, sizeof(*pkt));
pkt->fp_uio.uio_iov = pkt->fp_iov;
pkt->fp_uio.uio_rw = UIO_WRITE;
pkt->fp_uio.uio_segflg = UIO_SYSSPACE;
- /* get first quadlet */
+ /* Get first quadlet. */
fb = TAILQ_FIRST(&fc->fc_buf);
count = 4;
len = fwohci_buf_pktget(sc, &fb, &p, count);
if (len <= 0) {
- DPRINTFN(1, ("fwohci_buf_input: no input for %d\n",
- fc->fc_ctx));
+ DPRINTFN(1, ("%s: no input for %d\n", __func__, fc->fc_ctx));
return 0;
}
- pkt->fp_hdr[0] = *(u_int32_t *)p;
+ pkt->fp_hdr[0] = *(u_int32_t *)p; /* XXX Alignment !!! */
pkt->fp_tcode = (pkt->fp_hdr[0] & 0x000000f0) >> 4;
switch (pkt->fp_tcode) {
- case IEEE1394_TCODE_WRITE_REQ_QUAD:
- case IEEE1394_TCODE_READ_RESP_QUAD:
+ case IEEE1394_TCODE_WRITE_REQUEST_QUADLET:
+ case IEEE1394_TCODE_READ_RESPONSE_QUADLET:
pkt->fp_hlen = 12;
pkt->fp_dlen = 4;
break;
- case IEEE1394_TCODE_READ_REQ_BLOCK:
+ case IEEE1394_TCODE_READ_REQUEST_DATABLOCK:
pkt->fp_hlen = 16;
pkt->fp_dlen = 0;
break;
- case IEEE1394_TCODE_WRITE_REQ_BLOCK:
- case IEEE1394_TCODE_READ_RESP_BLOCK:
- case IEEE1394_TCODE_LOCK_REQ:
- case IEEE1394_TCODE_LOCK_RESP:
+ case IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK:
+ case IEEE1394_TCODE_READ_RESPONSE_DATABLOCK:
+ case IEEE1394_TCODE_LOCK_REQUEST:
+ case IEEE1394_TCODE_LOCK_RESPONSE:
pkt->fp_hlen = 16;
break;
- case IEEE1394_TCODE_STREAM_DATA:
-#ifdef DIAGNOSTIC
+ case IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK:
+#ifdef DIAGNOSTIC
if (fc->fc_type == FWOHCI_CTX_ISO_MULTI)
#endif
{
pkt->fp_hlen = 4;
- pkt->fp_dlen = pkt->fp_hdr[0] >> 16;
+ pkt->fp_dlen = (pkt->fp_hdr[0] >> 16) & 0xffff;
DPRINTFN(5, ("[%d]", pkt->fp_dlen));
break;
}
-#ifdef DIAGNOSTIC
+#ifdef DIAGNOSTIC
else {
- printf("fwohci_buf_input: bad tcode: STREAM_DATA\n");
+ printf("%s: bad tcode: STREAM_DATA\n", __func__);
return 0;
}
#endif
@@ -1480,32 +1870,38 @@ fwohci_buf_input(struct fwohci_softc *sc, struct fwohci_ctx *fc,
break;
}
- /* get header */
+ /* Get header. */
while (count < pkt->fp_hlen) {
len = fwohci_buf_pktget(sc, &fb, &p, pkt->fp_hlen - count);
if (len == 0) {
- printf("fwohci_buf_input: malformed input 1: %d\n",
+ printf("%s: malformed input 1: %d\n", __func__,
pkt->fp_hlen - count);
return 0;
}
- memcpy((caddr_t)pkt->fp_hdr + count, p, len);
+#ifdef FWOHCI_DEBUG
+ fwptr = p; fwlen = len; fwbuf = fb;
+#endif /* FWOHCI_DEBUG */
+ bcopy(p, (caddr_t)pkt->fp_hdr + count, len);
+#ifdef FWOHCI_DEBUG
+ fwptr = NULL; fwlen = 0; fwbuf = NULL;
+#endif /* FWOHCI_DEBUG */
count += len;
}
if (pkt->fp_hlen == 16 &&
- pkt->fp_tcode != IEEE1394_TCODE_READ_REQ_BLOCK)
+ pkt->fp_tcode != IEEE1394_TCODE_READ_REQUEST_DATABLOCK)
pkt->fp_dlen = pkt->fp_hdr[3] >> 16;
- DPRINTFN(1, ("fwohci_buf_input: tcode=0x%x, hlen=%d, dlen=%d\n",
+ DPRINTFN(1, ("%s: tcode=0x%x, hlen=%d, dlen=%d\n", __func__,
pkt->fp_tcode, pkt->fp_hlen, pkt->fp_dlen));
- /* get data */
+ /* Get data. */
count = 0;
i = 0;
- while (count < pkt->fp_dlen) {
+ while (i < 6 && count < pkt->fp_dlen) {
len = fwohci_buf_pktget(sc, &fb,
(caddr_t *)&pkt->fp_iov[i].iov_base,
pkt->fp_dlen - count);
if (len == 0) {
- printf("fwohci_buf_input: malformed input 2: %d\n",
+ printf("%s: malformed input 2: %d\n", __func__,
pkt->fp_dlen - count);
return 0;
}
@@ -1515,11 +1911,23 @@ fwohci_buf_input(struct fwohci_softc *sc, struct fwohci_ctx *fc,
pkt->fp_uio.uio_iovcnt = i;
pkt->fp_uio.uio_resid = count;
- /* get trailer */
+ if (count < pkt->fp_dlen) { /* Eat the remainder of the packet. */
+ printf("%s: %d iov exhausted, %d bytes not gotten\n",
+ __func__, i, pkt->fp_dlen - count);
+ while (count < pkt->fp_dlen) {
+ len = fwohci_buf_pktget(sc, &fb,
+ (caddr_t *)&pkt->fp_trail,
+ ((pkt->fp_dlen - count) > sizeof(*pkt->fp_trail)) ?
+ sizeof(*pkt->fp_trail) : (pkt->fp_dlen - count));
+ count += len;
+ }
+ }
+
+ /* Get trailer. */
len = fwohci_buf_pktget(sc, &fb, (caddr_t *)&pkt->fp_trail,
sizeof(*pkt->fp_trail));
if (len <= 0) {
- printf("fwohci_buf_input: malformed input 3: %d\n",
+ printf("%s: malformed input 3: %d\n", __func__,
pkt->fp_hlen - count);
return 0;
}
@@ -1539,17 +1947,18 @@ fwohci_buf_input_ppb(struct fwohci_softc *sc, struct fwohci_ctx *fc,
return fwohci_buf_input(sc, fc, pkt);
}
- memset(pkt, 0, sizeof(*pkt));
+ bzero(pkt, sizeof(*pkt));
pkt->fp_uio.uio_iov = pkt->fp_iov;
pkt->fp_uio.uio_rw = UIO_WRITE;
pkt->fp_uio.uio_segflg = UIO_SYSSPACE;
- for (fb = TAILQ_FIRST(&fc->fc_buf); ; fb = TAILQ_NEXT(fb, fb_list)) {
- if (fb == NULL)
- return 0;
+ TAILQ_FOREACH(fb, &fc->fc_buf, fb_list) {
if (fb->fb_off == 0)
break;
}
+ if (fb == NULL)
+ return 0;
+
fd = fb->fb_desc;
len = fd->fd_reqcount - fd->fd_rescount;
if (len == 0)
@@ -1560,22 +1969,21 @@ fwohci_buf_input_ppb(struct fwohci_softc *sc, struct fwohci_ctx *fc,
p = fb->fb_buf;
fb->fb_off += roundup(len, 4);
if (len < 8) {
- printf("fwohci_buf_input_ppb: malformed input 1: %d\n", len);
+ printf("%s: malformed input 1: %d\n", __func__, len);
return 0;
}
/*
- * get trailer first, may be bogus data unless status update
+ * Get trailer first, may be bogus data unless status update
* in descriptor is set.
*/
pkt->fp_trail = (u_int32_t *)p;
*pkt->fp_trail = (*pkt->fp_trail & 0xffff) | (fd->fd_status << 16);
pkt->fp_hdr[0] = ((u_int32_t *)p)[1];
pkt->fp_tcode = (pkt->fp_hdr[0] & 0x000000f0) >> 4;
-#ifdef DIAGNOSTIC
- if (pkt->fp_tcode != IEEE1394_TCODE_STREAM_DATA) {
- printf("fwohci_buf_input_ppb: bad tcode: 0x%x\n",
- pkt->fp_tcode);
+#ifdef DIAGNOSTIC
+ if (pkt->fp_tcode != IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK) {
+ printf("%s: bad tcode: 0x%x\n", __func__, pkt->fp_tcode);
return 0;
}
#endif
@@ -1584,30 +1992,29 @@ fwohci_buf_input_ppb(struct fwohci_softc *sc, struct fwohci_ctx *fc,
p += 8;
len -= 8;
if (pkt->fp_dlen != len) {
- printf("fwohci_buf_input_ppb: malformed input 2: %d != %d\n",
+ printf("%s: malformed input 2: %d != %d\n", __func__,
pkt->fp_dlen, len);
return 0;
}
- DPRINTFN(1, ("fwohci_buf_input_ppb: tcode=0x%x, hlen=%d, dlen=%d\n",
+ DPRINTFN(1, ("%s: tcode=0x%x, hlen=%d, dlen=%d\n", __func__,
pkt->fp_tcode, pkt->fp_hlen, pkt->fp_dlen));
pkt->fp_iov[0].iov_base = p;
pkt->fp_iov[0].iov_len = len;
- pkt->fp_uio.uio_iovcnt = 0;
+ pkt->fp_uio.uio_iovcnt = 1;
pkt->fp_uio.uio_resid = len;
return 1;
}
int
-fwohci_handler_set(struct fwohci_softc *sc,
- int tcode, u_int32_t key1, u_int32_t key2,
- int (*handler)(struct fwohci_softc *, void *, struct fwohci_pkt *),
- void *arg)
+fwohci_handler_set(struct fwohci_softc *sc, int tcode, u_int32_t key1,
+ u_int32_t key2, int (*handler)(struct fwohci_softc *, void *,
+ struct fwohci_pkt *), void *arg)
{
struct fwohci_ctx *fc;
struct fwohci_handler *fh;
- int i, j;
+ int i, j, s;
- if (tcode == IEEE1394_TCODE_STREAM_DATA) {
+ if (tcode == IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK) {
int isasync = key1 & OHCI_ASYNC_STREAM;
key1 &= IEEE1394_ISOCH_MASK;
@@ -1629,8 +2036,8 @@ fwohci_handler_set(struct fwohci_softc *sc,
if (handler == NULL)
return 0;
if (j == sc->sc_isoctx) {
- DPRINTF(("fwohci_handler_set: no more free "
- "context\n"));
+ DPRINTF(("%s: no more free context\n",
+ __func__));
return ENOMEM;
}
if ((fc = sc->sc_ctx_ir[j]) == NULL) {
@@ -1642,24 +2049,23 @@ fwohci_handler_set(struct fwohci_softc *sc,
}
} else {
switch (tcode) {
- case IEEE1394_TCODE_WRITE_REQ_QUAD:
- case IEEE1394_TCODE_WRITE_REQ_BLOCK:
- case IEEE1394_TCODE_READ_REQ_QUAD:
- case IEEE1394_TCODE_READ_REQ_BLOCK:
- case IEEE1394_TCODE_LOCK_REQ:
+ case IEEE1394_TCODE_WRITE_REQUEST_QUADLET:
+ case IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK:
+ case IEEE1394_TCODE_READ_REQUEST_QUADLET:
+ case IEEE1394_TCODE_READ_REQUEST_DATABLOCK:
+ case IEEE1394_TCODE_LOCK_REQUEST:
fc = sc->sc_ctx_arrq;
break;
- case IEEE1394_TCODE_WRITE_RESP:
- case IEEE1394_TCODE_READ_RESP_QUAD:
- case IEEE1394_TCODE_READ_RESP_BLOCK:
- case IEEE1394_TCODE_LOCK_RESP:
+ case IEEE1394_TCODE_WRITE_RESPONSE:
+ case IEEE1394_TCODE_READ_RESPONSE_QUADLET:
+ case IEEE1394_TCODE_READ_RESPONSE_DATABLOCK:
+ case IEEE1394_TCODE_LOCK_RESPONSE:
fc = sc->sc_ctx_arrs;
break;
default:
return EIO;
}
- for (fh = LIST_FIRST(&fc->fc_handler); fh != NULL;
- fh = LIST_NEXT(fh, fh_list)) {
+ LIST_FOREACH(fh, &fc->fc_handler, fh_list) {
if (fh->fh_tcode == tcode &&
fh->fh_key1 == key1 && fh->fh_key2 == key2)
break;
@@ -1668,9 +2074,11 @@ fwohci_handler_set(struct fwohci_softc *sc,
if (handler == NULL) {
if (fh != NULL) {
LIST_REMOVE(fh, fh_list);
- free(fh, M_DEVBUF);
+ FREE(fh, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", fh);
+ fh = NULL; /* XXX */
}
- if (tcode == IEEE1394_TCODE_STREAM_DATA) {
+ if (tcode == IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK) {
OHCI_SYNC_RX_DMA_WRITE(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlClear, OHCI_CTXCTL_RUN);
sc->sc_ctx_ir[fc->fc_ctx] = NULL;
@@ -1678,35 +2086,56 @@ fwohci_handler_set(struct fwohci_softc *sc,
}
return 0;
}
+ s = splbio();
if (fh == NULL) {
- fh = malloc(sizeof(*fh), M_DEVBUF, M_WAITOK);
- LIST_INSERT_HEAD(&fc->fc_handler, fh, fh_list);
+ MALLOC(fh, struct fwohci_handler *, sizeof(*fh),
+ M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", fh);
+ bzero(fh, sizeof(*fh));
}
fh->fh_tcode = tcode;
fh->fh_key1 = key1;
fh->fh_key2 = key2;
fh->fh_handler = handler;
fh->fh_handarg = arg;
- DPRINTFN(1, ("fwohci_handler_set: ctx %d, tcode %x, key 0x%x, 0x%x\n",
+
+ if (fh->fh_list.le_prev == NULL)
+ LIST_INSERT_HEAD(&fc->fc_handler, fh, fh_list);
+ splx(s);
+
+ DPRINTFN(1, ("%s: ctx %d, tcode %x, key 0x%x, 0x%x\n", __func__,
fc->fc_ctx, tcode, key1, key2));
- if (tcode == IEEE1394_TCODE_STREAM_DATA) {
+ if (tcode == IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK) {
+ s = splbio();
fwohci_ctx_init(sc, fc);
- DPRINTFN(1, ("fwohci_handler_set: SYNC desc %ld\n",
- (long)(TAILQ_FIRST(&fc->fc_buf)->fb_desc - sc->sc_desc)));
OHCI_SYNC_RX_DMA_WRITE(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlSet, OHCI_CTXCTL_RUN);
+ splx(s);
+ DPRINTFN(1, ("%s: SYNC desc %ld\n", __func__,
+ (long)(TAILQ_FIRST(&fc->fc_buf)->fb_desc - sc->sc_desc)));
}
return 0;
}
+int
+fwohci_block_handler_set(struct fwohci_softc *sc, int tcode, u_int32_t key1,
+ u_int32_t key2, int len, int (*handler)(struct fwohci_softc *, void *,
+ struct fwohci_pkt *), void *arg)
+{
+ u_int32_t key1_n = (key1 & 0xffff) | ((len & 0xffff) << 16);
+
+ return (fwohci_handler_set(sc, tcode, key1_n, key2, handler, arg));
+}
+
/*
* Asyncronous Receive Requests input frontend.
*/
void
fwohci_arrq_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
{
- int rcode;
+ u_int16_t srcid, datalen = 0;
+ int rcode, tlabel;
u_int32_t key1, key2;
struct fwohci_handler *fh;
struct fwohci_pkt pkt, res;
@@ -1716,40 +2145,60 @@ fwohci_arrq_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
* packet cannot be received until the next receive interrupt.
*/
while (fwohci_buf_input(sc, fc, &pkt)) {
- if (pkt.fp_tcode == OHCI_TCODE_PHY) {
+ switch(pkt.fp_tcode) {
+ case OHCI_TCODE_PHY:
fwohci_phy_input(sc, &pkt);
- continue;
+ continue; break;
+ case IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK:
+ datalen = pkt.fp_dlen;
+ break;
+ case IEEE1394_TCODE_READ_REQUEST_DATABLOCK:
+ datalen = pkt.fp_hdr[3] >> 16;
+ break;
}
key1 = pkt.fp_hdr[1] & 0xffff;
key2 = pkt.fp_hdr[2];
- memset(&res, 0, sizeof(res));
+ bzero(&res, sizeof(res));
res.fp_uio.uio_rw = UIO_WRITE;
res.fp_uio.uio_segflg = UIO_SYSSPACE;
- for (fh = LIST_FIRST(&fc->fc_handler); fh != NULL;
- fh = LIST_NEXT(fh, fh_list)) {
+ srcid = pkt.fp_hdr[1] >> 16;
+ tlabel = (pkt.fp_hdr[0] & 0x0000fc00) >> 10;
+ DPRINTFN(1, ("%s: tcode 0x%x, from 0x%04x, tlabel 0x%x, "
+ "hlen %d, dlen %d\n", __func__, pkt.fp_tcode,
+ srcid, tlabel, pkt.fp_hlen, pkt.fp_dlen));
+ LIST_FOREACH(fh, &fc->fc_handler, fh_list) {
if (pkt.fp_tcode == fh->fh_tcode &&
- key1 == fh->fh_key1 &&
- key2 == fh->fh_key2) {
+ ((key1 == fh->fh_key1 && key2 == fh->fh_key2) ||
+ (datalen && key1 == (fh->fh_key1 & 0xffff) &&
+ key2 >= fh->fh_key2 &&
+ (key2 + datalen) <=
+ (fh->fh_key2 + ((fh->fh_key1 >> 16) & 0xffff)))))
+ {
+ DPRINTFN(5, ("%s: handler 0x%08x(0x%08x)\n",
+ __func__, (u_int32_t)(*fh->fh_handler),
+ (u_int32_t)(fh->fh_handarg)));
rcode = (*fh->fh_handler)(sc, fh->fh_handarg,
&pkt);
+ DPRINTFN(5, ("%s: --> rcode %d\n", __func__,
+ rcode));
break;
}
}
if (fh == NULL) {
rcode = IEEE1394_RCODE_ADDRESS_ERROR;
- DPRINTFN(1, ("fwohci_arrq_input: no listener: tcode "
- "0x%x, addr=0x%04x %08x\n", pkt.fp_tcode, key1,
- key2));
+ DPRINTFN(1, ("%s: no listener: tcode 0x%x, "
+ "addr=0x%04x%08x\n", __func__, pkt.fp_tcode,
+ key1, key2));
}
if (((*pkt.fp_trail & 0x001f0000) >> 16) !=
OHCI_CTXCTL_EVENT_ACK_PENDING)
continue;
- if (rcode != -1)
+ if (rcode != -1)
fwohci_atrs_output(sc, rcode, &pkt, &res);
}
fwohci_buf_next(sc, fc);
- OHCI_ASYNC_DMA_WRITE(sc, fc->fc_ctx,
- OHCI_SUBREG_ContextControlSet, OHCI_CTXCTL_WAKE);
+ OHCI_ASYNC_DMA_WRITE(sc, fc->fc_ctx, OHCI_SUBREG_ContextControlSet,
+ OHCI_CTXCTL_WAKE);
}
@@ -1768,27 +2217,28 @@ fwohci_arrs_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
srcid = pkt.fp_hdr[1] >> 16;
rcode = (pkt.fp_hdr[1] & 0x0000f000) >> 12;
tlabel = (pkt.fp_hdr[0] & 0x0000fc00) >> 10;
- DPRINTFN(1, ("fwohci_arrs_input: tcode 0x%x, from 0x%04x,"
- " tlabel 0x%x, rcode 0x%x, hlen %d, dlen %d\n",
+ DPRINTFN(1, ("%s: tcode 0x%x, from 0x%04x, tlabel 0x%x, "
+ "rcode 0x%x, hlen %d, dlen %d\n", __func__,
pkt.fp_tcode, srcid, tlabel, rcode, pkt.fp_hlen,
pkt.fp_dlen));
- for (fh = LIST_FIRST(&fc->fc_handler); fh != NULL;
- fh = LIST_NEXT(fh, fh_list)) {
+ LIST_FOREACH(fh, &fc->fc_handler, fh_list) {
if (pkt.fp_tcode == fh->fh_tcode &&
(srcid & OHCI_NodeId_NodeNumber) == fh->fh_key1 &&
tlabel == fh->fh_key2) {
(*fh->fh_handler)(sc, fh->fh_handarg, &pkt);
LIST_REMOVE(fh, fh_list);
- free(fh, M_DEVBUF);
+ FREE(fh, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", fh);
+ fh = NULL; /* XXX */
break;
}
}
- if (fh == NULL)
- DPRINTFN(1, ("fwohci_arrs_input: no listner\n"));
+ if (fh == NULL)
+ DPRINTFN(1, ("%s: no listener\n", __func__));
}
fwohci_buf_next(sc, fc);
- OHCI_ASYNC_DMA_WRITE(sc, fc->fc_ctx,
- OHCI_SUBREG_ContextControlSet, OHCI_CTXCTL_WAKE);
+ OHCI_ASYNC_DMA_WRITE(sc, fc->fc_ctx, OHCI_SUBREG_ContextControlSet,
+ OHCI_CTXCTL_WAKE);
}
/*
@@ -1808,18 +2258,20 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
int i;
u_int32_t reg;
- /* stop dma engine before read buffer */
+ /* Stop dma engine before read buffer. */
reg = OHCI_SYNC_RX_DMA_READ(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlClear);
- DPRINTFN(5, ("ir_input %08x =>", reg));
+ DPRINTFN(5, ("%s: %08x =>", __func__, reg));
if (reg & OHCI_CTXCTL_RUN) {
OHCI_SYNC_RX_DMA_WRITE(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlClear, OHCI_CTXCTL_RUN);
}
- DPRINTFN(5, (" %08x\n", OHCI_SYNC_RX_DMA_READ(sc, fc->fc_ctx, OHCI_SUBREG_ContextControlClear)));
+ DPRINTFN(5, (" %08x\n", OHCI_SYNC_RX_DMA_READ(sc, fc->fc_ctx,
+ OHCI_SUBREG_ContextControlClear)));
i = 0;
- while ((reg = OHCI_SYNC_RX_DMA_READ(sc, fc->fc_ctx, OHCI_SUBREG_ContextControlSet)) & OHCI_CTXCTL_ACTIVE) {
+ while ((reg = OHCI_SYNC_RX_DMA_READ(sc, fc->fc_ctx,
+ OHCI_SUBREG_ContextControlSet)) & OHCI_CTXCTL_ACTIVE) {
delay(10);
if (++i > 10000) {
printf("cannot stop dma engine 0x%08x\n", reg);
@@ -1827,11 +2279,12 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
}
}
- /* rotate dma buffer */
+ /* Rotate dma buffer. */
fb = TAILQ_FIRST(&fc->fc_buf2);
OHCI_SYNC_RX_DMA_WRITE(sc, fc->fc_ctx, OHCI_SUBREG_CommandPtr,
fb->fb_daddr | 1);
- /* start dma engine */
+ MPRINTF("OHCI_SUBREG_CommandPtr(SYNC_RX)", fb->fb_daddr);
+ /* Start dma engine. */
OHCI_SYNC_RX_DMA_WRITE(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlSet, OHCI_CTXCTL_RUN);
OHCI_CSR_WRITE(sc, OHCI_REG_IsoRecvIntEventClear,
@@ -1842,8 +2295,8 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
while (fwohci_buf_input_ppb(sc, fc, &pkt)) {
chan = (pkt.fp_hdr[0] & 0x00003f00) >> 8;
tag = (pkt.fp_hdr[0] & 0x0000c000) >> 14;
- DPRINTFN(1, ("fwohci_ir_input: hdr 0x%08x, tcode 0x%0x, hlen %d"
- ", dlen %d\n", pkt.fp_hdr[0], pkt.fp_tcode, pkt.fp_hlen,
+ DPRINTFN(1, ("%s: hdr 0x%08x, tcode 0x%0x, hlen %d, dlen %d\n",
+ __func__, pkt.fp_hdr[0], pkt.fp_tcode, pkt.fp_hlen,
pkt.fp_dlen));
if (tag == IEEE1394_TAG_GASP) {
/*
@@ -1853,7 +2306,7 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
if (pkt.fp_dlen < 8)
continue;
iov = pkt.fp_iov;
- /* assuming pkt per buffer mode */
+ /* Assuming pkt per buffer mode. */
pkt.fp_hdr[1] = ntohl(((u_int32_t *)iov->iov_base)[0]);
pkt.fp_hdr[2] = ntohl(((u_int32_t *)iov->iov_base)[1]);
iov->iov_base = (caddr_t)iov->iov_base + 8;
@@ -1862,8 +2315,7 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
pkt.fp_dlen -= 8;
}
sc->sc_isopktcnt.ev_count++;
- for (fh = LIST_FIRST(&fc->fc_handler); fh != NULL;
- fh = LIST_NEXT(fh, fh_list)) {
+ LIST_FOREACH(fh, &fc->fc_handler, fh_list) {
if (pkt.fp_tcode == fh->fh_tcode &&
chan == fh->fh_key1 && tag == fh->fh_key2) {
rcode = (*fh->fh_handler)(sc, fh->fh_handarg,
@@ -1871,13 +2323,13 @@ fwohci_ir_input(struct fwohci_softc *sc, struct fwohci_ctx *fc)
break;
}
}
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
if (fh == NULL) {
- DPRINTFN(1, ("fwohci_ir_input: no handler\n"));
+ DPRINTFN(1, ("%s: no handler\n", __func__));
} else {
- DPRINTFN(1, ("fwohci_ir_input: rcode %d\n", rcode));
+ DPRINTFN(1, ("%s: rcode %d\n", __func__, rcode));
}
-#endif
+#endif /* FWOHCI_DEBUG */
}
fwohci_buf_next(sc, fc);
@@ -1900,29 +2352,32 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
struct mbuf *m, *m0;
int i, ndesc, error, off, len;
u_int32_t val;
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
struct iovec *iov;
-#endif
-
+#endif /* FWOHCI_DEBUG */
+
if ((sc->sc_nodeid & OHCI_NodeId_NodeNumber) == IEEE1394_BCAST_PHY_ID)
/* We can't send anything during selfid duration */
return EAGAIN;
-#ifdef FW_DEBUG
- DPRINTFN(1, ("fwohci_at_output: tcode 0x%x, hlen %d, dlen %d",
+#ifdef FWOHCI_DEBUG
+ DPRINTFN(1, ("%s: tcode 0x%x, hlen %d, dlen %d", __func__,
pkt->fp_tcode, pkt->fp_hlen, pkt->fp_dlen));
- for (i = 0; i < pkt->fp_hlen/4; i++)
+ for (i = 0; i < pkt->fp_hlen/4; i++)
DPRINTFN(2, ("%s%08x", i?" ":"\n ", pkt->fp_hdr[i]));
- DPRINTFN(2, ("$"));
- for (ndesc = 0, iov = pkt->fp_iov;
- ndesc < pkt->fp_uio.uio_iovcnt; ndesc++, iov++) {
- for (i = 0; i < iov->iov_len; i++)
- DPRINTFN(2, ("%s%02x", (i%32)?((i%4)?"":" "):"\n ",
- ((u_int8_t *)iov->iov_base)[i]));
- DPRINTFN(2, ("$"));
+ DPRINTFN(2, (" $"));
+ if (pkt->fp_uio.uio_iovcnt) {
+ for (ndesc = 0, iov = pkt->fp_iov;
+ ndesc < pkt->fp_uio.uio_iovcnt; ndesc++, iov++) {
+ for (i = 0; i < iov->iov_len; i++)
+ DPRINTFN(2, ("%s%02x", (i%32)?((i%4)?"":" ")
+ :"\n ",
+ ((u_int8_t *)iov->iov_base)[i]));
+ DPRINTFN(2, (" $"));
+ }
}
DPRINTFN(1, ("\n"));
-#endif
+#endif /* FWOHCI_DEBUG */
if ((m = pkt->fp_m) != NULL) {
for (ndesc = 2; m != NULL; m = m->m_next)
@@ -1933,8 +2388,9 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
for (off = 0; off < pkt->fp_dlen; off += len) {
if (m0 == NULL) {
MGETHDR(m0, M_DONTWAIT, MT_DATA);
+ //MPRINTF_OLD("MGETHDR", m0);
if (m0 != NULL) {
-#ifdef __NetBSD__
+#ifdef __NetBSD__
M_COPY_PKTHDR(m0, pkt->fp_m);
#else
M_DUP_PKTHDR(m0, pkt->fp_m);
@@ -1943,12 +2399,14 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
m = m0;
} else {
MGET(m->m_next, M_DONTWAIT, MT_DATA);
+ //MPRINTF_OLD("MGET", m->m_next);
m = m->m_next;
}
if (m != NULL)
MCLGET(m, M_DONTWAIT);
if (m == NULL || (m->m_flags & M_EXT) == 0) {
m_freem(m0);
+ //MPRINTF_OLD("m_freem", m0);
return ENOMEM;
}
len = pkt->fp_dlen - off;
@@ -1960,6 +2418,7 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
ndesc++;
}
m_freem(pkt->fp_m);
+ //MPRINTF_OLD("m_freem", pkt->fp_m);
pkt->fp_m = m0;
}
} else
@@ -1968,13 +2427,17 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
if (ndesc > OHCI_DESC_MAX)
return ENOBUFS;
- if (fc->fc_bufcnt > 50) /*XXX*/
+ if (fc->fc_bufcnt > 50) /* XXX */
return ENOBUFS;
+
fb = malloc(sizeof(*fb), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", fb);
fb->fb_nseg = ndesc;
fb->fb_desc = fwohci_desc_get(sc, ndesc);
if (fb->fb_desc == NULL) {
free(fb, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", fb);
+ fb = NULL; /* XXX */
return ENOBUFS;
}
fb->fb_daddr = sc->sc_ddmamap->dm_segs[0].ds_addr +
@@ -1983,14 +2446,17 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
fb->fb_callback = pkt->fp_callback;
fb->fb_statuscb = pkt->fp_statuscb;
fb->fb_statusarg = pkt->fp_statusarg;
-
+
if (ndesc > 2) {
if ((error = bus_dmamap_create(sc->sc_dmat, pkt->fp_dlen, ndesc,
PAGE_SIZE, 0, BUS_DMA_WAITOK, &fb->fb_dmamap)) != 0) {
fwohci_desc_put(sc, fb->fb_desc, ndesc);
free(fb, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", fb);
+ fb = NULL; /* XXX */
return error;
}
+ //MPRINTF_OLD("bus_dmamap_create", fb->fb_dmamap);
if (pkt->fp_m != NULL)
error = bus_dmamap_load_mbuf(sc->sc_dmat, fb->fb_dmamap,
@@ -2000,8 +2466,11 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
&pkt->fp_uio, BUS_DMA_WAITOK);
if (error != 0) {
bus_dmamap_destroy(sc->sc_dmat, fb->fb_dmamap);
+ //MPRINTF_OLD("bus_dmamap_destroy", fb->fb_dmamap);
fwohci_desc_put(sc, fb->fb_desc, ndesc);
free(fb, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", fb);
+ fb = NULL; /* XXX */
return error;
}
bus_dmamap_sync(sc->sc_dmat, fb->fb_dmamap, 0, pkt->fp_dlen,
@@ -2021,27 +2490,37 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
((((val >> 25) + i) & 0x7) << 13);
} else
fd->fd_timestamp = 0;
- memcpy(fd + 1, pkt->fp_hdr, pkt->fp_hlen);
- for (i = 0; i < ndesc - 2; i++) {
- fd = fb->fb_desc + 2 + i;
- fd->fd_flags = 0;
- fd->fd_reqcount = fb->fb_dmamap->dm_segs[i].ds_len;
- fd->fd_data = fb->fb_dmamap->dm_segs[i].ds_addr;
- fd->fd_branch = 0;
- fd->fd_status = 0;
- fd->fd_timestamp = 0;
+
+#if 1 /* XXX */
+ bcopy(pkt->fp_hdr, fd + 1, pkt->fp_hlen);
+#else
+ bcopy(pkt->fp_hdr, fd->fd_immed, pkt->fp_hlen);
+#endif
+
+ if (ndesc > 2) {
+ for (i = 0; i < ndesc - 2; i++) {
+ fd = fb->fb_desc + 2 + i;
+ fd->fd_flags = 0;
+ fd->fd_reqcount = fb->fb_dmamap->dm_segs[i].ds_len;
+ fd->fd_data = fb->fb_dmamap->dm_segs[i].ds_addr;
+ fd->fd_branch = 0;
+ fd->fd_status = 0;
+ fd->fd_timestamp = 0;
+ }
+ bus_dmamap_sync(sc->sc_dmat, fb->fb_dmamap, 0, pkt->fp_dlen,
+ BUS_DMASYNC_POSTWRITE);
}
fd->fd_flags |= OHCI_DESC_LAST | OHCI_DESC_BRANCH;
fd->fd_flags |= OHCI_DESC_INTR_ALWAYS;
-#ifdef FW_DEBUG
- DPRINTFN(1, ("fwohci_at_output: desc %ld",
+#ifdef FWOHCI_DEBUG
+ DPRINTFN(1, ("%s: desc %ld", __func__,
(long)(fb->fb_desc - sc->sc_desc)));
for (i = 0; i < ndesc * 4; i++)
DPRINTFN(2, ("%s%08x", i&7?" ":"\n ",
((u_int32_t *)fb->fb_desc)[i]));
DPRINTFN(1, ("\n"));
-#endif
+#endif /* FWOHCI_DEBUG */
val = OHCI_ASYNC_DMA_READ(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlClear);
@@ -2059,6 +2538,7 @@ fwohci_at_output(struct fwohci_softc *sc, struct fwohci_ctx *fc,
run:
OHCI_ASYNC_DMA_WRITE(sc, fc->fc_ctx,
OHCI_SUBREG_CommandPtr, fb->fb_daddr | ndesc);
+ MPRINTF("OHCI_SUBREG_CommandPtr(ASYNC)", fb->fb_daddr);
OHCI_ASYNC_DMA_WRITE(sc, fc->fc_ctx,
OHCI_SUBREG_ContextControlSet, OHCI_CTXCTL_RUN);
}
@@ -2078,17 +2558,19 @@ fwohci_at_done(struct fwohci_softc *sc, struct fwohci_ctx *fc, int force)
struct fwohci_pkt pkt;
int i;
+// splassert(IPL_BIO);
+
while ((fb = TAILQ_FIRST(&fc->fc_buf)) != NULL) {
fd = fb->fb_desc;
-#ifdef FW_DEBUG
- DPRINTFN(1, ("fwohci_at_done: %sdesc %ld (%d)",
+#ifdef FWOHCI_DEBUG
+ DPRINTFN(1, ("%s: %sdesc %ld (%d)", __func__,
force ? "force " : "", (long)(fd - sc->sc_desc),
fb->fb_nseg));
for (i = 0; i < fb->fb_nseg * 4; i++)
DPRINTFN(2, ("%s%08x", i&7?" ":"\n ",
((u_int32_t *)fd)[i]));
DPRINTFN(1, ("\n"));
-#endif
+#endif /* FWOHCI_DEBUG */
if (fb->fb_nseg > 2)
fd += fb->fb_nseg - 1;
if (!force && !(fd->fd_status & OHCI_CTXCTL_ACTIVE))
@@ -2108,10 +2590,10 @@ fwohci_at_done(struct fwohci_softc *sc, struct fwohci_ctx *fc, int force)
}
if (fb->fb_statuscb) {
- memset(&pkt, 0, sizeof(pkt));
- pkt.fp_status = fd->fd_status;
- memcpy(pkt.fp_hdr, fd + 1, sizeof(pkt.fp_hdr[0]));
-
+ bzero(&pkt, sizeof(pkt));
+ pkt.fp_status = fd->fd_status;
+ bcopy(fd + 1, pkt.fp_hdr, sizeof(pkt.fp_hdr[0]));
+
/* Indicate this is just returning the status bits. */
pkt.fp_tcode = -1;
(*fb->fb_statuscb)(sc, fb->fb_statusarg, &pkt);
@@ -2119,15 +2601,21 @@ fwohci_at_done(struct fwohci_softc *sc, struct fwohci_ctx *fc, int force)
fb->fb_statusarg = NULL;
}
fwohci_desc_put(sc, fb->fb_desc, fb->fb_nseg);
- if (fb->fb_nseg > 2)
+ if (fb->fb_nseg > 2) {
bus_dmamap_destroy(sc->sc_dmat, fb->fb_dmamap);
+ //MPRINTF_OLD("bus_dmamap_destroy", fb->fb_dmamap);
+ }
fc->fc_bufcnt--;
if (fb->fb_callback) {
(*fb->fb_callback)(sc->sc_sc1394.sc1394_if, fb->fb_m);
fb->fb_callback = NULL;
- } else if (fb->fb_m != NULL)
+ } else if (fb->fb_m != NULL) {
m_freem(fb->fb_m);
+ //MPRINTF_OLD("m_freem", fb->fb_m);
+ }
free(fb, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", fb);
+ fb = NULL; /* XXX */
}
}
@@ -2140,19 +2628,19 @@ fwohci_atrs_output(struct fwohci_softc *sc, int rcode, struct fwohci_pkt *req,
{
if (((*req->fp_trail & 0x001f0000) >> 16) !=
- OHCI_CTXCTL_EVENT_ACK_PENDING)
+ OHCI_CTXCTL_EVENT_ACK_PENDING)
return;
res->fp_hdr[0] = (req->fp_hdr[0] & 0x0000fc00) | 0x00000100;
res->fp_hdr[1] = (req->fp_hdr[1] & 0xffff0000) | (rcode << 12);
switch (req->fp_tcode) {
- case IEEE1394_TCODE_WRITE_REQ_QUAD:
- case IEEE1394_TCODE_WRITE_REQ_BLOCK:
- res->fp_tcode = IEEE1394_TCODE_WRITE_RESP;
+ case IEEE1394_TCODE_WRITE_REQUEST_QUADLET:
+ case IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK:
+ res->fp_tcode = IEEE1394_TCODE_WRITE_RESPONSE;
res->fp_hlen = 12;
break;
- case IEEE1394_TCODE_READ_REQ_QUAD:
- res->fp_tcode = IEEE1394_TCODE_READ_RESP_QUAD;
+ case IEEE1394_TCODE_READ_REQUEST_QUADLET:
+ res->fp_tcode = IEEE1394_TCODE_READ_RESPONSE_QUADLET;
res->fp_hlen = 16;
res->fp_dlen = 0;
if (res->fp_uio.uio_iovcnt == 1 && res->fp_iov[0].iov_len == 4)
@@ -2160,12 +2648,12 @@ fwohci_atrs_output(struct fwohci_softc *sc, int rcode, struct fwohci_pkt *req,
*(u_int32_t *)res->fp_iov[0].iov_base;
res->fp_uio.uio_iovcnt = 0;
break;
- case IEEE1394_TCODE_READ_REQ_BLOCK:
- case IEEE1394_TCODE_LOCK_REQ:
- if (req->fp_tcode == IEEE1394_TCODE_LOCK_REQ)
- res->fp_tcode = IEEE1394_TCODE_LOCK_RESP;
+ case IEEE1394_TCODE_READ_REQUEST_DATABLOCK:
+ case IEEE1394_TCODE_LOCK_REQUEST:
+ if (req->fp_tcode == IEEE1394_TCODE_LOCK_REQUEST)
+ res->fp_tcode = IEEE1394_TCODE_LOCK_RESPONSE;
else
- res->fp_tcode = IEEE1394_TCODE_READ_RESP_BLOCK;
+ res->fp_tcode = IEEE1394_TCODE_READ_RESPONSE_DATABLOCK;
res->fp_hlen = 16;
res->fp_dlen = res->fp_uio.uio_resid;
res->fp_hdr[3] = res->fp_dlen << 16;
@@ -2176,11 +2664,11 @@ fwohci_atrs_output(struct fwohci_softc *sc, int rcode, struct fwohci_pkt *req,
}
/*
- * APPLICATION LAYER SERVICES
+ * APPLICATION LAYER SERVICES.
*/
/*
- * Retrieve Global UID from GUID ROM
+ * Retrieve Global UID from GUID ROM.
*/
int
fwohci_guidrom_init(struct fwohci_softc *sc)
@@ -2188,7 +2676,8 @@ fwohci_guidrom_init(struct fwohci_softc *sc)
int i, n, off;
u_int32_t val1, val2;
- /* Extract the Global UID
+ /*
+ * Extract the Global UID.
*/
val1 = OHCI_CSR_READ(sc, OHCI_REG_GUIDHi);
val2 = OHCI_CSR_READ(sc, OHCI_REG_GUIDLo);
@@ -2237,26 +2726,26 @@ fwohci_guidrom_init(struct fwohci_softc *sc)
}
/*
- * Initialization for Configuration ROM (no DMA context)
+ * Initialization for Configuration ROM (no DMA context).
*/
#define CFR_MAXUNIT 20
-struct configromctx {
+typedef struct configromctx {
u_int32_t *ptr;
- int curunit;
+ int curunit;
struct {
u_int32_t *start;
- int length;
+ int length;
u_int32_t *refer;
- int refunit;
+ int refunit;
} unit[CFR_MAXUNIT];
-};
+} configromctx;
#define CFR_PUT_DATA4(cfr, d1, d2, d3, d4) \
(*(cfr)->ptr++ = (((d1)<<24) | ((d2)<<16) | ((d3)<<8) | (d4)))
-#define CFR_PUT_DATA1(cfr, d) (*(cfr)->ptr++ = (d))
+#define CFR_PUT_DATA1(cfr, d) (*(cfr)->ptr++ = (d))
#define CFR_PUT_VALUE(cfr, key, d) (*(cfr)->ptr++ = ((key)<<24) | (d))
@@ -2273,21 +2762,21 @@ do { \
} \
(cfr)->curunit = (n); \
(cfr)->unit[n].start = (cfr)->ptr++; \
-} while (0 /* CONSTCOND */)
+} while (0)
#define CFR_PUT_REFER(cfr, key, n) \
do { \
(cfr)->unit[n].refer = (cfr)->ptr; \
(cfr)->unit[n].refunit = (cfr)->curunit; \
*(cfr)->ptr++ = (key) << 24; \
-} while (0 /* CONSTCOND */)
+} while (0)
#define CFR_END_UNIT(cfr) \
do { \
(cfr)->unit[(cfr)->curunit].length = (cfr)->ptr - \
((cfr)->unit[(cfr)->curunit].start + 1); \
CFR_PUT_CRC(cfr, (cfr)->curunit); \
-} while (0 /* CONSTCOND */)
+} while (0)
u_int16_t
fwohci_crc16(u_int32_t *ptr, int len)
@@ -2315,38 +2804,40 @@ fwohci_configrom_init(struct fwohci_softc *sc)
u_int32_t *hdr;
struct configromctx cfr;
+ splassert(IPL_BIO);
+
fb = &sc->sc_buf_cnfrom;
- memset(&cfr, 0, sizeof(cfr));
+ bzero(&cfr, sizeof(cfr));
cfr.ptr = hdr = (u_int32_t *)fb->fb_buf;
- /* headers */
+ /* Headers. */
CFR_START_UNIT(&cfr, 0);
CFR_PUT_DATA1(&cfr, OHCI_CSR_READ(sc, OHCI_REG_BusId));
CFR_PUT_DATA1(&cfr, OHCI_CSR_READ(sc, OHCI_REG_BusOptions));
CFR_PUT_DATA1(&cfr, OHCI_CSR_READ(sc, OHCI_REG_GUIDHi));
CFR_PUT_DATA1(&cfr, OHCI_CSR_READ(sc, OHCI_REG_GUIDLo));
CFR_END_UNIT(&cfr);
- /* copy info_length from crc_length */
+ /* Copy info_length from crc_length. */
*hdr |= (*hdr & 0x00ff0000) << 8;
OHCI_CSR_WRITE(sc, OHCI_REG_ConfigROMhdr, *hdr);
- /* root directory */
+ /* Root directory. */
CFR_START_UNIT(&cfr, 1);
- CFR_PUT_VALUE(&cfr, 0x03, 0x00005e); /* vendor id */
- CFR_PUT_REFER(&cfr, 0x81, 2); /* textual descriptor offset */
- CFR_PUT_VALUE(&cfr, 0x0c, 0x0083c0); /* node capability */
+ CFR_PUT_VALUE(&cfr, 0x03, 0x00005e); /* Vendor ID. */
+ CFR_PUT_REFER(&cfr, 0x81, 2); /* Textual descriptor offset. */
+ CFR_PUT_VALUE(&cfr, 0x0c, 0x0083c0); /* Node capability. */
/* spt,64,fix,lst,drq */
-#ifdef INET
- CFR_PUT_REFER(&cfr, 0xd1, 3); /* IPv4 unit directory */
-#endif /* INET */
-#ifdef INET6
- CFR_PUT_REFER(&cfr, 0xd1, 4); /* IPv6 unit directory */
-#endif /* INET6 */
+#ifdef INET
+ CFR_PUT_REFER(&cfr, 0xd1, 3); /* IPv4 unit directory. */
+#endif /* INET */
+#ifdef INET6
+ CFR_PUT_REFER(&cfr, 0xd1, 4); /* IPv6 unit directory. */
+#endif /* INET6 */
CFR_END_UNIT(&cfr);
CFR_START_UNIT(&cfr, 2);
- CFR_PUT_VALUE(&cfr, 0, 0); /* textual descriptor */
- CFR_PUT_DATA1(&cfr, 0); /* minimal ASCII */
+ CFR_PUT_VALUE(&cfr, 0, 0); /* Textual descriptor. */
+ CFR_PUT_DATA1(&cfr, 0); /* Minimal ASCII. */
#ifdef __NetBSD__
CFR_PUT_DATA4(&cfr, 'N', 'e', 't', 'B');
CFR_PUT_DATA4(&cfr, 'S', 'D', 0x00, 0x00);
@@ -2356,25 +2847,25 @@ fwohci_configrom_init(struct fwohci_softc *sc)
#endif
CFR_END_UNIT(&cfr);
-#ifdef INET
- /* IPv4 unit directory */
+#ifdef INET
+ /* IPv4 unit directory. */
CFR_START_UNIT(&cfr, 3);
- CFR_PUT_VALUE(&cfr, 0x12, 0x00005e); /* unit spec id */
- CFR_PUT_REFER(&cfr, 0x81, 6); /* textual descriptor offset */
- CFR_PUT_VALUE(&cfr, 0x13, 0x000001); /* unit sw version */
- CFR_PUT_REFER(&cfr, 0x81, 7); /* textual descriptor offset */
- CFR_PUT_REFER(&cfr, 0x95, 8); /* Unit location */
+ CFR_PUT_VALUE(&cfr, 0x12, 0x00005e); /* Unit spec ID. */
+ CFR_PUT_REFER(&cfr, 0x81, 6); /* Textual descriptor offset. */
+ CFR_PUT_VALUE(&cfr, 0x13, 0x000001); /* Unit sw version. */
+ CFR_PUT_REFER(&cfr, 0x81, 7); /* Textual descriptor offset. */
+ CFR_PUT_REFER(&cfr, 0x95, 8); /* unit location. */
CFR_END_UNIT(&cfr);
CFR_START_UNIT(&cfr, 6);
- CFR_PUT_VALUE(&cfr, 0, 0); /* textual descriptor */
- CFR_PUT_DATA1(&cfr, 0); /* minimal ASCII */
+ CFR_PUT_VALUE(&cfr, 0, 0); /* Textual descriptor. */
+ CFR_PUT_DATA1(&cfr, 0); /* Minimal ASCII. */
CFR_PUT_DATA4(&cfr, 'I', 'A', 'N', 'A');
CFR_END_UNIT(&cfr);
CFR_START_UNIT(&cfr, 7);
- CFR_PUT_VALUE(&cfr, 0, 0); /* textual descriptor */
- CFR_PUT_DATA1(&cfr, 0); /* minimal ASCII */
+ CFR_PUT_VALUE(&cfr, 0, 0); /* Textual descriptor. */
+ CFR_PUT_DATA1(&cfr, 0); /* Minimal ASCII. */
CFR_PUT_DATA4(&cfr, 'I', 'P', 'v', '4');
CFR_END_UNIT(&cfr);
@@ -2384,28 +2875,28 @@ fwohci_configrom_init(struct fwohci_softc *sc)
CFR_PUT_DATA1(&cfr, FW_FIFO_HI);
CFR_PUT_DATA1(&cfr, FW_FIFO_LO);
CFR_END_UNIT(&cfr);
-
-#endif /* INET */
-#ifdef INET6
- /* IPv6 unit directory */
+#endif /* INET */
+
+#ifdef INET6
+ /* IPv6 unit directory. */
CFR_START_UNIT(&cfr, 4);
- CFR_PUT_VALUE(&cfr, 0x12, 0x00005e); /* unit spec id */
- CFR_PUT_REFER(&cfr, 0x81, 9); /* textual descriptor offset */
- CFR_PUT_VALUE(&cfr, 0x13, 0x000002); /* unit sw version */
+ CFR_PUT_VALUE(&cfr, 0x12, 0x00005e); /* Unit spec id. */
+ CFR_PUT_REFER(&cfr, 0x81, 9); /* Textual descriptor offset. */
+ CFR_PUT_VALUE(&cfr, 0x13, 0x000002); /* Unit sw version. */
/* XXX: TBA by IANA */
- CFR_PUT_REFER(&cfr, 0x81, 10); /* textual descriptor offset */
- CFR_PUT_REFER(&cfr, 0x95, 11); /* Unit location */
+ CFR_PUT_REFER(&cfr, 0x81, 10); /* Textual descriptor offset. */
+ CFR_PUT_REFER(&cfr, 0x95, 11); /* Unit location. */
CFR_END_UNIT(&cfr);
CFR_START_UNIT(&cfr, 9);
- CFR_PUT_VALUE(&cfr, 0, 0); /* textual descriptor */
- CFR_PUT_DATA1(&cfr, 0); /* minimal ASCII */
+ CFR_PUT_VALUE(&cfr, 0, 0); /* Textual descriptor. */
+ CFR_PUT_DATA1(&cfr, 0); /* Minimal ASCII. */
CFR_PUT_DATA4(&cfr, 'I', 'A', 'N', 'A');
CFR_END_UNIT(&cfr);
CFR_START_UNIT(&cfr, 10);
- CFR_PUT_VALUE(&cfr, 0, 0); /* textual descriptor */
+ CFR_PUT_VALUE(&cfr, 0, 0); /* Textual descriptor. */
CFR_PUT_DATA1(&cfr, 0);
CFR_PUT_DATA4(&cfr, 'I', 'P', 'v', '6');
CFR_END_UNIT(&cfr);
@@ -2416,19 +2907,19 @@ fwohci_configrom_init(struct fwohci_softc *sc)
CFR_PUT_DATA1(&cfr, FW_FIFO_HI);
CFR_PUT_DATA1(&cfr, FW_FIFO_LO);
CFR_END_UNIT(&cfr);
-
-#endif /* INET6 */
+
+#endif /* INET6 */
fb->fb_off = cfr.ptr - hdr;
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
DPRINTF(("%s: Config ROM:", sc->sc_sc1394.sc1394_dev.dv_xname));
for (i = 0; i < fb->fb_off; i++)
DPRINTF(("%s%08x", i&7?" ":"\n ", hdr[i]));
DPRINTF(("\n"));
-#endif /* FW_DEBUG */
+#endif /* FWOHCI_DEBUG */
/*
- * Make network byte order for DMA
+ * Make network byte order for DMA.
*/
for (i = 0; i < fb->fb_off; i++)
HTONL(hdr[i]);
@@ -2444,10 +2935,10 @@ fwohci_configrom_init(struct fwohci_softc *sc)
(OHCI_Version_GET_Revision(val) == 1))
OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet,
OHCI_HCControl_BIBImageValid);
-
+
/* Just allow quad reads of the rom. */
- for (i = 0; i < fb->fb_off; i++)
- fwohci_handler_set(sc, IEEE1394_TCODE_READ_REQ_QUAD,
+ for (i = 0; i < fb->fb_off; i++)
+ fwohci_handler_set(sc, IEEE1394_TCODE_READ_REQUEST_QUADLET,
CSR_BASE_HI, CSR_BASE_LO + CSR_CONFIG_ROM + (i * 4),
fwohci_configrom_input, NULL);
}
@@ -2462,38 +2953,40 @@ fwohci_configrom_input(struct fwohci_softc *sc, void *arg,
/* This will be used as an array index so size accordingly. */
loc = pkt->fp_hdr[2] - (CSR_BASE_LO + CSR_CONFIG_ROM);
if ((loc & 0x03) != 0) {
- /* alignment error */
+ /* Alignment error. */
return IEEE1394_RCODE_ADDRESS_ERROR;
}
else
loc /= 4;
rom = (u_int32_t *)sc->sc_buf_cnfrom.fb_buf;
- DPRINTFN(1, ("fwohci_configrom_input: ConfigRom[0x%04x]: 0x%08x\n", loc,
+ DPRINTFN(1, ("%s: ConfigRom[0x%04x]: 0x%08x\n", __func__, loc,
ntohl(rom[loc])));
- memset(&res, 0, sizeof(res));
+ bzero(&res, sizeof(res));
res.fp_hdr[3] = rom[loc];
fwohci_atrs_output(sc, IEEE1394_RCODE_COMPLETE, pkt, &res);
return -1;
}
/*
- * SelfID buffer (no DMA context)
+ * SelfID buffer (no DMA context).
*/
void
fwohci_selfid_init(struct fwohci_softc *sc)
{
struct fwohci_buf *fb;
+ splassert(IPL_BIO);
+
fb = &sc->sc_buf_selfid;
-#ifdef DIAGNOSTIC
+#ifdef DIAGNOSTIC
if ((fb->fb_dmamap->dm_segs[0].ds_addr & 0x7ff) != 0)
panic("fwohci_selfid_init: not aligned: %ld (%ld) %p",
(unsigned long)fb->fb_dmamap->dm_segs[0].ds_addr,
(unsigned long)fb->fb_dmamap->dm_segs[0].ds_len, fb->fb_buf);
#endif
- memset(fb->fb_buf, 0, fb->fb_dmamap->dm_segs[0].ds_len);
+ bzero(fb->fb_buf, fb->fb_dmamap->dm_segs[0].ds_len);
bus_dmamap_sync(sc->sc_dmat, fb->fb_dmamap, 0,
fb->fb_dmamap->dm_segs[0].ds_len, BUS_DMASYNC_PREREAD);
@@ -2521,21 +3014,21 @@ fwohci_selfid_input(struct fwohci_softc *sc)
0, count << 2, BUS_DMASYNC_POSTREAD);
gen = OHCI_BITVAL(buf[0], OHCI_SelfID_Gen);
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
DPRINTFN(1, ("%s: SelfID: 0x%08x", sc->sc_sc1394.sc1394_dev.dv_xname,
val));
for (i = 0; i < count; i++)
DPRINTFN(2, ("%s%08x", i&7?" ":"\n ", buf[i]));
DPRINTFN(1, ("\n"));
-#endif /* FW_DEBUG */
+#endif /* FWOHCI_DEBUG */
for (i = 1; i < count; i += 2) {
if (buf[i] != ~buf[i + 1])
break;
if (buf[i] & 0x00000001)
- continue; /* more pkt */
+ continue; /* More pkt. */
if (buf[i] & 0x00800000)
- continue; /* external id */
+ continue; /* External ID. */
sc->sc_rootid = (buf[i] & 0x3f000000) >> 24;
if ((buf[i] & 0x00400800) == 0x00400800)
sc->sc_irmid = sc->sc_rootid;
@@ -2569,13 +3062,13 @@ fwohci_selfid_input(struct fwohci_softc *sc)
val = OHCI_CSR_READ(sc, OHCI_REG_NodeId);
if ((val & OHCI_NodeId_IDValid) == 0) {
- sc->sc_nodeid = 0xffff; /* invalid */
+ sc->sc_nodeid = 0xffff; /* Invalid. */
printf("%s: nodeid is invalid\n",
sc->sc_sc1394.sc1394_dev.dv_xname);
return -1;
}
sc->sc_nodeid = val & 0xffff;
-
+
DPRINTF(("%s: nodeid=0x%04x(%d), rootid=%d, irmid=%d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, sc->sc_nodeid,
sc->sc_nodeid & OHCI_NodeId_NodeNumber, sc->sc_rootid,
@@ -2594,23 +3087,25 @@ fwohci_selfid_input(struct fwohci_softc *sc)
}
/*
- * some CSRs are handled by driver.
+ * Some CSRs are handled by driver.
*/
void
fwohci_csr_init(struct fwohci_softc *sc)
{
int i;
- static u_int32_t csr[] = {
+ static u_int32_t csr[] = {
CSR_STATE_CLEAR, CSR_STATE_SET, CSR_SB_CYCLE_TIME,
CSR_SB_BUS_TIME, CSR_SB_BUSY_TIMEOUT, CSR_SB_BUS_MANAGER_ID,
CSR_SB_CHANNEL_AVAILABLE_HI, CSR_SB_CHANNEL_AVAILABLE_LO,
CSR_SB_BROADCAST_CHANNEL
};
+ splassert(IPL_BIO);
+
for (i = 0; i < sizeof(csr) / sizeof(csr[0]); i++) {
- fwohci_handler_set(sc, IEEE1394_TCODE_WRITE_REQ_QUAD,
+ fwohci_handler_set(sc, IEEE1394_TCODE_WRITE_REQUEST_QUADLET,
CSR_BASE_HI, CSR_BASE_LO + csr[i], fwohci_csr_input, NULL);
- fwohci_handler_set(sc, IEEE1394_TCODE_READ_REQ_QUAD,
+ fwohci_handler_set(sc, IEEE1394_TCODE_READ_REQUEST_QUADLET,
CSR_BASE_HI, CSR_BASE_LO + csr[i], fwohci_csr_input, NULL);
}
sc->sc_csr[CSR_SB_BROADCAST_CHANNEL] = 31; /*XXX*/
@@ -2623,17 +3118,17 @@ fwohci_csr_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
u_int32_t reg;
/*
- * XXX need to do special functionality other than just r/w...
+ * XXX Need to do special functionality other than just r/w...
*/
reg = pkt->fp_hdr[2] - CSR_BASE_LO;
if ((reg & 0x03) != 0) {
- /* alignment error */
+ /* Alignment error. */
return IEEE1394_RCODE_ADDRESS_ERROR;
}
- DPRINTFN(1, ("fwohci_csr_input: CSR[0x%04x]: 0x%08x", reg,
+ DPRINTFN(1, ("%s: CSR[0x%04x]: 0x%08x", __func__, reg,
*(u_int32_t *)(&sc->sc_csr[reg])));
- if (pkt->fp_tcode == IEEE1394_TCODE_WRITE_REQ_QUAD) {
+ if (pkt->fp_tcode == IEEE1394_TCODE_WRITE_REQUEST_QUADLET) {
DPRINTFN(1, (" -> 0x%08x\n",
ntohl(*(u_int32_t *)pkt->fp_iov[0].iov_base)));
*(u_int32_t *)&sc->sc_csr[reg] =
@@ -2667,28 +3162,35 @@ fwohci_uid_collect(struct fwohci_softc *sc)
LIST_FOREACH(iea, &sc->sc_nodelist, sc1394_node)
iea->sc1394_node_id = 0xffff;
- if (sc->sc_uidtbl != NULL)
+ if (sc->sc_uidtbl != NULL) {
free(sc->sc_uidtbl, M_DEVBUF);
-#ifdef M_ZERO
+ //MPRINTF_OLD("free(DEVBUF)", sc->sc_uidtbl);
+ sc->sc_uidtbl = NULL; /* XXX */
+ }
+#ifdef M_ZERO
sc->sc_uidtbl = malloc(sizeof(*fu) * (sc->sc_rootid + 1), M_DEVBUF,
- M_NOWAIT|M_ZERO); /* XXX M_WAITOK requires locks */
+ M_NOWAIT|M_ZERO); /* XXX M_WAITOK requires locks. */
+ //MPRINTF_OLD("malloc(DEVBUF)", sc->sc_uidtbl);
#else
sc->sc_uidtbl = malloc(sizeof(*fu) * (sc->sc_rootid + 1), M_DEVBUF,
- M_NOWAIT); /* XXX M_WAITOK requires locks */
- bzero(sc->sc_uidtbl, sizeof(*fu) * (sc->sc_rootid + 1));
+ M_NOWAIT); /* XXX M_WAITOK requires locks. */
+ //MPRINTF_OLD("malloc(DEVBUF)", sc->sc_uidtbl);
#endif
if (sc->sc_uidtbl == NULL)
return;
+#ifndef M_ZERO
+ bzero(sc->sc_uidtbl, sizeof(*fu) * (sc->sc_rootid + 1));
+#endif
for (i = 0, fu = sc->sc_uidtbl; i <= sc->sc_rootid; i++, fu++) {
if (i == (sc->sc_nodeid & OHCI_NodeId_NodeNumber)) {
- memcpy(fu->fu_uid, sc->sc_sc1394.sc1394_guid, 8);
+ bcopy(sc->sc_sc1394.sc1394_guid, fu->fu_uid, 8);
fu->fu_valid = 3;
iea = (struct ieee1394_softc *)sc->sc_sc1394.sc1394_if;
if (iea) {
iea->sc1394_node_id = i;
- DPRINTF(("%s: Updating nodeid to %d\n",
+ DPRINTF(("%s: Updating nodeid to %d\n",
iea->sc1394_dev.dv_xname,
iea->sc1394_node_id));
}
@@ -2706,23 +3208,23 @@ fwohci_uid_req(struct fwohci_softc *sc, int phyid)
{
struct fwohci_pkt pkt;
- memset(&pkt, 0, sizeof(pkt));
- pkt.fp_tcode = IEEE1394_TCODE_READ_REQ_QUAD;
+ bzero(&pkt, sizeof(pkt));
+ pkt.fp_tcode = IEEE1394_TCODE_READ_REQUEST_QUADLET;
pkt.fp_hlen = 12;
pkt.fp_dlen = 0;
- pkt.fp_hdr[0] = 0x00000100 | (sc->sc_tlabel << 10) |
+ pkt.fp_hdr[0] = 0x00000100 | (sc->sc_tlabel << 10) |
(pkt.fp_tcode << 4);
pkt.fp_hdr[1] = ((0xffc0 | phyid) << 16) | CSR_BASE_HI;
pkt.fp_hdr[2] = CSR_BASE_LO + CSR_CONFIG_ROM + 12;
- fwohci_handler_set(sc, IEEE1394_TCODE_READ_RESP_QUAD, phyid,
+ fwohci_handler_set(sc, IEEE1394_TCODE_READ_RESPONSE_QUADLET, phyid,
sc->sc_tlabel, fwohci_uid_input, (void *)0);
sc->sc_tlabel = (sc->sc_tlabel + 1) & 0x3f;
fwohci_at_output(sc, sc->sc_ctx_atrq, &pkt);
- pkt.fp_hdr[0] = 0x00000100 | (sc->sc_tlabel << 10) |
+ pkt.fp_hdr[0] = 0x00000100 | (sc->sc_tlabel << 10) |
(pkt.fp_tcode << 4);
pkt.fp_hdr[2] = CSR_BASE_LO + CSR_CONFIG_ROM + 16;
- fwohci_handler_set(sc, IEEE1394_TCODE_READ_RESP_QUAD, phyid,
+ fwohci_handler_set(sc, IEEE1394_TCODE_READ_RESPONSE_QUADLET, phyid,
sc->sc_tlabel, fwohci_uid_input, (void *)1);
sc->sc_tlabel = (sc->sc_tlabel + 1) & 0x3f;
fwohci_at_output(sc, sc->sc_ctx_atrq, &pkt);
@@ -2746,39 +3248,39 @@ fwohci_uid_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *res)
return 0;
fu = &sc->sc_uidtbl[n];
if (arg == 0) {
- memcpy(fu->fu_uid, res->fp_iov[0].iov_base, 4);
+ bcopy(res->fp_iov[0].iov_base, fu->fu_uid, 4);
fu->fu_valid |= 0x1;
} else {
- memcpy(fu->fu_uid + 4, res->fp_iov[0].iov_base, 4);
+ bcopy(res->fp_iov[0].iov_base, fu->fu_uid + 4, 4);
fu->fu_valid |= 0x2;
}
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
if (fu->fu_valid == 0x3)
- DPRINTFN(1, ("fwohci_uid_input: "
- "Node %d, UID %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", n,
+ DPRINTFN(1, ("%s: Node %d, UID %02x:%02x:%02x:%02x:%02x:%02x:"
+ "%02x:%02x\n", __func__, n,
fu->fu_uid[0], fu->fu_uid[1], fu->fu_uid[2], fu->fu_uid[3],
fu->fu_uid[4], fu->fu_uid[5], fu->fu_uid[6], fu->fu_uid[7]));
-#endif
+#endif /* FWOHCI_DEBUG */
if (fu->fu_valid == 0x3) {
LIST_FOREACH(iea, &sc->sc_nodelist, sc1394_node)
if (memcmp(iea->sc1394_guid, fu->fu_uid, 8) == 0) {
found = 1;
iea->sc1394_node_id = n;
- DPRINTF(("%s: Updating nodeid to %d\n",
+ DPRINTF(("%s: Updating nodeid to %d\n",
iea->sc1394_dev.dv_xname,
iea->sc1394_node_id));
break;
}
if (!found) {
strcpy(fwa.name, "fwnode");
- memcpy(fwa.uid, fu->fu_uid, 8);
+ bcopy(fu->fu_uid, fwa.uid, 8);
fwa.nodeid = n;
fwa.read = fwohci_read;
fwa.write = fwohci_write;
fwa.inreg = fwohci_inreg;
fwa.unreg = fwohci_unreg;
iea = (struct ieee1394_softc *)
- config_found_sm(&sc->sc_sc1394.sc1394_dev, &fwa,
+ config_found_sm(&sc->sc_sc1394.sc1394_dev, &fwa,
fwohci_print, fwohci_submatch);
if (iea != NULL)
LIST_INSERT_HEAD(&sc->sc_nodelist, iea,
@@ -2787,7 +3289,7 @@ fwohci_uid_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *res)
}
done = 1;
- for (i = 0; i < sc->sc_rootid + 1; i++) {
+ for (i = 0; i <= sc->sc_rootid; i++) {
fu = &sc->sc_uidtbl[i];
if (fu->fu_valid != 0x3) {
done = 0;
@@ -2817,6 +3319,7 @@ fwohci_check_nodes(struct fwohci_softc *sc)
*/
if (detach) {
+// config_detach_children(detach, 0);
config_detach(detach, 0);
detach = NULL;
}
@@ -2825,8 +3328,10 @@ fwohci_check_nodes(struct fwohci_softc *sc)
LIST_REMOVE(iea, sc1394_node);
}
}
- if (detach)
+ if (detach) {
+// config_detach_children(detach, 0);
config_detach(detach, 0);
+ }
}
int
@@ -2841,7 +3346,7 @@ fwohci_uid_lookup(struct fwohci_softc *sc, const u_int8_t *uid)
if (fu == NULL) {
if (memcmp(uid, bcast, sizeof(bcast)) == 0)
return IEEE1394_BCAST_PHY_ID;
- fwohci_uid_collect(sc); /* try to get */
+ fwohci_uid_collect(sc); /* Try to get. */
return -1;
}
for (n = 0; n <= sc->sc_rootid; n++, fu++) {
@@ -2853,7 +3358,7 @@ fwohci_uid_lookup(struct fwohci_softc *sc, const u_int8_t *uid)
for (n = 0, fu = sc->sc_uidtbl; n <= sc->sc_rootid; n++, fu++) {
if (fu->fu_valid != 0x3) {
/*
- * XXX: need timer before retransmission
+ * XXX: Need timer before retransmission.
*/
fwohci_uid_req(sc, n);
}
@@ -2862,7 +3367,7 @@ fwohci_uid_lookup(struct fwohci_softc *sc, const u_int8_t *uid)
}
/*
- * functions to support network interface
+ * Functions to support network interface.
*/
int
fwohci_if_inreg(struct device *self, u_int32_t offhi, u_int32_t offlo,
@@ -2870,9 +3375,9 @@ fwohci_if_inreg(struct device *self, u_int32_t offhi, u_int32_t offlo,
{
struct fwohci_softc *sc = (struct fwohci_softc *)self;
- fwohci_handler_set(sc, IEEE1394_TCODE_WRITE_REQ_BLOCK, offhi, offlo,
- handler ? fwohci_if_input : NULL, handler);
- fwohci_handler_set(sc, IEEE1394_TCODE_STREAM_DATA,
+ fwohci_handler_set(sc, IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK, offhi,
+ offlo, handler ? fwohci_if_input : NULL, handler);
+ fwohci_handler_set(sc, IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK,
(sc->sc_csr[CSR_SB_BROADCAST_CHANNEL] & IEEE1394_ISOCH_MASK) |
OHCI_ASYNC_STREAM,
IEEE1394_TAG_GASP, handler ? fwohci_if_input : NULL, handler);
@@ -2887,22 +3392,25 @@ fwohci_if_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
struct iovec *iov;
void (*handler)(struct device *, struct mbuf *) = arg;
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
int i;
- DPRINTFN(1, ("fwohci_if_input: tcode=0x%x, dlen=%d", pkt->fp_tcode,
+ DPRINTFN(1, ("%s: tcode=0x%x, dlen=%d", __func__, pkt->fp_tcode,
pkt->fp_dlen));
for (i = 0; i < pkt->fp_hlen/4; i++)
DPRINTFN(2, ("%s%08x", i?" ":"\n ", pkt->fp_hdr[i]));
DPRINTFN(2, ("$"));
- for (n = 0, len = pkt->fp_dlen; len > 0; len -= i, n++){
- iov = &pkt->fp_iov[n];
- for (i = 0; i < iov->iov_len; i++)
- DPRINTFN(2, ("%s%02x", (i%32)?((i%4)?"":" "):"\n ",
- ((u_int8_t *)iov->iov_base)[i]));
- DPRINTFN(2, ("$"));
+ if (pkt->fp_dlen) {
+ for (n = 0, len = pkt->fp_dlen; len > 0; len -= i, n++){
+ iov = &pkt->fp_iov[n];
+ for (i = 0; i < iov->iov_len; i++)
+ DPRINTFN(2, ("%s%02x", (i%32)?((i%4)?"":" ")
+ :"\n ",
+ ((u_int8_t *)iov->iov_base)[i]));
+ DPRINTFN(2, ("$"));
+ }
}
DPRINTFN(1, ("\n"));
-#endif /* FW_DEBUG */
+#endif /* FWOHCI_DEBUG */
len = pkt->fp_dlen;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
@@ -2912,6 +3420,7 @@ fwohci_if_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
+ //MPRINTF_OLD("m_freem", m);
return IEEE1394_RCODE_COMPLETE;
}
}
@@ -2921,18 +3430,19 @@ fwohci_if_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
printf("%s: packet from unknown node: phy id %d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, n);
m_freem(m);
+ //MPRINTF_OLD("m_freem", m);
fwohci_uid_req(sc, n);
return IEEE1394_RCODE_COMPLETE;
}
- memcpy(mtod(m, caddr_t), sc->sc_uidtbl[n].fu_uid, 8);
- if (pkt->fp_tcode == IEEE1394_TCODE_STREAM_DATA) {
+ bcopy(sc->sc_uidtbl[n].fu_uid, mtod(m, caddr_t), 8);
+ if (pkt->fp_tcode == IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK) {
m->m_flags |= M_BCAST;
mtod(m, u_int32_t *)[2] = mtod(m, u_int32_t *)[3] = 0;
} else {
mtod(m, u_int32_t *)[2] = htonl(pkt->fp_hdr[1]);
mtod(m, u_int32_t *)[3] = htonl(pkt->fp_hdr[2]);
}
- mtod(m, u_int8_t *)[8] = n; /*XXX: node id for debug */
+ mtod(m, u_int8_t *)[8] = n; /*XXX: Node id for debug. */
mtod(m, u_int8_t *)[9] =
(*pkt->fp_trail >> (16 + OHCI_CTXCTL_SPD_BITPOS)) &
((1 << OHCI_CTXCTL_SPD_BITLEN) - 1);
@@ -2946,7 +3456,7 @@ fwohci_if_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
* If upper layer doesn't free mbuf soon, e.g. application program
* is suspended, buffer must be reallocated.
* Isochronous buffer must be operate in packet buffer mode, and
- * it is easy to map receive buffer to external mbuf. But it is
+ * it is easy to map receive buffer to external mbuf. But it is
* used for broadcast/multicast only, and is expected not so
* performance sensitive for now.
* XXX: The performance may be important for multicast case,
@@ -2956,7 +3466,7 @@ fwohci_if_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
n = 0;
iov = pkt->fp_uio.uio_iov;
while (len > 0) {
- memcpy(mtod(m, caddr_t) + m->m_len, iov->iov_base,
+ bcopy(iov->iov_base, mtod(m, caddr_t) + m->m_len,
iov->iov_len);
m->m_len += iov->iov_len;
len -= iov->iov_len;
@@ -2974,29 +3484,30 @@ fwohci_if_input_iso(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
struct mbuf *m;
struct iovec *iov;
void (*handler)(struct device *, struct mbuf *) = arg;
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
int i;
-#endif
+#endif /* FWOHCI_DEBUG */
chan = (pkt->fp_hdr[0] & 0x00003f00) >> 8;
tag = (pkt->fp_hdr[0] & 0x0000c000) >> 14;
-#ifdef FW_DEBUG
- DPRINTFN(1, ("fwohci_if_input_iso: "
- "tcode=0x%x, chan=%d, tag=%x, dlen=%d",
+#ifdef FWOHCI_DEBUG
+ DPRINTFN(1, ("%s: tcode=0x%x, chan=%d, tag=%x, dlen=%d", __func__,
pkt->fp_tcode, chan, tag, pkt->fp_dlen));
for (i = 0; i < pkt->fp_hlen/4; i++)
DPRINTFN(2, ("%s%08x", i?" ":"\n\t", pkt->fp_hdr[i]));
DPRINTFN(2, ("$"));
- for (n = 0, len = pkt->fp_dlen; len > 0; len -= i, n++){
- iov = &pkt->fp_iov[n];
- for (i = 0; i < iov->iov_len; i++)
- DPRINTFN(2, ("%s%02x",
- (i%32)?((i%4)?"":" "):"\n\t",
- ((u_int8_t *)iov->iov_base)[i]));
- DPRINTFN(2, ("$"));
+ if (pkt->fp_dlen) {
+ for (n = 0, len = pkt->fp_dlen; len > 0; len -= i, n++){
+ iov = &pkt->fp_iov[n];
+ for (i = 0; i < iov->iov_len; i++)
+ DPRINTFN(2, ("%s%02x",
+ (i%32)?((i%4)?"":" "):"\n\t",
+ ((u_int8_t *)iov->iov_base)[i]));
+ DPRINTFN(2, ("$"));
+ }
}
DPRINTFN(2, ("\n"));
-#endif /* FW_DEBUG */
+#endif /* FWOHCI_DEBUG */
len = pkt->fp_dlen;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
@@ -3006,6 +3517,7 @@ fwohci_if_input_iso(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
+ //MPRINTF_OLD("m_freem", m);
return IEEE1394_RCODE_COMPLETE;
}
}
@@ -3019,9 +3531,10 @@ fwohci_if_input_iso(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
printf("%s: packet from unknown node: phy id %d\n",
sc->sc_sc1394.sc1394_dev.dv_xname, n);
m_freem(m);
+ //MPRINTF_OLD("m_freem", m);
return IEEE1394_RCODE_COMPLETE;
}
- memcpy(mtod(m, caddr_t), sc->sc_uidtbl[n].fu_uid, 8);
+ bcopy(sc->sc_uidtbl[n].fu_uid, mtod(m, caddr_t), 8);
mtod(m, u_int32_t *)[2] = htonl(pkt->fp_hdr[1]);
mtod(m, u_int32_t *)[3] = htonl(pkt->fp_hdr[2]);
mtod(m, u_int8_t *)[8] = n; /*XXX: node id for debug */
@@ -3042,7 +3555,7 @@ fwohci_if_input_iso(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
* If upper layer doesn't free mbuf soon, e.g. application program
* is suspended, buffer must be reallocated.
* Isochronous buffer must be operate in packet buffer mode, and
- * it is easy to map receive buffer to external mbuf. But it is
+ * it is easy to map receive buffer to external mbuf. But it is
* used for broadcast/multicast only, and is expected not so
* performance sensitive for now.
* XXX: The performance may be important for multicast case,
@@ -3052,10 +3565,10 @@ fwohci_if_input_iso(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
n = 0;
iov = pkt->fp_uio.uio_iov;
while (len > 0) {
- memcpy(mtod(m, caddr_t) + m->m_len, iov->iov_base,
+ bcopy(iov->iov_base, mtod(m, caddr_t) + m->m_len,
iov->iov_len);
- m->m_len += iov->iov_len;
- len -= iov->iov_len;
+ m->m_len += iov->iov_len;
+ len -= iov->iov_len;
iov++;
}
(*handler)(sc->sc_sc1394.sc1394_if, m);
@@ -3072,9 +3585,9 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
struct fwohci_pkt pkt;
u_int8_t *p;
int n, error, spd, hdrlen, maxrec;
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
struct mbuf *m;
-#endif
+#endif /* FWOHCI_DEBUG */
p = mtod(m0, u_int8_t *);
if (m0->m_flags & (M_BCAST | M_MCAST)) {
@@ -3094,7 +3607,7 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
if (n == IEEE1394_BCAST_PHY_ID) {
printf("%s: broadcast with !M_MCAST\n",
sc->sc_sc1394.sc1394_dev.dv_xname);
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
DPRINTFN(2, ("packet:"));
for (m = m0; m != NULL; m = m->m_next) {
for (n = 0; n < m->m_len; n++)
@@ -3104,7 +3617,7 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
DPRINTFN(2, ("$"));
}
DPRINTFN(2, ("\n"));
-#endif
+#endif /* FWOHCI_DEBUG */
error = EHOSTUNREACH;
goto end;
}
@@ -3113,53 +3626,53 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
hdrlen = 0;
}
if (spd > sc->sc_sc1394.sc1394_link_speed) {
- DPRINTF(("fwohci_if_output: spd (%d) is faster than %d\n",
+ DPRINTF(("%s: spd (%d) is faster than %d\n", __func__,
spd, sc->sc_sc1394.sc1394_link_speed));
spd = sc->sc_sc1394.sc1394_link_speed;
}
if (maxrec > (512 << spd)) {
- DPRINTF(("fwohci_if_output: maxrec (%d) is larger for spd (%d)"
- "\n", maxrec, spd));
+ DPRINTF(("%s: maxrec (%d) is larger for spd (%d)\n", __func__,
+ maxrec, spd));
maxrec = 512 << spd;
}
while (maxrec > sc->sc_sc1394.sc1394_max_receive) {
- DPRINTF(("fwohci_if_output: maxrec (%d) is larger than"
- " %d\n", maxrec, sc->sc_sc1394.sc1394_max_receive));
+ DPRINTF(("%s: maxrec (%d) is larger than %d\n", __func__,
+ maxrec, sc->sc_sc1394.sc1394_max_receive));
maxrec >>= 1;
}
if (maxrec < 512) {
- DPRINTF(("fwohci_if_output: maxrec (%d) is smaller than "
- "minimum\n", maxrec));
+ DPRINTF(("%s: maxrec (%d) is smaller than minimum\n",
+ __func__, maxrec));
maxrec = 512;
}
m_adj(m0, 16 - hdrlen);
if (m0->m_pkthdr.len > maxrec) {
- DPRINTF(("fwohci_if_output: packet too big: hdr %d, pktlen "
- "%d, maxrec %d\n", hdrlen, m0->m_pkthdr.len, maxrec));
+ DPRINTF(("%s: packet too big: hdr %d, pktlen %d, maxrec %d\n",
+ __func__, hdrlen, m0->m_pkthdr.len, maxrec));
error = E2BIG; /*XXX*/
goto end;
}
- memset(&pkt, 0, sizeof(pkt));
+ bzero(&pkt, sizeof(pkt));
pkt.fp_uio.uio_iov = pkt.fp_iov;
pkt.fp_uio.uio_segflg = UIO_SYSSPACE;
pkt.fp_uio.uio_rw = UIO_WRITE;
if (m0->m_flags & (M_BCAST | M_MCAST)) {
- /* construct GASP header */
+ /* Construct GASP header. */
p = mtod(m0, u_int8_t *);
p[0] = sc->sc_nodeid >> 8;
p[1] = sc->sc_nodeid & 0xff;
p[2] = 0x00; p[3] = 0x00; p[4] = 0x5e;
p[5] = 0x00; p[6] = 0x00; p[7] = 0x01;
- pkt.fp_tcode = IEEE1394_TCODE_STREAM_DATA;
+ pkt.fp_tcode = IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK;
pkt.fp_hlen = 8;
pkt.fp_hdr[0] = (spd << 16) | (IEEE1394_TAG_GASP << 14) |
((sc->sc_csr[CSR_SB_BROADCAST_CHANNEL] &
OHCI_NodeId_NodeNumber) << 8);
pkt.fp_hdr[1] = m0->m_pkthdr.len << 16;
} else {
- pkt.fp_tcode = IEEE1394_TCODE_WRITE_REQ_BLOCK;
+ pkt.fp_tcode = IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK;
pkt.fp_hlen = 16;
pkt.fp_hdr[0] = 0x00800100 | (sc->sc_tlabel << 10) |
(spd << 16);
@@ -3178,10 +3691,12 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
m0 = pkt.fp_m;
end:
if (m0 != NULL) {
- if (callback)
+ if (callback) {
(*callback)(sc->sc_sc1394.sc1394_if, m0);
- else
+ } else {
m_freem(m0);
+ //MPRINTF_OLD("m_freem", m0);
+ }
}
return error;
}
@@ -3199,18 +3714,18 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
* This routine will attempt to read a region from the requested node.
* A callback must be provided which will be called when either the completed
* read is done or an unrecoverable error occurs. This is mainly a convenience
- * routine since it will encapsulate retrying a region as quadlet vs. block
- * reads and recombining all the returned data. This could also be done with a
+ * routine since it will encapsulate retrying a region as quadlet vs. block
+ * reads and recombining all the returned data. This could also be done with a
* series of write/inreg's for each packet sent.
*
* int fwohci_write(struct ieee1394_abuf *)
*
* The work horse main entry point for putting packets on the bus. This is the
* generalized interface for fwnode/etc code to put packets out onto the bus.
- * It accepts all standard ieee1394 tcodes (XXX: only a few today) and
- * optionally will callback via a func pointer to the calling code with the
- * resulting ACK code from the packet. If the ACK code is to be ignored (i.e.
- * no cb) then the write routine will take care of free'ing the abuf since the
+ * It accepts all standard ieee1394 tcodes (XXX: only a few today) and
+ * optionally will callback via a func pointer to the calling code with the
+ * resulting ACK code from the packet. If the ACK code is to be ignored (i.e.
+ * no cb) then the write routine will take care of free'ing the abuf since the
* fwnode/etc code won't have any knowledge of when to do this. This allows for
* simple one-off packets to be sent from the upper-level code without worrying
* about a callback for cleanup.
@@ -3228,12 +3743,12 @@ fwohci_if_output(struct device *self, struct mbuf *m0,
* int fwohci_unreg(struct ieee1394_abuf *, int)
*
* This simply unregisters the respective callback done via inreg for items
- * which only need to register an area for a one-time operation (like a status
+ * that only need to register an area for a one-time operation (like a status
* buffer a remote node will write to when the current operation is done). The
* int argument specifies the same behavior as inreg, except in reverse (i.e.
* it unregisters).
*/
-
+
int
fwohci_read(struct ieee1394_abuf *ab)
{
@@ -3249,27 +3764,28 @@ fwohci_read(struct ieee1394_abuf *ab)
if (ab->ab_cb == NULL)
return -1;
- fcb = malloc(sizeof(struct fwohci_cb), M_DEVBUF, M_WAITOK);
+ MALLOC(fcb, struct fwohci_cb *, sizeof(*fcb), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", fcb);
fcb->ab = ab;
fcb->count = 0;
fcb->abuf_valid = 1;
-
+
high = ((ab->ab_addr & 0x0000ffff00000000) >> 32);
lo = (ab->ab_addr & 0x00000000ffffffff);
- memset(&pkt, 0, sizeof(pkt));
+ bzero(&pkt, sizeof(pkt));
pkt.fp_hdr[1] = ((0xffc0 | ab->ab_req->sc1394_node_id) << 16) | high;
pkt.fp_hdr[2] = lo;
pkt.fp_dlen = 0;
if (ab->ab_length == 4) {
- pkt.fp_tcode = IEEE1394_TCODE_READ_REQ_QUAD;
- tcode = IEEE1394_TCODE_READ_RESP_QUAD;
+ pkt.fp_tcode = IEEE1394_TCODE_READ_REQUEST_QUADLET;
+ tcode = IEEE1394_TCODE_READ_RESPONSE_QUADLET;
pkt.fp_hlen = 12;
} else {
- pkt.fp_tcode = IEEE1394_TCODE_READ_REQ_BLOCK;
+ pkt.fp_tcode = IEEE1394_TCODE_READ_REQUEST_DATABLOCK;
pkt.fp_hlen = 16;
- tcode = IEEE1394_TCODE_READ_RESP_BLOCK;
+ tcode = IEEE1394_TCODE_READ_RESPONSE_DATABLOCK;
pkt.fp_hdr[3] = (ab->ab_length << 16);
}
pkt.fp_hdr[0] = 0x00000100 | (sc->sc1394_link_speed << 16) |
@@ -3280,7 +3796,7 @@ fwohci_read(struct ieee1394_abuf *ab)
rv = fwohci_handler_set(psc, tcode, ab->ab_req->sc1394_node_id,
psc->sc_tlabel, fwohci_read_resp, fcb);
- if (rv)
+ if (rv)
return rv;
rv = fwohci_at_output(psc, psc->sc_ctx_atrq, &pkt);
if (rv)
@@ -3297,12 +3813,13 @@ fwohci_write(struct ieee1394_abuf *ab)
struct fwohci_pkt pkt;
struct ieee1394_softc *sc = ab->ab_req;
struct fwohci_softc *psc =
- (struct fwohci_softc *)sc->sc1394_dev.dv_parent;
+ (struct fwohci_softc *)sc->sc1394_dev.dv_parent;
u_int32_t high, lo;
int rv;
if (ab->ab_length > IEEE1394_MAX_REC(sc->sc1394_max_receive)) {
- DPRINTF(("Packet too large: %d\n", ab->ab_length));
+ DPRINTF(("%s: Packet too large: %d\n", __func__,
+ ab->ab_length));
return E2BIG;
}
@@ -3311,24 +3828,24 @@ fwohci_write(struct ieee1394_abuf *ab)
if ((ab->ab_data == NULL) && (ab->ab_uio == NULL))
panic("One of either ab_data or ab_uio must be set");
- memset(&pkt, 0, sizeof(pkt));
+ bzero(&pkt, sizeof(pkt));
pkt.fp_tcode = ab->ab_tcode;
if (ab->ab_data) {
pkt.fp_uio.uio_iov = pkt.fp_iov;
pkt.fp_uio.uio_segflg = UIO_SYSSPACE;
pkt.fp_uio.uio_rw = UIO_WRITE;
- } else
- memcpy(&pkt.fp_uio, ab->ab_uio, sizeof(struct uio));
-
+ } else
+ bcopy(ab->ab_uio, &pkt.fp_uio, sizeof(struct uio));
+
pkt.fp_statusarg = ab;
pkt.fp_statuscb = fwohci_write_ack;
switch (ab->ab_tcode) {
- case IEEE1394_TCODE_WRITE_RESP:
+ case IEEE1394_TCODE_WRITE_RESPONSE:
pkt.fp_hlen = 12;
- case IEEE1394_TCODE_READ_RESP_QUAD:
- case IEEE1394_TCODE_READ_RESP_BLOCK:
+ case IEEE1394_TCODE_READ_RESPONSE_QUADLET:
+ case IEEE1394_TCODE_READ_RESPONSE_DATABLOCK:
if (!pkt.fp_hlen)
pkt.fp_hlen = 16;
high = ab->ab_retlen;
@@ -3364,9 +3881,9 @@ fwohci_write(struct ieee1394_abuf *ab)
}
}
switch (ab->ab_tcode) {
- case IEEE1394_TCODE_WRITE_RESP:
- case IEEE1394_TCODE_READ_RESP_QUAD:
- case IEEE1394_TCODE_READ_RESP_BLOCK:
+ case IEEE1394_TCODE_WRITE_RESPONSE:
+ case IEEE1394_TCODE_READ_RESPONSE_QUADLET:
+ case IEEE1394_TCODE_READ_RESPONSE_DATABLOCK:
rv = fwohci_at_output(psc, psc->sc_ctx_atrs, &pkt);
break;
default:
@@ -3393,7 +3910,7 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
* etc which makes it much more difficult to process if both aren't
* handled here.
*/
-
+
/* Check for status packet. */
if (pkt->fp_tcode == -1) {
@@ -3402,18 +3919,21 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
tcode = (pkt->fp_hdr[0] >> 4) & 0xf;
if ((status != OHCI_CTXCTL_EVENT_ACK_COMPLETE) &&
(status != OHCI_CTXCTL_EVENT_ACK_PENDING))
- DPRINTFN(2, ("Got status packet: 0x%02x\n",
- (unsigned int)status));
+ DPRINTFN(2, ("%s: Got status packet: 0x%02x\n",
+ __func__, (unsigned int)status));
fcb->count--;
/*
* Got all the ack's back and the buffer is invalid (i.e. the
- * callback has been called. Clean up.
+ * callback has been called). Clean up.
*/
-
+
if (fcb->abuf_valid == 0) {
- if (fcb->count == 0)
- free(fcb, M_DEVBUF);
+ if (fcb->count == 0) {
+ FREE(fcb, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", fcb);
+ fcb = NULL; /* XXX */
+ }
return IEEE1394_RCODE_COMPLETE;
}
} else {
@@ -3423,7 +3943,7 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
}
/*
- * Some area's (like the config rom want to be read as quadlets only.
+ * Some areas (like the config rom) want to be read as quadlets only.
*
* The current ideas to try are:
*
@@ -3433,23 +3953,23 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
* response.
*
* In all cases construct a new packet for a quadlet read and let
- * mutli_resp handle the iteration over the space.
+ * multi_resp handle the iteration over the space.
*/
if (((status == OHCI_CTXCTL_EVENT_ACK_TYPE_ERROR) &&
- (tcode == IEEE1394_TCODE_READ_REQ_BLOCK)) ||
+ (tcode == IEEE1394_TCODE_READ_REQUEST_DATABLOCK)) ||
(((rcode == IEEE1394_RCODE_TYPE_ERROR) ||
- (rcode == IEEE1394_RCODE_ADDRESS_ERROR)) &&
- (tcode == IEEE1394_TCODE_READ_RESP_BLOCK))) {
+ (rcode == IEEE1394_RCODE_ADDRESS_ERROR)) &&
+ (tcode == IEEE1394_TCODE_READ_RESPONSE_DATABLOCK))) {
/* Read the area in quadlet chunks (internally track this). */
- memset(&newpkt, 0, sizeof(newpkt));
+ bzero(&newpkt, sizeof(newpkt));
high = ((ab->ab_addr & 0x0000ffff00000000) >> 32);
lo = (ab->ab_addr & 0x00000000ffffffff);
- newpkt.fp_tcode = IEEE1394_TCODE_READ_REQ_QUAD;
+ newpkt.fp_tcode = IEEE1394_TCODE_READ_REQUEST_QUADLET;
newpkt.fp_hlen = 12;
newpkt.fp_dlen = 0;
newpkt.fp_hdr[1] =
@@ -3458,7 +3978,8 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
newpkt.fp_hdr[0] = 0x00000100 | (sc->sc_tlabel << 10) |
(newpkt.fp_tcode << 4);
- rv = fwohci_handler_set(sc, IEEE1394_TCODE_READ_RESP_QUAD,
+ rv = fwohci_handler_set(sc,
+ IEEE1394_TCODE_READ_RESPONSE_QUADLET,
ab->ab_req->sc1394_node_id, sc->sc_tlabel,
fwohci_read_multi_resp, fcb);
if (rv) {
@@ -3469,7 +3990,8 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
newpkt.fp_statuscb = fwohci_read_resp;
rv = fwohci_at_output(sc, sc->sc_ctx_atrq, &newpkt);
if (rv) {
- fwohci_handler_set(sc, IEEE1394_TCODE_READ_RESP_QUAD,
+ fwohci_handler_set(sc,
+ IEEE1394_TCODE_READ_RESPONSE_QUADLET,
ab->ab_req->sc1394_node_id, sc->sc_tlabel, NULL,
NULL);
(*ab->ab_cb)(ab, -1);
@@ -3489,6 +4011,9 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
if (rcode != -1) {
cur = ab->ab_data;
+
+ assert(pkt->fp_uio.uio_iovcnt > 0);
+
for (i = 0; i < pkt->fp_uio.uio_iovcnt; i++) {
/*
* Make sure and don't exceed the buffer
@@ -3496,22 +4021,23 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
*/
if ((ab->ab_retlen + pkt->fp_iov[i].iov_len) >
ab->ab_length) {
- memcpy(cur, pkt->fp_iov[i].iov_base,
+ bcopy(pkt->fp_iov[i].iov_base, cur,
(ab->ab_length - ab->ab_retlen));
ab->ab_retlen = ab->ab_length;
break;
}
- memcpy(cur, pkt->fp_iov[i].iov_base,
+ bcopy(pkt->fp_iov[i].iov_base, cur,
pkt->fp_iov[i].iov_len);
- cur += pkt->fp_iov[i].iov_len;
+ (caddr_t)cur += pkt->fp_iov[i].iov_len;
ab->ab_retlen += pkt->fp_iov[i].iov_len;
}
+ DPRINTF(("%s: retlen=%d\n", __func__, ab->ab_retlen));
}
- if (status != -1)
+ if (status != -1)
/* XXX: Need a complete tlabel interface. */
for (i = 0; i < 64; i++)
fwohci_handler_set(sc,
- IEEE1394_TCODE_READ_RESP_QUAD,
+ IEEE1394_TCODE_READ_RESPONSE_QUADLET,
ab->ab_req->sc1394_node_id, i, NULL, NULL);
(*ab->ab_cb)(ab, rcode);
goto cleanup;
@@ -3520,11 +4046,14 @@ fwohci_read_resp(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
return IEEE1394_RCODE_COMPLETE;
/* Can't get here unless ab->ab_cb has been called. */
-
+
cleanup:
fcb->abuf_valid = 0;
- if (fcb->count == 0)
- free(fcb, M_DEVBUF);
+ if (fcb->count == 0) {
+ FREE(fcb, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", fcb);
+ fcb = NULL;
+ }
return IEEE1394_RCODE_COMPLETE;
}
@@ -3555,22 +4084,24 @@ fwohci_read_multi_resp(struct fwohci_softc *sc, void *arg,
}
if ((ab->ab_retlen + pkt->fp_iov[0].iov_len) > ab->ab_length) {
- memcpy(((char *)ab->ab_data + ab->ab_retlen),
- pkt->fp_iov[0].iov_base, (ab->ab_length - ab->ab_retlen));
+ bcopy(pkt->fp_iov[0].iov_base,
+ ((char *)ab->ab_data + ab->ab_retlen),
+ (ab->ab_length - ab->ab_retlen));
ab->ab_retlen = ab->ab_length;
} else {
- memcpy(((char *)ab->ab_data + ab->ab_retlen),
- pkt->fp_iov[0].iov_base, 4);
+ bcopy(pkt->fp_iov[0].iov_base,
+ ((char *)ab->ab_data + ab->ab_retlen), 4);
ab->ab_retlen += 4;
}
+ DPRINTF(("%s: retlen=%d\n", __func__, ab->ab_retlen));
/* Still more, loop and read 4 more bytes. */
if (ab->ab_retlen < ab->ab_length) {
- memset(&newpkt, 0, sizeof(newpkt));
+ bzero(&newpkt, sizeof(newpkt));
high = ((ab->ab_addr & 0x0000ffff00000000) >> 32);
lo = (ab->ab_addr & 0x00000000ffffffff) + ab->ab_retlen;
- newpkt.fp_tcode = IEEE1394_TCODE_READ_REQ_QUAD;
+ newpkt.fp_tcode = IEEE1394_TCODE_READ_REQUEST_QUADLET;
newpkt.fp_hlen = 12;
newpkt.fp_dlen = 0;
newpkt.fp_hdr[1] =
@@ -3583,19 +4114,20 @@ fwohci_read_multi_resp(struct fwohci_softc *sc, void *arg,
newpkt.fp_statuscb = fwohci_read_resp;
/*
- * Bad return code. Just give up and return what's
+ * Bad return code. Just give up and return what's
* come in now.
*/
- rv = fwohci_handler_set(sc, IEEE1394_TCODE_READ_RESP_QUAD,
+ rv = fwohci_handler_set(sc,
+ IEEE1394_TCODE_READ_RESPONSE_QUADLET,
ab->ab_req->sc1394_node_id, sc->sc_tlabel,
fwohci_read_multi_resp, fcb);
- if (rv)
+ if (rv)
(*ab->ab_cb)(ab, -1);
else {
rv = fwohci_at_output(sc, sc->sc_ctx_atrq, &newpkt);
if (rv) {
fwohci_handler_set(sc,
- IEEE1394_TCODE_READ_RESP_QUAD,
+ IEEE1394_TCODE_READ_RESPONSE_QUADLET,
ab->ab_req->sc1394_node_id, sc->sc_tlabel,
NULL, NULL);
(*ab->ab_cb)(ab, -1);
@@ -3611,8 +4143,11 @@ fwohci_read_multi_resp(struct fwohci_softc *sc, void *arg,
cleanup:
/* Can't get here unless ab_cb has been called. */
fcb->abuf_valid = 0;
- if (fcb->count == 0)
- free(fcb, M_DEVBUF);
+ if (fcb->count == 0) {
+ FREE(fcb, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", fcb);
+ fcb = NULL;
+ }
return IEEE1394_RCODE_COMPLETE;
}
@@ -3626,16 +4161,21 @@ fwohci_write_ack(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
status = pkt->fp_status & OHCI_DESC_STATUS_ACK_MASK;
if ((status != OHCI_CTXCTL_EVENT_ACK_COMPLETE) &&
(status != OHCI_CTXCTL_EVENT_ACK_PENDING))
- DPRINTF(("Got status packet: 0x%02x\n",
+ DPRINTF(("%s: Got status packet: 0x%02x\n", __func__,
(unsigned int)status));
/* No callback means this level should free the buffers. */
if (ab->ab_cb)
(*ab->ab_cb)(ab, status);
else {
- if (ab->ab_data)
+ if (ab->ab_data) {
free(ab->ab_data, M_1394DATA);
- free(ab, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL; /* XXX */
+ }
+ FREE(ab, M_1394DATA);
+ //MPRINTF_OLD("FREE(1394DATA)", ab);
+ ab = NULL; /* XXX */
}
return IEEE1394_RCODE_COMPLETE;
}
@@ -3645,27 +4185,36 @@ fwohci_inreg(struct ieee1394_abuf *ab, int allow)
{
struct ieee1394_softc *sc = ab->ab_req;
struct fwohci_softc *psc =
- (struct fwohci_softc *)sc->sc1394_dev.dv_parent;
+ (struct fwohci_softc *)sc->sc1394_dev.dv_parent;
u_int32_t high, lo;
- int i, j, rv;
+#if 0 /* use fwohci_block_handler_set */
+ int i, j;
+#endif
+ int rv;
high = ((ab->ab_addr & 0x0000ffff00000000) >> 32);
lo = (ab->ab_addr & 0x00000000ffffffff);
+#ifdef FWOHCI_DEBUG
+ if (ab->ab_retlen)
+ DPRINTF(("%s: retlen=%d\n", __func__, ab->ab_retlen));
+#endif /* FWOHCI_DEBUG */
+
rv = 0;
switch (ab->ab_tcode) {
- case IEEE1394_TCODE_READ_REQ_QUAD:
- case IEEE1394_TCODE_WRITE_REQ_QUAD:
+ case IEEE1394_TCODE_READ_REQUEST_QUADLET:
+ case IEEE1394_TCODE_WRITE_REQUEST_QUADLET:
if (ab->ab_cb)
rv = fwohci_handler_set(psc, ab->ab_tcode, high, lo,
fwohci_parse_input, ab);
else
- fwohci_handler_set(psc, ab->ab_tcode, high, lo, NULL,
- NULL);
+ fwohci_handler_set(psc, ab->ab_tcode, high, lo,
+ NULL, NULL);
break;
- case IEEE1394_TCODE_READ_REQ_BLOCK:
- case IEEE1394_TCODE_WRITE_REQ_BLOCK:
+ case IEEE1394_TCODE_READ_REQUEST_DATABLOCK:
+ case IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK:
if (allow) {
+#if 0 /* use fwohci_block_handler_set */
for (i = 0; i < (ab->ab_length / 4); i++) {
if (ab->ab_cb) {
rv = fwohci_handler_set(psc,
@@ -3679,18 +4228,27 @@ fwohci_inreg(struct ieee1394_abuf *ab, int allow)
}
if (i != (ab->ab_length / 4)) {
j = i + 1;
- for (i = 0; i < j; i++)
+ for (i = 0; i < j; i++)
fwohci_handler_set(psc, ab->ab_tcode,
high, lo + (i * 4), NULL, NULL);
}
+#else /* use fwohci_block_handler_set */
+ if (ab->ab_cb)
+ rv = fwohci_block_handler_set(psc, ab->ab_tcode,
+ high, lo, ab->ab_length, fwohci_parse_input,
+ ab);
+ else
+ fwohci_block_handler_set(psc, ab->ab_tcode,
+ high, lo, ab->ab_length, NULL, NULL);
+#endif /* use fwohci_block_handler_set */
/*
* XXX: Need something to indicate writing a smaller
* amount is ok.
- */
+ */
if (ab->ab_cb)
- ab->ab_data = (void *)1;
+ ab->ab_data = (void *)1;
} else {
- if (ab->ab_cb)
+ if (ab->ab_cb)
rv = fwohci_handler_set(psc, ab->ab_tcode, high,
lo, fwohci_parse_input, ab);
else
@@ -3699,7 +4257,8 @@ fwohci_inreg(struct ieee1394_abuf *ab, int allow)
}
break;
default:
- DPRINTF(("Invalid registration tcode: %d\n", ab->ab_tcode));
+ DPRINTF(("%s: Invalid registration tcode: %d\n", __func__,
+ ab->ab_tcode));
return -1;
break;
}
@@ -3711,7 +4270,7 @@ fwohci_unreg(struct ieee1394_abuf *ab, int allow)
{
void *save;
int rv;
-
+
save = ab->ab_cb;
ab->ab_cb = NULL;
rv = fwohci_inreg(ab, allow);
@@ -3731,50 +4290,76 @@ fwohci_parse_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
ab->ab_tlabel = (pkt->fp_hdr[0] >> 10) & 0x3f;
addr = (((u_int64_t)(pkt->fp_hdr[1] & 0xffff) << 32) | pkt->fp_hdr[2]);
+ DPRINTFN(3, ("%s: ab=0x%08x ab_cb=0x%08x\n\ttcode=%d tlabel=0x%02x"
+ " addr=%04x%08x\n", __func__, (u_int32_t)ab, (u_int32_t)ab->ab_cb,
+ ab->ab_tcode, ab->ab_tlabel, pkt->fp_hdr[1] & 0xffff,
+ pkt->fp_hdr[2]));
+
switch (ab->ab_tcode) {
- case IEEE1394_TCODE_READ_REQ_QUAD:
+ case IEEE1394_TCODE_READ_REQUEST_QUADLET:
ab->ab_retlen = 4;
break;
- case IEEE1394_TCODE_READ_REQ_BLOCK:
+ case IEEE1394_TCODE_READ_REQUEST_DATABLOCK:
ab->ab_retlen = (pkt->fp_hdr[3] >> 16) & 0xffff;
- if (ab->ab_data) {
- if ((addr + ab->ab_retlen) >
- (ab->ab_addr + ab->ab_length))
- return IEEE1394_RCODE_ADDRESS_ERROR;
+ if ((ab->ab_retlen > ab->ab_length) ||
+ ((addr + ab->ab_retlen) > (ab->ab_addr + ab->ab_length)))
+ return IEEE1394_RCODE_ADDRESS_ERROR;
+
+ if ((caddr_t)ab->ab_data > (caddr_t)1) {
+ free(ab->ab_data, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
ab->ab_data = NULL;
- } else
- if (ab->ab_retlen != ab->ab_length)
- return IEEE1394_RCODE_ADDRESS_ERROR;
+ }
break;
- case IEEE1394_TCODE_WRITE_REQ_QUAD:
+ case IEEE1394_TCODE_WRITE_REQUEST_QUADLET:
ab->ab_retlen = 4;
- case IEEE1394_TCODE_WRITE_REQ_BLOCK:
- if (!ab->ab_retlen)
+ case IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK:
+ if (!ab->ab_retlen)
ab->ab_retlen = (pkt->fp_hdr[3] >> 16) & 0xffff;
- if (ab->ab_data) {
- if ((addr + ab->ab_retlen) >
- (ab->ab_addr + ab->ab_length))
- return IEEE1394_RCODE_ADDRESS_ERROR;
- ab->ab_data = NULL;
- } else
- if (ab->ab_retlen != ab->ab_length)
- return IEEE1394_RCODE_ADDRESS_ERROR;
+ else {
+#ifdef FWOHCI_DEBUG
+ if (ab->ab_retlen != ((pkt->fp_hdr[3] >> 16) & 0xffff))
+ DPRINTF(("%s: retlen(%d) <> pktlen(%d)\n",
+ __func__, ab->ab_retlen,
+ (pkt->fp_hdr[3] >> 16) & 0xffff));
+#endif /* FWOHCI_DEBUG */
+#if 0
+ ab->ab_retlen = (pkt->fp_hdr[3] >> 16) & 0xffff;
+#endif
+ }
+ if ((ab->ab_retlen > ab->ab_length) ||
+ ((addr + ab->ab_retlen) > (ab->ab_addr + ab->ab_length)))
+ return IEEE1394_RCODE_ADDRESS_ERROR;
+ if ((caddr_t)ab->ab_data > (caddr_t)1) {
+ free(ab->ab_data, M_1394DATA);
+ //MPRINTF_OLD("free(1394DATA)", ab->ab_data);
+ ab->ab_data = NULL;
+ }
ab->ab_data = malloc(ab->ab_retlen, M_1394DATA, M_WAITOK);
- if (ab->ab_tcode == IEEE1394_TCODE_WRITE_REQ_QUAD)
+ //MPRINTF_OLD("malloc(1394DATA)", ab->ab_data);
+
+ if (ab->ab_tcode == IEEE1394_TCODE_WRITE_REQUEST_QUADLET)
ab->ab_data[0] = pkt->fp_hdr[3];
else {
count = 0;
cur = ab->ab_data;
+
+ assert(pkt->fp_uio.uio_iovcnt > 0);
+
for (i = 0; i < pkt->fp_uio.uio_iovcnt; i++) {
- memcpy(cur, pkt->fp_iov[i].iov_base,
+ DPRINTFN(3, ("\t%d : bcopy(0x%08x, 0x%08x,"
+ " 0x%x)\n", i,
+ (u_int32_t)pkt->fp_iov[i].iov_base,
+ (u_int32_t)cur, pkt->fp_iov[i].iov_len));
+ bcopy(pkt->fp_iov[i].iov_base, cur,
pkt->fp_iov[i].iov_len);
- cur += pkt->fp_iov[i].iov_len;
+ (caddr_t)cur += pkt->fp_iov[i].iov_len;
count += pkt->fp_iov[i].iov_len;
}
if (ab->ab_retlen != count)
panic("Packet claims %d length "
- "but only %d bytes returned",
+ "but %d bytes returned",
ab->ab_retlen, count);
}
break;
@@ -3788,7 +4373,7 @@ fwohci_parse_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
return -1;
}
-#ifdef __NetBSD__
+#ifdef __NetBSD__
int
fwohci_submatch(struct device *parent, struct cfdata *cf, void *aux)
#else
@@ -3797,7 +4382,7 @@ fwohci_submatch(struct device *parent, void *vcf, void *aux)
#endif
{
struct ieee1394_attach_args *fwa = aux;
-#ifdef __OpenBSD__
+#ifdef __OpenBSD__
struct cfdata *cf = (struct cfdata *)vcf;
#endif
@@ -3815,12 +4400,23 @@ fwohci_detach(struct fwohci_softc *sc, int flags)
{
int rv = 0;
- if (sc->sc_sc1394.sc1394_if != NULL)
- rv = config_detach(sc->sc_sc1394.sc1394_if, flags);
- if (rv != 0)
+ *sc->sc_dying = 1; /* Stop the event thread. */
+ wakeup(fwohci_event_thread);
+ DPRINTF(("%s: waiting 0x%08x\n", __func__, sc->sc_dying));
+ tsleep(sc->sc_dying, PZERO, "detach", 3 * hz);
+ DPRINTF(("%s: woken up...\n", __func__));
+ FREE(sc->sc_dying, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", sc->sc_dying);
+ sc->sc_dying = NULL; /* XXX */
+
+ if (sc->sc_sc1394.sc1394_if != NULL) {
+ rv = config_detach_children(sc->sc_sc1394.sc1394_if, flags);
+ rv |= config_detach(sc->sc_sc1394.sc1394_if, flags);
+ }
+ if (rv)
return (rv);
-#ifdef __NetBSD__
+#ifdef __NetBSD__
callout_stop(&sc->sc_selfid_callout);
#else
timeout_del(&sc->sc_selfid_callout);
@@ -3848,66 +4444,66 @@ fwohci_activate(struct device *self, enum devact act)
case DVACT_DEACTIVATE:
if (sc->sc_sc1394.sc1394_if != NULL)
- rv = config_deactivate(sc->sc_sc1394.sc1394_if);
- break;
+ rv = config_deactivate(sc->sc_sc1394.sc1394_if);
+ break;
}
splx(s);
return (rv);
}
-#ifdef FW_DEBUG
+#ifdef FWOHCI_DEBUG
void
fwohci_show_intr(struct fwohci_softc *sc, u_int32_t intmask)
{
- printf("%s: intmask=0x%08x:", sc->sc_sc1394.sc1394_dev.dv_xname,
- intmask);
+ DPRINTF(("%s: intmask=0x%08x:", sc->sc_sc1394.sc1394_dev.dv_xname,
+ intmask));
if (intmask & OHCI_Int_CycleTooLong)
- printf(" CycleTooLong");
+ DPRINTF((" CycleTooLong"));
if (intmask & OHCI_Int_UnrecoverableError)
- printf(" UnrecoverableError");
+ DPRINTF((" UnrecoverableError"));
if (intmask & OHCI_Int_CycleInconsistent)
- printf(" CycleInconsistent");
+ DPRINTF((" CycleInconsistent"));
if (intmask & OHCI_Int_BusReset)
- printf(" BusReset");
+ DPRINTF((" BusReset"));
if (intmask & OHCI_Int_SelfIDComplete)
- printf(" SelfIDComplete");
+ DPRINTF((" SelfIDComplete"));
if (intmask & OHCI_Int_LockRespErr)
- printf(" LockRespErr");
+ DPRINTF((" LockRespErr"));
if (intmask & OHCI_Int_PostedWriteErr)
- printf(" PostedWriteErr");
+ DPRINTF((" PostedWriteErr"));
if (intmask & OHCI_Int_ReqTxComplete)
- printf(" ReqTxComplete(0x%04x)",
+ DPRINTF((" ReqTxComplete(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_TX_REQUEST,
- OHCI_SUBREG_ContextControlClear));
+ OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_RespTxComplete)
- printf(" RespTxComplete(0x%04x)",
+ DPRINTF((" RespTxComplete(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_TX_RESPONSE,
- OHCI_SUBREG_ContextControlClear));
+ OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_ARRS)
- printf(" ARRS(0x%04x)",
+ DPRINTF((" ARRS(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_RESPONSE,
- OHCI_SUBREG_ContextControlClear));
+ OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_ARRQ)
- printf(" ARRQ(0x%04x)",
+ DPRINTF((" ARRQ(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_REQUEST,
- OHCI_SUBREG_ContextControlClear));
+ OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_IsochRx)
- printf(" IsochRx(0x%08x)",
- OHCI_CSR_READ(sc, OHCI_REG_IsoRecvIntEventClear));
+ DPRINTF((" IsochRx(0x%08x)",
+ OHCI_CSR_READ(sc, OHCI_REG_IsoRecvIntEventClear)));
if (intmask & OHCI_Int_IsochTx)
- printf(" IsochTx(0x%08x)",
- OHCI_CSR_READ(sc, OHCI_REG_IsoXmitIntEventClear));
+ DPRINTF((" IsochTx(0x%08x)",
+ OHCI_CSR_READ(sc, OHCI_REG_IsoXmitIntEventClear)));
if (intmask & OHCI_Int_RQPkt)
- printf(" RQPkt(0x%04x)",
+ DPRINTF((" RQPkt(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_REQUEST,
- OHCI_SUBREG_ContextControlClear));
+ OHCI_SUBREG_ContextControlClear)));
if (intmask & OHCI_Int_RSPkt)
- printf(" RSPkt(0x%04x)",
+ DPRINTF((" RSPkt(0x%04x)",
OHCI_ASYNC_DMA_READ(sc, OHCI_CTX_ASYNC_RX_RESPONSE,
- OHCI_SUBREG_ContextControlClear));
- printf("\n");
+ OHCI_SUBREG_ContextControlClear)));
+ DPRINTF(("\n"));
}
void
@@ -3917,41 +4513,42 @@ fwohci_show_phypkt(struct fwohci_softc *sc, u_int32_t val)
key = (val & 0xc0000000) >> 30;
phyid = (val & 0x3f000000) >> 24;
- printf("%s: PHY packet from %d: ",
- sc->sc_sc1394.sc1394_dev.dv_xname, phyid);
+ DPRINTF(("%s: PHY packet from %d: ",
+ sc->sc_sc1394.sc1394_dev.dv_xname, phyid));
switch (key) {
case 0:
- printf("PHY Config:");
+ DPRINTF(("PHY Config:"));
if (val & 0x00800000)
- printf(" ForceRoot");
+ DPRINTF((" ForceRoot"));
if (val & 0x00400000)
- printf(" Gap=%x", (val & 0x003f0000) >> 16);
- printf("\n");
+ DPRINTF((" Gap=%x", (val & 0x003f0000) >> 16));
+ DPRINTF(("\n"));
break;
case 1:
- printf("Link-on\n");
+ DPRINTF(("Link-on\n"));
break;
case 2:
- printf("SelfID:");
+ DPRINTF(("SelfID:"));
if (val & 0x00800000) {
- printf(" #%d", (val & 0x00700000) >> 20);
+ DPRINTF((" #%d", (val & 0x00700000) >> 20));
} else {
if (val & 0x00400000)
- printf(" LinkActive");
- printf(" Gap=%x", (val & 0x003f0000) >> 16);
- printf(" Spd=S%d", 100 << ((val & 0x0000c000) >> 14));
+ DPRINTF((" LinkActive"));
+ DPRINTF((" Gap=%x", (val & 0x003f0000) >> 16));
+ DPRINTF((" Spd=S%d", 100 <<
+ ((val & 0x0000c000) >> 14)));
if (val & 0x00000800)
- printf(" Cont");
+ DPRINTF((" Cont"));
if (val & 0x00000002)
- printf(" InitiateBusReset");
+ DPRINTF((" InitiateBusReset"));
}
if (val & 0x00000001)
- printf(" +");
- printf("\n");
+ DPRINTF((" +"));
+ DPRINTF(("\n"));
break;
default:
- printf("unknown: 0x%08x\n", val);
+ DPRINTF(("unknown: 0x%08x\n", val));
break;
}
}
-#endif /* FW_DEBUG */
+#endif /* FWOHCI_DEBUG */
diff --git a/sys/dev/ieee1394/fwohcireg.h b/sys/dev/ieee1394/fwohcireg.h
index 9cb85bb0d9b..d3fdf1f8f4e 100644
--- a/sys/dev/ieee1394/fwohcireg.h
+++ b/sys/dev/ieee1394/fwohcireg.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: fwohcireg.h,v 1.1 2002/06/25 17:11:49 itojun Exp $ */
+/* $OpenBSD: fwohcireg.h,v 1.2 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: fwohcireg.h,v 1.11 2002/01/26 16:34:27 ichiro Exp $ */
-/*-
+/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -18,8 +18,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@@ -37,7 +37,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_IEEE1394_FWOHCIREG_H_
+#ifndef _DEV_IEEE1394_FWOHCIREG_H_
#define _DEV_IEEE1394_FWOHCIREG_H_
/* PCI/CardBus-Specific definitions
@@ -45,25 +45,25 @@
/* In the PCI Class Code Register ...
*/
-#define PCI_INTERFACE_OHCI 0x10
+#define PCI_INTERFACE_OHCI 0x10
/* The OHCI Regisers are in PCI BAR0.
*/
-#define PCI_OHCI_MAP_REGISTER 0x10
+#define PCI_OHCI_MAP_REGISTER 0x10
/* HCI Control Register (in PCI config space)
*/
-#define PCI_OHCI_CONTROL_REGISTER 0x40
+#define PCI_OHCI_CONTROL_REGISTER 0x40
/* If the following bit, all OHCI register access
* and DMA transactions are byte swapped.
*/
-#define PCI_GLOBAL_SWAP_BE 0x00000001
+#define PCI_GLOBAL_SWAP_BE 0x00000001
/* Bus Independent Definitions */
-#define OHCI_CONFIG_SIZE 1024
-#define OHCI_CONFIG_ALIGNMENT 1024
+#define OHCI_CONFIG_SIZE 1024
+#define OHCI_CONFIG_ALIGNMENT 1024
/* OHCI Registers
* OHCI Registers are divided into four spaces:
@@ -140,9 +140,9 @@
#define OHCI_REG_reserved_0f8 0x0f8
#define OHCI_REG_reserved_0fc 0x0fc
#define OHCI_REG_AsynchronousRequestFilterHiSet 0x100
-#define OHCI_REG_AsynchronousRequestFilterHiClear 0x104
+#define OHCI_REG_AsynchronousRequestFilterHiClear 0x104
#define OHCI_REG_AsynchronousRequestFilterLoSet 0x108
-#define OHCI_REG_AsynchronousRequestFilterLoClear 0x10c
+#define OHCI_REG_AsynchronousRequestFilterLoClear 0x10c
#define OHCI_REG_PhysicalRequestFilterHiSet 0x110
#define OHCI_REG_PhysicalRequestFilterHiClear 0x114
#define OHCI_REG_PhysicalRequestFilterLoSet 0x118
@@ -197,7 +197,7 @@
#define OHCI_SYNC_TX_DMA_READ(sc, ctx, reg) \
OHCI_CSR_READ(sc, OHCI_REG_SYNC_TX_DMA_BASE + 16*(ctx) + (reg))
-#define OHCI_REG_SYNC_RX_DMA_BASE 0x400
+#define OHCI_REG_SYNC_RX_DMA_BASE 0x400
#define OHCI_SYNC_RX_DMA_WRITE(sc, ctx, reg, val) \
OHCI_CSR_WRITE(sc, OHCI_REG_SYNC_RX_DMA_BASE + 32*(ctx) + (reg), val)
#define OHCI_SYNC_RX_DMA_READ(sc, ctx, reg) \
@@ -208,7 +208,7 @@
/* OHCI_REG_Version
*/
-#define OHCI_Version_GUID_ROM 0x01000000
+#define OHCI_Version_GUID_ROM 0x01000000
#define OHCI_Version_GET_Version(x) \
((((x) >> 16) & 0xf) + (((x) >> 20) & 0xf) * 10)
#define OHCI_Version_GET_Revision(x) \
@@ -216,20 +216,20 @@
/* OHCI_REG_Guid_Rom
*/
-#define OHCI_Guid_AddrReset 0x80000000
-#define OHCI_Guid_RdStart 0x02000000
-#define OHCI_Guid_RdData_MASK 0x00ff0000
-#define OHCI_Guid_RdData_BITPOS 16
-#define OHCI_Guid_MiniROM_MASK 0x000000ff
-#define OHCI_Guid_MiniROM_BITPOS 0
+#define OHCI_Guid_AddrReset 0x80000000
+#define OHCI_Guid_RdStart 0x02000000
+#define OHCI_Guid_RdData_MASK 0x00ff0000
+#define OHCI_Guid_RdData_BITPOS 16
+#define OHCI_Guid_MiniROM_MASK 0x000000ff
+#define OHCI_Guid_MiniROM_BITPOS 0
/* OHCI_REG_GUIDxx
*/
/* OHCI_REG_CsrControl
*/
-#define OHCI_CsrControl_Done 0x80000000
-#define OHCI_CsrControl_SelMASK 0x00000003
+#define OHCI_CsrControl_Done 0x80000000
+#define OHCI_CsrControl_SelMASK 0x00000003
#define OHCI_CsrControl_BusManId 0
#define OHCI_CsrControl_BWAvail 1
#define OHCI_CsrControl_ChanAvailHi 2
@@ -237,120 +237,120 @@
/* OHCI_REG_BusOptions
*/
-#define OHCI_BusOptions_LinkSpd_MASK 0x00000007
-#define OHCI_BusOptions_LinkSpd_BITPOS 0
-#define OHCI_BusOptions_G_MASK 0x000000c0
-#define OHCI_BusOptions_G_BITPOS 6
-#define OHCI_BusOptions_MaxRec_MASK 0x0000f000
-#define OHCI_BusOptions_MaxRec_BITPOS 12
-#define OHCI_BusOptions_CycClkAcc_MASK 0x00ff0000
-#define OHCI_BusOptions_CycClkAcc_BITPOS 16
-#define OHCI_BusOptions_PMC 0x08000000
-#define OHCI_BusOptions_BMC 0x10000000
-#define OHCI_BusOptions_ISC 0x20000000
-#define OHCI_BusOptions_CMC 0x40000000
-#define OHCI_BusOptions_IRMC 0x80000000
-#define OHCI_BusOptions_reserved 0x07000f38
+#define OHCI_BusOptions_LinkSpd_MASK 0x00000007
+#define OHCI_BusOptions_LinkSpd_BITPOS 0
+#define OHCI_BusOptions_G_MASK 0x000000c0
+#define OHCI_BusOptions_G_BITPOS 6
+#define OHCI_BusOptions_MaxRec_MASK 0x0000f000
+#define OHCI_BusOptions_MaxRec_BITPOS 12
+#define OHCI_BusOptions_CycClkAcc_MASK 0x00ff0000
+#define OHCI_BusOptions_CycClkAcc_BITPOS 16
+#define OHCI_BusOptions_PMC 0x08000000
+#define OHCI_BusOptions_BMC 0x10000000
+#define OHCI_BusOptions_ISC 0x20000000
+#define OHCI_BusOptions_CMC 0x40000000
+#define OHCI_BusOptions_IRMC 0x80000000
+#define OHCI_BusOptions_reserved 0x07000f38
/* OHCI_REG_HCControl
*/
-#define OHCI_HCControl_SoftReset 0x00010000
-#define OHCI_HCControl_LinkEnable 0x00020000
-#define OHCI_HCControl_PostedWriteEnable 0x00040000
-#define OHCI_HCControl_LPS 0x00080000
-#define OHCI_HCControl_APhyEnhanceEnable 0x00400000
-#define OHCI_HCControl_ProgramPhyEnable 0x00800000
-#define OHCI_HCControl_NoByteSwapData 0x40000000
-#define OHCI_HCControl_BIBImageValid 0x80000000
+#define OHCI_HCControl_SoftReset 0x00010000
+#define OHCI_HCControl_LinkEnable 0x00020000
+#define OHCI_HCControl_PostedWriteEnable 0x00040000
+#define OHCI_HCControl_LPS 0x00080000
+#define OHCI_HCControl_APhyEnhanceEnable 0x00400000
+#define OHCI_HCControl_ProgramPhyEnable 0x00800000
+#define OHCI_HCControl_NoByteSwapData 0x40000000
+#define OHCI_HCControl_BIBImageValid 0x80000000
/* OHCI_REG_SelfID
*/
-#define OHCI_SelfID_Error 0x80000000
-#define OHCI_SelfID_Gen_MASK 0x00ff0000
-#define OHCI_SelfID_Gen_BITPOS 16
-#define OHCI_SelfID_Size_MASK 0x000007fc
-#define OHCI_SelfID_Size_BITPOS 2
+#define OHCI_SelfID_Error 0x80000000
+#define OHCI_SelfID_Gen_MASK 0x00ff0000
+#define OHCI_SelfID_Gen_BITPOS 16
+#define OHCI_SelfID_Size_MASK 0x000007fc
+#define OHCI_SelfID_Size_BITPOS 2
/* OHCI_REG_Int{Event|Mask}*
*/
-#define OHCI_Int_MasterEnable 0x80000000
-#define OHCI_Int_VendorSpecific 0x40000000
-#define OHCI_Int_SoftInterrupt 0x20000000
-#define OHCI_Int_Ack_Tardy 0x08000000
-#define OHCI_Int_PhyRegRcvd 0x04000000
-#define OHCI_Int_CycleTooLong 0x02000000
-#define OHCI_Int_UnrecoverableError 0x01000000
-#define OHCI_Int_CycleInconsistent 0x00800000
-#define OHCI_Int_CycleLost 0x00400000
-#define OHCI_Int_Cycle64Seconds 0x00200000
-#define OHCI_Int_CycleSynch 0x00100000
-#define OHCI_Int_Phy 0x00080000
-#define OHCI_Int_RegAccessFail 0x00040000
-#define OHCI_Int_BusReset 0x00020000
-#define OHCI_Int_SelfIDComplete 0x00010000
-#define OHCI_Int_SelfIDCOmplete2 0x00008000
-#define OHCI_Int_LockRespErr 0x00000200
-#define OHCI_Int_PostedWriteErr 0x00000100
-#define OHCI_Int_IsochRx 0x00000080
-#define OHCI_Int_IsochTx 0x00000040
-#define OHCI_Int_RSPkt 0x00000020
-#define OHCI_Int_RQPkt 0x00000010
-#define OHCI_Int_ARRS 0x00000008
-#define OHCI_Int_ARRQ 0x00000004
-#define OHCI_Int_RespTxComplete 0x00000002
-#define OHCI_Int_ReqTxComplete 0x00000001
+#define OHCI_Int_MasterEnable 0x80000000
+#define OHCI_Int_VendorSpecific 0x40000000
+#define OHCI_Int_SoftInterrupt 0x20000000
+#define OHCI_Int_Ack_Tardy 0x08000000
+#define OHCI_Int_PhyRegRcvd 0x04000000
+#define OHCI_Int_CycleTooLong 0x02000000
+#define OHCI_Int_UnrecoverableError 0x01000000
+#define OHCI_Int_CycleInconsistent 0x00800000
+#define OHCI_Int_CycleLost 0x00400000
+#define OHCI_Int_Cycle64Seconds 0x00200000
+#define OHCI_Int_CycleSynch 0x00100000
+#define OHCI_Int_Phy 0x00080000
+#define OHCI_Int_RegAccessFail 0x00040000
+#define OHCI_Int_BusReset 0x00020000
+#define OHCI_Int_SelfIDComplete 0x00010000
+#define OHCI_Int_SelfIDCOmplete2 0x00008000
+#define OHCI_Int_LockRespErr 0x00000200
+#define OHCI_Int_PostedWriteErr 0x00000100
+#define OHCI_Int_IsochRx 0x00000080
+#define OHCI_Int_IsochTx 0x00000040
+#define OHCI_Int_RSPkt 0x00000020
+#define OHCI_Int_RQPkt 0x00000010
+#define OHCI_Int_ARRS 0x00000008
+#define OHCI_Int_ARRQ 0x00000004
+#define OHCI_Int_RespTxComplete 0x00000002
+#define OHCI_Int_ReqTxComplete 0x00000001
/* OHCI_REG_LinkControl
*/
-#define OHCI_LinkControl_CycleSource 0x00400000
-#define OHCI_LinkControl_CycleMaster 0x00200000
-#define OHCI_LinkControl_CycleTimerEnable 0x00100000
-#define OHCI_LinkControl_RcvPhyPkt 0x00000400
-#define OHCI_LinkControl_RcvSelfID 0x00000200
-#define OHCI_LinkControl_Tag1SyncFilterLock 0x00000040
+#define OHCI_LinkControl_CycleSource 0x00400000
+#define OHCI_LinkControl_CycleMaster 0x00200000
+#define OHCI_LinkControl_CycleTimerEnable 0x00100000
+#define OHCI_LinkControl_RcvPhyPkt 0x00000400
+#define OHCI_LinkControl_RcvSelfID 0x00000200
+#define OHCI_LinkControl_Tag1SyncFilterLock 0x00000040
/* OHCI_REG_NodeId
*/
-#define OHCI_NodeId_IDValid 0x80000000
-#define OHCI_NodeId_ROOT 0x40000000
-#define OHCI_NodeId_CPS 0x08000000
-#define OHCI_NodeId_BusNumber 0x0000ffc0
-#define OHCI_NodeId_NodeNumber 0x0000003f
+#define OHCI_NodeId_IDValid 0x80000000
+#define OHCI_NodeId_ROOT 0x40000000
+#define OHCI_NodeId_CPS 0x08000000
+#define OHCI_NodeId_BusNumber 0x0000ffc0
+#define OHCI_NodeId_NodeNumber 0x0000003f
/* OHCI_REG_PhyControl
*/
-#define OHCI_PhyControl_RdDone 0x80000000
-#define OHCI_PhyControl_RdAddr 0x0f000000
-#define OHCI_PhyControl_RdAddr_BITPOS 24
-#define OHCI_PhyControl_RdData 0x00ff0000
-#define OHCI_PhyControl_RdData_BITPOS 16
-#define OHCI_PhyControl_RdReg 0x00008000
-#define OHCI_PhyControl_WrReg 0x00004000
-#define OHCI_PhyControl_RegAddr 0x00000f00
-#define OHCI_PhyControl_RegAddr_BITPOS 8
-#define OHCI_PhyControl_WrData 0x000000ff
-#define OHCI_PhyControl_WrData_BITPOS 0
+#define OHCI_PhyControl_RdDone 0x80000000
+#define OHCI_PhyControl_RdAddr 0x0f000000
+#define OHCI_PhyControl_RdAddr_BITPOS 24
+#define OHCI_PhyControl_RdData 0x00ff0000
+#define OHCI_PhyControl_RdData_BITPOS 16
+#define OHCI_PhyControl_RdReg 0x00008000
+#define OHCI_PhyControl_WrReg 0x00004000
+#define OHCI_PhyControl_RegAddr 0x00000f00
+#define OHCI_PhyControl_RegAddr_BITPOS 8
+#define OHCI_PhyControl_WrData 0x000000ff
+#define OHCI_PhyControl_WrData_BITPOS 0
/*
* Section 3.1.1: ContextControl register
*
*
*/
-#define OHCI_CTXCTL_RUN 0x00008000
-#define OHCI_CTXCTL_WAKE 0x00001000
-#define OHCI_CTXCTL_DEAD 0x00000800
-#define OHCI_CTXCTL_ACTIVE 0x00000400
+#define OHCI_CTXCTL_RUN 0x00008000
+#define OHCI_CTXCTL_WAKE 0x00001000
+#define OHCI_CTXCTL_DEAD 0x00000800
+#define OHCI_CTXCTL_ACTIVE 0x00000400
-#define OHCI_CTXCTL_SPD_BITLEN 3
-#define OHCI_CTXCTL_SPD_BITPOS 5
+#define OHCI_CTXCTL_SPD_BITLEN 3
+#define OHCI_CTXCTL_SPD_BITPOS 5
-#define OHCI_CTXCTL_SPD_100 0
-#define OHCI_CTXCTL_SPD_200 1
-#define OHCI_CTXCTL_SPD_400 2
+#define OHCI_CTXCTL_SPD_100 0
+#define OHCI_CTXCTL_SPD_200 1
+#define OHCI_CTXCTL_SPD_400 2
-#define OHCI_CTXCTL_EVENT_BITLEN 5
-#define OHCI_CTXCTL_EVENT_BITPOS 0
+#define OHCI_CTXCTL_EVENT_BITLEN 5
+#define OHCI_CTXCTL_EVENT_BITPOS 0
/* Events from 0 to 15 are generated by the OpenHCI controller.
* Events from 16 to 31 are four-bit IEEE 1394 ack codes or'ed with bit 4 set.
@@ -512,41 +512,47 @@
#define OHCI_TCODE_PHY 0xe
#if BYTE_ORDER == BIG_ENDIAN
-struct fwohci_desc {
+typedef struct fwohci_desc {
u_int16_t fd_flags;
u_int16_t fd_reqcount;
u_int32_t fd_data;
u_int32_t fd_branch;
u_int16_t fd_status;
u_int16_t fd_rescount;
-};
+#if 0 /* XXX */
+ u_int32_t fd_immed[4];
+#endif
+} fwohci_desc;
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
-struct fwohci_desc {
+typedef struct fwohci_desc {
u_int16_t fd_reqcount;
u_int16_t fd_flags;
u_int32_t fd_data;
u_int32_t fd_branch;
u_int16_t fd_rescount;
u_int16_t fd_status;
-};
+#if 0 /* XXX */
+ u_int32_t fd_immed[4];
+#endif
+} fwohci_desc;
#endif
#define fd_timestamp fd_rescount
-#define OHCI_DESC_INPUT 0x2000
-#define OHCI_DESC_LAST 0x1000
-#define OHCI_DESC_STATUS 0x0800
-#define OHCI_DESC_IMMED 0x0200
-#define OHCI_DESC_PING 0x0080
-#define OHCI_DESC_INTR_ALWAYS 0x0030
-#define OHCI_DESC_INTR_ERR 0x0010
-#define OHCI_DESC_BRANCH 0x000c
-#define OHCI_DESC_WAIT 0x0003
+#define OHCI_DESC_INPUT 0x2000
+#define OHCI_DESC_LAST 0x1000
+#define OHCI_DESC_STATUS 0x0800
+#define OHCI_DESC_IMMED 0x0200
+#define OHCI_DESC_PING 0x0080
+#define OHCI_DESC_INTR_ALWAYS 0x0030
+#define OHCI_DESC_INTR_ERR 0x0010
+#define OHCI_DESC_BRANCH 0x000c
+#define OHCI_DESC_WAIT 0x0003
-#define OHCI_DESC_MAX 8
+#define OHCI_DESC_MAX 8
/* Some constants for passing ACK values around with from status reg's */
-#define OHCI_DESC_STATUS_ACK_MASK 0x1f
+#define OHCI_DESC_STATUS_ACK_MASK 0x1f
#endif /* _DEV_IEEE1394_FWOHCIREG_ */
diff --git a/sys/dev/ieee1394/fwohcivar.h b/sys/dev/ieee1394/fwohcivar.h
index 65a9c4470aa..d762c374788 100644
--- a/sys/dev/ieee1394/fwohcivar.h
+++ b/sys/dev/ieee1394/fwohcivar.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: fwohcivar.h,v 1.1 2002/06/25 17:11:49 itojun Exp $ */
+/* $OpenBSD: fwohcivar.h,v 1.2 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: fwohcivar.h,v 1.17 2002/01/16 01:47:37 eeh Exp $ */
-/*-
+/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -18,8 +18,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@@ -37,10 +37,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_IEEE1394_FWOHCIVAR_H_
+#ifndef _DEV_IEEE1394_FWOHCIVAR_H_
#define _DEV_IEEE1394_FWOHCIVAR_H_
-#ifdef __NetBSD__
+#ifdef __NetBSD__
#include <sys/callout.h>
#else
#include <sys/timeout.h>
@@ -49,79 +49,85 @@
#include <machine/bus.h>
-#define OHCI_PAGE_SIZE 0x0800
-#define OHCI_BUF_ARRQ_CNT 16
-#define OHCI_BUF_ARRS_CNT 8
-#define OHCI_BUF_ATRQ_CNT (8*8)
-#define OHCI_BUF_ATRS_CNT (8*8)
-#define OHCI_BUF_IR_CNT 8
+#define OHCI_PAGE_SIZE 0x0800
+#define OHCI_BUF_ARRQ_CNT 16
+#define OHCI_BUF_ARRS_CNT 8
+#define OHCI_BUF_ATRQ_CNT (8*8)
+#define OHCI_BUF_ATRS_CNT (8*8)
+#define OHCI_BUF_IR_CNT 8
#define OHCI_BUF_CNT \
(OHCI_BUF_ARRQ_CNT + OHCI_BUF_ARRS_CNT + OHCI_BUF_ATRQ_CNT + \
OHCI_BUF_ATRS_CNT + OHCI_BUF_IR_CNT + 1 + 1)
-#define OHCI_LOOP 1000
-#define OHCI_SELFID_TIMEOUT (hz * 3)
-#define OHCI_ASYNC_STREAM 0x40
+#define OHCI_LOOP 1000
+#define OHCI_SELFID_TIMEOUT (hz * 3)
+#define OHCI_ASYNC_STREAM 0x40
struct fwohci_softc;
struct fwohci_pkt;
struct mbuf;
-struct fwohci_buf {
- TAILQ_ENTRY(fwohci_buf) fb_list;
- bus_dma_segment_t fb_seg;
- int fb_nseg;
- bus_dmamap_t fb_dmamap; /* DMA map of the buffer */
- caddr_t fb_buf; /* kernel virtual addr of the buffer */
- struct fwohci_desc *fb_desc; /* kernel virtual addr of descriptor */
- bus_addr_t fb_daddr; /* physical addr of the descriptor */
- int fb_off;
- struct mbuf *fb_m;
- void *fb_statusarg;
- void (*fb_callback)(struct device *, struct mbuf *);
- int (*fb_statuscb)(struct fwohci_softc *, void *, struct fwohci_pkt *);
-};
-
-struct fwohci_pkt {
- int fp_tcode;
- int fp_hlen;
- int fp_dlen;
- u_int32_t fp_hdr[4];
- struct uio fp_uio;
- struct iovec fp_iov[6];
- u_int32_t *fp_trail;
- struct mbuf *fp_m;
- u_int16_t fp_status;
- void *fp_statusarg;
- int (*fp_statuscb)(struct fwohci_softc *, void *, struct fwohci_pkt *);
- void (*fp_callback)(struct device *, struct mbuf *);
-};
-
-struct fwohci_handler {
+typedef struct fwohci_buf {
+ TAILQ_ENTRY(fwohci_buf) fb_list;
+ bus_dma_segment_t fb_seg;
+ int fb_nseg;
+ bus_dmamap_t fb_dmamap; /* DMA map of the buffer */
+ caddr_t fb_buf; /* kernel vaddr of the buffer */
+ struct fwohci_desc *fb_desc; /* kernel vaddr of descriptor */
+ bus_addr_t fb_daddr; /* paddr of the descriptor */
+ int fb_off;
+ struct mbuf *fb_m;
+ void *fb_statusarg;
+ void (*fb_callback)(struct device *, struct mbuf *);
+ int (*fb_statuscb)(struct fwohci_softc *, void *,
+ struct fwohci_pkt *);
+} fwohci_buf;
+
+typedef struct fwohci_pkt {
+ int fp_tcode;
+ int fp_hlen;
+ int fp_dlen;
+ u_int32_t fp_hdr[4];
+ struct uio fp_uio;
+ struct iovec fp_iov[6];
+ u_int32_t *fp_trail;
+ struct mbuf *fp_m;
+ u_int16_t fp_status;
+ void *fp_statusarg;
+ void (*fp_callback)(struct device *, struct mbuf *);
+ int (*fp_statuscb)(struct fwohci_softc *, void *,
+ struct fwohci_pkt *);
+} fwohci_pkt;
+
+typedef struct fwohci_handler {
LIST_ENTRY(fwohci_handler) fh_list;
- u_int32_t fh_tcode; /* ARRQ / ARRS / IR */
- u_int32_t fh_key1; /* addrhi / srcid / chan */
- u_int32_t fh_key2; /* addrlo / tlabel / tag */
- int (*fh_handler)(struct fwohci_softc *, void *,
- struct fwohci_pkt *);
- void *fh_handarg;
-};
-
-struct fwohci_ctx {
- int fc_ctx;
- int fc_type; /* FWOHCI_CTX_(ASYNC|ISO_SINGLE|ISO_MULTI) */
- int fc_bufcnt;
- u_int32_t *fc_branch;
+ u_int32_t fh_tcode; /* ARRQ / ARRS / IR */
+ u_int32_t fh_key1; /* addrhi / srcid / chan */
+ u_int32_t fh_key2; /* addrlo / tlabel / tag */
+ int (*fh_handler)(struct fwohci_softc *, void *,
+ struct fwohci_pkt *);
+ void *fh_handarg;
+} fwohci_handler;
+
+typedef struct fwohci_ctx {
+ int fc_ctx;
+ int fc_type; /*
+ * FWOHCI_CTX_(ASYNC|
+ * ISO_SINGLE|
+ * ISO_MULTI)
+ */
+ int fc_bufcnt;
+ u_int32_t *fc_branch;
TAILQ_HEAD(fwohci_buf_s, fwohci_buf) fc_buf;
- struct fwohci_buf_s fc_buf2; /* for iso */
+ struct fwohci_buf_s fc_buf2; /* for iso */
LIST_HEAD(, fwohci_handler) fc_handler;
- struct fwohci_buf *fc_buffers;
-};
+ struct fwohci_buf *fc_buffers;
+} fwohci_ctx;
-struct fwohci_uidtbl {
- int fu_valid;
- u_int8_t fu_uid[8];
-};
+typedef struct fwohci_uidtbl {
+ int fu_valid;
+ u_int8_t fu_uid[8];
+} fwohci_uidtbl;
/*
* Needed to keep track of outstanding packets during a read op. Since the
@@ -130,73 +136,76 @@ struct fwohci_uidtbl {
* abuf is still valid before possibly attempting to use items from within it.
*/
-struct fwohci_cb {
- struct ieee1394_abuf *ab;
- int count;
- int abuf_valid;
-};
-
-struct fwohci_softc {
- struct ieee1394_softc sc_sc1394;
- struct evcnt sc_intrcnt;
- struct evcnt sc_isocnt;
- struct evcnt sc_isopktcnt;
-
- bus_space_tag_t sc_memt;
- bus_space_handle_t sc_memh;
- bus_dma_tag_t sc_dmat;
- bus_size_t sc_memsize;
+typedef struct fwohci_cb {
+ struct ieee1394_abuf *ab;
+ int count;
+ int abuf_valid;
+} fwohci_cb;
+
+typedef struct fwohci_softc {
+ struct ieee1394_softc sc_sc1394;
+ struct evcnt sc_intrcnt;
+ struct evcnt sc_isocnt;
+ struct evcnt sc_isopktcnt;
+
+ bus_space_tag_t sc_memt;
+ bus_space_handle_t sc_memh;
+ bus_dma_tag_t sc_dmat;
+ bus_size_t sc_memsize;
#if 0
-/* Mandatory structures to get the link enabled
+/*
+ * Mandatory structures to get the link enabled.
*/
- bus_dmamap_t sc_configrom_map;
- bus_dmamap_t sc_selfid_map;
- u_int32_t *sc_selfid_buf;
- u_int32_t *sc_configrom;
+ bus_dmamap_t sc_configrom_map;
+ bus_dmamap_t sc_selfid_map;
+ u_int32_t *sc_selfid_buf;
+ u_int32_t *sc_configrom;
#endif
- bus_dma_segment_t sc_dseg;
- int sc_dnseg;
- bus_dmamap_t sc_ddmamap;
- struct fwohci_desc *sc_desc;
- u_int8_t *sc_descmap;
- int sc_descsize;
- int sc_isoctx;
-
- void *sc_shutdownhook;
- void *sc_powerhook;
-#ifdef __NetBSD__
- struct callout sc_selfid_callout;
+ bus_dma_segment_t sc_dseg;
+ int sc_dnseg;
+ bus_dmamap_t sc_ddmamap;
+ struct fwohci_desc *sc_desc;
+ u_int8_t *sc_descmap;
+ int sc_descsize;
+ int sc_isoctx;
+
+ void *sc_shutdownhook;
+ void *sc_powerhook;
+#ifdef __NetBSD__
+ struct callout sc_selfid_callout;
#else
- struct timeout sc_selfid_callout;
+ struct timeout sc_selfid_callout;
#endif
- int sc_selfid_fail;
-
- struct fwohci_ctx *sc_ctx_arrq;
- struct fwohci_ctx *sc_ctx_arrs;
- struct fwohci_ctx *sc_ctx_atrq;
- struct fwohci_ctx *sc_ctx_atrs;
- struct fwohci_ctx **sc_ctx_ir;
- struct fwohci_buf sc_buf_cnfrom;
- struct fwohci_buf sc_buf_selfid;
-
- struct proc *sc_event_thread;
-
- int sc_dying;
- u_int32_t sc_intmask;
- u_int32_t sc_iso;
-
- u_int8_t sc_csr[CSR_SB_END];
-
- struct fwohci_uidtbl *sc_uidtbl;
- u_int16_t sc_nodeid; /* Full Node ID of this node */
- u_int8_t sc_rootid; /* Phy ID of Root */
- u_int8_t sc_irmid; /* Phy ID of IRM */
- u_int8_t sc_tlabel; /* Transaction Label */
-
+ int sc_selfid_fail;
+
+ struct fwohci_ctx *sc_ctx_arrq;
+ struct fwohci_ctx *sc_ctx_arrs;
+ struct fwohci_ctx *sc_ctx_atrq;
+ struct fwohci_ctx *sc_ctx_atrs;
+ struct fwohci_ctx **sc_ctx_ir;
+ struct fwohci_buf sc_buf_cnfrom;
+ struct fwohci_buf sc_buf_selfid;
+
+ struct proc *sc_event_thread;
+
+ int *sc_dying;
+ u_int32_t sc_intmask;
+ u_int32_t sc_iso;
+ u_int32_t sc_isorxrst;
+ u_int32_t sc_isotxrst;
+
+ u_int8_t sc_csr[CSR_SB_END];
+
+ struct fwohci_uidtbl *sc_uidtbl;
+ u_int16_t sc_nodeid; /* Full Node ID of this node */
+ u_int8_t sc_rootid; /* Phy ID of Root */
+ u_int8_t sc_irmid; /* Phy ID of IRM */
+ u_int8_t sc_tlabel; /* Transaction Label */
+
LIST_HEAD(, ieee1394_softc) sc_nodelist;
-};
+} fwohci_softc;
int fwohci_init (struct fwohci_softc *, const struct evcnt *);
int fwohci_intr (void *);
@@ -208,7 +217,7 @@ int fwohci_activate(struct device *, enum devact);
*/
#define OHCI_CSR_WRITE(sc, reg, val) \
bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, reg, htole32(val))
-#ifdef __NetBSD__
+#ifdef __NetBSD__
#define OHCI_CSR_READ(sc, reg) \
le32toh(bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, reg))
#else
@@ -216,26 +225,26 @@ int fwohci_activate(struct device *, enum devact);
letoh32(bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, reg))
#endif
-#define FWOHCI_CTX_ASYNC 0
-#define FWOHCI_CTX_ISO_SINGLE 1 /* for async stream */
-#define FWOHCI_CTX_ISO_MULTI 2 /* for isochronous */
+#define FWOHCI_CTX_ASYNC 0
+#define FWOHCI_CTX_ISO_SINGLE 1 /* for async stream */
+#define FWOHCI_CTX_ISO_MULTI 2 /* for isochronous */
/* Locators. */
-#ifdef __NetBSD__
+#ifdef __NetBSD__
#include "locators.h"
#else
/* dup from sys/conf/files */
-#define FWBUSCF_IDHI_DEFAULT (-1)
-#define FWBUSCF_IDLO_DEFAULT (-1)
-#define FWBUSCF_IDHI 1
-#define FWBUSCF_IDLO 0
+#define FWBUSCF_IDHI_DEFAULT (-1)
+#define FWBUSCF_IDLO_DEFAULT (-1)
+#define FWBUSCF_IDHI 1
+#define FWBUSCF_IDLO 0
#endif
-#define fwbuscf_idhi cf_loc[FWBUSCF_IDHI]
-#define FWBUS_UNK_IDHI FWBUSCF_IDHI_DEFAULT
+#define fwbuscf_idhi cf_loc[FWBUSCF_IDHI]
+#define FWBUS_UNK_IDHI FWBUSCF_IDHI_DEFAULT
-#define fwbuscf_idlo cf_loc[FWBUSCF_IDLO]
-#define FWBUS_UNK_IDLO FWBUSCF_IDLO_DEFAULT
+#define fwbuscf_idlo cf_loc[FWBUSCF_IDLO]
+#define FWBUS_UNK_IDLO FWBUSCF_IDLO_DEFAULT
#endif /* _DEV_IEEE1394_FWOHCIVAR_H_ */
diff --git a/sys/dev/ieee1394/ieee1394reg.h b/sys/dev/ieee1394/ieee1394reg.h
index bf9df800d13..fa7e52cd615 100644
--- a/sys/dev/ieee1394/ieee1394reg.h
+++ b/sys/dev/ieee1394/ieee1394reg.h
@@ -1,12 +1,12 @@
-/* $OpenBSD: ieee1394reg.h,v 1.1 2002/06/25 17:11:49 itojun Exp $ */
+/* $OpenBSD: ieee1394reg.h,v 1.2 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: ieee1394reg.h,v 1.12 2002/02/27 05:07:25 jmc Exp $ */
-/*-
+/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by
+ * by
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -18,8 +18,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@@ -37,12 +37,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_IEEE1394_IEEE1394REG_H_
+#ifndef _DEV_IEEE1394_IEEE1394REG_H_
#define _DEV_IEEE1394_IEEE1394REG_H_
#include <dev/std/ieee1212reg.h>
-/* Transaction Codes (Table 6-9)
+/*
+ * Transaction Codes (Table 6-9)
*/
#define IEEE1394_TCODE_WRITE_REQUEST_QUADLET 0
#define IEEE1394_TCODE_WRITE_REQUEST_DATABLOCK 1
@@ -52,16 +53,17 @@
#define IEEE1394_TCODE_READ_REQUEST_DATABLOCK 5
#define IEEE1394_TCODE_READ_RESPONSE_QUADLET 6
#define IEEE1394_TCODE_READ_RESPONSE_DATABLOCK 7
-#define IEEE1394_TCODE_CYCLE_START 0x8
+#define IEEE1394_TCODE_CYCLE_START 8
#define IEEE1394_TCODE_LOCK_REQUEST 9
-#define IEEE1394_TCODE_ISOCHRONOUS_DATA_BLOCK 10
+#define IEEE1394_TCODE_ISOCHRONOUS_DATABLOCK 10
#define IEEE1394_TCODE_LOCK_RESPONSE 11
#define IEEE1394_TCODE_RESERVED_12 12
#define IEEE1394_TCODE_RESERVED_13 13
#define IEEE1394_TCODE_RESERVED_14 14
#define IEEE1394_TCODE_RESERVED_15 15
-/* Extended transaction codes (Table 6-10)
+/*
+ * Extended transaction codes (Table 6-10)
*/
#define IEEE1394_XTCODE_RESERVED_0 P1212_LOCK_RESERVED_0
#define IEEE1394_XTCODE_MASK_SWAP P1212_LOCK_MASK_SWAP
@@ -71,19 +73,21 @@
#define IEEE1394_XTCODE_BOUNDED_ADD P1212_LOCK_BOUNDED_ADD
#define IEEE1394_XTCODE_WRAP_ADD P1212_LOCK_WRAP_ADD
#define IEEE1394_XTCODE_VENDOR_DEPENDENT P1212_LOCK_VENDOR_DEPENDENT
-/* 0x0008 .. 0xFFFF are reserved.
+/*
+ * 0x0008 .. 0xFFFF are reserved.
*/
-/* Response codes (Table 6-11)
+/*
+ * Response codes (Table 6-11)
*/
-#define IEEE1394_RCODE_RESP_COMPLETE 0
+#define IEEE1394_RCODE_COMPLETE 0
#define IEEE1394_RCODE_RESERVED_1 1
#define IEEE1394_RCODE_RESERVED_2 2
#define IEEE1394_RCODE_RESERVED_3 3
-#define IEEE1394_RCODE_RESP_CONFLICT_ERROR 4
-#define IEEE1394_RCODE_RESP_DATA_ERROR 5
-#define IEEE1394_RCODE_RESP_TYPE_ERROR 6
-#define IEEE1394_RCODE_RESP_ADDRESS_ERROR 7
+#define IEEE1394_RCODE_CONFLICT_ERROR 4
+#define IEEE1394_RCODE_DATA_ERROR 5
+#define IEEE1394_RCODE_TYPE_ERROR 6
+#define IEEE1394_RCODE_ADDRESS_ERROR 7
#define IEEE1394_RCODE_RESERVED_8 8
#define IEEE1394_RCODE_RESERVED_9 9
#define IEEE1394_RCODE_RESERVED_10 10
@@ -115,127 +119,106 @@
#define IEEE1394_ACK_TYPE_ERROR 14
#define IEEE1394_ACK_RESERVED_15 15
-/* Defined IEEE 1394 speeds.
+/*
+ * Defined IEEE 1394 speeds.
*/
-#define IEEE1394_SPD_S100 0 /* 1394-1995 */
-#define IEEE1394_SPD_S200 1 /* 1394-1995 */
-#define IEEE1394_SPD_S400 2 /* 1394-1995 */
-#define IEEE1394_SPD_S800 3 /* 1394b */
-#define IEEE1394_SPD_S1600 4 /* 1394b */
-#define IEEE1394_SPD_S3200 5 /* 1394b */
-#define IEEE1394_SPD_MAX 6
+#define IEEE1394_SPD_S100 0 /* 1394-1995 */
+#define IEEE1394_SPD_S200 1 /* 1394-1995 */
+#define IEEE1394_SPD_S400 2 /* 1394-1995 */
+#define IEEE1394_SPD_S800 3 /* 1394b */
+#define IEEE1394_SPD_S1600 4 /* 1394b */
+#define IEEE1394_SPD_S3200 5 /* 1394b */
+#define IEEE1394_SPD_MAX 6
#define IEEE1394_SPD_STRINGS "100Mb/s", "200Mb/s", "400Mb/s", "800Mb/s", \
- "1.6Gb/s", "3.2Gb/s"
+ "1.6Gb/s", "3.2Gb/s"
#if 0
-struct ieee1394_async_nodata {
- u_int32_t an_header_crc;
-} __attribute((__packed__));
+typedef struct ieee1394_async_nodata {
+ u_int32_t an_header_crc;
+} ieee1394_async_nodata __attribute((__packed__));
#endif
-#define IEEE1394_BCAST_PHY_ID 0x3f
-#define IEEE1394_ISOCH_MASK 0x3f
+#define IEEE1394_BCAST_PHY_ID 0x3f
+#define IEEE1394_ISOCH_MASK 0x3f
/*
- * Transaction code
+ * Signature
*/
-#define IEEE1394_TCODE_WRITE_REQ_QUAD 0x0
-#define IEEE1394_TCODE_WRITE_REQ_BLOCK 0x1
-#define IEEE1394_TCODE_WRITE_RESP 0x2
-#define IEEE1394_TCODE_READ_REQ_QUAD 0x4
-#define IEEE1394_TCODE_READ_REQ_BLOCK 0x5
-#define IEEE1394_TCODE_READ_RESP_QUAD 0x6
-#define IEEE1394_TCODE_READ_RESP_BLOCK 0x7
-#define IEEE1394_TCODE_CYCLE_START 0x8
-#define IEEE1394_TCODE_LOCK_REQ 0x9
-#define IEEE1394_TCODE_STREAM_DATA 0xa
-#define IEEE1394_TCODE_LOCK_RESP 0xb
+#define IEEE1394_SIGNATURE 0x31333934
/*
- * Response code
+ * Tag value
*/
-#define IEEE1394_RCODE_COMPLETE 0x0
-#define IEEE1394_RCODE_CONFLICT_ERROR 0x4
-#define IEEE1394_RCODE_DATA_ERROR 0x5
-#define IEEE1394_RCODE_TYPE_ERROR 0x6
-#define IEEE1394_RCODE_ADDRESS_ERROR 0x7
+#define IEEE1394_TAG_GASP 0x3
/*
- * Signature
+ * Control and Status Registers (IEEE1212 & IEEE1394)
*/
-#define IEEE1394_SIGNATURE 0x31333934
+#define CSR_BASE_HI 0x0000ffff
+#define CSR_BASE_LO 0xf0000000
+#define CSR_BASE 0x0000fffff0000000UL
+
+#define CSR_STATE_CLEAR 0x0000
+#define CSR_STATE_SET 0x0004
+#define CSR_NODE_IDS 0x0008
+#define CSR_RESET_START 0x000c
+#define CSR_INDIRECT_ADDRESS 0x0010
+#define CSR_INDIRECT_DATA 0x0014
+#define CSR_SPLIT_TIMEOUT_HI 0x0018
+#define CSR_SPLIT_TIMEOUT_LO 0x001c
+#define CSR_ARGUMENT_HI 0x0020
+#define CSR_ARGUMENT_LO 0x0024
+#define CSR_TEST_START 0x0028
+#define CSR_TEST_STATUS 0x002c
+#define CSR_INTERRUPT_TARGET 0x0050
+#define CSR_INTERRUPT_MASK 0x0054
+#define CSR_CLOCK_VALUE 0x0058
+#define CSR_CLOCK_PERIOD 0x005c
+#define CSR_CLOCK_STROBE_ARRIVED 0x0060
+#define CSR_CLOCK_INFO 0x0064
+#define CSR_MESSAGE_REQUEST 0x0080
+#define CSR_MESSAGE_RESPONSE 0x00c0
+
+#define CSR_SB_CYCLE_TIME 0x0200
+#define CSR_SB_BUS_TIME 0x0204
+#define CSR_SB_POWER_FAIL_IMMINENT 0x0208
+#define CSR_SB_POWER_SOURCE 0x020c
+#define CSR_SB_BUSY_TIMEOUT 0x0210
+#define CSR_SB_PRIORITY_BUDGET_HI 0x0214
+#define CSR_SB_PRIORITY_BUDGET_LO 0x0218
+#define CSR_SB_BUS_MANAGER_ID 0x021c
+#define CSR_SB_BANDWIDTH_AVAILABLE 0x0220
+#define CSR_SB_CHANNEL_AVAILABLE_HI 0x0224
+#define CSR_SB_CHANNEL_AVAILABLE_LO 0x0228
+#define CSR_SB_MAINT_CONTROL 0x022c
+#define CSR_SB_MAINT_UTILITY 0x0230
+#define CSR_SB_BROADCAST_CHANNEL 0x0234
+
+#define CSR_CONFIG_ROM 0x0400
+
+#define CSR_SB_OUTPUT_MASTER_PLUG 0x0900
+#define CSR_SB_OUTPUT_PLUG 0x0904
+#define CSR_SB_INPUT_MASTER_PLUG 0x0980
+#define CSR_SB_INPUT_PLUG 0x0984
+#define CSR_SB_FCP_COMMAND_FRAME 0x0b00
+#define CSR_SB_FCP_RESPONSE_FRAME 0x0d00
+#define CSR_SB_TOPOLOGY_MAP 0x1000
+#define CSR_SB_END 0x1400
+
+#define IEEE1394_MAX_REC(i) ((0x1 << (i + 1)))
+#define IEEE1394_BUSINFO_LEN 3
+
+#define IEEE1394_GET_MAX_REC(i) ((i & 0x0000f000) >> 12)
+#define IEEE1394_GET_LINK_SPD(i) (i & 0x00000007)
/*
- * Tag value
+ * XXX. Should be at if_fw level but needed here for constructing the config
+ * rom. An interface for if_fw to send up a config rom should be done (probably
+ * in the p1212 routines.
*/
-#define IEEE1394_TAG_GASP 0x3
-/*
- * Control and Status Registers (IEEE1212 & IEEE1394)
- */
-#define CSR_BASE_HI 0x0000ffff
-#define CSR_BASE_LO 0xf0000000
-#define CSR_BASE 0x0000fffff0000000
-
-#define CSR_STATE_CLEAR 0x0000
-#define CSR_STATE_SET 0x0004
-#define CSR_NODE_IDS 0x0008
-#define CSR_RESET_START 0x000c
-#define CSR_INDIRECT_ADDRESS 0x0010
-#define CSR_INDIRECT_DATA 0x0014
-#define CSR_SPLIT_TIMEOUT_HI 0x0018
-#define CSR_SPLIT_TIMEOUT_LO 0x001c
-#define CSR_ARGUMENT_HI 0x0020
-#define CSR_ARGUMENT_LO 0x0024
-#define CSR_TEST_START 0x0028
-#define CSR_TEST_STATUS 0x002c
-#define CSR_INTERRUPT_TARGET 0x0050
-#define CSR_INTERRUPT_MASK 0x0054
-#define CSR_CLOCK_VALUE 0x0058
-#define CSR_CLOCK_PERIOD 0x005c
-#define CSR_CLOCK_STROBE_ARRIVED 0x0060
-#define CSR_CLOCK_INFO 0x0064
-#define CSR_MESSAGE_REQUEST 0x0080
-#define CSR_MESSAGE_RESPONSE 0x00c0
-
-#define CSR_SB_CYCLE_TIME 0x0200
-#define CSR_SB_BUS_TIME 0x0204
-#define CSR_SB_POWER_FAIL_IMMINENT 0x0208
-#define CSR_SB_POWER_SOURCE 0x020c
-#define CSR_SB_BUSY_TIMEOUT 0x0210
-#define CSR_SB_PRIORITY_BUDGET_HI 0x0214
-#define CSR_SB_PRIORITY_BUDGET_LO 0x0218
-#define CSR_SB_BUS_MANAGER_ID 0x021c
-#define CSR_SB_BANDWIDTH_AVAILABLE 0x0220
-#define CSR_SB_CHANNEL_AVAILABLE_HI 0x0224
-#define CSR_SB_CHANNEL_AVAILABLE_LO 0x0228
-#define CSR_SB_MAINT_CONTROL 0x022c
-#define CSR_SB_MAINT_UTILITY 0x0230
-#define CSR_SB_BROADCAST_CHANNEL 0x0234
-
-#define CSR_CONFIG_ROM 0x0400
-
-#define CSR_SB_OUTPUT_MASTER_PLUG 0x0900
-#define CSR_SB_OUTPUT_PLUG 0x0904
-#define CSR_SB_INPUT_MASTER_PLUG 0x0980
-#define CSR_SB_INPUT_PLUG 0x0984
-#define CSR_SB_FCP_COMMAND_FRAME 0x0b00
-#define CSR_SB_FCP_RESPONSE_FRAME 0x0d00
-#define CSR_SB_TOPOLOGY_MAP 0x1000
-#define CSR_SB_END 0x1400
-
-#define IEEE1394_MAX_REC(i) ((0x1 << (i + 1)))
-#define IEEE1394_BUSINFO_LEN 3
-
-#define IEEE1394_GET_MAX_REC(i) ((i & 0x0000f000) >> 12)
-#define IEEE1394_GET_LINK_SPD(i) (i & 0x00000007)
-
-/* XXX. Should be at if_fw level but needed here for constructing the config
- rom. An interface for if_fw to send up a config rom should be done (probably
- in the p1212 routines. */
-
-#define FW_FIFO_HI 0x2000
-#define FW_FIFO_LO 0x00000000
+#define FW_FIFO_HI 0x2000
+#define FW_FIFO_LO 0x00000000
#endif /* _DEV_IEEE1394_IEEE1394REG_H_ */
diff --git a/sys/dev/ieee1394/ieee1394var.h b/sys/dev/ieee1394/ieee1394var.h
index 415f9007e83..5120054c111 100644
--- a/sys/dev/ieee1394/ieee1394var.h
+++ b/sys/dev/ieee1394/ieee1394var.h
@@ -1,12 +1,12 @@
-/* $OpenBSD: ieee1394var.h,v 1.2 2002/06/25 23:33:31 itojun Exp $ */
+/* $OpenBSD: ieee1394var.h,v 1.3 2002/12/13 02:52:04 tdeval Exp $ */
/* $NetBSD: ieee1394var.h,v 1.15 2002/02/27 05:04:28 jmc Exp $ */
-/*-
+/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by
+ * by
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -18,8 +18,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@@ -37,82 +37,87 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_IEEE1394_IEEE1394VAR_H_
+#ifndef _DEV_IEEE1394_IEEE1394VAR_H_
#define _DEV_IEEE1394_IEEE1394VAR_H_
+extern const char * const ieee1394_speeds[];
+
struct ieee1394_softc;
struct ieee1394_node;
-/* These buffers have no reference counting. It is assumed that
+/* These buffers have no reference counting. It is assumed that
* the upper level buffer (struct buf or struct mbuf) will have the
* requisite reference counting.
*/
-struct ieee1394_abuf {
- struct ieee1394_softc *ab_req; /* requestor */
- struct ieee1394_softc *ab_resp; /* response */
- u_int32_t *ab_data;
- struct uio *ab_uio;
- u_int64_t ab_addr;
- u_int8_t ab_tcode;
- u_int8_t ab_tlabel;
- u_int32_t ab_length;
- u_int32_t ab_retlen; /* length returned from read. */
- u_int32_t ab_retries;
- void (*ab_cb)(struct ieee1394_abuf *, int);
- void *ab_cbarg;
-};
+typedef struct ieee1394_abuf {
+ struct ieee1394_softc *ab_req; /* requestor */
+ struct ieee1394_softc *ab_resp; /* response */
+ u_int32_t *ab_data;
+ struct uio *ab_uio;
+ u_int64_t ab_addr;
+ u_int8_t ab_tcode;
+ u_int8_t ab_tlabel;
+ u_int32_t ab_length;
+ u_int32_t ab_retlen; /* length returned from read. */
+ u_int32_t ab_retries;
+ void (*ab_cb)(struct ieee1394_abuf *, int);
+ void *ab_cbarg;
+} ieee1394_abuf;
+
+typedef struct ieee1394_callbacks {
+ void (*cb1394_busreset)(struct ieee1394_softc *);
+ void (*cb1394_at_queue)(struct ieee1394_softc *, int type,
+ struct ieee1394_abuf *);
+ void (*cb1394_at_done) (struct ieee1394_softc *,
+ struct ieee1394_abuf *);
+} ieee1394_callbacks;
-struct ieee1394_callbacks {
- void (*cb1394_busreset)(struct ieee1394_softc *);
- void (*cb1394_at_queue)(struct ieee1394_softc *, int type,
- struct ieee1394_abuf *);
- void (*cb1394_at_done)(struct ieee1394_softc *,
- struct ieee1394_abuf *);
-};
+typedef struct ieee1394_attach_args {
+ char name[7];
+ u_int8_t uid[8];
+ u_int16_t nodeid;
+ int (*read) (struct ieee1394_abuf *);
+ int (*write)(struct ieee1394_abuf *);
+ int (*inreg)(struct ieee1394_abuf *, int);
+ int (*unreg)(struct ieee1394_abuf *, int);
+} ieee1394_attach_args;
-struct ieee1394_attach_args {
- char name[7];
- u_int8_t uid[8];
- u_int16_t nodeid;
- int (*read)(struct ieee1394_abuf *);
- int (*write)(struct ieee1394_abuf *);
- int (*inreg)(struct ieee1394_abuf *, int);
- int (*unreg)(struct ieee1394_abuf *, int);
-};
+typedef struct ieee1394_softc {
+ struct device sc1394_dev;
+ struct device *sc1394_if; /* Move to fwohci level. */
+
+ const struct ieee1394_callbacks sc1394_callback; /* Nuke probably. */
+ u_int32_t *sc1394_configrom;
+ u_int32_t sc1394_configrom_len; /* quadlets. */
+ u_int32_t sc1394_max_receive;
+ u_int8_t sc1394_guid[8];
+ u_int8_t sc1394_link_speed; /* IEEE1394_SPD_* */
+ u_int16_t sc1394_node_id; /* my node id
+ * in network order */
+ int (*sc1394_ifoutput)(struct device *, struct mbuf *,
+ void (*)(struct device *, struct mbuf *));
+ /* Nuke. */
+ int (*sc1394_ifinreg)(struct device *, u_int32_t, u_int32_t,
+ void (*)(struct device *, struct mbuf *));
+ /* Nuke */
+ int (*sc1394_ifsetiso)(struct device *, u_int32_t, u_int32_t,
+ u_int32_t, void (*)(struct device *, struct mbuf *));
+ /* Nuke */
-struct ieee1394_softc {
- struct device sc1394_dev;
- struct device *sc1394_if; /* Move to fwohci level. */
-
- const struct ieee1394_callbacks sc1394_callback; /* Nuke probably. */
- u_int32_t *sc1394_configrom;
- u_int32_t sc1394_configrom_len; /* quadlets. */
- u_int32_t sc1394_max_receive;
- u_int8_t sc1394_guid[8];
- u_int8_t sc1394_link_speed; /* IEEE1394_SPD_* */
- u_int16_t sc1394_node_id; /* my node id in network order */
-
- int (*sc1394_ifoutput)(struct device *, struct mbuf *,
- void (*)(struct device *, struct mbuf *)); /* Nuke. */
- int (*sc1394_ifinreg)(struct device *, u_int32_t, u_int32_t,
- void (*)(struct device *, struct mbuf *)); /* Nuke */
- int (*sc1394_ifsetiso)(struct device *, u_int32_t, u_int32_t, u_int32_t,
- void (*)(struct device *, struct mbuf *)); /* Nuke */
-
LIST_ENTRY(ieee1394_softc) sc1394_node;
-};
+} ieee1394_softc;
+
+typedef struct ieee1394_node {
+ struct device node_dev;
-struct ieee1394_node {
- struct device node_dev;
-
- struct ieee1394_softc *node_sc; /* owning bus */
- u_int32_t *node_configrom;
- size_t node_configrom_len;
-};
+ struct ieee1394_softc *node_sc; /* owning bus */
+ u_int32_t *node_configrom;
+ size_t node_configrom_len;
+} ieee1394_node;
int ieee1394_init(struct ieee1394_softc *);
-#define IEEE1394_ARGTYPE_PTR 0
-#define IEEE1394_ARGTYPE_MBUF 1
+#define IEEE1394_ARGTYPE_PTR 0
+#define IEEE1394_ARGTYPE_MBUF 1
#endif /* _DEV_IEEE1394_IEEE1394VAR_H_ */
diff --git a/sys/dev/std/ieee1212.c b/sys/dev/std/ieee1212.c
index 55838c565f6..b0872ce1fc4 100644
--- a/sys/dev/std/ieee1212.c
+++ b/sys/dev/std/ieee1212.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee1212.c,v 1.2 2002/06/26 13:50:56 tdeval Exp $ */
+/* $OpenBSD: ieee1212.c,v 1.3 2002/12/13 02:52:11 tdeval Exp $ */
/* $NetBSD: ieee1212.c,v 1.3 2002/05/23 00:10:46 jmc Exp $ */
/*
@@ -45,9 +45,11 @@
#include <dev/std/ieee1212reg.h>
#include <dev/std/ieee1212var.h>
+#include <dev/std/sbp2reg.h>
+#include <dev/std/sbp2var.h>
-static const char * const p1212_keytype_strings[] = P1212_KEYTYPE_STRINGS ;
-static const char * const p1212_keyvalue_strings[] = P1212_KEYVALUE_STRINGS ;
+static const char * const p1212_keytype_strings[] = P1212_KEYTYPE_STRINGS;
+static const char * const p1212_keyvalue_strings[] = P1212_KEYVALUE_STRINGS;
u_int16_t p1212_calc_crc(u_int32_t, u_int32_t *, int, int);
int p1212_parse_directory(struct p1212_dir *, u_int32_t *, u_int32_t);
@@ -60,14 +62,27 @@ int p1212_validate_immed(u_int16_t, u_int32_t);
int p1212_validate_leaf(u_int16_t, u_int32_t);
int p1212_validate_dir(u_int16_t, u_int32_t);
-#ifdef P1212_DEBUG
-#define DPRINTF(x) if (p1212debug) printf x
-#define DPRINTFN(n,x) if (p1212debug>(n)) printf x
-int p1212debug = 1;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
+#ifdef P1212_DEBUG
+#include <sys/syslog.h>
+extern int log_open;
+int p1212_oldlog;
+#define DPRINTF(x) if (p1212debug) do { \
+ p1212_oldlog = log_open; log_open = 1; \
+ addlog x; log_open = p1212_oldlog; \
+} while (0)
+#define DPRINTFN(n,x) if (p1212debug>(n)) do { \
+ p1212_oldlog = log_open; log_open = 1; \
+ addlog x; log_open = p1212_oldlog; \
+} while (0)
+#define MPRINTF(x,y) DPRINTF(("%s[%d]: %s 0x%08x\n", \
+ __func__, __LINE__, (x), (u_int32_t)(y)))
+
+int p1212debug = 0;
+#else /* P1212_DEBUG */
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#define MPRINTF(x,y)
+#endif /* ! P1212_DEBUG */
/*
* Routines to parse the ROM into a tree that's usable. Also verify integrity
@@ -89,12 +104,12 @@ int p1212debug = 1;
int
p1212_iscomplete(u_int32_t *t, u_int32_t *size)
{
- u_int16_t infolen, crclen, len;
+ u_int16_t infolen, crclen, len;
u_int32_t newlen, offset, test;
int complete, i, numdirs, type, val, *dirs;
-#ifdef __OpenBSD__
+#ifdef __OpenBSD__
int *p;
-#endif
+#endif /* __OpenBSD__ */
dirs = NULL;
@@ -115,12 +130,12 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
"Info len: %d\n", crclen, infolen));
return -1;
}
-
+
/*
* Now loop through it to check if all the offsets referenced are
* within the image stored so far. If not, get those as well.
*/
-
+
offset = P1212_ROMFMT_GET_INFOLEN((ntohl(t[0]))) + 1;
/*
@@ -130,7 +145,7 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
* then add another since infolen doesn't end on the root dir entry but
* right before it.
*/
-
+
if ((*size == 1) || (*size < (offset + 1))) {
*size = (crclen > infolen) ? crclen : infolen;
if (crclen == infolen)
@@ -142,9 +157,9 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
complete = 0;
numdirs = 0;
newlen = 0;
-
+
while (!complete) {
-
+
/*
* Make sure the whole directory is in memory. If not, bail now
* and read it in.
@@ -155,7 +170,7 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
newlen += offset + 1;
break;
}
-
+
if (newlen == 0) {
DPRINTF(("Impossible directory length of 0!\n"));
return -1;
@@ -179,20 +194,20 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
case P1212_KEYTYPE_Offset:
break;
case P1212_KEYTYPE_Leaf:
-
+
/*
* If a leaf is found, and it's beyond the
* current rom length and it's beyond the
* current newlen setting,
* then set newlen accordingly.
*/
-
+
test = offset + i + val + 1;
if ((test > *size) && (test > newlen)) {
newlen = test;
break;
}
-
+
/*
* For leaf nodes just make sure the whole leaf
* length is in the buffer. There's no data
@@ -202,7 +217,7 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
*/
test--;
- infolen =
+ infolen =
P1212_DIRENT_GET_LEN((ntohl(t[test])));
test++;
test += infolen;
@@ -210,40 +225,43 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
newlen = test;
}
break;
-
+
case P1212_KEYTYPE_Directory:
-
+
/* Make sure the first quad is in memory. */
-
+
test = offset + i + val + 1;
if ((test > *size) && (test > newlen)) {
newlen = test;
break;
}
-
+
/*
- * Can't just walk the ROM looking at type
- * codes since these are only valid on
+ * Can't just walk the ROM looking at type
+ * codes since these are only valid on
* directory entries. So save any directories
* we find into a queue and the bottom of the
- * while loop will pop the last one off and
+ * while loop will pop the last one off and
* walk that directory.
*/
-
+
test--;
#ifdef __NetBSD__
dirs = realloc(dirs,
sizeof(int) * (numdirs + 1), M_DEVBUF,
M_WAITOK);
-#else
+#else /* __NetBSD__ */
p = malloc(sizeof(int) * (numdirs + 1),
M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", p);
if (dirs != NULL) {
bcopy(dirs, p, sizeof(int) * numdirs);
free(dirs, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", dirs);
+ dirs = NULL; /* XXX */
}
dirs = p;
-#endif
+#endif /* ! __NetBSD__ */
dirs[numdirs++] = test;
break;
default:
@@ -252,11 +270,14 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
break;
}
}
-
+
if (newlen) {
/* Cleanup. */
- if (dirs)
+ if (dirs) {
free(dirs, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", dirs);
+ dirs = NULL; /* XXX */
+ }
break;
}
if (dirs != NULL) {
@@ -265,36 +286,39 @@ p1212_iscomplete(u_int32_t *t, u_int32_t *size)
#ifdef __NetBSD__
dirs = realloc(dirs, sizeof(int) * numdirs,
M_DEVBUF, M_WAITOK);
-#else
+#else /* __NetBSD__ */
p = malloc(sizeof(int) * numdirs,
M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", p);
bcopy(dirs, p, sizeof(int) * numdirs);
free(dirs, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", dirs);
dirs = p;
-#endif
+#endif /* ! __NetBSD__ */
} else {
free(dirs, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", dirs);
dirs = NULL;
}
} else
complete = 1;
}
-
+
if (newlen)
*size = newlen;
return 0;
-
+
}
struct p1212_rom *
p1212_parse(u_int32_t *t, u_int32_t size, u_int32_t mask)
{
- u_int16_t crc, romcrc, crc1;
+ u_int16_t crc, romcrc, crc1, crc2;
u_int32_t next, check;
struct p1212_rom *rom;
int i;
-
+
check = size;
if (p1212_iscomplete(t, &check) == -1) {
@@ -307,45 +331,53 @@ p1212_parse(u_int32_t *t, u_int32_t size, u_int32_t mask)
}
/* Calculate both a good and known bad crc. */
-
+
/* CRC's are calculated from everything except the first quad. */
-
- crc = p1212_calc_crc(0, &t[1], P1212_ROMFMT_GET_CRCLEN((ntohl(t[0]))),
+
+ crc = p1212_calc_crc(0, &t[1], P1212_ROMFMT_GET_CRCLEN((ntohl(t[0]))),
0);
-
+
romcrc = P1212_ROMFMT_GET_CRC((ntohl(t[0])));
if (crc != romcrc) {
crc1 = p1212_calc_crc(0, &t[1],
P1212_ROMFMT_GET_CRCLEN((ntohl(t[0]))), 1);
- if (crc1 != romcrc) {
+ crc2 = p1212_calc_crc(0, &t[1],
+ P1212_ROMFMT_GET_CRCLEN((ntohl(t[0]))), 2);
+ if ((crc1 != romcrc) && (crc2 != romcrc)) {
DPRINTF(("Invalid ROM: CRC: 0x%04hx, Calculated "
- "CRC: 0x%04hx, CRC1: 0x%04hx\n",
+ "CRC: 0x%04hx, CRC1: 0x%04hx, CRC2: 0x%04hx\n",
(unsigned short)romcrc, (unsigned short)crc,
- (unsigned short)crc1));
+ (unsigned short)crc1, (unsigned short)crc2));
return NULL;
}
}
+ if (romcrc == crc2)
+ DPRINTF(("%s: warning byte-swapping rom problems\n", __func__));
/* Now, walk the ROM. */
-
+
/* Get the initial offset for the root dir. */
-
- rom = malloc(sizeof(struct p1212_rom), M_DEVBUF, M_WAITOK);
+
+ MALLOC(rom, struct p1212_rom *, sizeof(*rom), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", rom);
rom->len = P1212_ROMFMT_GET_INFOLEN((ntohl(t[0])));
next = rom->len + 1;
if ((rom->len < 1) || (rom->len > size)) {
DPRINTF(("Invalid ROM info length: %d\n", rom->len));
- free(rom, M_DEVBUF);
+ FREE(rom, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", rom);
+ rom = NULL; /* XXX */
return NULL;
}
-
+
/* Exclude the quad which covers the bus name. */
rom->len--;
if (rom->len) {
rom->data = malloc(sizeof(u_int32_t) * rom->len, M_DEVBUF,
M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", rom->data);
/* Add 2 to account for info/crc and bus name skipped. */
for (i = 0; i < rom->len; i++)
rom->data[i] = t[i + 2];
@@ -354,25 +386,29 @@ p1212_parse(u_int32_t *t, u_int32_t size, u_int32_t mask)
/* The name field is always 4 bytes and always the 2nd field. */
strncpy(rom->name, (char *)&t[1], 4);
rom->name[4] = 0;
-
+
/*
* Fill out the root directory. All these values are hardcoded so the
* parse/print/match routines have a standard layout to work against.
*/
-
-#ifdef M_ZERO
- rom->root = malloc(sizeof(*rom->root), M_DEVBUF, M_WAITOK|M_ZERO);
-#else
- rom->root = malloc(sizeof(*rom->root), M_DEVBUF, M_WAITOK);
+
+#ifdef M_ZERO
+ MALLOC(rom->root, struct p1212_dir *, sizeof(*rom->root),
+ M_DEVBUF, M_WAITOK|M_ZERO);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", rom->root);
+#else /* M_ZERO */
+ MALLOC(rom->root, struct p1212_dir *, sizeof(*rom->root),
+ M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", rom->root);
bzero(rom->root, sizeof(*rom->root));
-#endif
+#endif /* ! M_ZERO */
rom->root->com.key.key_type = P1212_KEYTYPE_Directory;
rom->root->com.key.key_value = 0;
rom->root->com.key.key = (u_int8_t)P1212_KEYTYPE_Directory;
rom->root->com.key.val = 0;
TAILQ_INIT(&rom->root->data_root);
TAILQ_INIT(&rom->root->subdir_root);
-
+
if (p1212_parse_directory(rom->root, &t[next], mask)) {
DPRINTF(("Parse error in ROM. Bailing\n"));
p1212_free(rom);
@@ -388,17 +424,18 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
struct p1212_data *data;
struct p1212_com *com;
u_int32_t *t, desc;
- u_int16_t crclen, crc, crc1, romcrc;
+ u_int16_t crclen, crc, crc1, crc2, romcrc;
u_int8_t type, val;
unsigned long size;
int i, module_vendor_flag, module_sw_flag, node_sw_flag, unit_sw_flag;
int node_capabilities_flag, offset, unit_location_flag, unitdir_cnt;
int leafoff;
int textcnt;
+ int draft;
#ifdef __OpenBSD__
struct p1212_textdata **p;
-#endif
-
+#endif /* __OpenBSD__ */
+
t = addr;
dir = root;
@@ -409,30 +446,39 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
unitdir_cnt = 0;
offset = 0;
textcnt = 0;
+ draft = 0;
- while (dir) {
+ while (dir) {
dir->match = 0;
crclen = P1212_DIRENT_GET_LEN((ntohl(t[offset])));
romcrc = P1212_DIRENT_GET_CRC((ntohl(t[offset])));
-
+
crc = p1212_calc_crc(0, &t[offset + 1], crclen, 0);
if (crc != romcrc) {
crc1 = p1212_calc_crc(0, &t[offset + 1], crclen, 1);
- if (crc1 != romcrc) {
+ crc2 = p1212_calc_crc(0, &t[offset + 1], crclen, 2);
+ if ((crc1 != romcrc) && (crc2 != romcrc)) {
DPRINTF(("Invalid ROM: CRC: 0x%04hx, "
"Calculated CRC: "
- "0x%04hx, CRC1: 0x%04hx\n",
+ "0x%04hx, CRC1: 0x%04hx",
+ ", CRC2: 0x%04hx\n",
(unsigned short)romcrc,
(unsigned short)crc,
- (unsigned short)crc1));
+ (unsigned short)crc1,
+ (unsigned short)crc2));
return 1;
}
}
+ if (romcrc == crc2) {
+ draft = 1;
+ DPRINTF(("%s: warning byte-swapping rom problems"
+ " (off: 0x%04hx)\n", __func__, (u_int16_t)offset));
+ }
com = NULL;
unit_sw_flag = 0;
unit_location_flag = 0;
offset++;
-
+
if ((dir->parent == NULL) && dir->com.key.val) {
DPRINTF(("Invalid root dir. key.val is 0x%0x and not"
" 0x0\n", dir->com.key.val));
@@ -443,7 +489,7 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
desc = ntohl(t[i]);
type = P1212_DIRENT_GET_KEYTYPE(desc);
val = P1212_DIRENT_GET_KEYVALUE(desc);
-
+
/*
* Sanity check for valid types/locations/etc.
*
@@ -451,7 +497,7 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
* ISO/IEC 13213:1194(ANSI/IEEE Std 1212, 1994 edition)
* for specifics.
*
- * XXX: These all really should be broken out into
+ * XXX: These all really should be broken out into
* subroutines as it's grown large and complicated
* in certain cases.
*/
@@ -479,7 +525,7 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
}
break;
}
-
+
switch (type) {
case P1212_KEYTYPE_Immediate:
if (p1212_validate_immed(val, mask)) {
@@ -492,9 +538,11 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
}
break;
case P1212_KEYTYPE_Offset:
+ if (draft && val == 0)
+ break;
if (p1212_validate_offset(val, mask)) {
DPRINTF(("Invalid ROM: Can't have "
- "an offset type with key %s."
+ "an offset type with key %s."
" Used at location 0x%0x in ROM\n",
p1212_keyvalue_strings[val],
(unsigned int)(&t[i]-&addr[0])));
@@ -526,7 +574,7 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
(unsigned short)type);
break;
}
-
+
/* Note flags for required fields. */
if (val == P1212_KEYVALUE_Module_Vendor_Id) {
@@ -536,13 +584,13 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
if (val == P1212_KEYVALUE_Node_Capabilities) {
node_capabilities_flag = 1;
}
-
+
if (val == P1212_KEYVALUE_Unit_Sw_Version)
unit_sw_flag = 1;
if (val == P1212_KEYVALUE_Unit_Location)
unit_location_flag = 1;
-
+
/*
* This is just easier to spell out. You can't have
* a module sw version if you include a node sw version
@@ -553,11 +601,11 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
if (val == P1212_KEYVALUE_Module_Sw_Version) {
if (node_sw_flag) {
DPRINTF(("Can't have a module software"
- " version along with a node "
+ " version along with a node "
"software version entry\n"));
return 1;
}
- if (unitdir_cnt) {
+ if (!draft && unitdir_cnt) {
DPRINTF(("Can't have unit directories "
"with module software version "
"defined.\n"));
@@ -569,11 +617,11 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
if (val == P1212_KEYVALUE_Node_Sw_Version) {
if (module_sw_flag) {
DPRINTF(("Can't have a node software "
- "version along with a module "
+ "version along with a module "
"software version entry\n"));
return 1;
}
- if (unitdir_cnt) {
+ if (!draft && unitdir_cnt) {
DPRINTF(("Can't have unit directories "
"with node software version "
"defined.\n"));
@@ -581,9 +629,10 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
}
node_sw_flag = 1;
}
-
+
if (val == P1212_KEYVALUE_Unit_Directory) {
- if (module_sw_flag || node_sw_flag) {
+ if (!draft &&
+ (module_sw_flag || node_sw_flag)) {
DPRINTF(("Can't have unit directories "
"with either module or node "
"software version defined.\n"));
@@ -591,7 +640,7 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
}
unitdir_cnt++;
}
-
+
/*
* Text descriptors are special. They describe the
* last entry they follow. So they need to be included
@@ -599,14 +648,14 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
* preventing one from putting text descriptors after
* directory descriptors. Also they can be a single
* value or a list of them in a directory format so
- * account for either. Finally if they're in a
- * directory those can be the only types in a
+ * account for either. Finally if they're in a
+ * directory those can be the only types in a
* directory.
*/
if (val == P1212_KEYVALUE_Textual_Descriptor) {
- size = sizeof(struct p1212_textdata *);
+ size = sizeof(*p);
leafoff = P1212_DIRENT_GET_VALUE(desc);
leafoff += i;
@@ -629,16 +678,19 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
com->text = realloc(com->text,
size * (com->textcnt + 1),
M_DEVBUF, M_WAITOK);
-#else
+#else /* __NetBSD__ */
p = malloc(size * (com->textcnt + 1),
M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", p);
if (com->text != NULL) {
bcopy(com->text, p,
size * com->textcnt);
free(com->text, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", com->text);
+ com->text = NULL; /* XXX */
}
com->text = p;
-#endif
+#endif /* ! __NetBSD__ */
com->text[com->textcnt] =
p1212_parse_text_desc(&t[leafoff]);
if (com->text[com->textcnt] == NULL) {
@@ -647,11 +699,13 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
"offset 0x%0x\n",
&t[leafoff]-&addr[0]));
free(com->text, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", com->text);
+ com->text = NULL; /* XXX */
return 1;
}
com->textcnt++;
} else {
- i = p1212_parse_textdir(com,
+ i = p1212_parse_textdir(com,
&t[leafoff]);
if (i)
return 1;
@@ -662,14 +716,16 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
if ((type != P1212_KEYTYPE_Directory) &&
(val != P1212_KEYVALUE_Textual_Descriptor)) {
-#ifdef M_ZERO
- data = malloc(sizeof(struct p1212_data),
+#ifdef M_ZERO
+ MALLOC(data, struct p1212_data *, sizeof(*data),
M_DEVBUF, M_WAITOK|M_ZERO);
-#else
- data = malloc(sizeof(struct p1212_data),
+ //MPRINTF_OLD("MALLOC(DEVBUF)", data);
+#else /* M_ZERO */
+ MALLOC(data, struct p1212_data *, sizeof(*data),
M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", data);
bzero(data, sizeof(struct p1212_data));
-#endif
+#endif /* ! M_ZERO */
data->com.key.key_type = type;
data->com.key.key_value = val;
data->com.key.key =
@@ -678,7 +734,7 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
P1212_DIRENT_GET_VALUE((ntohl(t[i])));
com = &data->com;
- /*
+ /*
* Don't try and read the offset. It may be
* a register or something special. Generally
* these are node specific so let the upper
@@ -686,12 +742,12 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
*/
if ((type == P1212_KEYTYPE_Immediate) ||
- (type == P1212_KEYTYPE_Offset))
+ (type == P1212_KEYTYPE_Offset))
data->val = data->com.key.val;
-
+
data->leafdata = NULL;
TAILQ_INSERT_TAIL(&dir->data_root, data, data);
-
+
if (type == P1212_KEYTYPE_Leaf) {
leafoff = i + data->com.key.val;
data->leafdata =
@@ -701,17 +757,19 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
return 1;
}
}
- }
+ }
if (type == P1212_KEYTYPE_Directory) {
-
-#ifdef M_ZERO
- sdir = malloc(sizeof(struct p1212_dir),
+
+#ifdef M_ZERO
+ MALLOC(sdir, struct p1212_dir *, sizeof(*sdir),
M_DEVBUF, M_WAITOK|M_ZERO);
-#else
- sdir = malloc(sizeof(struct p1212_dir),
+ //MPRINTF_OLD("MALLOC(DEVBUF)", sdir);
+#else /* M_ZERO */
+ MALLOC(sdir, struct p1212_dir *, sizeof(*sdir),
M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", sdir);
bzero(sdir, sizeof(struct p1212_dir));
-#endif
+#endif /* ! M_ZERO */
sdir->parent = dir;
sdir->com.key.key_type = type;
sdir->com.key.key_value = val;
@@ -735,11 +793,13 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
"directory.\n"));
return 1;
}
+#if 0 /* XXX : Not Mandatory */
if (node_capabilities_flag == 0) {
DPRINTF(("Missing node capabilities entry in "
"root directory.\n"));
return 1;
}
+#endif
} else {
if ((unitdir_cnt > 1) && (unit_location_flag == 0)) {
DPRINTF(("Must have a unit location in each "
@@ -780,7 +840,7 @@ p1212_parse_directory(struct p1212_dir *root, u_int32_t *addr, u_int32_t mask)
struct p1212_leafdata *
p1212_parse_leaf(u_int32_t *t)
{
- u_int16_t crclen, crc, crc1, romcrc;
+ u_int16_t crclen, crc, crc1, crc2, romcrc;
struct p1212_leafdata *leafdata;
int i;
@@ -788,22 +848,29 @@ p1212_parse_leaf(u_int32_t *t)
romcrc = P1212_DIRENT_GET_CRC((ntohl(t[0])));
crc = p1212_calc_crc(0, &t[1], crclen, 0);
crc1 = p1212_calc_crc(0,&t[1], crclen, 1);
- if ((crc != romcrc) && (crc1 != romcrc)) {
+ crc2 = p1212_calc_crc(0,&t[1], crclen, 2);
+ if ((crc != romcrc) && (crc1 != romcrc) && (crc2 != romcrc)) {
DPRINTF(("Invalid ROM: CRC: 0x%04hx, Calculated CRC: "
- "0x%04hx, CRC1: 0x%04hx\n", (unsigned short)romcrc,
- (unsigned short)crc, (unsigned short)crc1));
+ "0x%04hx, CRC1: 0x%04hx, CRC2: 0x%04hx\n",
+ (unsigned short)romcrc, (unsigned short)crc,
+ (unsigned short)crc1, (unsigned short)crc2));
return NULL;
}
+ if (romcrc == crc2)
+ DPRINTF(("%s: warning byte-swapping rom problems\n", __func__));
t++;
-
+
/*
* Most of these are vendor specific so don't bother trying to map them
* out. Anything which needs them later on can extract them.
*/
- leafdata = malloc(sizeof(struct p1212_leafdata), M_DEVBUF, M_WAITOK);
+ MALLOC(leafdata, struct p1212_leafdata *, sizeof(*leafdata),
+ M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", leafdata);
leafdata->data = malloc((sizeof(u_int32_t) * crclen), M_DEVBUF,
M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", leafdata->data);
leafdata->len = crclen;
for (i = 0; i < crclen; i++)
leafdata->data[i] = ntohl(t[i]);
@@ -814,11 +881,11 @@ int
p1212_parse_textdir(struct p1212_com *com, u_int32_t *addr)
{
u_int32_t *t, entry, new;
- u_int16_t crclen, crc, crc1, romcrc;
+ u_int16_t crclen, crc, crc1, crc2, romcrc;
u_int8_t type, val;
-#ifdef __OpenBSD__
+#ifdef __OpenBSD__
struct p1212_textdata **p;
-#endif
+#endif /* __OpenBSD__ */
int i, size;
@@ -826,24 +893,28 @@ p1212_parse_textdir(struct p1212_com *com, u_int32_t *addr)
* A bit more complicated. A directory for a text descriptor can
* contain text descriptor leaf nodes only.
*/
-
+
com->text = NULL;
- size = sizeof(struct p1212_text *);
-
+ size = sizeof(*p);
+
crclen = P1212_DIRENT_GET_LEN((ntohl(t[0])));
romcrc = P1212_DIRENT_GET_CRC((ntohl(t[0])));
crc = p1212_calc_crc(0, &t[1], crclen, 0);
crc1 = p1212_calc_crc(0,&t[1], crclen, 1);
- if ((crc != romcrc) && (crc1 != romcrc)) {
+ crc2 = p1212_calc_crc(0,&t[1], crclen, 2);
+ if ((crc != romcrc) && (crc1 != romcrc) && (crc2 != romcrc)) {
DPRINTF(("Invalid ROM: CRC: 0x%04hx, Calculated CRC: "
- "0x%04hx, CRC1: 0x%04hx\n", (unsigned short)romcrc,
- (unsigned short)crc, (unsigned short)crc1));
+ "0x%04hx, CRC1: 0x%04hx, CRC2: 0x%04hx\n",
+ (unsigned short)romcrc, (unsigned short)crc,
+ (unsigned short)crc1, (unsigned short)crc2));
return 1;
}
+ if (romcrc == crc2)
+ DPRINTF(("%s: warning byte-swapping rom problems\n", __func__));
t++;
for (i = 0; i < crclen; i++) {
entry = ntohl(t[i]);
-
+
type = P1212_DIRENT_GET_KEYTYPE(entry);
val = P1212_DIRENT_GET_KEYVALUE(entry);
if ((type != P1212_KEYTYPE_Leaf) ||
@@ -857,22 +928,28 @@ p1212_parse_textdir(struct p1212_com *com, u_int32_t *addr)
}
new = P1212_DIRENT_GET_VALUE(entry);
-#ifdef __NetBSD__
+#ifdef __NetBSD__
com->text = realloc(com->text, size * (com->textcnt + 1),
M_DEVBUF, M_WAITOK);
-#else
+#else /* __NetBSD__ */
p = malloc(size * (com->textcnt + 1), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", p);
bzero(&p[com->textcnt], size);
if (com->text != NULL) {
bcopy(com->text, p, size * (com->textcnt));
free(com->text, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", com->text);
+ com->text = NULL; /* XXX */
}
com->text = p;
-#endif
+#endif /* ! __NetBSD__ */
if ((com->text[i] = p1212_parse_text_desc(&t[i+new])) == NULL) {
DPRINTF(("Got an error parsing text descriptor.\n"));
- if (com->textcnt == 0)
+ if (com->textcnt == 0) {
free(com->text, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", com->text);
+ com->text = NULL; /* XXX */
+ }
return 1;
}
com->textcnt++;
@@ -884,15 +961,15 @@ struct p1212_textdata *
p1212_parse_text_desc(u_int32_t *addr)
{
u_int32_t *t;
- u_int16_t crclen, crc, crc1, romcrc;
+ u_int16_t crclen, crc, crc1, crc2, romcrc;
struct p1212_textdata *text;
int size;
-
+
t = addr;
-
+
crclen = P1212_DIRENT_GET_LEN((ntohl(t[0])));
romcrc = P1212_DIRENT_GET_CRC((ntohl(t[0])));
-
+
if (crclen < P1212_TEXT_Min_Leaf_Length) {
DPRINTF(("Invalid ROM: text descriptor too short\n"));
return NULL;
@@ -901,16 +978,22 @@ p1212_parse_text_desc(u_int32_t *addr)
crc = p1212_calc_crc(0, &t[1], crclen, 0);
if (crc != romcrc) {
crc1 = p1212_calc_crc(0, &t[1], crclen, 1);
- if (crc1 != romcrc) {
+ crc2 = p1212_calc_crc(0, &t[1], crclen, 2);
+ if ((crc1 != romcrc) && (crc2 != romcrc)) {
DPRINTF(("Invalid ROM: CRC: 0x%04hx, Calculated CRC: "
- "0x%04hx, CRC1: 0x%04hx\n", (unsigned short)romcrc,
- (unsigned short)crc, (unsigned short)crc1));
+ "0x%04hx, CRC1: 0x%04hx, CRC1: 0x%04hx\n",
+ (unsigned short)romcrc, (unsigned short)crc,
+ (unsigned short)crc1, (unsigned short)crc2));
return NULL;
}
}
+ if (romcrc == crc2)
+ DPRINTF(("%s: warning byte-swapping rom problems\n", __func__));
t++;
- text = malloc(sizeof(struct p1212_textdata), M_DEVBUF, M_WAITOK);
+ MALLOC(text, struct p1212_textdata *, sizeof(*text), M_DEVBUF,
+ M_WAITOK);
+ //MPRINTF_OLD("MALLOC(DEVBUF)", text);
text->spec_type = P1212_TEXT_GET_Spec_Type((ntohl(t[0])));
text->spec_id = P1212_TEXT_GET_Spec_Id((ntohl(t[0])));
text->lang_id = ntohl(t[1]);
@@ -920,14 +1003,16 @@ p1212_parse_text_desc(u_int32_t *addr)
crclen -= 2;
size = (crclen * sizeof(u_int32_t));
-#ifdef M_ZERO
+#ifdef M_ZERO
text->text = malloc(size + 1, M_DEVBUF, M_WAITOK|M_ZERO);
-#else
+ //MPRINTF_OLD("malloc(DEVBUF)", text->text);
+#else /* M_ZERO */
text->text = malloc(size + 1, M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", text->text);
bzero(text->text, size + 1);
-#endif
+#endif /* ! M_ZERO */
- memcpy(text->text, &t[0], size);
+ bcopy(&t[0], text->text, size);
return text;
}
@@ -939,33 +1024,27 @@ p1212_find(struct p1212_dir *root, int type, int value, int flags)
struct p1212_dir *dir, *sdir, *parent;
struct p1212_data *data;
int numkeys;
-#ifdef __OpenBSD__
+#ifdef __OpenBSD__
struct p1212_key **p;
-#endif
+#endif /* __OpenBSD__ */
numkeys = 0;
retkeys = NULL;
-
+
if ((type < P1212_KEYTYPE_Immediate) ||
(type > P1212_KEYTYPE_Directory)) {
-#ifdef DIAGNOSTIC
- printf("p1212_find: invalid type - %d\n", type);
-#endif
+ DPRINTF(("p1212_find: invalid type - %d\n", type));
return NULL;
}
if ((value < -1) ||
(value > (sizeof(p1212_keyvalue_strings) / sizeof(char *)))) {
-#ifdef DIAGNOSTIC
- printf("p1212_find: invalid value - %d\n", value);
-#endif
+ DPRINTF(("p1212_find: invalid value - %d\n", value));
return NULL;
}
-
+
if (flags & ~(P1212_FIND_SEARCHALL | P1212_FIND_RETURNALL)) {
-#ifdef DIAGNOSTIC
- printf("p1212_find: invalid flags - %d\n", flags);
-#endif
+ DPRINTF(("p1212_find: invalid flags - %d\n", flags));
return NULL;
}
@@ -974,7 +1053,7 @@ p1212_find(struct p1212_dir *root, int type, int value, int flags)
* without using recursion. Using the walk API would have made things
* more complicated in trying to build up the return struct otherwise.
*/
-
+
dir = root;
sdir = NULL;
@@ -991,16 +1070,19 @@ p1212_find(struct p1212_dir *root, int type, int value, int flags)
retkeys = realloc(retkeys,
sizeof(struct p1212_key *) *
(numkeys + 1), M_DEVBUF, M_WAITOK);
-#else
+#else /* __NetBSD__ */
p = malloc(sizeof(struct p1212_key *) *
(numkeys + 1), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", p);
if (retkeys != NULL) {
bcopy(retkeys, p, numkeys *
sizeof(struct p1212_key *));
free(retkeys, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", retkeys);
+ retkeys = NULL; /* XXX */
}
retkeys = p;
-#endif
+#endif /* ! __NetBSD__ */
retkeys[numkeys - 1] = &sdir->com.key;
retkeys[numkeys] = NULL;
if ((flags & P1212_FIND_RETURNALL)
@@ -1021,16 +1103,19 @@ p1212_find(struct p1212_dir *root, int type, int value, int flags)
retkeys = realloc(retkeys,
sizeof(struct p1212_key *) *
(numkeys + 1), M_DEVBUF, M_WAITOK);
-#else
+#else /* __NetBSD__ */
p = malloc(sizeof(struct p1212_key *) *
(numkeys + 1), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", p);
if (retkeys != NULL) {
bcopy(retkeys, p, numkeys *
sizeof(struct p1212_key *));
free(retkeys, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", retkeys);
+ retkeys = NULL; /* XXX */
}
retkeys = p;
-#endif
+#endif /* ! __NetBSD__ */
retkeys[numkeys - 1] = &data->com.key;
retkeys[numkeys] = NULL;
if ((flags & P1212_FIND_RETURNALL)
@@ -1056,7 +1141,7 @@ p1212_find(struct p1212_dir *root, int type, int value, int flags)
return retkeys;
}
-void
+void
p1212_walk(struct p1212_dir *root, void *arg,
void (*func)(struct p1212_key *, void *))
{
@@ -1067,22 +1152,18 @@ p1212_walk(struct p1212_dir *root, void *arg,
sdir = NULL;
if (func == NULL) {
-#ifdef DIAGNOSTIC
- printf("p1212_walk: Passed in NULL function\n");
-#endif
+ DPRINTF(("p1212_walk: Passed in NULL function\n"));
return;
}
if (root == NULL) {
-#ifdef DIAGNOSTIC
- printf("p1212_walk: Called with NULL root\n");
-#endif
+ DPRINTF(("p1212_walk: Called with NULL root\n"));
return;
}
-
+
/* Allow walking from any point. Just mark the starting point. */
parent = root->parent;
root->parent = NULL;
-
+
/*
* Depth first traversal that doesn't use recursion.
*
@@ -1095,7 +1176,7 @@ p1212_walk(struct p1212_dir *root, void *arg,
while (dir) {
func((struct p1212_key *) dir, arg);
- TAILQ_FOREACH(data, &dir->data_root, data)
+ TAILQ_FOREACH(data, &dir->data_root, data)
func((struct p1212_key *) data, arg);
if (!TAILQ_EMPTY(&dir->subdir_root)) {
sdir = TAILQ_FIRST(&dir->subdir_root);
@@ -1108,7 +1189,7 @@ p1212_walk(struct p1212_dir *root, void *arg,
} while ((sdir == NULL) && dir);
}
dir = sdir;
- }
+ }
root->parent = parent;
}
@@ -1117,17 +1198,17 @@ void
p1212_print(struct p1212_dir *dir)
{
int indent;
-
+
indent = 0;
-
+
p1212_walk(dir, &indent, p1212_print_node);
printf("\n");
}
-
+
void
p1212_print_node(struct p1212_key *key, void *arg)
{
-
+
struct p1212_data *data;
struct p1212_dir *sdir, *dir;
int i, j, *indent;
@@ -1158,14 +1239,14 @@ p1212_print_node(struct p1212_key *key, void *arg)
/* Set the indent string up. 4 spaces per level. */
for (i = 0; i < (*indent * 4); i++)
printf(" ");
-
+
if (dir) {
printf("Directory: ");
if (dir->print)
dir->print(dir);
else {
if (key->key_value >=
- (sizeof(p1212_keyvalue_strings) / sizeof(char *)))
+ (sizeof(p1212_keyvalue_strings) / sizeof(char *)))
printf("Unknown type 0x%04hx\n",
(unsigned short)key->key_value);
else
@@ -1186,7 +1267,7 @@ p1212_print_node(struct p1212_key *key, void *arg)
data->print(data);
else {
if (key->key_value >=
- (sizeof(p1212_keyvalue_strings) / sizeof(char *)))
+ (sizeof(p1212_keyvalue_strings) / sizeof(char *)))
printf("Unknown type 0x%04hx: ",
(unsigned short)key->key_value);
else
@@ -1194,12 +1275,12 @@ p1212_print_node(struct p1212_key *key, void *arg)
p1212_keyvalue_strings[key->key_value]);
printf("0x%08x\n", key->val);
-#ifdef DIAGNOSTIC
+#ifdef DIAGNOSTIC
if ((data->com.key.key_type == P1212_KEYTYPE_Leaf) &&
- (data->leafdata == NULL))
+ (data->leafdata == NULL))
panic("Invalid data node in configrom tree");
-#endif
-
+#endif /* DIAGNOSTIC */
+
if (data->leafdata) {
for (i = 0; i < data->leafdata->len; i++) {
for (j = 0; j < (*indent * 4); j++)
@@ -1208,14 +1289,14 @@ p1212_print_node(struct p1212_key *key, void *arg)
data->leafdata->data[i]);
}
}
- if (data->com.textcnt)
+ if (data->com.textcnt)
for (i = 0; i < data->com.textcnt; i++) {
for (j = 0; j < (*indent * 4); j++)
printf(" ");
printf("Text descriptor: %s\n",
data->com.text[i]->text);
}
-
+
}
}
}
@@ -1229,7 +1310,7 @@ p1212_free(struct p1212_rom *rom)
int i;
dir = rom->root;
-
+
/* Avoid recursing. Find the bottom most node and work back. */
while (dir) {
if (!TAILQ_EMPTY(&dir->subdir_root)) {
@@ -1247,36 +1328,63 @@ p1212_free(struct p1212_rom *rom)
TAILQ_REMOVE(&dir->parent->subdir_root, dir,
dir);
}
-
+
while ((data = TAILQ_FIRST(&dir->data_root))) {
if (data->leafdata) {
- if (data->leafdata->data)
+ if (data->leafdata->data) {
free(data->leafdata->data, M_DEVBUF);
- free(data->leafdata, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", data->leafdata->data);
+ data->leafdata->data = NULL; /* XXX */
+ }
+ FREE(data->leafdata, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", data->leafdata);
+ data->leafdata = NULL; /* XXX */
}
TAILQ_REMOVE(&dir->data_root, data, data);
if (data->com.textcnt) {
- for (i = 0; i < data->com.textcnt; i++)
- free(data->com.text[i], M_DEVBUF);
+ for (i = 0; i < data->com.textcnt; i++) {
+ free(data->com.text[i]->text, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", data->com.text[i]->text);
+ data->com.text[i]->text = NULL; /* XXX */
+ FREE(data->com.text[i], M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", data->com.text[i]);
+ data->com.text[i] = NULL; /* XXX */
+ }
free(data->com.text, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", data->com.text);
+ data->com.text = NULL; /* XXX */
}
- free(data, M_DEVBUF);
+ FREE(data, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", data);
+ data = NULL; /* XXX */
}
sdir = dir;
- if (dir->parent)
+ if (dir->parent)
dir = dir->parent;
else
dir = NULL;
if (sdir->com.textcnt) {
- for (i = 0; i < sdir->com.textcnt; i++)
- free(sdir->com.text[i], M_DEVBUF);
+ for (i = 0; i < sdir->com.textcnt; i++) {
+ FREE(sdir->com.text[i], M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", sdir->com.text[i]);
+ sdir->com.text[i] = NULL; /* XXX */
+ }
free(sdir->com.text, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", sdir->com.text);
+ sdir->com.text = NULL; /* XXX */
}
- free(sdir, M_DEVBUF);
+ FREE(sdir, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", sdir);
+ sdir = NULL; /* XXX */
}
- if (rom->len)
+ if (rom->len) {
free(rom->data, M_DEVBUF);
- free(rom, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", rom->data);
+ rom->data = NULL; /* XXX */
+ }
+ FREE(rom, M_DEVBUF);
+ //MPRINTF_OLD("FREE(DEVBUF)", rom);
+ rom = NULL; /* XXX */
}
/*
@@ -1294,22 +1402,38 @@ p1212_calc_crc(u_int32_t crc, u_int32_t *data, int len, int broke)
int shift;
u_int32_t sum;
int i;
-
+
for (i = 0; i < len; i++) {
for (shift = 28; shift > 0; shift -= 4) {
- sum = ((crc >> 12) ^ (ntohl(data[i]) >> shift)) &
- 0x0000000f;
+ if (broke == 2)
+ sum = ((crc >> 12) ^
+ (letoh32(data[i]) >> shift)) & 0x0000000f;
+ else
+ sum = ((crc >> 12) ^ (ntohl(data[i]) >> shift))
+ & 0x0000000f;
crc = (crc << 4) ^ (sum << 12) ^ (sum << 5) ^ sum;
}
-
-
+
+
/* The broken implementation doesn't do the last shift. */
- if (!broke) {
+ switch (broke) {
+ case 0:
sum = ((crc >> 12) ^ ntohl(data[i])) & 0x0000000f;
crc = (crc << 4) ^ (sum << 12) ^ (sum << 5) ^ sum;
+ break;
+ case 2:
+ sum = ((crc >> 12) ^ letoh32(data[i])) & 0x0000000f;
+ crc = (crc << 4) ^ (sum << 12) ^ (sum << 5) ^ sum;
+ break;
+ default:
+ break;
}
}
- return (u_int16_t)crc;
+
+ if (broke == 2)
+ return swap16((u_int16_t)crc);
+ else
+ return (u_int16_t)crc;
}
/*
@@ -1323,82 +1447,91 @@ p1212_match_units(struct device *sc, struct p1212_dir *dir,
{
struct p1212_dir **udirs;
struct device **devret, *dev;
- int numdev;
-#ifdef __OpenBSD__
+ int numdev, i;
+#ifdef __OpenBSD__
struct device **p;
-#endif
-
+#endif /* __OpenBSD__ */
+
/*
- * Setup typical return val. Always allocate one extra pointer for a
+ * Setup typically return val. Always allocate one extra pointer for a
* NULL guard end pointer.
*/
numdev = 0;
devret = malloc(sizeof(struct device *) * 2, M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", devret);
devret[0] = devret[1] = NULL;
udirs = (struct p1212_dir **)p1212_find(dir, P1212_KEYTYPE_Directory,
- P1212_KEYVALUE_Unit_Directory,
+ P1212_KEYVALUE_Unit_Directory,
P1212_FIND_SEARCHALL|P1212_FIND_RETURNALL);
-
+
if (udirs) {
+ i = 0;
do {
- dev = config_found_sm(sc, udirs, print, NULL);
+ dev = config_found_sm(sc, &udirs[i], print, NULL);
if (dev && numdev) {
#ifdef __NetBSD__
devret = realloc(devret,
sizeof(struct device *) *
(numdev + 2), M_DEVBUF, M_WAITOK);
-#else
+#else /* __NetBSD__ */
p = malloc(sizeof(struct device *) *
(numdev + 2), M_DEVBUF, M_WAITOK);
+ //MPRINTF_OLD("malloc(DEVBUF)", p);
bcopy(devret, p,
numdev * sizeof(struct device *));
free(devret, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", devret);
devret = p;
-#endif
+#endif /* ! __NetBSD__ */
devret[numdev++] = dev;
devret[numdev] = NULL;
} else if (dev) {
devret[0] = dev;
numdev++;
}
- udirs++;
- } while (*udirs);
+ } while (udirs[++i]);
+
+ free(udirs, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", udirs);
+ udirs = NULL; /* XXX */
}
if (numdev == 0) {
free(devret, M_DEVBUF);
+ //MPRINTF_OLD("free(DEVBUF)", devret);
+ devret = NULL; /* XXX */
return NULL;
}
return devret;
}
-/*
+/*
* Make these their own functions as they have slightly complicated rules.
*
* For example:
*
* Under normal circumstances only the 2 extent types can be offset
* types. However some spec's which use p1212 like SBP2 for
- * firewire/1394 will define a dependent info type as an offset value.
- * Allow the upper level code to flag this and pass it down during
+ * firewire/1394 will define a dependent info type as an offset value.
+ * Allow the upper level code to flag this and pass it down during
* parsing. The same thing applies to immediate types.
*/
int
p1212_validate_offset(u_int16_t val, u_int32_t mask)
{
- if ((val == P1212_KEYVALUE_Node_Units_Extent) ||
- (val == P1212_KEYVALUE_Node_Memory_Extent) ||
- ((mask & P1212_ALLOW_DEPENDENT_INFO_OFFSET_TYPE) &&
- ((val == P1212_KEYVALUE_Unit_Dependent_Info) ||
- (val == P1212_KEYVALUE_Node_Dependent_Info) ||
- (val == P1212_KEYVALUE_Module_Dependent_Info))))
- return 0;
- return 1;
+ if ((val == P1212_KEYVALUE_Node_Units_Extent) ||
+ (val == P1212_KEYVALUE_Node_Memory_Extent) ||
+ ((mask & P1212_ALLOW_DEPENDENT_INFO_OFFSET_TYPE) &&
+ ((val == P1212_KEYVALUE_Unit_Dependent_Info) ||
+ (val == P1212_KEYVALUE_Node_Dependent_Info) ||
+ (val == P1212_KEYVALUE_Module_Dependent_Info))))
+ return 0;
+ return 1;
}
-int
+int
p1212_validate_immed(u_int16_t val, u_int32_t mask)
{
switch (val) {
diff --git a/sys/dev/std/ieee1212reg.h b/sys/dev/std/ieee1212reg.h
index c60f22134c3..bf7d920021d 100644
--- a/sys/dev/std/ieee1212reg.h
+++ b/sys/dev/std/ieee1212reg.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: ieee1212reg.h,v 1.1 2002/06/25 17:11:49 itojun Exp $ */
+/* $OpenBSD: ieee1212reg.h,v 1.2 2002/12/13 02:52:11 tdeval Exp $ */
/* $NetBSD: ieee1212reg.h,v 1.7 2002/04/02 10:10:54 jmc Exp $ */
-/*-
+/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -18,8 +18,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@@ -37,12 +37,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_STD_IEEE1212REG_H_
-#define _DEV_STD_IEEE1212REG_H_
+#ifndef _DEV_STD_IEEE1212REG_H_
+#define _DEV_STD_IEEE1212REG_H_
/* This file contains definitions from ISO/IEC 1312 or ANSI/IEEE Std 1212
* Informaton techonology
- * Microprocessor systes
+ * Microprocessor systems
* Control and Status Registers (CSR)
* Architecture for microcomputer buses
* First edition 1994-10-05
@@ -106,7 +106,7 @@
(oui)[0] = ((quadlet) >> 16) & 0xff; \
(oui)[1] = ((quadlet) >> 8) & 0xff; \
(oui)[2] = ((quadlet) >> 0) & 0xff; \
- } while (0)
+ } while (0)
/* size_t P1212_ROMGET_GET_INFOLEN(uint32_t quadlet);
*/
@@ -120,9 +120,9 @@
*/
#define P1212_ROMFMT_GET_CRC(quadlet) ((uint16_t)(quadlet))
-/* uint8_t P1212_DIRENT_GET_KEY(uint32_t quadlet);
+/* uint8_t P1212_DIRENT_GET_KEY(uint32_t quadlet);
*/
-#define P1212_DIRENT_GET_KEY(quadlet) (((quadlet) >> 24) & 0xff)
+#define P1212_DIRENT_GET_KEY(quadlet) (((quadlet) >> 24) & 0xff)
/* unsigned int P1212_DIRENT_GET_KEYTYPE(uint32_t quadlet);
*/
@@ -140,13 +140,13 @@
*/
#define P1212_DIRENT_GET_VALUE(quadlet) ((quadlet) & 0xffffff)
-/* u_int16_t P1212_DIRENT_GET_LEN(quadlet);
+/* u_int16_t P1212_DIRENT_GET_LEN(quadlet);
*/
-#define P1212_DIRENT_GET_LEN(quadlet) (((quadlet) >> 16) & 0xffff)
+#define P1212_DIRENT_GET_LEN(quadlet) (((quadlet) >> 16) & 0xffff)
-/* u_int16_t P1212_DIRENT_GET_CRC(quadlet);
+/* u_int16_t P1212_DIRENT_GET_CRC(quadlet);
*/
-#define P1212_DIRENT_GET_CRC(quadlet) ((uint16_t)(quadlet))
+#define P1212_DIRENT_GET_CRC(quadlet) ((uint16_t)(quadlet))
/* Key Types are stored in bits 31-30 of a directory entry.
*/
@@ -177,7 +177,7 @@
#define P1212_KEYVALUE_Unit_Directory 0x11 /* directory */
#define P1212_KEYVALUE_Unit_Spec_Id 0x12 /* immediate */
#define P1212_KEYVALUE_Unit_Sw_Version 0x13 /* immediate */
-#define P1212_KEYVALUE_Unit_Dependent_Info 0x14 /* leaf | directory */
+#define P1212_KEYVALUE_Unit_Dependent_Info 0x14 /* imm|off|leaf|dir */
#define P1212_KEYVALUE_Unit_Location 0x15 /* leaf */
#define P1212_KEYVALUE_Unit_Poll_Mask 0x16 /* immediate */
@@ -186,20 +186,20 @@
* already in some roms.
*/
-#define P1212_KEYVALUE_Model 0x17 /* immediate */
-#define P1212_KEYVALUR_Instance_Directory 0x18 /* directory */
-#define P1212_KEYVALUE_Keyword 0x19 /* leaf */
-#define P1212_KEYVALUE_Feature_Directory 0x1A /* directory */
-#define P1212_KEYVALUE_Extended_ROM 0x1B /* leaf */
-#define P1212_KEYVALUE_Extended_Key_Spec_Id 0x1C /* immediate */
-#define P1212_KEYVALUE_Extended_Key 0x1D /* immediate */
-#define P1212_KEYVALUE_Extended_Data 0x1E /* imm|leaf|dir|offset */
-#define P1212_KEYVALUE_Modifiable_Descriptor 0x1F /* leaf */
-#define P1212_KEYVALUE_Directory_Id 0x20 /* immediate */
+#define P1212_KEYVALUE_Model 0x17 /* immediate */
+#define P1212_KEYVALUR_Instance_Directory 0x18 /* directory */
+#define P1212_KEYVALUE_Keyword 0x19 /* leaf */
+#define P1212_KEYVALUE_Feature_Directory 0x1A /* directory */
+#define P1212_KEYVALUE_Extended_ROM 0x1B /* leaf */
+#define P1212_KEYVALUE_Extended_Key_Spec_Id 0x1C /* immediate */
+#define P1212_KEYVALUE_Extended_Key 0x1D /* immediate */
+#define P1212_KEYVALUE_Extended_Data 0x1E /* imm|off|leaf|dir */
+#define P1212_KEYVALUE_Modifiable_Descriptor 0x1F /* leaf */
+#define P1212_KEYVALUE_Directory_Id 0x20 /* immediate */
#define P1212_KEYTYPE_STRINGS { "Immediate", "Offset", "Leaf", "Directory" }
-#define P1212_KEYVALUE_STRINGS { "Root-Directory", \
+#define P1212_KEYVALUE_STRINGS { "Root-Directory", \
"Textual-Descriptor", "Bus-Dependent-Info", "Module-Vendor-Id", \
"Module-Hw-Version", "Module-Spec-Id", "Module-Sw-Version", \
"Module-Dependent-Info", "Node-Vendor-Id", "Node-Hw_Version", \
@@ -208,9 +208,17 @@
"Node-Dependent-Info", "Unit-Directory", "Unit-Spec-Id", \
"Unit-Sw-Version", "Unit-Dependent-Info", "Unit-Location", \
"Unit-Poll-Mask", "Model", "Instance-Directory", "Keyword", \
- "Feature-Directory", "Extended-ROM", "Extended-Key-Spec-Id", \
- "Extended-Key", "Extended-Data", "Modifiable-Descriptor", \
- "Directory-Id" }
+ "Feature-Directory", "Extended-ROM", "Extended-Key-Spec-Id", \
+ "Extended-Key", "Extended-Data", "Modifiable-Descriptor", \
+ "Directory-Id", NULL /* 0x21 */, NULL /* 0x22 */, NULL /* 0x23 */, \
+ NULL /* 0x24 */, NULL /* 0x25 */, NULL /* 0x26 */, NULL /* 0x27 */, \
+ NULL /* 0x28 */, NULL /* 0x29 */, NULL /* 0x2A */, NULL /* 0x2B */, \
+ NULL /* 0x2C */, NULL /* 0x2D */, NULL /* 0x2E */, NULL /* 0x2F */, \
+ NULL /* 0x30 */, NULL /* 0x31 */, NULL /* 0x32 */, NULL /* 0x33 */, \
+ NULL /* 0x34 */, NULL /* 0x35 */, NULL /* 0x36 */, NULL /* 0x37 */, \
+ "Command-Set-Spec-ID", "Commant-Set", "Unit-Characteristics", \
+ "Command-Set-Revision", "Firmware-Revision", "Reconnect-Timeout", \
+}
/* Leaf nodes look like:
*
@@ -223,9 +231,9 @@
* [2] 0xllllllll language id
*/
-#define P1212_TEXT_Min_Leaf_Length 0x3
-#define P1212_TEXT_GET_Spec_Type(quadlet) (((quadlet) & 0xff000000) >> 24)
-#define P1212_TEXT_GET_Spec_Id(quadlet) ((quadlet) & 0xffffff)
+#define P1212_TEXT_Min_Leaf_Length 0x3
+#define P1212_TEXT_GET_Spec_Type(quadlet) (((quadlet) & 0xff000000) >> 24)
+#define P1212_TEXT_GET_Spec_Id(quadlet) ((quadlet) & 0xffffff)
/*
* Directory nodes look like:
@@ -236,8 +244,8 @@
/* Some definitions for the p1212_find routines. */
-#define P1212_FIND_SEARCHALL 0x1
-#define P1212_FIND_RETURNALL 0x2
+#define P1212_FIND_SEARCHALL 0x1
+#define P1212_FIND_RETURNALL 0x2
/* Mask definitions for overriding the p1212 standard checks. */
@@ -248,10 +256,10 @@
/* Normally dependent info can only be leaf or directory. Allow offsets also */
-#define P1212_ALLOW_DEPENDENT_INFO_OFFSET_TYPE 0x1
+#define P1212_ALLOW_DEPENDENT_INFO_OFFSET_TYPE 0x1
/* Same thing applies for immediate types. */
-#define P1212_ALLOW_DEPENDENT_INFO_IMMED_TYPE 0x2
-#define P1212_ALLOW_VENDOR_DIRECTORY_TYPE 0x4
+#define P1212_ALLOW_DEPENDENT_INFO_IMMED_TYPE 0x2
+#define P1212_ALLOW_VENDOR_DIRECTORY_TYPE 0x4
#endif /* _DEV_STD_IEEE1212REG_H_ */
diff --git a/sys/dev/std/ieee1212var.h b/sys/dev/std/ieee1212var.h
index 7bb34364ebb..8c525750cc1 100644
--- a/sys/dev/std/ieee1212var.h
+++ b/sys/dev/std/ieee1212var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee1212var.h,v 1.1 2002/06/25 17:11:49 itojun Exp $ */
+/* $OpenBSD: ieee1212var.h,v 1.2 2002/12/13 02:52:11 tdeval Exp $ */
/* $NetBSD: ieee1212var.h,v 1.1 2002/02/27 04:58:51 jmc Exp $ */
/*
@@ -37,47 +37,46 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _DEV_STD_IEEE1212VAR_H
-#define _DEV_STD_IEEE1212VAR_H
+#ifndef _DEV_STD_IEEE1212VAR_H
+#define _DEV_STD_IEEE1212VAR_H
struct p1212_dir;
-struct p1212_key {
+typedef struct p1212_key {
u_int8_t key_type;
u_int8_t key_value;
u_int8_t key;
u_int32_t val;
-};
+} p1212_key;
-struct p1212_leafdata {
+typedef struct p1212_leafdata {
u_int32_t len;
u_int32_t *data;
-};
+} p1212_leafdata;
-struct p1212_textdata {
+typedef struct p1212_textdata {
u_int8_t spec_type;
u_int32_t spec_id;
u_int32_t lang_id;
char *text;
-};
+} p1212_textdata;
-struct p1212_com {
+typedef struct p1212_com {
struct p1212_key key;
u_int32_t textcnt;
struct p1212_textdata **text;
-};
+} p1212_com;
-struct p1212_data {
+typedef struct p1212_data {
struct p1212_com com;
-
+
u_int32_t val;
struct p1212_leafdata *leafdata;
void (*print)(struct p1212_data *);
TAILQ_ENTRY(p1212_data) data;
-};
-
+} p1212_data;
-struct p1212_dir {
+typedef struct p1212_dir {
struct p1212_com com;
int match;
@@ -86,17 +85,17 @@ struct p1212_dir {
TAILQ_HEAD(, p1212_data) data_root;
TAILQ_HEAD(, p1212_dir) subdir_root;
TAILQ_ENTRY(p1212_dir) dir;
-};
+} p1212_dir;
-struct p1212_rom {
+typedef struct p1212_rom {
char name[5];
u_int32_t len;
u_int32_t *data;
struct p1212_dir *root;
-};
+} p1212_rom;
int p1212_iscomplete(u_int32_t *, u_int32_t *);
-struct p1212_rom *p1212_parse (u_int32_t *, u_int32_t, u_int32_t);
+struct p1212_rom *p1212_parse(u_int32_t *, u_int32_t, u_int32_t);
void p1212_walk(struct p1212_dir *, void *,
void (*)(struct p1212_key *, void *));
struct p1212_key **p1212_find(struct p1212_dir *, int, int, int);
@@ -105,4 +104,4 @@ void p1212_free(struct p1212_rom *);
struct device **p1212_match_units(struct device *, struct p1212_dir *,
int (*)(void *, const char *));
-#endif /* _DEV_STD_IEEE1212VAR_H */
+#endif /* _DEV_STD_IEEE1212VAR_H */