Subject: lance in 3400
To: Robin Birch <robin@falstaf.demon.co.uk>
From: Bertram Barth <bertram@gummo.bbb.sub.org>
List: port-vax
Date: 02/06/1997 10:49:51
> Well, I have a problem here.  All of the implementations of Le
> interfaces on VS or DS systems appear to refer to a static lump of RAM
> called the NIBUFFER.  I've looked in a DS3100 manual and there it is,
> large as life.  Well, I trolled through the ka640 manual and there is no
> mention of this apart from an oblique reference in the monitor
> documentaion.  The device driver appears to want too be passed the
> address of a lump of RAM set up in user space.
> 
> So, can someone confirm this?.  If this is so then what I intend to do
> is:
>         allocate a 64kByte lump of RAM at the top of available memory.

Easiest done in xxx_steal_pages():
- Make avail_end having the correct alignment (64K is overkill but save):
        avail_end &= ~0xffff;           /* make avail_end 64K-aligned */
- Subtract the space you need from avail_end and now avail_end is
  the base-address of your iobuf: 
        avail_end -= (64 * 1024);       /* steal 64K for LANCE's iobuf */

>         find it's physical address at the time of allocation.

in ka410.c/if_le.c I'm using the name "le_ioaddr" for that:
        le_ioaddr = avail_end;          /* ioaddr=phys, iomem=virt */

>         map it into the kernel's virtual memory space.

I'm using the name "le_iomem" for that:
        MAPVIRT(le_iomem, (64 * 1024)/NBPG);
        pmap_map((vm_offset_t)le_iomem, le_ioaddr, le_ioaddr + 0xffff,
                 VM_PROT_READ|VM_PROT_WRITE);

>         send the phys address to the device driver.

for VS2000 both "le_iomem" and "le_ioaddr" are given to the MI driver:
        sc->sc_am7990.sc_mem = le_iomem;
        sc->sc_am7990.sc_addr = le_ioaddr;

> If this is wrong then can someone either tell me where the NIBUFF is on
> the ka640 or suggest a different method.

I don't know for ka640, but ka410 and ka43 don't have NIBUFF. 
Since ka640 is more similiar to them than to DS3100...

> BTW.  In the if_le.c code in le_attach there is a line:
> 
>         sc->sc_r1 = (void *)uvax_phys2virt(ca->ca_ioaddr);
> 
> What does this line do?.  Perhaps Bertram can help me here?.

VS2000/VS3100 have their device's IO-ports mapped into physical memory.
During setup all the interesting/needed physical addresses are mapped
into virtual memory and these mappings are kept in a table. 
uvax_phys2virt() extracts and returns the virtual address for the
physical address given as argument from this table.

BTW: Here ka640 (Q-bus) and ka410 ("busless") are different!
     For ka640 you'll need the qbus-routines to access the lance's IO-port.

Ciao,
	bertram