Some updates based on information from Bob Nestor <rnestor@metronet.com>

about his SONIC-T LC/PDS card.
This commit is contained in:
briggs 1997-04-13 14:21:09 +00:00
parent 601c0eaed7
commit 4a3016b6b6
6 changed files with 93 additions and 170 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn.c,v 1.9 1997/04/10 03:22:45 briggs Exp $ */
/* $NetBSD: if_sn.c,v 1.10 1997/04/13 14:21:09 briggs Exp $ */
/*
* National Semiconductor SONIC Driver
@ -1190,3 +1190,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;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn_nubus.c,v 1.4 1997/04/10 03:22:47 briggs Exp $ */
/* $NetBSD: if_sn_nubus.c,v 1.5 1997/04/13 14:21:10 briggs Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
@ -59,8 +59,6 @@
static int sn_nubus_match __P((struct device *, struct cfdata *, 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
@ -148,16 +146,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)
myaddr[i] = bus_space_read_1(bst, tmp_bsh, i);
sn_get_enaddr(bst, tmp_bsh, 0, myaddr);
bus_space_unmap(bst, tmp_bsh, ETHER_ADDR_LEN);
success = 1;
break;
@ -167,15 +158,23 @@ 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;
}
if (sn_nb_get_enaddr(na, myaddr, 0x8) == 0)
success = 1;
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, myaddr);
bus_space_unmap(bst, tmp_bsh, ETHER_ADDR_LEN);
success = 1;
break;
default:
@ -269,25 +268,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;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn_obio.c,v 1.7 1997/04/10 03:22:48 briggs Exp $ */
/* $NetBSD: if_sn_obio.c,v 1.8 1997/04/13 14:21:11 briggs Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
@ -146,17 +146,12 @@ 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, lladdr)
struct sn_softc *sc;
u_int8_t *lladdr;
{
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");
@ -167,46 +162,7 @@ sn_obio_getaddr(sc, lladdr)
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;
lladdr[0] = (do_bbr) ? bbr(b) : b;
for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
b = bus_space_read_1(sc->sc_regt, bsh, i);
lladdr[i] = (do_bbr) ? bbr(b) : b;
}
sn_get_enaddr(sc->sc_regt, bsh, 0, lladdr);
bus_space_unmap(sc->sc_regt, bsh, NBPG);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_snvar.h,v 1.5 1997/04/10 03:22:47 briggs Exp $ */
/* $NetBSD: if_snvar.h,v 1.6 1997/04/13 14:21:12 briggs Exp $ */
/*
* Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk)
@ -237,3 +237,5 @@ typedef struct sn_softc {
int snsetup __P((struct sn_softc *sc, u_int8_t *));
void snintr __P((void *, int));
void sn_get_enaddr __P((bus_space_tag_t t, bus_space_handle_t h,
vm_offset_t o, u_char *dst));

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn_nubus.c,v 1.4 1997/04/10 03:22:47 briggs Exp $ */
/* $NetBSD: if_sn_nubus.c,v 1.5 1997/04/13 14:21:10 briggs Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
@ -59,8 +59,6 @@
static int sn_nubus_match __P((struct device *, struct cfdata *, 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
@ -148,16 +146,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)
myaddr[i] = bus_space_read_1(bst, tmp_bsh, i);
sn_get_enaddr(bst, tmp_bsh, 0, myaddr);
bus_space_unmap(bst, tmp_bsh, ETHER_ADDR_LEN);
success = 1;
break;
@ -167,15 +158,23 @@ 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;
}
if (sn_nb_get_enaddr(na, myaddr, 0x8) == 0)
success = 1;
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, myaddr);
bus_space_unmap(bst, tmp_bsh, ETHER_ADDR_LEN);
success = 1;
break;
default:
@ -269,25 +268,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;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn_obio.c,v 1.7 1997/04/10 03:22:48 briggs Exp $ */
/* $NetBSD: if_sn_obio.c,v 1.8 1997/04/13 14:21:11 briggs Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
@ -146,17 +146,12 @@ 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, lladdr)
struct sn_softc *sc;
u_int8_t *lladdr;
{
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");
@ -167,46 +162,7 @@ sn_obio_getaddr(sc, lladdr)
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;
lladdr[0] = (do_bbr) ? bbr(b) : b;
for (i = 1 ; i < ETHER_ADDR_LEN ; i++) {
b = bus_space_read_1(sc->sc_regt, bsh, i);
lladdr[i] = (do_bbr) ? bbr(b) : b;
}
sn_get_enaddr(sc->sc_regt, bsh, 0, lladdr);
bus_space_unmap(sc->sc_regt, bsh, NBPG);