--- mac68k/locore.s.orig Fri Mar 10 04:31:57 2000 +++ mac68k/locore.s Mon Apr 10 07:27:13 2000 @@ -120,6 +120,10 @@ GLOBAL(bletch) .long 0 +/* to use tt1 instead of tt0 in get_pte() */ +GLOBAL(mac68k_use_tt1) + .long 0 + BSS(esym,4) ASENTRY_NOPROFILE(start) @@ -1632,7 +1636,13 @@ lea _ASM_LABEL(longscratch),a0 movl #0x00ff8710,a0@ | Set up FC 1 r/w access + tstl _C_LABEL(mac68k_use_tt1) + beq Lusett0_1 + .long 0xf0100c00 | pmove a0@,tt1 + bra Ldonett0_1 +Lusett0_1: .long 0xf0100800 | pmove a0@,tt0 +Ldonett0_1: movl sp@(8),a0 | logical address to look up movl #0,a1 | clear in case of failure @@ -1757,7 +1767,13 @@ get_pte_success: lea _ASM_LABEL(longscratch),a0 | disable tt movl #0,a0@ + tstl _C_LABEL(mac68k_use_tt1) + beq Lusett0_2 + .long 0xf0100c00 | pmove a0@,tt1 + bra Ldonett0_2 +Lusett0_2: .long 0xf0100800 | pmove a0@,tt0 +Ldonett0_2: addql #4,sp | return temporary space rts --- mac68k/machdep.c.orig Mon Mar 20 04:20:54 2000 +++ mac68k/machdep.c Mon Apr 10 07:27:14 2000 @@ -215,6 +215,9 @@ struct extent *iomem_ex; int iomem_malloc_safe; +/* this value is used in locore.s */ /* by daishi */ +extern u_long mac68k_use_tt1; + static void identifycpu __P((void)); static u_long get_physical __P((u_int, u_long *)); @@ -2146,6 +2149,8 @@ via_reg(VIA1, vIER) = 0x6f; /* disable VIA1 int */ /* Are we disabling something important? */ via_reg(VIA2, rIER) = 0x7f; /* disable VIA2 int */ + /* to use tt1 instead of tt0 in get_pte() */ /* by daishi */ + mac68k_use_tt1 = 1; break; case MACH_CLASSQ: case MACH_CLASSQ2: @@ -2446,10 +2451,17 @@ { u_long addr, phys; - if (!get_physical(videoaddr, &phys)) { + if (current_mac_model->class == MACH_CLASSDUO && + 0x60000000 <= videoaddr && videoaddr < 0x70000000) { + /* get_physical(videoaddr, &phys) always fails */ + /* by daishi only testd with Duo230 */ + phys = videoaddr; + }else if (!get_physical(videoaddr, &phys)) { if (mac68k_machine.do_graybars) printf("get_mapping(): %s. False start.\n", id); - } else { + return; + } + { mac68k_vidlog = videoaddr; mac68k_vidphys = phys; mac68k_vidlen = 32768; --- dev/adb_direct.c.orig Thu Mar 23 04:27:02 2000 +++ dev/adb_direct.c Mon Apr 10 07:27:15 2000 @@ -2104,6 +2104,8 @@ int device; int nonewtimes; /* times thru loop w/o any new devices */ + adb_setup_hw_type(); /* setup hardware type */ + /* Make sure we are not interrupted while building the table. */ /* ints must be on for PB & IOP (at least, for now) */ if (adbHardware != ADB_HW_PB && adbHardware != ADB_HW_IOP) @@ -2122,8 +2124,6 @@ */ for (i = 0; i < 16; i++) ADBDevTable[i].devType = 0; - - adb_setup_hw_type(); /* setup hardware type */ adb_hw_setup(); /* init the VIA bits and hard reset ADB */ --- dev/pm_direct.c.orig Sun Mar 19 04:17:11 2000 +++ dev/pm_direct.c Mon Apr 10 07:27:16 2000 @@ -1066,8 +1066,20 @@ /* wait until the PM interrupt is occured */ delay = 0x80000; while (adbWaiting == 1) { + switch (mac68k_machine.machineid) { /* by daishi only tested with Duo230 */ + case MACH_MACPB210: + case MACH_MACPB230: + case MACH_MACPB250: + case MACH_MACPB270: + case MACH_MACPB280: + case MACH_MACPB280C: + pm_intr((void *)0); + break; + default: if ((via_reg(VIA1, vIFR) & 0x10) == 0x10) pm_intr((void *)0); + break; + } #ifdef PM_GRAB_SI #if 0 zshard(0); /* grab any serial interrupts */ --- /dev/null Tue Apr 25 05:02:03 2000 +++ nubus/if_netdock_nubus.c Tue Apr 25 04:34:38 2000 @@ -0,0 +1,865 @@ +/* + * Copyright (C) 2000 Daishi Kato + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * 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 Daishi Kato + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Asante NetDock (for Duo series) driver + * the chip inside is not known + */ + +/***********************/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "opt_inet.h" +#ifdef INET +#include +#include +#endif + +#include "bpfilter.h" +#if NBPFILTER > 0 +#include +#endif + +#include +#include +#include + +/***********************/ + +#define NETDOCK_DEBUG + +#define NETDOCK_NUBUS_CATEGORY 0x0020 +#define NETDOCK_NUBUS_TYPE 0x0003 +#define NETDOCK_NUBUS_DRSW 0x0103 +#define NETDOCK_NUBUS_DRHW 0x0100 + +#define REG_ISR 0x000c +#define REG_000E 0x000e +#define REG_0000 0x0000 +#define REG_0002 0x0002 +#define REG_0004 0x0004 +#define REG_0006 0x0006 +#define REG_DATA 0x0008 +#define REG_EFD00 0xefd00 + +#define ISR_ALL 0x3300 +#define ISR_TX 0x0200 +#define ISR_RX 0x0100 +#define ISR_READY 0x0800 +#define ISR_BIT_0C 0x1000 +#define ISR_BIT_0D 0x2000 +#define ISR_MASK 0x0033 +#define ISR_BIT_03 0x0008 + +#define REG_0002_BIT_04 0x0010 +#define REG_0000_BIT_08 0x0100 +#define REG_0004_BIT_0F 0x8000 +#define REG_0004_BIT_07 0x0080 +#define REG_DATA_BIT_02 0x0004 +#define REG_DATA_BIT_03 0x0008 +#define REG_DATA_BIT_04 0x0010 +#define REG_DATA_BIT_05 0x0020 +#define REG_DATA_BIT_08 0x0100 +#define REG_DATA_BIT_07 0x0080 +#define REG_DATA_BIT_0F 0x8000 + +/***********************/ + +typedef struct netdock_softc { + struct device sc_dev; + struct ethercom sc_ethercom; +#define sc_if sc_ethercom.ec_if + + bus_space_tag_t sc_regt; + bus_space_handle_t sc_regh; + + u_int8_t sc_enaddr[ETHER_ADDR_LEN]; + +} netdock_softc_t; + +/***********************/ + +static int netdock_nubus_match __P((struct device *, struct cfdata *, + void*)); +static void netdock_nubus_attach __P((struct device *, struct device *, + void *)); +static int netdock_nb_get_enaddr __P((bus_space_tag_t, bus_space_handle_t, + struct nubus_attach_args *, u_int8_t *)); +#ifdef NETDOCK_DEBUG_DRIVER +static void netdock_print_driver __P((bus_space_tag_t, bus_space_handle_t, + struct nubus_attach_args *)); +#endif + +int netdock_setup __P((struct netdock_softc *, u_int8_t *)); +void netdock_intr __P((void *)); + +static void netdock_watchdog __P((struct ifnet *)); +static int netdock_init __P((struct netdock_softc *)); +static int netdock_stop __P((struct netdock_softc *)); +static int netdock_ioctl __P((struct ifnet *, u_long, caddr_t)); +static void netdock_start __P((struct ifnet *)); +static void netdock_reset __P((struct netdock_softc *)); +static void netdock_txint __P((struct netdock_softc *)); +static void netdock_rxint __P((struct netdock_softc *)); + +static __inline__ u_int netdock_put __P((struct netdock_softc *, + struct mbuf *)); +static __inline__ int netdock_read __P((struct netdock_softc *, int)); +static __inline__ struct mbuf *netdock_get __P((struct netdock_softc *, int)); + +/***********************/ + +#define NIC_GET_1(sc, o) (bus_space_read_1((sc)->sc_regt, \ + (sc)->sc_regh, (o))) +#define NIC_PUT_1(sc, o, val) (bus_space_write_1((sc)->sc_regt, \ + (sc)->sc_regh, (o), (val))) +#define NIC_GET_2(sc, o) (bus_space_read_2((sc)->sc_regt, \ + (sc)->sc_regh, (o))) +#define NIC_PUT_2(sc, o, val) (bus_space_write_2((sc)->sc_regt, \ + (sc)->sc_regh, (o), (val))) +#define NIC_GET_4(sc, o) (bus_space_read_4((sc)->sc_regt, \ + (sc)->sc_regh, (o))) +#define NIC_PUT_4(sc, o, val) (bus_space_write_4((sc)->sc_regt, \ + (sc)->sc_regh, (o), (val))) + +#define NIC_BSET(sc, o, b) \ + __asm__ __volatile("bset %0,%1" : : "di" ((u_short)(b)), \ + "g" (*(u_int8_t *)((sc)->sc_regh + (o)))) +#define NIC_BCLR(sc, o, b) \ + __asm__ __volatile("bclr %0,%1" : : "di" ((u_short)(b)), \ + "g" (*(u_int8_t *)((sc)->sc_regh + (o)))) +#define NIC_ANDW(sc, o, b) \ + __asm__ __volatile("andw %0,%1" : : "di" ((u_short)(b)), \ + "g" (*(u_int8_t *)((sc)->sc_regh + (o)))) +#define NIC_ORW(sc, o, b) \ + __asm__ __volatile("orw %0,%1" : : "di" ((u_short)(b)), \ + "g" (*(u_int8_t *)((sc)->sc_regh + (o)))) + + +/***********************/ + +struct cfattach netdock_nubus_ca = { + sizeof(struct netdock_softc), netdock_nubus_match, netdock_nubus_attach +}; + +/***********************/ + +static int +netdock_nubus_match(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + struct nubus_attach_args *na = (struct nubus_attach_args *)aux; + bus_space_handle_t bsh; + int rv; + + if(bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot), + NBMEMSIZE, 0, &bsh)) + return(0); + + rv = 0; + + if(na->category == NETDOCK_NUBUS_CATEGORY && + na->type == NETDOCK_NUBUS_TYPE && + na->drsw == NETDOCK_NUBUS_DRSW){ + /* assuming this IS Asante NetDock */ + rv = 1; + } + + bus_space_unmap(na->na_tag, bsh, NBMEMSIZE); + + return rv; +} + +static void +netdock_nubus_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct netdock_softc *sc = (struct netdock_softc *)self; + struct nubus_attach_args *na = (struct nubus_attach_args *)aux; + bus_space_tag_t bst; + bus_space_handle_t bsh; + u_int8_t enaddr[ETHER_ADDR_LEN]; + char *cardtype; + + bst = na->na_tag; + if(bus_space_map(bst, NUBUS_SLOT2PA(na->slot), + NBMEMSIZE, 0, &bsh)){ + printf(": failed to map memory space.\n"); + return; + } + + sc->sc_regt = bst; + cardtype = nubus_get_card_name(bst, bsh, na->fmt); + +#ifdef NETDOCK_DEBUG_DRIVER + netdock_print_driver(bst, bsh, na); +#endif + + if(netdock_nb_get_enaddr(bst, bsh, na, enaddr)){ + printf(": can't find MAC address.\n"); + bus_space_unmap(bst, bsh, NBMEMSIZE); + return; + } + + if(bus_space_subregion(bst, bsh, 0xe00300, 0xf0000, &sc->sc_regh)){ + printf(": failed to map register space.\n"); + bus_space_unmap(bst, bsh, NBMEMSIZE); + return; + } + + printf(": %s\n", cardtype); + + if(netdock_setup(sc, enaddr)){ + bus_space_unmap(bst, bsh, NBMEMSIZE); + return; + } + + add_nubus_intr(na->slot, netdock_intr, (void *)sc); + + return; +} + +static int +netdock_nb_get_enaddr(bst, bsh, na, ep) + bus_space_tag_t bst; + bus_space_handle_t bsh; + struct nubus_attach_args *na; + u_int8_t *ep; +{ + nubus_dir dir; + nubus_dirent dirent; + + /* + * these hardwired resource IDs are only for NetDock + */ + nubus_get_main_dir(na->fmt, &dir); + if(nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x81, &dirent) <= 0) + return 1; + nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir); + if(nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent) <= 0) + return 1; + if(nubus_get_ind_data(bst, bsh, na->fmt, &dirent, + ep, ETHER_ADDR_LEN) <= 0) + return 1; + + return 0; +} + +#ifdef NETDOCK_DEBUG_DRIVER +static void +netdock_print_driver(bst, bsh, na) + bus_space_tag_t bst; + bus_space_handle_t bsh; + struct nubus_attach_args *na; +{ +#define HEADSIZE (8+4) +#define CODESIZE (6759-4) + unsigned char mydata[HEADSIZE+CODESIZE]; + nubus_dir dir; + nubus_dirent dirent; + int i, rv; + + nubus_get_main_dir(na->fmt, &dir); + rv = nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x81, &dirent); + if (rv <= 0){ + printf(": can't find sResource.\n"); + return; + } + nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir); + if (nubus_find_rsrc(bst, bsh, na->fmt, + &dir, NUBUS_RSRC_DRVRDIR, &dirent) <= 0){ + printf(": can't find sResource.\n"); + return; + } + if (nubus_get_ind_data(bst, bsh, na->fmt, + &dirent, mydata, HEADSIZE+CODESIZE) <= 0){ + printf(": can't find indirect data.\n"); + return; + } + printf("\n########## begin driver dir"); + for(i = 0; i < HEADSIZE; i++){ + if(i % 16 == 0) printf("\n%02x:",i); + printf(" %02x", mydata[i]); + } + printf("\n########## begin driver code"); + for(i = 0; i < CODESIZE; i++){ + if(i % 16 == 0) printf("\n%02x:",i); + printf(" %02x", mydata[i + HEADSIZE]); + } +/* + printf("\n########## begin driver code (partial)\n"); +#define PARTSIZE 256 +#define OFFSET 0x1568 + for(i = OFFSET; i < OFFSET+PARTSIZE; i++){ + if((i - OFFSET) % 16 == 0) printf("\n%02x:",i); + printf(" %02x", mydata[i + HEADSIZE]); + } +*/ + printf("\n########## end\n"); +} +#endif + + +int +netdock_setup(sc, lladdr) + struct netdock_softc *sc; + u_int8_t *lladdr; +{ + struct ifnet *ifp = &sc->sc_if; + + bcopy(lladdr, sc->sc_enaddr, ETHER_ADDR_LEN); + printf("%s: Ethernet address %s\n", + sc->sc_dev.dv_xname, ether_sprintf(lladdr)); + + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; + ifp->if_ioctl = netdock_ioctl; + ifp->if_start = netdock_start; + ifp->if_flags = + IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + ifp->if_watchdog = netdock_watchdog; +#if NBPFILTER > 0 + bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); +#endif + if_attach(ifp); + ether_ifattach(ifp, lladdr); + + return(0); +} + +static int +netdock_ioctl(ifp, cmd, data) + struct ifnet *ifp; + u_long cmd; + caddr_t data; +{ + struct ifaddr *ifa; + struct ifreq *ifr; + struct netdock_softc *sc = ifp->if_softc; + int s = splnet(); + int err = 0; + int temp; + + switch(cmd){ + + case SIOCSIFADDR: + ifa = (struct ifaddr *)data; + ifp->if_flags |= IFF_UP; + switch(ifa->ifa_addr->sa_family){ +#ifdef INET + case AF_INET: + (void)netdock_init(sc); + arp_ifinit(ifp, ifa); + break; +#endif + default: + (void)netdock_init(sc); + break; + } + break; + + case SIOCSIFFLAGS: + if((ifp->if_flags & IFF_UP) == 0 && + (ifp->if_flags & IFF_RUNNING) != 0){ + netdock_stop(sc); + ifp->if_flags &= ~IFF_RUNNING; + }else if((ifp->if_flags & IFF_UP) != 0 && + (ifp->if_flags & IFF_RUNNING) == 0){ + (void)netdock_init(sc); + }else{ + temp = ifp->if_flags & IFF_UP; + netdock_reset(sc); + ifp->if_flags |= temp; + netdock_start(ifp); + } + break; + + case SIOCADDMULTI: + case SIOCDELMULTI: + ifr = (struct ifreq *)data; + if(cmd == SIOCADDMULTI) + err = ether_addmulti(ifr, &sc->sc_ethercom); + else + err = ether_delmulti(ifr, &sc->sc_ethercom); + + if(err == ENETRESET){ + temp = ifp->if_flags & IFF_UP; + netdock_reset(sc); + ifp->if_flags |= temp; + err = 0; + } + break; + default: + err = EINVAL; + } + splx(s); + return(err); +} + +static void +netdock_start(ifp) + struct ifnet *ifp; +{ + struct netdock_softc *sc = ifp->if_softc; + struct mbuf *m; + + if((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) + return; + + while(1){ + IF_DEQUEUE(&ifp->if_snd, m); + if(m == 0) + return; + + if((m->m_flags & M_PKTHDR) == 0) + panic("%s: netdock_start: no header mbuf", + sc->sc_dev.dv_xname); + +#if NBPFILTER > 0 + if(ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m); +#endif + + if((netdock_put(sc, m)) == 0){ + IF_PREPEND(&ifp->if_snd, m); + return; + } + + ifp->if_opackets++; + } + +} + +static void +netdock_reset(sc) + struct netdock_softc *sc; +{ + netdock_stop(sc); + netdock_init(sc); +} + +static int +netdock_init(sc) + struct netdock_softc *sc; +{ + int s; + int saveisr; + int savetmp; + + if(sc->sc_if.if_flags & IFF_RUNNING) + return(0); + + s = splnet(); + + /* 0606 */ + NIC_PUT_2(sc, REG_000E, 0x0200); + NIC_PUT_2(sc, REG_ISR , 0); + NIC_PUT_2(sc, REG_000E, 0); + + NIC_PUT_2(sc, REG_0000, 0x8104); + NIC_PUT_2(sc, REG_0004, 0x0043); + NIC_PUT_2(sc, REG_000E, 0x0100); + NIC_PUT_2(sc, REG_0002, 0x6618); + NIC_PUT_2(sc, REG_0000, 0x8010); + + NIC_PUT_1(sc, REG_0004 + 0, sc->sc_enaddr[0]); + NIC_PUT_1(sc, REG_0004 + 1, sc->sc_enaddr[1]); + NIC_PUT_1(sc, REG_0004 + 2, sc->sc_enaddr[2]); + NIC_PUT_1(sc, REG_0004 + 3, sc->sc_enaddr[3]); + NIC_PUT_1(sc, REG_0004 + 4, sc->sc_enaddr[4]); + NIC_PUT_1(sc, REG_0004 + 5, sc->sc_enaddr[5]); + + NIC_PUT_2(sc, REG_ISR , 0x2008); + NIC_PUT_2(sc, REG_000E, 0x0200); + NIC_PUT_2(sc, REG_0000, 0x4000); + NIC_PUT_2(sc, REG_ISR, ISR_MASK); + + + /* 1320 */ + saveisr = NIC_GET_2(sc, REG_ISR); + NIC_PUT_2(sc, REG_ISR , 0); + savetmp = NIC_GET_2(sc, REG_000E); + NIC_PUT_2(sc, REG_000E, 0x0100); + NIC_ANDW(sc, REG_ISR, ~ISR_BIT_03); + NIC_PUT_2(sc, REG_000E, savetmp); + + /* 1382 */ + savetmp = NIC_GET_2(sc, REG_000E); + NIC_PUT_2(sc, REG_000E, 0x0100); + NIC_ORW(sc, REG_ISR, ISR_BIT_03); + NIC_PUT_2(sc, REG_000E, savetmp); + NIC_PUT_2(sc, REG_ISR , saveisr); + + + sc->sc_if.if_flags |= IFF_RUNNING; + sc->sc_if.if_flags &= ~IFF_OACTIVE; + + splx(s); + return(0); +} + +static int +netdock_stop(sc) + struct netdock_softc *sc; +{ + int s = splnet(); + + sc->sc_if.if_timer = 0; + sc->sc_if.if_flags &= ~(IFF_RUNNING | IFF_UP); + + splx(s); + return(0); +} + +static void +netdock_watchdog(ifp) + struct ifnet *ifp; +{ + struct netdock_softc *sc = ifp->if_softc; + int tmp; + + printf("netdock_watchdog: resetting chip\n"); + tmp = ifp->if_flags & IFF_UP; + netdock_reset(sc); + ifp->if_flags |= tmp; +} + +static __inline__ u_int +netdock_put(sc, m0) + struct netdock_softc *sc; + struct mbuf *m0; +{ + struct mbuf *m; + u_int totlen = 0; + u_int tmplen; + int isr; + int timeout; + int tmp; + u_int i; + + for(m = m0; m; m = m->m_next){ + totlen += m->m_len; + } + + if(totlen >= ETHER_MAX_LEN) + panic("%s: netdock_put: packet overflow", sc->sc_dev.dv_xname); + + totlen += 6; + tmplen = totlen; + tmplen &= 0xff00; + tmplen |= 0x2000; + NIC_PUT_2(sc, REG_0000, tmplen); + + timeout = 0x3000; + while((((isr = NIC_GET_2(sc, REG_ISR)) & ISR_READY) == 0) && timeout--){ + if(isr & ISR_TX) + netdock_txint(sc); + } + if(timeout == 0) + return(0); + + tmp = NIC_GET_2(sc, REG_0002); + tmp <<= 8; + NIC_PUT_2(sc, REG_0002, tmp); + NIC_PUT_2(sc, REG_0006, 0x240); + NIC_GET_2(sc, REG_ISR); + tmplen = ((totlen << 8) & 0xfe00) | ((totlen >> 8) & 0x00ff); + NIC_PUT_2(sc, REG_DATA, tmplen); + + for(m = m0; m; m = m->m_next){ + u_char *data = mtod(m, u_char *); + u_int len = m->m_len; + u_int len4 = len >> 2; + u_long *data4 = (u_long *)data; + for(i = 0; i < len4; i++) + NIC_PUT_4(sc, REG_DATA, data4[i]); + for(i = len4 << 2; i < len; i++) + NIC_PUT_1(sc, REG_DATA, data[i]); + } + + if(totlen & 0x01) + NIC_PUT_2(sc, REG_DATA, 0x2020); + else + NIC_PUT_2(sc, REG_DATA, 0); + + NIC_PUT_2(sc, REG_0000, 0xc000); + + m_freem(m0); + /* sc->sc_if.if_timer = 5; */ + return(totlen); +} + +void +netdock_intr(arg) + void *arg; +{ + struct netdock_softc *sc = (struct netdock_softc *)arg; + int isr; + int tmp; + + NIC_PUT_2(sc, REG_ISR, 0); + while((isr = (NIC_GET_2(sc, REG_ISR) & ISR_ALL)) != 0){ + + if(isr & ISR_TX) + netdock_txint(sc); + + if(isr & ISR_RX) + netdock_rxint(sc); + + if(isr & (ISR_BIT_0C | ISR_BIT_0D)){ + if(isr & ISR_BIT_0C){ + NIC_PUT_2(sc, REG_000E, 0); + NIC_BSET(sc, REG_0004, 0x08); + NIC_PUT_2(sc, REG_000E, 0x0200); + } + if(isr & ISR_BIT_0D){ + NIC_PUT_2(sc, REG_000E, 0); + tmp = NIC_GET_2(sc, REG_0002); + if(tmp & REG_0002_BIT_04) + NIC_GET_2(sc, REG_0006); + tmp = NIC_GET_2(sc, REG_0000); + if(tmp & REG_0000_BIT_08) + NIC_BSET(sc, REG_0000, 0x08); + NIC_PUT_2(sc, REG_000E, 0x0200); + } + NIC_PUT_2(sc, REG_ISR, isr); + } + + } + NIC_PUT_2(sc, REG_ISR, ISR_MASK); +} + +static void +netdock_txint(sc) + struct netdock_softc *sc; +{ + struct ifnet *ifp = &sc->sc_if; + int savereg0002; + int reg0004; + int regdata; + + ifp->if_flags &= ~IFF_OACTIVE; + ifp->if_timer = 0; + + savereg0002 = NIC_GET_2(sc, REG_0002); + + while(((reg0004 = NIC_GET_2(sc, REG_0004)) & REG_0004_BIT_0F) == 0){ + NIC_PUT_2(sc, REG_0002, reg0004); + NIC_PUT_2(sc, REG_0006, 0x0060); + NIC_GET_2(sc, REG_ISR); + regdata = NIC_GET_2(sc, REG_DATA); + if((regdata & REG_DATA_BIT_08) == 0){ + /* ifp->if_collisions++ */ ; + if(regdata & REG_DATA_BIT_07) + /* ifp->if_oerrors++ */ ; + NIC_PUT_2(sc, REG_000E, 0); + NIC_ORW(sc, REG_0000, 0x0100); + NIC_PUT_2(sc, REG_000E, 0x0200); + } + NIC_GET_2(sc ,REG_DATA); + + if(regdata & REG_DATA_BIT_0F){ + NIC_GET_4(sc, REG_EFD00); + } + NIC_PUT_2(sc, REG_0000, 0xa000); + NIC_PUT_2(sc, REG_ISR, ISR_TX); + } + + NIC_PUT_2(sc, REG_0002, savereg0002); + NIC_PUT_2(sc, REG_000E, 0); + NIC_GET_2(sc, REG_0006); + NIC_PUT_2(sc, REG_000E, 0x0200); + NIC_PUT_2(sc, REG_0006, 0); +} + +static void +netdock_rxint(sc) + struct netdock_softc *sc; +{ + struct ifnet *ifp = &sc->sc_if; + int regdata1; + int regdata2; + u_int len; + int timeout; + + while((NIC_GET_2(sc, REG_0004) & REG_0004_BIT_07) == 0){ + NIC_GET_2(sc, REG_ISR); + NIC_PUT_2(sc, REG_0006, 0x00e0); + NIC_GET_2(sc, REG_ISR); + regdata1 = NIC_GET_2(sc, REG_DATA); + regdata2 = NIC_GET_2(sc, REG_DATA); + len = ((regdata2 << 8) & 0x0700) | ((regdata2 >> 8) & 0x00ff); + + if((regdata1 & REG_DATA_BIT_04) == 0) + len--; + + if((regdata1 & 0x00ac) == 0){ + + if(netdock_read(sc, len)) + ifp->if_ipackets++; + else + ifp->if_ierrors++; + }else{ + ifp->if_ierrors++; + + if(regdata1 & REG_DATA_BIT_02) + NIC_GET_4(sc, REG_EFD00); + if(regdata1 & REG_DATA_BIT_03) + ; + if(regdata1 & REG_DATA_BIT_05) + NIC_GET_4(sc, REG_EFD00); + if(regdata1 & REG_DATA_BIT_07) + ; + } + + timeout = 0x14; + while((NIC_GET_2(sc, REG_0000) & REG_0000_BIT_08) && timeout--){ + } + if(timeout == 0) + ; + + NIC_PUT_2(sc, REG_0000, 0x8000); + } + NIC_PUT_2(sc, REG_0006, 0); +} + +static __inline__ int +netdock_read(sc, len) + struct netdock_softc *sc; + int len; +{ + struct ifnet *ifp = &sc->sc_if; + struct ether_header *eh; + struct mbuf *m; + + m = netdock_get(sc, len); + if(m == 0) + return(0); + + /* We assume that the header fits entirely in one mbuf. */ + eh = mtod(m, struct ether_header *); + +#if NBPFILTER > 0 + if(ifp->if_bpf) { + bpf_mtap(ifp->if_bpf, m); + if((ifp->if_flags & IFF_PROMISC) && + (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ + bcmp(eh->ether_dhost, LLADDR(ifp->if_sadl), + sizeof(eh->ether_dhost)) != 0) { + m_freem(m); + return(0); + } + } +#endif + + (*ifp->if_input)(ifp, m); + + return(1); +} + +static __inline__ struct mbuf * +netdock_get(sc, datalen) + struct netdock_softc *sc; + int datalen; +{ + struct mbuf *m, *top, **mp; + u_char *data; + u_int i; + u_int len; + u_int len4; + u_long *data4; + + MGETHDR(m, M_DONTWAIT, MT_DATA); + if(m == 0) + return(0); + m->m_pkthdr.rcvif = &sc->sc_if; + m->m_pkthdr.len = datalen; + len = MHLEN; + top = 0; + mp = ⊤ + + while(datalen > 0){ + if(top){ + MGET(m, M_DONTWAIT, MT_DATA); + if(m == 0){ + m_freem(top); + return(0); + } + len = MHLEN; + } + if(datalen >= MINCLSIZE){ + MCLGET(m, M_DONTWAIT); + if((m->m_flags & M_EXT) == 0){ + if(top) + m_freem(top); + return(0); + } + len = MCLBYTES; + } + + if(mp == &top){ + caddr_t newdata = (caddr_t) + ALIGN(m->m_data + sizeof(struct ether_header)) - + sizeof(struct ether_header); + len -= newdata - m->m_data; + m->m_data = newdata; + } + + m->m_len = len = min(datalen, len); + + data = mtod(m, u_char *); + len4 = len >> 2; + data4 = (u_long *)data; + for(i = 0; i < len4; i++) + data4[i] = NIC_GET_4(sc, REG_DATA); + for(i = len4 << 2; i < len; i++) + data[i] = NIC_GET_1(sc, REG_DATA); + + datalen -= len; + *mp = m; + mp = &m->m_next; + } + + return(top); +} + --- /dev/null Tue Apr 25 05:02:03 2000 +++ conf/DUOTEST Tue Apr 18 04:32:55 2000 @@ -0,0 +1,274 @@ +# $NetBSD: GENERIC,v 1.99 2000/03/31 08:27:43 scottr Exp $ +# +# GENERIC + +include "arch/mac68k/conf/std.mac68k" + +#ident "GENERIC-$Revision: 1.99 $" + +maxusers 16 # estimated number of users + +# CPU support. At least one is REQUIRED. +options M68040 +options M68030 +options M68020 # Note: must have 68851 PMMU + +# CPU-related options. +options FPSP +options FPU_EMULATE + +# Standard system options + +options UCONSOLE # users can use TIOCCONS (for xconsole) +options INSECURE # disable kernel security levels + +options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT +#options NTP # NTP phase/frequency locked loop + +options KTRACE # system call tracing via ktrace(1) + +options SYSVMSG # System V-like message queues +options SYSVSEM # System V-like semaphores +options SYSVSHM # System V-like memory sharing +#options SHMMAXPGS=1024 # 1024 pages is the default + +options LKM # loadable kernel modules + +# Diagnostic/debugging support options +options DIAGNOSTIC # cheap kernel consistency checks +#options DEBUG # expensive debugging checks/support +options KMEMSTATS # kernel memory statistics (vmstat -m) +options DDB # in-kernel debugger +#options DDB_HISTORY_SIZE=100 # enable history editing in DDB +#options KGDB # remote debugger +#options KGDBDEV=0xc01 # kgdb device number (dev_t) +#options KGDBRATE=38400 # baud rate +#makeoptions DEBUG="-g" # compile full symbol table + +# Compatibility options +#options COMPAT_NOMID # compatibility with 386BSD, BSDI, NetBSD 0.8, +#options COMPAT_09 # NetBSD 0.9, +options COMPAT_10 # NetBSD 1.0, +options COMPAT_11 # NetBSD 1.1, +options COMPAT_12 # NetBSD 1.2, +options COMPAT_13 # NetBSD 1.3, +options COMPAT_14 # NetBSD 1.4, +options COMPAT_43 # and 4.3BSD + +options COMPAT_SUNOS # compatibility with SunOS 4.x binaries +#options COMPAT_SVR4 # compatibility with SVR4 binaries +#options COMPAT_M68K4K # compatibility with NetBSD/m68k4k binaries +#options COMPAT_LINUX # compatibility with Linux/m68k binaries +#options EXEC_ELF32 # 32-bit ELF executables (Linux, SVR4) + +# File systems +file-system FFS # UFS +file-system EXT2FS # second extended file system (linux) +file-system LFS # log-structured file system +file-system MFS # memory file system +file-system NFS # Network File System client +file-system CD9660 # ISO 9660 + Rock Ridge file system +file-system MSDOSFS # MS-DOS file system +file-system FDESC # /dev/fd +file-system KERNFS # /kern +file-system NULLFS # loopback file system +file-system OVERLAY # overlay file system +file-system PORTAL # portal filesystem (still experimental) +file-system PROCFS # /proc +file-system UMAPFS # NULLFS + uid and gid remapping +file-system UNION # union file system +file-system CODA # Venus/Coda distributed file system + +# File system options +options QUOTA # UFS quotas +#options FFS_EI # FFS Endian Independant support +#options SOFTDEP # FFS soft updates support. +options NFSSERVER # Network File System server +#options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and + # immutable) behave as system flags. + +# Pull in config fragments for kernel crypto. This is required for +# options IPSEC etc. to work. If you want to run with IPSEC, uncomment +# one of these, based on whether you use crypto-us or crypto-intl, and +# adjust the prefixes as necessary. + +#prefix ../crypto-us/sys +#cinclude "conf/files.crypto-us" +#prefix + +#prefix ../crypto-intl/sys +#cinclude "conf/files.crypto-intl" +#prefix + +# Networking options +options GATEWAY # packet forwarding +options INET # IP + ICMP + TCP + UDP +options INET6 # IPV6 +#options IPSEC # IP security +#options IPSEC_ESP # IP security (encryption part; define w/IPSEC) +#options IPSEC_DEBUG # debug for IP security +#options MROUTING # IP multicast routing +options NS # XNS +#options NSIP # XNS tunneling over IP +options ISO,TPIP # OSI +options EON # OSI tunneling over IP +options CCITT,LLC,HDLC # X.25 +options NETATALK # AppleTalk networking protocols +options PPP_BSDCOMP # BSD-Compress compression support for PPP +options PPP_DEFLATE # Deflate compression support for PPP +options PPP_FILTER # Active filter support for PPP (requires bpf) +options PFIL_HOOKS # pfil(9) packet filter hooks + +# Compatibility with 4.2BSD implementation of TCP/IP. Not recommended. +#options TCP_COMPAT_42 + +# These options enable verbose messages for several subsystems. +# Warning, these may compile large string tables into the kernel! +options SCSIVERBOSE # human readable SCSI error messages + +# wscons options +#options WSEMUL_SUN # sun terminal emulation +options WSEMUL_VT100 # VT100 / VT220 emulation +options WSDISPLAY_COMPAT_ITEFONT # use ite font (6x10) + +# rcons options; note that 1-bit and 8-bit displays are supported by default. +options RCONS_2BPP # Support for 2-bit display +options RCONS_4BPP # Support for 4-bit display +options RCONS_16BPP # Support for 16-bit display + +# Mac-specific options +#options ALTXBUTTONS # Map Opt-{1,2,3} to mouse buttons +#options DISABLE_EXT_CACHE # If really paranoid, disable IIci ext. cache +options GRF_COMPAT # Include grf compatibility code +#options MRG_ADB # Use ROM-based ADB driver +options ZS_CONSOLE_ABORT + +options NFS_BOOT_DHCP + +# Kernel root file system and dump configuration. +config netbsd root on ? type ? + +# +# Device configuration +# + +mainbus0 at root + +fpu0 at mainbus? # Floating-Point Coprocessor support + + +# Basic Bus Support + +# On-board I/O bus support +obio0 at mainbus? + +# NuBus support +nubus0 at mainbus? + + +# Console Devices + +# Apple Desktop Bus interface +adb0 at obio? +aed* at adb? # ADB event device +akbd* at adb? # ADB keyboard +ams* at adb? # ADB mouse + +# Basic frame buffer support +intvid0 at obio? # Internal video hardware +macvid* at nubus? # NuBus video card + +# Device-independent frame buffer interface +macfb* at intvid? +macfb* at macvid? + +# Workstation Console devices +wsdisplay* at macfb? console ? +wskbd* at akbd? console ? +wsmouse* at ams? + + +# Serial Devices + +# On-board serial interface +zsc0 at obio? +zstty* at zsc? channel ? + + +# SCSI Controllers and Devices + +# SCSI controllers +# XXX - use only one of ncrscsi or sbc +#ncrscsi0 at obio? # SCSI NCR 5380 +sbc0 at obio? flags 0x1 # MI SCSI NCR 5380 +esp0 at obio? # SCSI NCR 53C9x +esp1 at obio? # SCSI NCR 53C9x + +# SCSI bus support +scsibus* at scsi? + +# SCSI devices +sd* at scsibus? target ? lun ? # SCSI disk drives +st* at scsibus? target ? lun ? # SCSI tape drives +cd* at scsibus? target ? lun ? # SCSI CD-ROM drives +ch* at scsibus? target ? lun ? # SCSI autochangers +se* at scsibus? target ? lun ? # SCSI ethernet +ss* at scsibus? target ? lun ? # SCSI scanners +uk* at scsibus? target ? lun ? # SCSI unknown + + +# Miscellaneous mass storage devices + +# IWM floppy disk controller +iwm0 at obio? # Sony driver (800K GCR) +fd* at iwm? drive ? + + +# Network Interfaces + +# On-board Ethernet controllers +sn* at obio? # SONIC-based (DP83932, DP83916) +mc* at obio? # MACE-based + +# NuBus Ethernet controllers +ae* at nubus? # DP8390-based +sn* at nubus? # SONIC-based (DP83932, DP83916) +netdock* at nubus? # Asante NetDock + + +# Audio Devices + +# On-board audio hardware +asc0 at obio? # ASC/EASC audio + +# Pseudo-Devices + +# disk/mass storage pseudo-devices +pseudo-device ccd 4 # concatenated/striped disk devices +#pseudo-device raid 4 # RAIDframe disk driver +#options RAID_AUTOCONFIG # auto-configuration of RAID components +pseudo-device md 1 # memory disk device (ramdisk) +pseudo-device vcoda 1 # Venus/Coda distributed file system +pseudo-device vnd 4 # disk-like interface to files + +# network pseudo-devices +pseudo-device bpfilter 12 # Berkeley packet filter +pseudo-device ipfilter # IP filter (firewall) and NAT +pseudo-device loop # network loopback +pseudo-device ppp 2 # Point-to-Point Protocol +pseudo-device sl 2 # Serial Line IP +#pseudo-device strip 2 # Starmode Radio IP (Metricom) +pseudo-device tun 2 # network tunneling over tty +#pseudo-device gre 2 # generic L3 over IP tunnel +pseudo-device gif 4 # IPv[46] over IPv[46] tunnel (RFC1933) +#pseudo-device faith 1 # IPv[46] tcp relay translation i/f + +# miscellaneous pseudo-devices +pseudo-device grf 2 # grf emulation for wscons +pseudo-device ite 1 # ite emulation for wscons +pseudo-device pty 64 # pseudo-terminals +#pseudo-device tb 1 # tablet line discipline + +# rnd is EXPERIMENTAL at this point. +#pseudo-device rnd # /dev/random and in-kernel generator +#options RND_COM # use "com" randomness as well (BROKEN) --- conf/files.mac68k.orig Tue Mar 28 04:16:58 2000 +++ conf/files.mac68k Mon Apr 10 07:27:17 2000 @@ -90,6 +90,10 @@ file arch/mac68k/obio/if_sn_obio.c sn_obio file arch/mac68k/nubus/if_sn_nubus.c sn_nubus +device netdock: ifnet, ether, arp +attach netdock at nubus with netdock_nubus +file arch/mac68k/nubus/if_netdock_nubus.c netdock_nubus + # Sony floppy disk controller device iwm { drive = -1 } attach iwm at obio_norm