diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/mac68k/dev/if_sn.c | 57 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_sn_nubus.c | 51 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_sn_obio.c | 48 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_snvar.h | 4 |
4 files changed, 75 insertions, 85 deletions
diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c index b92e858ca70..e3034b18763 100644 --- a/sys/arch/mac68k/dev/if_sn.c +++ b/sys/arch/mac68k/dev/if_sn.c @@ -1,5 +1,5 @@ /* $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 @@ -1192,3 +1192,58 @@ sonic_get(sc, eh, datalen) } 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; + } +} diff --git a/sys/arch/mac68k/dev/if_sn_nubus.c b/sys/arch/mac68k/dev/if_sn_nubus.c index 37cf8af20ae..2c0b47e0dce 100644 --- a/sys/arch/mac68k/dev/if_sn_nubus.c +++ b/sys/arch/mac68k/dev/if_sn_nubus.c @@ -1,4 +1,4 @@ -/* $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 @@ -54,8 +54,6 @@ 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 @@ -142,17 +140,9 @@ sn_nubus_attach(parent, self, aux) 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; @@ -162,13 +152,21 @@ sn_nubus_attach(parent, self, aux) 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; @@ -265,24 +263,3 @@ sn_nb_card_vendor(na) } 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; -} diff --git a/sys/arch/mac68k/dev/if_sn_obio.c b/sys/arch/mac68k/dev/if_sn_obio.c index a432dd59067..135ebbac1b9 100644 --- a/sys/arch/mac68k/dev/if_sn_obio.c +++ b/sys/arch/mac68k/dev/if_sn_obio.c @@ -1,4 +1,4 @@ -/* $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 @@ -137,16 +137,11 @@ sn_obio_attach(parent, self, aux) 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"); @@ -157,46 +152,7 @@ sn_obio_getaddr(sc) 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); diff --git a/sys/arch/mac68k/dev/if_snvar.h b/sys/arch/mac68k/dev/if_snvar.h index d5db4b9987a..773ad836877 100644 --- a/sys/arch/mac68k/dev/if_snvar.h +++ b/sys/arch/mac68k/dev/if_snvar.h @@ -1,4 +1,4 @@ -/* $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) @@ -237,4 +237,6 @@ typedef struct sn_softc { #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)); |