Subject: ed improvements
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: James Jegers <jimj@miller.cs.uwm.edu>
List: current-users
Date: 04/16/1994 12:26:08
  Here are some patches to the ed0 driver to allow the selection of 
  which ethernet port to use.  I am currently using it on my Accton
  16bit 3port card and can switch between all of ports.

-------------------- insert these lines in edreg.h ----------


#define ED_P0_CRA	0x0a	/* Read, Write only after just reading */
#define ED_P0_CRB 	0x0b	/* Read, Write only after just reading */

/* Control Register B bit positions */
#define ED_CRB_CTPI	0x00	/* TPI (10BASE-T) compatible squelch */
#define ED_CRB_THIN	0x01	/* Thin Ethernet (10BASE2) */
#define ED_CRB_THICK	0x02	/* Thick Ethernet (10BASE5) (AUI) */
#define ED_CRB_RTPI	0x03	/* TPI (10BASE-T) reduced squelch */
#define ED_CRB_GDLNK	0X04	/* Good Link */
#define ED_CRB_IO16CON	0x08	/* IO16 control */
#define ED_CRB_CHRDY	0x10	/* CHRDY from IORD or IOWR or from BALE */
#define ED_CRB_BE	0x20	/* Bus error detected */
#define ED_CRB_BPWR	0x40	/* Boot prom write */
#define ED_CRB_EELOAD	0x80	/* EEPROM load */

-------------------- add these lines to ed.c ----------

	/*
	 * Enable the following interrupts: receive/transmit complete,
	 * receive/transmit error, and Receiver OverWrite.
	 *
	 * Counter overflow and Remote DMA complete are *not* enabled.
	 */
	outb(sc->nic_addr + ED_P0_IMR,
	    ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE |
	    ED_IMR_OVWE);
---new section---
	/* 
	**  Set which ethernet port to use. If none of the LINK's are
	**  set then we won't touch anything and use whatever the cards
	**  EEPROM/hardware is set for.
	**  Control Reg A/B are hidden registers which can only be 
	**  written to if they were just read from.  
	**  User LINK options are:
	**  link0 enable 10 base 2 (BNC thin)
	**  link1 enable 10 base 5 (AUI 15 pin thick)
	**  link2 enable 10 base T (UTP normal twisted pair)
	*/

	if (ifp->if_flags & IFF_LINK0 || 
	    ifp->if_flags & IFF_LINK1 || 
	    ifp->if_flags & IFF_LINK2)
	{
		int crb;

		/* Read in control register B */
		crb = inb(sc->nic_addr + ED_P0_CRB);

		/* Ignore the Good LINK bit */
		crb = crb & (~ED_CRB_GDLNK);

		/* Zero out bits 0 and 1 */
		crb &= 0x0c; 

		if (ifp->if_flags & IFF_LINK0)		/* Thin net */
			crb |= ED_CRB_THIN;
		else if (ifp->if_flags & IFF_LINK1)	/* Thick net */
			crb |= ED_CRB_THICK;
		else if (ifp->if_flags & IFF_LINK2)	/* Normal Twisted pair*/
			crb |= ED_CRB_CTPI;

		/* Write the new setup */
		outb(sc->nic_addr + ED_P0_CRB, crb);
	}
----end new section
	/* Program command register for page 1. */
	outb(sc->nic_addr + ED_P0_CR,
	    ED_CR_PAGE_1 | ED_CR_STP | sc->ed_cr_rd2);

	/* Copy out our station address. */
	for (i = 0; i < ETHER_ADDR_LEN; ++i)
		outb(sc->nic_addr + ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);

	/* Set multicast filter on chip. */
	ed_getmcaf(&sc->sc_arpcom, mcaf);

-----------------------  new man page improvement ------

The default port to use is the one configured in the 8390. To choose an 
alternate port, use the following flag combinations with
.Xr ifconfig 8,
or in your /etc/hostname.ed? file.
.Pp 
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
.It link0 -link1 -link2
Use the BNC port.
.It -link0 link1 -link2
Use the AUI port.
.It -link0 -link1 link2
Use the UTP port.
.El



------------------------------------------------------------------------------