Move bus-independent setup code back into if_ae.c; enable the use of
configuration flags. For NuBus cards, attempt to find the MAC address in the declaration ROM resources.
This commit is contained in:
parent
b2d1fe0537
commit
a2a40938b1
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_ae.c,v 1.53 1997/02/24 07:34:18 scottr Exp $ */
|
||||
/* $NetBSD: if_ae.c,v 1.54 1997/02/25 06:36:04 scottr Exp $ */
|
||||
|
||||
/*
|
||||
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
|
||||
@ -126,6 +126,65 @@ ae_size_card_memory(bst, bsh, ofs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do bus-independent setup.
|
||||
*/
|
||||
void
|
||||
aesetup(sc)
|
||||
struct ae_softc *sc;
|
||||
{
|
||||
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
|
||||
int i;
|
||||
|
||||
sc->cr_proto = ED_CR_RD2;
|
||||
|
||||
/* Allocate one xmit buffer if < 16k, two buffers otherwise. */
|
||||
if ((sc->mem_size < 16384) ||
|
||||
(sc->sc_flags & AE_FLAGS_NO_DOUBLE_BUFFERING))
|
||||
sc->txb_cnt = 1;
|
||||
else
|
||||
sc->txb_cnt = 2;
|
||||
|
||||
sc->tx_page_start = 0;
|
||||
sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
|
||||
sc->rec_page_stop = sc->tx_page_start + (sc->mem_size >> ED_PAGE_SHIFT);
|
||||
sc->mem_ring = sc->rec_page_start << ED_PAGE_SHIFT;
|
||||
|
||||
/* Now zero memory and verify that it is clear. */
|
||||
bus_space_set_region_2(sc->sc_buf_tag, sc->sc_buf_handle, 0,
|
||||
0, sc->mem_size / 2);
|
||||
|
||||
for (i = 0; i < sc->mem_size; ++i)
|
||||
if (bus_space_read_1(sc->sc_buf_tag, sc->sc_buf_handle, i))
|
||||
printf("%s: failed to clear shared memory - check configuration\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
|
||||
/* Set interface to stopped condition (reset). */
|
||||
aestop(sc);
|
||||
|
||||
/* Initialize ifnet structure. */
|
||||
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
|
||||
ifp->if_softc = sc;
|
||||
ifp->if_start = aestart;
|
||||
ifp->if_ioctl = aeioctl;
|
||||
ifp->if_watchdog = aewatchdog;
|
||||
ifp->if_flags =
|
||||
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
|
||||
|
||||
/* Attach the interface. */
|
||||
if_attach(ifp);
|
||||
ether_ifattach(ifp);
|
||||
|
||||
/* Print additional info when attached. */
|
||||
printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
|
||||
|
||||
printf("type %s, %dKB memory\n", sc->type_str, sc->mem_size / 1024);
|
||||
|
||||
#if NBPFILTER > 0
|
||||
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset interface.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_ae_nubus.c,v 1.2 1997/02/24 07:34:19 scottr Exp $ */
|
||||
/* $NetBSD: if_ae_nubus.c,v 1.3 1997/02/25 06:36:06 scottr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Scott Reynolds
|
||||
@ -31,8 +31,6 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bpfilter.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/errno.h>
|
||||
@ -41,28 +39,12 @@
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/netisr.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in_var.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#endif
|
||||
|
||||
#ifdef NS
|
||||
#include <netns/ns.h>
|
||||
#include <netns/ns_if.h>
|
||||
#endif
|
||||
|
||||
#if NBPFILTER > 0
|
||||
#include <net/bpf.h>
|
||||
#include <net/bpfdesc.h>
|
||||
#endif
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/viareg.h>
|
||||
|
||||
@ -74,6 +56,7 @@
|
||||
static int ae_nubus_match __P((struct device *, struct cfdata *, void *));
|
||||
static void ae_nubus_attach __P((struct device *, struct device *, void *));
|
||||
static int ae_card_vendor __P((struct nubus_attach_args *na));
|
||||
static int ae_get_enaddr __P((struct nubus_attach_args *na, u_int8_t *ep));
|
||||
|
||||
struct cfattach ae_nubus_ca = {
|
||||
sizeof(struct ae_softc), ae_nubus_match, ae_nubus_attach
|
||||
@ -129,11 +112,12 @@ ae_nubus_attach(parent, self, aux)
|
||||
{
|
||||
struct ae_softc *sc = (struct ae_softc *) self;
|
||||
struct nubus_attach_args *na = (struct nubus_attach_args *) aux;
|
||||
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
int i, success;
|
||||
int flags = 0;
|
||||
int success;
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
int i;
|
||||
#endif
|
||||
|
||||
bst = na->na_tag;
|
||||
if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
|
||||
@ -142,6 +126,8 @@ ae_nubus_attach(parent, self, aux)
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_reg_tag = sc->sc_buf_tag = bst;
|
||||
sc->sc_flags = self->dv_cfdata->cf_flags;
|
||||
sc->regs_rev = 0;
|
||||
sc->use16bit = 1;
|
||||
sc->vendor = ae_card_vendor(na);
|
||||
@ -153,37 +139,8 @@ ae_nubus_attach(parent, self, aux)
|
||||
success = 0;
|
||||
|
||||
switch (sc->vendor) {
|
||||
case AE_VENDOR_INTERLAN:
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_reg_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
if ((sc->mem_size = ae_size_card_memory(bst, bsh,
|
||||
GC_DATA_OFFSET)) == 0) {
|
||||
printf(": failed to determine size of RAM.\n");
|
||||
break;
|
||||
}
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_DATA_OFFSET, sc->mem_size, &sc->sc_buf_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset the NIC chip */
|
||||
bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
|
||||
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (GC_ROM_OFFSET + i * 4));
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
|
||||
/* Apple-compatible cards */
|
||||
case AE_VENDOR_APPLE: /* Apple-compatible cards */
|
||||
case AE_VENDOR_ASANTE:
|
||||
case AE_VENDOR_APPLE:
|
||||
sc->regs_rev = 1;
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_reg_handle)) {
|
||||
@ -200,11 +157,17 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (AE_ROM_OFFSET + i * 2));
|
||||
#else
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
@ -221,11 +184,17 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (DP_ROM_OFFSET + i * 2));
|
||||
#else
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
printf(": unsupported Dayna hardware\n");
|
||||
break;
|
||||
@ -247,11 +216,12 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (FE_ROM_OFFSET + i));
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
@ -260,6 +230,41 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": unsupported Focus hardware\n");
|
||||
break;
|
||||
|
||||
case AE_VENDOR_INTERLAN:
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_reg_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
if ((sc->mem_size = ae_size_card_memory(bst, bsh,
|
||||
GC_DATA_OFFSET)) == 0) {
|
||||
printf(": failed to determine size of RAM.\n");
|
||||
break;
|
||||
}
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_DATA_OFFSET, sc->mem_size, &sc->sc_buf_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset the NIC chip */
|
||||
bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (GC_ROM_OFFSET + i * 4));
|
||||
#else
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
|
||||
case AE_VENDOR_KINETICS:
|
||||
sc->use16bit = 0;
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
@ -277,30 +282,10 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get station address from on-board ROM */
|
||||
#if 0
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (KE_ROM_OFFSET + i));
|
||||
#else
|
||||
{
|
||||
nubus_dir dir;
|
||||
nubus_dirent dirent;
|
||||
|
||||
/* getting the MAC address */
|
||||
nubus_get_main_dir(na->fmt, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
break;
|
||||
nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
break;
|
||||
if (nubus_get_ind_data(na->fmt, &dirent,
|
||||
(caddr_t)sc->sc_arpcom.ac_enaddr,
|
||||
ETHER_ADDR_LEN) <= 0)
|
||||
break;
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
@ -314,54 +299,7 @@ ae_nubus_attach(parent, self, aux)
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_reg_tag = sc->sc_buf_tag = bst;
|
||||
|
||||
sc->cr_proto = ED_CR_RD2;
|
||||
|
||||
/* Allocate one xmit buffer if < 16k, two buffers otherwise. */
|
||||
if ((sc->mem_size < 16384) || (flags & AE_FLAGS_NO_DOUBLE_BUFFERING))
|
||||
sc->txb_cnt = 1;
|
||||
else
|
||||
sc->txb_cnt = 2;
|
||||
|
||||
sc->tx_page_start = 0;
|
||||
sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
|
||||
sc->rec_page_stop = sc->tx_page_start + (sc->mem_size >> ED_PAGE_SHIFT);
|
||||
sc->mem_ring = sc->rec_page_start << ED_PAGE_SHIFT;
|
||||
|
||||
/* Now zero memory and verify that it is clear. */
|
||||
bus_space_set_region_2(sc->sc_buf_tag, sc->sc_buf_handle, 0,
|
||||
0, sc->mem_size / 2);
|
||||
|
||||
for (i = 0; i < sc->mem_size; ++i)
|
||||
if (bus_space_read_1(sc->sc_buf_tag, sc->sc_buf_handle, i))
|
||||
printf("%s: failed to clear shared memory - check configuration\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
|
||||
/* Set interface to stopped condition (reset). */
|
||||
aestop(sc);
|
||||
|
||||
/* Initialize ifnet structure. */
|
||||
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
|
||||
ifp->if_softc = sc;
|
||||
ifp->if_start = aestart;
|
||||
ifp->if_ioctl = aeioctl;
|
||||
ifp->if_watchdog = aewatchdog;
|
||||
ifp->if_flags =
|
||||
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
|
||||
|
||||
/* Attach the interface. */
|
||||
if_attach(ifp);
|
||||
ether_ifattach(ifp);
|
||||
|
||||
/* Print additional info when attached. */
|
||||
printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
|
||||
|
||||
printf("type %s, %dKB memory\n", sc->type_str, sc->mem_size / 1024);
|
||||
|
||||
#if NBPFILTER > 0
|
||||
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
|
||||
#endif
|
||||
aesetup(sc);
|
||||
|
||||
/* make sure interrupts are vectored to us */
|
||||
add_nubus_intr(na->slot, aeintr, sc);
|
||||
@ -419,3 +357,28 @@ ae_card_vendor(na)
|
||||
}
|
||||
return vendor;
|
||||
}
|
||||
|
||||
static int
|
||||
ae_get_enaddr(na, ep)
|
||||
struct nubus_attach_args *na;
|
||||
u_int8_t *ep;
|
||||
{
|
||||
nubus_dir dir;
|
||||
nubus_dirent dirent;
|
||||
|
||||
/*
|
||||
* XXX - note hardwired resource IDs here (0x80); these are
|
||||
* assumed to be used by all cards, but should be fixed when
|
||||
* we find out more about Ethernet card resources.
|
||||
*/
|
||||
nubus_get_main_dir(na->fmt, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
return 1;
|
||||
nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
return 1;
|
||||
if (nubus_get_ind_data(na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_aevar.h,v 1.2 1997/02/24 07:34:21 scottr Exp $ */
|
||||
/* $NetBSD: if_aevar.h,v 1.3 1997/02/25 06:36:07 scottr Exp $ */
|
||||
|
||||
/*
|
||||
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
|
||||
@ -30,6 +30,7 @@ struct ae_softc {
|
||||
/* struct intrhand sc_ih; */
|
||||
|
||||
struct arpcom sc_arpcom;/* ethernet common */
|
||||
int sc_flags; /* interface flags, from config */
|
||||
|
||||
char type_str[INTERFACE_NAME_LEN]; /* type string */
|
||||
u_short type; /* interface type code */
|
||||
@ -57,6 +58,7 @@ struct ae_softc {
|
||||
int ae_size_card_memory __P((
|
||||
bus_space_tag_t, bus_space_handle_t, int));
|
||||
|
||||
void aesetup __P((struct ae_softc *));
|
||||
void aeintr __P((void *, int));
|
||||
int aeioctl __P((struct ifnet *, u_long, caddr_t));
|
||||
void aestart __P((struct ifnet *));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_ae_nubus.c,v 1.2 1997/02/24 07:34:19 scottr Exp $ */
|
||||
/* $NetBSD: if_ae_nubus.c,v 1.3 1997/02/25 06:36:06 scottr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Scott Reynolds
|
||||
@ -31,8 +31,6 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bpfilter.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/errno.h>
|
||||
@ -41,28 +39,12 @@
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/netisr.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in_var.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#endif
|
||||
|
||||
#ifdef NS
|
||||
#include <netns/ns.h>
|
||||
#include <netns/ns_if.h>
|
||||
#endif
|
||||
|
||||
#if NBPFILTER > 0
|
||||
#include <net/bpf.h>
|
||||
#include <net/bpfdesc.h>
|
||||
#endif
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/viareg.h>
|
||||
|
||||
@ -74,6 +56,7 @@
|
||||
static int ae_nubus_match __P((struct device *, struct cfdata *, void *));
|
||||
static void ae_nubus_attach __P((struct device *, struct device *, void *));
|
||||
static int ae_card_vendor __P((struct nubus_attach_args *na));
|
||||
static int ae_get_enaddr __P((struct nubus_attach_args *na, u_int8_t *ep));
|
||||
|
||||
struct cfattach ae_nubus_ca = {
|
||||
sizeof(struct ae_softc), ae_nubus_match, ae_nubus_attach
|
||||
@ -129,11 +112,12 @@ ae_nubus_attach(parent, self, aux)
|
||||
{
|
||||
struct ae_softc *sc = (struct ae_softc *) self;
|
||||
struct nubus_attach_args *na = (struct nubus_attach_args *) aux;
|
||||
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
|
||||
bus_space_tag_t bst;
|
||||
bus_space_handle_t bsh;
|
||||
int i, success;
|
||||
int flags = 0;
|
||||
int success;
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
int i;
|
||||
#endif
|
||||
|
||||
bst = na->na_tag;
|
||||
if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
|
||||
@ -142,6 +126,8 @@ ae_nubus_attach(parent, self, aux)
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_reg_tag = sc->sc_buf_tag = bst;
|
||||
sc->sc_flags = self->dv_cfdata->cf_flags;
|
||||
sc->regs_rev = 0;
|
||||
sc->use16bit = 1;
|
||||
sc->vendor = ae_card_vendor(na);
|
||||
@ -153,37 +139,8 @@ ae_nubus_attach(parent, self, aux)
|
||||
success = 0;
|
||||
|
||||
switch (sc->vendor) {
|
||||
case AE_VENDOR_INTERLAN:
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_reg_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
if ((sc->mem_size = ae_size_card_memory(bst, bsh,
|
||||
GC_DATA_OFFSET)) == 0) {
|
||||
printf(": failed to determine size of RAM.\n");
|
||||
break;
|
||||
}
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_DATA_OFFSET, sc->mem_size, &sc->sc_buf_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset the NIC chip */
|
||||
bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
|
||||
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (GC_ROM_OFFSET + i * 4));
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
|
||||
/* Apple-compatible cards */
|
||||
case AE_VENDOR_APPLE: /* Apple-compatible cards */
|
||||
case AE_VENDOR_ASANTE:
|
||||
case AE_VENDOR_APPLE:
|
||||
sc->regs_rev = 1;
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_reg_handle)) {
|
||||
@ -200,11 +157,17 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (AE_ROM_OFFSET + i * 2));
|
||||
#else
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
@ -221,11 +184,17 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (DP_ROM_OFFSET + i * 2));
|
||||
#else
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
printf(": unsupported Dayna hardware\n");
|
||||
break;
|
||||
@ -247,11 +216,12 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (FE_ROM_OFFSET + i));
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
@ -260,6 +230,41 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": unsupported Focus hardware\n");
|
||||
break;
|
||||
|
||||
case AE_VENDOR_INTERLAN:
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_reg_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
if ((sc->mem_size = ae_size_card_memory(bst, bsh,
|
||||
GC_DATA_OFFSET)) == 0) {
|
||||
printf(": failed to determine size of RAM.\n");
|
||||
break;
|
||||
}
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
GC_DATA_OFFSET, sc->mem_size, &sc->sc_buf_handle)) {
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset the NIC chip */
|
||||
bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
|
||||
|
||||
#ifdef AE_OLD_GET_ENADDR
|
||||
/* Get station address from on-board ROM */
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (GC_ROM_OFFSET + i * 4));
|
||||
#else
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
|
||||
case AE_VENDOR_KINETICS:
|
||||
sc->use16bit = 0;
|
||||
if (bus_space_subregion(bst, bsh,
|
||||
@ -277,30 +282,10 @@ ae_nubus_attach(parent, self, aux)
|
||||
printf(": failed to map register space\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get station address from on-board ROM */
|
||||
#if 0
|
||||
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
||||
sc->sc_arpcom.ac_enaddr[i] =
|
||||
bus_space_read_1(bst, bsh, (KE_ROM_OFFSET + i));
|
||||
#else
|
||||
{
|
||||
nubus_dir dir;
|
||||
nubus_dirent dirent;
|
||||
|
||||
/* getting the MAC address */
|
||||
nubus_get_main_dir(na->fmt, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
break;
|
||||
nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
break;
|
||||
if (nubus_get_ind_data(na->fmt, &dirent,
|
||||
(caddr_t)sc->sc_arpcom.ac_enaddr,
|
||||
ETHER_ADDR_LEN) <= 0)
|
||||
break;
|
||||
if (ae_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
|
||||
printf(": can't find MAC address\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
success = 1;
|
||||
break;
|
||||
@ -314,54 +299,7 @@ ae_nubus_attach(parent, self, aux)
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_reg_tag = sc->sc_buf_tag = bst;
|
||||
|
||||
sc->cr_proto = ED_CR_RD2;
|
||||
|
||||
/* Allocate one xmit buffer if < 16k, two buffers otherwise. */
|
||||
if ((sc->mem_size < 16384) || (flags & AE_FLAGS_NO_DOUBLE_BUFFERING))
|
||||
sc->txb_cnt = 1;
|
||||
else
|
||||
sc->txb_cnt = 2;
|
||||
|
||||
sc->tx_page_start = 0;
|
||||
sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
|
||||
sc->rec_page_stop = sc->tx_page_start + (sc->mem_size >> ED_PAGE_SHIFT);
|
||||
sc->mem_ring = sc->rec_page_start << ED_PAGE_SHIFT;
|
||||
|
||||
/* Now zero memory and verify that it is clear. */
|
||||
bus_space_set_region_2(sc->sc_buf_tag, sc->sc_buf_handle, 0,
|
||||
0, sc->mem_size / 2);
|
||||
|
||||
for (i = 0; i < sc->mem_size; ++i)
|
||||
if (bus_space_read_1(sc->sc_buf_tag, sc->sc_buf_handle, i))
|
||||
printf("%s: failed to clear shared memory - check configuration\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
|
||||
/* Set interface to stopped condition (reset). */
|
||||
aestop(sc);
|
||||
|
||||
/* Initialize ifnet structure. */
|
||||
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
|
||||
ifp->if_softc = sc;
|
||||
ifp->if_start = aestart;
|
||||
ifp->if_ioctl = aeioctl;
|
||||
ifp->if_watchdog = aewatchdog;
|
||||
ifp->if_flags =
|
||||
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
|
||||
|
||||
/* Attach the interface. */
|
||||
if_attach(ifp);
|
||||
ether_ifattach(ifp);
|
||||
|
||||
/* Print additional info when attached. */
|
||||
printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
|
||||
|
||||
printf("type %s, %dKB memory\n", sc->type_str, sc->mem_size / 1024);
|
||||
|
||||
#if NBPFILTER > 0
|
||||
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
|
||||
#endif
|
||||
aesetup(sc);
|
||||
|
||||
/* make sure interrupts are vectored to us */
|
||||
add_nubus_intr(na->slot, aeintr, sc);
|
||||
@ -419,3 +357,28 @@ ae_card_vendor(na)
|
||||
}
|
||||
return vendor;
|
||||
}
|
||||
|
||||
static int
|
||||
ae_get_enaddr(na, ep)
|
||||
struct nubus_attach_args *na;
|
||||
u_int8_t *ep;
|
||||
{
|
||||
nubus_dir dir;
|
||||
nubus_dirent dirent;
|
||||
|
||||
/*
|
||||
* XXX - note hardwired resource IDs here (0x80); these are
|
||||
* assumed to be used by all cards, but should be fixed when
|
||||
* we find out more about Ethernet card resources.
|
||||
*/
|
||||
nubus_get_main_dir(na->fmt, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
return 1;
|
||||
nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
|
||||
if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
|
||||
return 1;
|
||||
if (nubus_get_ind_data(na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user