Network interface. by Lee Davison

As featured on 
Read a sample of the comments.
Introduction

I've seen a few web-server-on-a-micro projects which are good, but usually use a bit banged serial port and SLIP or PPP via some other machine to get onto the network proper. I wanted something I could plug into an ethernet port on my home network without needing another, intermediate, machine.

Hardware

Deciding what network chip to use was a choice between 3com Etherlink III, generic 8390 and Realtek 8019AS. As I'd seen projects that used the 8019AS and I have three cards the same I decided to use the Realtek cards.

After getting the software to run on the Realtek cards I eventually looked into using the 3Com cards of various types that I have. Investigation revealed that the 3C509B can work in 8 bit mode but would need a small hardware change to access an ID port, this is needed to initialise the card. As I have a few 3C509Bs of various types I made the change and re-wrote the code to drive them. Both versions are available.

If you do decide to use a PC network card like I have, make sure that..

  • It works (one of my cards doesn't though it seems to).
  • It is configured for the expected I/O range and interrupt ($03xx and IRQ4 in this case).
  • It is configured for the media type you're going to use (BNC, twisted pair or AUI).
  • I chose to use the SuprChip V as the developement platform for two reasons. First, I was already involved in developing software on it, and second, it was the easiest target to build the ISA slot for.

    As it runs EhBASIC that part of the code should port to any 6502 EhBASIC system without too much trouble (interrupts being the only real difference) and the assembly code that actually drives the card depends on the system used so would probably need changing in any case.


    Software

    Two assembly routines are used that allow EhBASIC easy access to the slot. Details about them can be found here.

    The rest of the software is written in EhBASIC and, while it's not particularly fast or pretty, does support ARP, ICMP echo requests (aka PING) and can serve one of three four web pages via TCP port 80.

    The program spends its idle time just waiting for a packet to arrive. Once a packet is flagged (this is done by the interrupt service routine) it is checked against known types and processed as needed. When this has been done the NIC buffer is checked for any pending packets and they are processed as needed. If the NIC buffer is empty then the program returns to the idle loop and waits for the next packet to arrive.

    The TCP handler is not a full TCP stack, it can only handle one passively opened thread, and does not time wait on closing due to limited resources. It also ignores out of sequence, repeated or error packets where it should send a RST. The other shortfall is that it can only handle unfragmented data so is limited to less than 1500 bytes for both receive and transmit.

    Source

    There are now two versions of the source available, the original version for the Realtek 8019AS cards and the newer version for the 3Com 3C509B cards. You can either download them as zipped text files or view them as html.

  • 8019AS source code - View or download
  • 3C509B source code - View or download

  • Last page update: 7th September, 2003. e-mail me