about his SONIC-T LC/PDS card.
/* $NetBSD: if_sn.c,v 1.7 1997/03/20 17:47:51 scottr Exp $ */
-/* $OpenBSD: if_sn.c,v 1.19 1997/04/10 03:15:59 briggs Exp $ */
+/* $OpenBSD: if_sn.c,v 1.20 1997/04/13 14:14:51 briggs Exp $ */
/*
* National Semiconductor SONIC Driver
}
return (top);
}
+
+static u_char bbr4[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
+#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
+
+void
+sn_get_enaddr(t, h, o, dst)
+ bus_space_tag_t t;
+ bus_space_handle_t h;
+ vm_offset_t o;
+ u_char *dst;
+{
+ int i, do_bbr;
+ u_char b;
+
+ /*
+ * For reasons known only to Apple, MAC addresses in the ethernet
+ * PROM are stored in Token Ring (IEEE 802.5) format, that is
+ * with all of the bits in each byte reversed (canonical bit format).
+ * When the address is read out it must be reversed to ethernet format
+ * before use.
+ *
+ * Apple has been assigned OUI's 08:00:07 and 00:a0:40. All onboard
+ * ethernet addresses on 68K machines should be in one of these
+ * two ranges.
+ *
+ * Here is where it gets complicated.
+ *
+ * The PMac 7200, 7500, 8500, and 9500 accidentally had the PROM
+ * written in standard ethernet format. The MacOS accounted for this
+ * in these systems, and did not reverse the bytes. Some other
+ * networking utilities were not so forgiving, and got confused.
+ * "Some" of Apple's Nubus ethernet cards also had their bits
+ * burned in ethernet format.
+ *
+ * Apple petitioned the IEEE and was granted the 00:05:02 (bit reversal
+ * of 00:a0:40) as well. As of OpenTransport 1.1.1, Apple removed
+ * their workaround and now reverses the bits regardless of
+ * what kind of machine it is. So PMac systems and the affected
+ * Nubus cards now use 00:05:02, instead of the 00:a0:40 for which they
+ * were intended.
+ *
+ * See Apple Techinfo article TECHINFO-0020552, "OpenTransport 1.1.1
+ * and MacOS System 7.5.3 FAQ (10/96)" for more details.
+ */
+ do_bbr = 0;
+ b = bus_space_read_1(t, h, o);
+ if (b == 0x10)
+ do_bbr = 1;
+ dst[0] = (do_bbr) ? bbr(b) : b;
+
+ for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
+ b = bus_space_read_1(t, h, o+i);
+ dst[i] = (do_bbr) ? bbr(b) : b;
+ }
+}
-/* $OpenBSD: if_sn_nubus.c,v 1.6 1997/04/10 00:17:42 briggs Exp $ */
+/* $OpenBSD: if_sn_nubus.c,v 1.7 1997/04/13 14:14:51 briggs Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
static int sn_nubus_match __P((struct device *, void *, void *));
static void sn_nubus_attach __P((struct device *, struct device *, void *));
static int sn_nb_card_vendor __P((struct nubus_attach_args *));
-static int sn_nb_get_enaddr __P((struct nubus_attach_args *,
- u_int8_t *, int));
struct cfattach sn_nubus_ca = {
sizeof(struct sn_softc), sn_nubus_match, sn_nubus_attach
break;
}
- /*
- * Copy out the ethernet address from the card's ROM
- *
- * See if_sn_obio.c for a discussion of bit reversal
- * in Apple's MAC address PROMs. As far as I can tell
- * Dayna stores their Mac address in ethernet format,
- * not Token Ring.
- */
- for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->sc_arpcom.ac_enaddr[i] =
- bus_space_read_1(bst, tmp_bsh, i);
+ sn_get_enaddr(bst, tmp_bsh, 0, sc->sc_arpcom.ac_enaddr);
+
+ bus_space_unmap(bst, tmp_bsh, ETHER_ADDR_LEN);
success = 1;
break;
DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16;
sc->snr_dcr2 = 0;
- if (bus_space_subregion(bst, bsh, 0x00180000, SN_REGSIZE,
+ if (bus_space_subregion(bst, bsh, 0x0, SN_REGSIZE,
&sc->sc_regh)) {
printf(": failed to map register space.\n");
break;
}
- sn_nb_get_enaddr(na, sc->sc_arpcom.ac_enaddr, 0x8);
+ if (bus_space_subregion(bst, bsh, 0x40000, ETHER_ADDR_LEN,
+ &tmp_bsh)) {
+ printf(": failed to map ROM space.\n");
+ break;
+ }
+
+ sn_get_enaddr(bst, tmp_bsh, 0, sc->sc_arpcom.ac_enaddr);
+
+ bus_space_unmap(bst, tmp_bsh, ETHER_ADDR_LEN);
success = 1;
break;
}
return vendor;
}
-
-static int
-sn_nb_get_enaddr(na, ep, rsrc1)
- struct nubus_attach_args *na;
- u_int8_t *ep;
- int rsrc1;
-{
- nubus_dir dir;
- nubus_dirent dirent;
-
- nubus_get_main_dir(na->fmt, &dir);
- if (nubus_find_rsrc(na->fmt, &dir, na->rsrcid, &dirent) <= 0)
- return 1;
- nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
- if (nubus_find_rsrc(na->fmt, &dir, rsrc1, &dirent) <= 0)
- return 1;
- if (nubus_get_ind_data(na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0)
- return 1;
-
- return 0;
-}
-/* $OpenBSD: if_sn_obio.c,v 1.11 1997/04/10 03:16:00 briggs Exp $ */
+/* $OpenBSD: if_sn_obio.c,v 1.12 1997/04/13 14:14:52 briggs Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
add_nubus_intr(sc->slotno, snintr, (void *)sc);
}
-static u_char bbr4[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
-#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf])
-
static int
sn_obio_getaddr(sc)
struct sn_softc *sc;
{
bus_space_handle_t bsh;
- int i, do_bbr;
- u_char b;
if (bus_space_map(sc->sc_regt, SONIC_PROM_BASE, NBPG, 0, &bsh)) {
panic("failed to map space to read SONIC address.\n");
return -1;
}
- /*
- * For reasons known only to Apple, MAC addresses in the ethernet
- * PROM are stored in Token Ring (IEEE 802.5) format, that is
- * with all of the bits in each byte reversed (canonical bit format).
- * When the address is read out it must be reversed to ethernet format
- * before use.
- *
- * Apple has been assigned OUI's 08:00:07 and 00:a0:40. All onboard
- * ethernet addresses on 68K machines should be in one of these
- * two ranges.
- *
- * Here is where it gets complicated.
- *
- * The PMac 7200, 7500, 8500, and 9500 accidentally had the PROM
- * written in standard ethernet format. The MacOS accounted for this
- * in these systems, and did not reverse the bytes. Some other
- * networking utilities were not so forgiving, and got confused.
- * "Some" of Apple's Nubus ethernet cards also had their bits
- * burned in ethernet format.
- *
- * Apple petitioned the IEEE and was granted the 00:05:02 (bit reversal
- * of 00:a0:40) as well. As of OpenTransport 1.1.1, Apple removed
- * their workaround and now reverses the bits regardless of
- * what kind of machine it is. So PMac systems and the affected
- * Nubus cards now use 00:05:02, instead of the 00:a0:40 for which they
- * were intended.
- *
- * See Apple Techinfo article TECHINFO-0020552, "OpenTransport 1.1.1
- * and MacOS System 7.5.3 FAQ (10/96)" for more details.
- */
- do_bbr = 0;
- b = bus_space_read_1(sc->sc_regt, bsh, 0);
- if (b == 0x10)
- do_bbr = 1;
- sc->sc_arpcom.ac_enaddr[0] = (do_bbr) ? bbr(b) : b;
-
- for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
- b = bus_space_read_1(sc->sc_regt, bsh, i);
- sc->sc_arpcom.ac_enaddr[i] = (do_bbr) ? bbr(b) : b;
- }
+ sn_get_enaddr(sc->sc_regt, bsh, 0, sc->sc_arpcom.ac_enaddr);
bus_space_unmap(sc->sc_regt, bsh, NBPG);
-/* $OpenBSD: if_snvar.h,v 1.4 1997/04/10 02:35:03 briggs Exp $ */
+/* $OpenBSD: if_snvar.h,v 1.5 1997/04/13 14:14:52 briggs Exp $ */
/*
* Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk)
#define CDA_SIZE(sc) ((4*16 + 1) * ((sc->bitmode) ? 4 : 2))
int snsetup __P((struct sn_softc *sc));
+void sn_get_enaddr __P((bus_space_tag_t t, bus_space_handle_t h,
+ vm_offset_t o, u_char *dst));
void snintr __P((void *, int));