sys/dev/ed/if_ed_novell.c
/*
 * Probe and vendor-specific initialization routine for NE1000/2000 boards
 */
Probe and vendor-specific initialization routine for NE1000/2000 boards
Probe and vendor - specific initialization routine for NE1000 / 2000 boards
int
ed_probe_Novell_generic(device_t dev, int flags)
{
	struct ed_softc *sc = device_get_softc(dev);
	u_int   memsize;
	int	error;
	u_char  tmp;
	static char test_pattern[32] = "THIS is A memory TEST pattern";
	char    test_buffer[32];
	if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) {
		ed_asic_outb(sc, ED_NOVELL_RESET, 0);
		DELAY(200);
	}
	tmp = ed_asic_inb(sc, ED_NOVELL_RESET);
	ed_asic_outb(sc, ED_NOVELL_RESET, tmp);
	DELAY(5000);
	ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP);
	DELAY(5000);
	if (!ed_probe_generic8390(sc))
		return (ENXIO);
	sc->vendor = ED_VENDOR_NOVELL;
	sc->mem_shared = 0;
	sc->cr_proto = ED_CR_RD2;
	ed_nic_outb(sc, ED_P0_RCR, ED_RCR_MON);
	ed_nic_outb(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
	ed_nic_outb(sc, ED_P0_PSTART, 8192 / ED_PAGE_SIZE);
	ed_nic_outb(sc, ED_P0_PSTOP, 16384 / ED_PAGE_SIZE);
	if (flags & ED_FLAGS_FORCE_8BIT_MODE) {
		sc->isa16bit = 0;
		sc->type = ED_TYPE_NE1000;
		sc->type_str = "NE1000";
	} else if (flags & ED_FLAGS_FORCE_16BIT_MODE) {
		sc->isa16bit = 1;
		sc->type = ED_TYPE_NE2000;
		sc->type_str = "NE2000";
		ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
		ed_nic_outb(sc, ED_P0_PSTART, 16384 / ED_PAGE_SIZE);
		ed_nic_outb(sc, ED_P0_PSTOP, 32768 / ED_PAGE_SIZE);
	} else {
		ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern));
		ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern));
		if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) == 0) {
			sc->type = ED_TYPE_NE1000;
			sc->type_str = "NE1000";
			sc->isa16bit = 0;
		} else {
			sc->isa16bit = 1;
			ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
			ed_nic_outb(sc, ED_P0_PSTART, 16384 / ED_PAGE_SIZE);
			ed_nic_outb(sc, ED_P0_PSTOP, 32768 / ED_PAGE_SIZE);
			ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern));
			ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
			if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) == 0) {
				sc->type = ED_TYPE_NE2000;
				sc->type_str = "NE2000";
			} else {
				return (ENXIO);
			}
		}
	}
	sc->chip_type = ED_CHIP_TYPE_DP8390;
	memsize = 8192 + sc->isa16bit * 8192;
	sc->mem_size = memsize;
	sc->mem_start = 8192 + sc->isa16bit * 8192;
	sc->mem_end = sc->mem_start + memsize;
	sc->tx_page_start = memsize / ED_PAGE_SIZE;
	if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) {
		error = ed_probe_gwether(dev);
		if (error)
			return (error);
	}
	if ((memsize < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING))
		sc->txb_cnt = 1;
	else
		sc->txb_cnt = 2;
	sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
	sc->rec_page_stop = sc->tx_page_start + memsize / ED_PAGE_SIZE;
	sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE;
	ed_nic_outb(sc, ED_P0_ISR, 0xff);
	sc->sc_write_mbufs = ed_pio_write_mbufs;
	return (0);
}
int ed_probe_Novell_generic ( device_t dev , int flags ) { struct ed_softc * sc = device_get_softc ( dev ) ; u_int memsize ; int error ; u_char tmp ; static char test_pattern [ 32 ] = " " ; char test_buffer [ 32 ] ; if ( ED_FLAGS_GETTYPE ( flags ) == ED_FLAGS_GWETHER ) { ed_asic_outb ( sc , ED_NOVELL_RESET , 0 ) ; DELAY ( 200 ) ; } tmp = ed_asic_inb ( sc , ED_NOVELL_RESET ) ; ed_asic_outb ( sc , ED_NOVELL_RESET , tmp ) ; DELAY ( 5000 ) ; ed_nic_outb ( sc , ED_P0_CR , ED_CR_RD2 | ED_CR_STP ) ; DELAY ( 5000 ) ; if ( ! ed_probe_generic8390 ( sc ) ) return ( ENXIO ) ; sc -> vendor = ED_VENDOR_NOVELL ; sc -> mem_shared = 0 ; sc -> cr_proto = ED_CR_RD2 ; ed_nic_outb ( sc , ED_P0_RCR , ED_RCR_MON ) ; ed_nic_outb ( sc , ED_P0_DCR , ED_DCR_FT1 | ED_DCR_LS ) ; ed_nic_outb ( sc , ED_P0_PSTART , 8192 / ED_PAGE_SIZE ) ; ed_nic_outb ( sc , ED_P0_PSTOP , 16384 / ED_PAGE_SIZE ) ; if ( flags & ED_FLAGS_FORCE_8BIT_MODE ) { sc -> isa16bit = 0 ; sc -> type = ED_TYPE_NE1000 ; sc -> type_str = " " ; } else if ( flags & ED_FLAGS_FORCE_16BIT_MODE ) { sc -> isa16bit = 1 ; sc -> type = ED_TYPE_NE2000 ; sc -> type_str = " " ; ed_nic_outb ( sc , ED_P0_DCR , ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS ) ; ed_nic_outb ( sc , ED_P0_PSTART , 16384 / ED_PAGE_SIZE ) ; ed_nic_outb ( sc , ED_P0_PSTOP , 32768 / ED_PAGE_SIZE ) ; } else { ed_pio_writemem ( sc , test_pattern , 8192 , sizeof ( test_pattern ) ) ; ed_pio_readmem ( sc , 8192 , test_buffer , sizeof ( test_pattern ) ) ; if ( bcmp ( test_pattern , test_buffer , sizeof ( test_pattern ) ) == 0 ) { sc -> type = ED_TYPE_NE1000 ; sc -> type_str = " " ; sc -> isa16bit = 0 ; } else { sc -> isa16bit = 1 ; ed_nic_outb ( sc , ED_P0_DCR , ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS ) ; ed_nic_outb ( sc , ED_P0_PSTART , 16384 / ED_PAGE_SIZE ) ; ed_nic_outb ( sc , ED_P0_PSTOP , 32768 / ED_PAGE_SIZE ) ; ed_pio_writemem ( sc , test_pattern , 16384 , sizeof ( test_pattern ) ) ; ed_pio_readmem ( sc , 16384 , test_buffer , sizeof ( test_pattern ) ) ; if ( bcmp ( test_pattern , test_buffer , sizeof ( test_pattern ) ) == 0 ) { sc -> type = ED_TYPE_NE2000 ; sc -> type_str = " " ; } else { return ( ENXIO ) ; } } } sc -> chip_type = ED_CHIP_TYPE_DP8390 ; memsize = 8192 + sc -> isa16bit * 8192 ; sc -> mem_size = memsize ; sc -> mem_start = 8192 + sc -> isa16bit * 8192 ; sc -> mem_end = sc -> mem_start + memsize ; sc -> tx_page_start = memsize / ED_PAGE_SIZE ; if ( ED_FLAGS_GETTYPE ( flags ) == ED_FLAGS_GWETHER ) { error = ed_probe_gwether ( dev ) ; if ( error ) return ( error ) ; } if ( ( memsize < 16384 ) || ( flags & ED_FLAGS_NO_MULTI_BUFFERING ) ) sc -> txb_cnt = 1 ; else sc -> txb_cnt = 2 ; sc -> rec_page_start = sc -> tx_page_start + sc -> txb_cnt * ED_TXBUF_SIZE ; sc -> rec_page_stop = sc -> tx_page_start + memsize / ED_PAGE_SIZE ; sc -> mem_ring = sc -> mem_start + sc -> txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE ; ed_nic_outb ( sc , ED_P0_ISR , 0xff ) ; sc -> sc_write_mbufs = ed_pio_write_mbufs ; return ( 0 ) ; }
Probe and vendor-specific initialization routine for NE1000/2000 boards
Probe and vendor - specific initialization routine for NE1000 / 2000 boards
/* Reset the board */ /*
	 * I don't know if this is necessary; probably cruft leftover from
	 * Clarkson packet driver code. Doesn't do a thing on the boards I've
	 * tested. -DG
	 */ /*
	 * This is needed because some NE clones apparently don't reset the
	 * NIC properly (or the NIC chip doesn't reset fully on power-up) XXX
	 * - this makes the probe invasive! ...Done against my better
	 * judgement. -DLG
	 */ /* Make sure that we really have an 8390 based board */ /*
	 * Test the ability to read and write to the NIC memory. This has the
	 * side affect of determining if this is an NE1000 or an NE2000.
	 */ /*
	 * This prevents packets from being stored in the NIC memory when the
	 * readmem routine turns on the start bit in the CR.
	 */ /* Temporarily initialize DCR for byte operations */ /*
	 * Some devices identify themselves.  Some of those devices
	 * can't handle being probed, so we allow forcing a mode.  If
	 * these flags are set, force it, otherwise probe.
	 */ /*
		 * Write a test pattern in byte mode. If this fails, then there
		 * probably isn't any memory at 8k - which likely means that the board
		 * is an NE2000.
		 */ /* Not an NE1000 - try NE2000 */ /*
			 * Write a test pattern in word mode. If this also fails, then
			 * we don't know what this board is.
			 */ /* 8k of memory plus an additional 8k if 16bit */ /* NIC memory doesn't start at zero on an NE board */ /* The start address is tied to the bus width */ /*
	 * Use one xmit buffer if < 16k, two buffers otherwise (if not told
	 * otherwise).
	 */ /* clear any pending interrupts that might have occurred above */