ETHERNEA.TXT                                         ThR
                                              2001-01-24


General

When designing this ethernet solution for the Atari ST I had the
following objectives:

- no need to open the Atari thus use of an external port of 
the Atari
- use of readily available standard ethernet hardware
- as simple as possible interface hardware
- as fast and compact driver software as possible.

I choose the ACSI port and standard NE2000 compatible ethernet 
cards for the PC-ISA slot.

I designed a simple interface to generate the signals for a 8-
bit ISA connector from the ACSI bus. Although the NE2000 cards 
are 16-bit cards they work also in an 8-bit slot. Please note 
that the interface only provides for the signals necessary for 
the NE2000; it does not provide a generally usable ISA slot.


Hardware circuit description

The interface circuit is directly connected to the ACSI port. 
It does not provide any buffering. Thus the cable to the ACSI 
shall be short (50cm). If another device is hooked to the ACSI 
bus please connect the interface to the ACSI output of that
device.

The ISA port is hardwired to work at an IO address of 0x300.
When writing to the ACSI bus and ACSI-A1 was set Low the 
'02 NOR gate output gets HI and the '373 latches the ACSI port 
address in the upper three bits and the lower 5 bits to be 
used as the lowest 5 bits of the ISA IO address. The '138 
decodes the ACSI-port address. The jumpers J1, J2, J3 allow to 
set the ACSI port address of the interface. Note that J3 
selects the ACSI port address from either 0 to 3 or 4 to 7. J1 
and J2 must be set consistently to choose from 0,1,2,3 or 
4,5,6,7 depending on J3.

In the prototyping phase it turned out that reads and writes 
to the ACSI port are too fast for the read and write cycles of 
NE2000 cards. As there is no capability to prolong the read or 
write cycles for single byte reads or writes on the ACSI bus, 
quite an unusual hardware solution was employed. A1 low will 
also set the two d-flip-flops '74 to a known initial state (no 
ISA read or write). The first write to the ACSI port will 
initiate an ISA write and the second ACSI write will terminate 
the ISA write. Similar procedure is done for reads.

The third NOR gate '02 is used to invert the ACSI ~RESET to 
the RESET signal needed on the ISA bus.

The forth '02 is simply used to generate a logical HI signal 
to connect to inputs that require a constant logical HI level. 
This is safer than connecting the inputs to +5 Volt in case of 
accidental short circuits on the board or during testing 
measurements (a short circuit of an output to +5 Volt is 
usually lethal to that IC).

I built the interface prototype in wire wrap technique. As the
interface is simple, a one-sided printed circuit board layout
should be possible. Please note that if you develop such a
printed cicuit board layout for this interface you must also
publish it under the public under the GNU public license and send
it to me so that I can include it into this package.

A NE2000 compatible card requires both +5 Volts and +12 Volts 
supplies. The interface needs +5 Volts. As my Atari ST is 
housed in a tower cabinet I connected the hardware to a power
connector of the standard power supply forseen for a harddisk.


Driver software

This package contains driver software to be used with STiNG: 
ETHERNEA.STX. Please note that due to speed reasons ETHERNEA.STX
can only handle an interface set to ACSI port 3. If you really
require another ACSI port address please contact me.

The driver software source code is available in directory SRC.
Pleae note that I publish this code under the GNU public license.
Any additions or changes by you must also published under this
license and brought to my attention.


Set-up under STiNG

Just copy ETHERNEA.STX to the STING directory where SERIAL.STX 
and other STiNG drivers are located. Then reboot. 

You must use STNGPORT.CPX to setup the ETHERNEA.STX driver. 
Even though there is no hardware start address to be 
configured as with other ethernet hardware, you still need to 
set the interfaces IP address and netmask (e.g. I use 
192.168.2.2 and 255.255.255.0). Note that you can read the NE 
card's MAC address as it is extracted by ETHERNEA.STX from the 
card hardware and displayed by STNGPORT.CPX but you can not 
change it.

Further you need to add a line to STiNG's ROUTE.TAB for example:
192.168.2.0		255.255.255.0		EtherNet	0.0.0.0

Pleas note you need to spell "EtherNet" exactly like this.

Performance of the driver depends on STiNG's port polling 
frequency. By default this is set to 50 milliseconds by the 
entry

THREADING   = 50

in the file DEFAULT.CFG. I changed this to read 10 to get 
optimum FTP performance. On a faster machine this may be 
unnecessary.
I did not do any other changes to DEFAULT.CFG shipped with STiNG
1.26.


Driver software architecture

The ETHERNEA.STX driver software source code has basically two
components:

ETHERNEA.C
This is largely copied from code written by the "father" of STiNG
Peter Rottengatter. It does general initialisation and the
interfacing of the driver to the STiNG API. It further contains
the ARP code that converts from IP numbers to ethernet MAC
addresses and back.

