Пример #1
0
/*
**  Name:	void ne_close(dpeth_t * dep);
**  Function:	Stops the board by resetting it and masking interrupts.
*/
static void ne_close(dpeth_t * dep)
{

  (void)ne_reset(dep);
  outb_ne(dep, DP_ISR, 0xFF);
  sys_irqdisable(&dep->de_hook);
  return;
}
Пример #2
0
/**************************************************************************
 NE_DISABLE - Turn off adapter
 **************************************************************************/
static void ne_disable(struct nic *nic, struct isa_device *isa) {
	ne_reset(nic, isa);
}
Пример #3
0
/*
**  Name:	int ne_probe(dpeth_t * dep);
**  Function:	Probe for the presence of a NE*000 card by testing
**  		whether the board is reachable through the dp8390.
**  		Note that the NE1000 is an 8bit card and has a memory
**  		region distict from the 16bit NE2000.
*/
int ne_probe(dpeth_t * dep)
{
  int ix, wd, loc1, loc2;
  char EPROM[32];
  static const struct {
	unsigned char offset;
	unsigned char value;
  } InitSeq[] =
  {
	{	/* Selects page 0. */
		DP_CR, (CR_NO_DMA | CR_PS_P0 | CR_STP),
	},
	{	/* Set byte-wide access and 8 bytes burst mode. */
		DP_DCR, (DCR_8BYTES | DCR_BMS), 
	},
	{	/* Clears the count registers. */
		DP_RBCR0, 0x00, }, {	DP_RBCR1, 0x00,
	},
	{	/* Mask completion irq. */
		DP_IMR, 0x00, }, {	DP_ISR, 0xFF,
	},
	{	/* Set receiver to monitor */
		DP_RCR, RCR_MON, 
	},
	{	/* and transmitter to loopback mode. */
		DP_TCR, TCR_INTERNAL, 
	},
	{	/* Transmit 32 bytes */
		DP_RBCR0, 32, }, { DP_RBCR1, 0,
	},
	{	/* DMA starting at 0x0000. */
		DP_RSAR0, 0x00, }, { DP_RSAR1, 0x00,
	},
	{			/* Start board (reads) */
		DP_CR, (CR_PS_P0 | CR_DM_RR | CR_STA),
	},
  };

  dep->de_dp8390_port = dep->de_base_port + NE_DP8390;

  if ((loc1 = inb_ne(dep, NE_DP8390)) == 0xFF) return FALSE;

  /* Check if the dp8390 is really there */
  outb_ne(dep, DP_CR, CR_STP | CR_NO_DMA | CR_PS_P1);
  loc2 = inb_ne(dep, DP_MAR5);	/* Saves one byte of the address */
  outb_ne(dep, DP_MAR5, 0xFF);	/* Write 0xFF to it (same offset as DP_CNTR0) */
  outb_ne(dep, DP_CR, CR_NO_DMA | CR_PS_P0);	/* Back to page 0 */
  inb_ne(dep, DP_CNTR0);	/* Reading counter resets it */
  if (inb_ne(dep, DP_CNTR0) != 0) {
	outb_ne(dep, NE_DP8390, loc1);	/* Try to restore modified bytes */
	outb_ne(dep, DP_TCR, loc2);
	return FALSE;
  }

  /* Try to reset the board */
  if (ne_reset(dep) == FALSE) return FALSE;

  /* Checks whether the board is 8/16bits and a real NE*000 or clone */
  for (ix = 0; ix < sizeof(InitSeq)/sizeof(InitSeq[0]); ix += 1) {
	outb_ne(dep, InitSeq[ix].offset, InitSeq[ix].value);
  }
  for (ix = 0, wd = 1; ix < 32; ix += 2) {
	EPROM[ix + 0] = inb_ne(dep, NE_DATA);
	EPROM[ix + 1] = inb_ne(dep, NE_DATA);
	/* NE2000s and clones read same value for even and odd addresses */
	if (EPROM[ix + 0] != EPROM[ix + 1]) wd = 0;
  }
  if (wd == 1) {	/* Normalize EPROM contents for NE2000 */
	for (ix = 0; ix < 16; ix += 1) EPROM[ix] = EPROM[ix * 2];
  }
  /* Real NE*000 and good clones have '0x57' at locations 14 and 15 */
  if (EPROM[14] != 0x57 || EPROM[15] != 0x57) return FALSE;

  /* Setup the ethernet address. */
  for (ix = 0; ix < SA_ADDR_LEN; ix += 1) {
	dep->de_address.ea_addr[ix] = EPROM[ix];
  }
  dep->de_16bit = wd;
  dep->de_linmem = 0;		/* Uses Programmed I/O only */
  dep->de_prog_IO = 1;
  dep->de_initf = ne_init;
  dep->de_stopf = ne_close;
  return TRUE;
}
Пример #4
0
/**************************************************************************
 NE_PROBE - Initialize an adapter ???
 **************************************************************************/