Please note that this module is also the main entry point for 
the operating system (or rather STING.PRG that loads the drivers 
from disk). No further startup code is needed.
I developed this with Turbo-C 2.0. Pure-C should also work. Care
was exercised to avoid the need for C-library code that may
unnecessarily enlarge the executable.

NE.S
Although completely written in 68000 assembler this source 
code largely is based on the source modules NE.C and 8390.C 
from Linux originally due to the authors Donald Becker and 
Paul Gortmaker and IF_ETHER.H due also to Alan Cox, Frad van 
Kempen and Steve Whitehouse.
I developed this with DEVPAC assembler 2.0. As I make heavy 
use of macros and other advanced assembler directives, 
changing to another assembler might not be easy.

If you study the source code you will notice quite some 
gymnastics to recover from funny behaviour of the original 
8390 chip in the NE2000 design. This is also present in the 
original Linux driver code and seems to be unavoidable. In 
fact if I knew these problems before I probably would have 
chosen another ethernet card family...


Features and Limitations

No Interrupts

The interface does not support interrupt operation. As STiNGs 
driver architecture does polling only this limitation does not 
hurt.
It would be possible to change the interface hardware to allow
for interrupt operation. However if you operate another device on
the ACSI bus using interrupts -like a harddisk controller (as I
do) -software to properly set up interrupt operation is very
difficult and still limited in performance.

The main limitation is due to the 68901 being operated in edge 
triggered interrupt mode effectively preventing a shared use 
if the ACSI interrupt line.

NE2000 clone compatibility

The interface was tested with the following ISA ethernet 
cards:

-	E2000-1: old NE2000 clone with Winbond W89C90 chip
This card works OK.

-	NE-2: old NE2000 clone with UMC UM9090 chip
This card works OK.

-	Lantech EN2000: new NE2000 clone using the Realtek RTL 8019 
AS chip. This card has some quirk that makes buffer wrap 
around unreliable. Thus it looses some packets. TCP can 
recover from that but perormance is degraded.

-	NE1: this is in a very old NE1000 clone card with Winbond 
W89C90 chip. The NE1000 is the 8-bit predecessor of the 
NE2000. I am using this card because it works best. I 
augmented the buffer RAM on the card to 16Kbyte.

Generally the driver software automatically detects NE1000 or 
NE2000 compatible cards and does appropriate setup 
automatically.

No use of ACSI-DMA

The ACSI bus supports DMA operations but this interface does 
not use this. I would be possible to design interface 
circuitry to allow for DMA operation. The software would need 
to always setup DMA transfers of 512 1024 or 1536 byte as the 
Atari DMA controller can only do transfers in multiples of 512 
byte.
Softwarewise the STiNG datagram buffer would just need to be 
large enough even if the IP packet was only 1 byte of user 
data.
Lets see whether somebody comes up with the necessary hardware 
and software extension...

Driver performance

The driver software has been carefully optimized for speed. In 
particular packet data is dirctly transferred from the NE2000 
card packet buffer RAM to the STiNG datagram buffer. Further 
"double buffering" in ST-RAM is avoided.
Overall this ethernet solution performs about 40Kbyte/sec ftp 
up or download from/to RAM disk to/from a Linux server using 
AFTP 1.41 on an Atari ST with 8MHz. As I have my SCSI harddisk 
connected to a SCSI interface also hooked to the ACSI bus, 
speed is about half of this when doing ftp to/from harddisk.
Measurements indicate that on reads the hardware/software 
setup can populate STiNG datagram buffers faster than the 
upper layer IP, TCP, FTP software can digest it.

OS compatibility

This ethernet solution was tested with both plain TOS 1.04 and 
Magic 5.3.
This version of the ETHERNEA package was tested with STING 1.26 
only.

Hardware compatibility

I have tested this ethernet solution only with an original 
Atari 260ST (albeit with 4MB RAM). A ACSI-SCSI interface with my
SCSI harddisk was also hooked to the ASCI port.
Please note that in case of other hardware devices using the ACSI
port -like harddisks- their driver software MUST do proper locking
to ensure mutually exclusive use of the ACSI bus. Otherwise loss
of data may occur!


What NE1000/NE2000 cards to use?

This package works only with ISA cards. I advise to use old 
cards with junpers from computer surplus outlets. New ISA 
NE2000 clones are all plug-and-pray cards. You need to stuff 
them into a PC first and set them to IO address 0x300 first 
and choose the cable type (BNC or twisted pair) by using the 
supplied DOS configuration utility.


Disclaimer

This package is provided to you as is. I do not guarantee any 
features nor do I take any responsibility for any damage or 
loss you may suffer when using this hardware and/or software.
I advise you should backup your harddisk before using this, if
your harddisk is connected to the ACSI port.


Contact Information

Suggestions, bug reports, flames to

Dr. Thomas Redelberger
EMail:     redetho@gmx.de
FAX:       +49 6023 999410

Copyright 2001 Dr. Thomas Redelberger