static int ne_probe(struct nic *nic, struct isa_device *isa) {
	int i;
	unsigned char c;
	unsigned char romdata[16];
	unsigned char testbuf[32];

	eth_vendor = VENDOR_NONE;
	eth_drain_receiver = 0;

	nic->irqno = 0;
	nic->ioaddr = isa->ioaddr;
	eth_nic_base = isa->ioaddr;

	/******************************************************************
	 Search for NE1000/2000 if no WD/SMC or 3com cards
	 ******************************************************************/
	if (eth_vendor == VENDOR_NONE) {

		static unsigned char test[] = "NE*000 memory";

		eth_bmem = 0; /* No shared memory */

		eth_flags = FLAG_PIO;
		eth_asic_base = eth_nic_base + NE_ASIC_OFFSET;
		eth_memsize = MEM_16384;
		eth_tx_start = 32;
		eth_rx_start = 32 + D8390_TXBUF_SIZE;
		c = inb(eth_asic_base + NE_RESET);
		outb(c, eth_asic_base + NE_RESET);
		(void) inb(0x84);
		outb(D8390_COMMAND_STP | D8390_COMMAND_RD2, eth_nic_base
				+ D8390_P0_COMMAND);
		outb(D8390_RCR_MON, eth_nic_base + D8390_P0_RCR);
		outb(D8390_DCR_FT1 | D8390_DCR_LS, eth_nic_base + D8390_P0_DCR);
		outb(MEM_8192, eth_nic_base + D8390_P0_PSTART);
		outb(MEM_16384, eth_nic_base + D8390_P0_PSTOP);
		eth_pio_write((unsigned char *) test, 8192, sizeof(test));
		eth_pio_read(8192, testbuf, sizeof(test));
		if (!memcmp(test, testbuf, sizeof(test)))
			goto out;
		eth_flags |= FLAG_16BIT;
		eth_memsize = MEM_32768;
		eth_tx_start = 64;
		eth_rx_start = 64 + D8390_TXBUF_SIZE;
		outb(D8390_DCR_WTS | D8390_DCR_FT1 | D8390_DCR_LS, eth_nic_base
				+ D8390_P0_DCR);
		outb(MEM_16384, eth_nic_base + D8390_P0_PSTART);
		outb(MEM_32768, eth_nic_base + D8390_P0_PSTOP);
		eth_pio_write((unsigned char *) test, 16384, sizeof(test));
		eth_pio_read(16384, testbuf, sizeof(test));
		if (!memcmp(testbuf, test, sizeof(test)))
			goto out;


out:
		if (eth_nic_base == 0)
			return (0);
		if (eth_nic_base > ISA_MAX_ADDR) /* PCI probably */
			eth_flags |= FLAG_16BIT;
		eth_vendor = VENDOR_NOVELL;
		eth_pio_read(0, romdata, sizeof(romdata));
		for (i = 0; i < ETH_ALEN; i++) {
			nic->node_addr[i] = romdata[i + ((eth_flags & FLAG_16BIT) ? i : 0)];
		}
		nic->ioaddr = eth_nic_base;
		DBG("\nNE%c000 base %4.4x, MAC Addr %s\n",
				(eth_flags & FLAG_16BIT) ? '2' : '1', eth_nic_base, eth_ntoa(
						nic->node_addr));
	}

	if (eth_vendor == VENDOR_NONE)
		return (0);

	if (eth_vendor != VENDOR_3COM)
		eth_rmem = eth_bmem;

	ne_reset(nic, isa);
	nic->nic_op = &ne_operations;
	return 1;
}