Writing a Human68k Driver for the RTL8019AS Ethernet Chip
Connecting an X68000 to a modern local network is more than a matter of wiring an RJ-45 socket to an expansion board. The RTL8019AS is a familiar and affordable Ethernet controller, but it expects software that understands its register layout, buffer memory, interrupt behavior, and NE2000-compatible packet-transfer model. Human68k adds another layer: the driver must fit the machine’s 68000 architecture and the conventions used by its operating environment.
A practical driver therefore sits between three different worlds. The hardware designer defines the I/O address, interrupt line, reset circuit, and shared memory arrangement. The RTL8019AS provides an 8390-style network engine with its own initialization sequence. Human68k needs a usable interface that applications, packet utilities, or a TCP/IP stack can call without knowing those details.
The most productive way to approach the project is to make each layer explicit. Start with a small diagnostic program that can reset the controller and read its identity. Then add transmit and receive paths, interrupt handling, and finally the Human68k-facing interface. This incremental method makes hardware faults distinguishable from driver bugs.
Define The Hardware Contract First
Before writing assembly or C, document how the expansion board exposes the RTL8019AS. The chip is designed for an ISA-like environment, while an X68000 expansion board may decode its registers through custom glue logic, a CPLD, or a memory-mapped interface. The driver must know whether accesses are byte-wide, word-wide, or translated by board logic.
The register base address is only one part of the contract. Record the reset register, interrupt source, shared packet memory location, memory window size, and any board-specific control bits. If the board includes configuration registers for bank selection or bus timing, keep those details out of the generic RTL8019AS code. A small hardware-abstraction layer will make later board revisions much easier to support.
The Nereid hardware documentation is a useful example of the kind of platform-specific information that belongs beside a driver project: expansion architecture, available signals, and practical constraints matter just as much as the Ethernet controller data sheet. Verify every address against the actual board revision rather than relying on a schematic or an old configuration file.
A simple diagnostic should perform a reset, wait for the reset indication to settle, select register pages, and read back known registers. It should also report the detected I/O base and interrupt configuration. If those reads are inconsistent, stop there. Packet transmission cannot compensate for incorrect bus decoding.
Understand The RTL8019AS Register Model
The RTL8019AS follows the programming model of the National Semiconductor DP8390, commonly described through the NE2000 interface. Its registers are divided into pages selected through the Command Register. Page zero contains operational state and interrupt controls, while pages one and two expose receive-ring configuration, the physical MAC address, current receive-page state, and diagnostic information.
The Command Register controls more than a simple start or stop state. It selects the register page, starts or stops the controller, and chooses between local DMA and remote DMA operations. A driver should use named constants and short helper routines instead of scattering literal values throughout the source. A wrong page selection can produce convincing but meaningless register values.
Initialization normally includes stopping the controller, clearing pending interrupts, configuring the data configuration register, setting the transmit configuration, defining the receive ring, loading the station address, and then enabling reception. The exact data width and FIFO settings should match the X68000 bus interface. A controller configured for a transfer width that the board does not actually provide may appear functional until a packet crosses a particular boundary.
The receive ring is located in the RTL8019AS packet memory. It begins at a selected page and ends at a boundary page, with packet headers stored inside the ring. Each received packet has a status byte, a next-page pointer, and a length field before its Ethernet data. The driver maintains a “current” page in software and compares it with the controller’s boundary pointer to determine whether packets are waiting.
Build A Reliable Packet Path
Transmission is easier to reason about because the driver owns the packet buffer and receives one completion result. The usual sequence is to reserve or copy a complete Ethernet frame, program the remote-DMA start address and byte count, transfer the frame into controller memory, then set the transmit page and length. The transmit command should be issued only after the remote DMA has completed successfully.
The driver must enforce Ethernet frame limits. A standard frame has a 14-byte header followed by payload and optional padding, with a minimum wire length of 64 bytes including the frame check sequence generated by the controller. The software generally supplies at least 60 bytes before the chip adds the FCS. Oversized packets should be rejected rather than truncated silently.
Remote DMA commands need careful completion handling. The RTL8019AS reports completion through an interrupt or status condition, and a stale completion flag can make a later operation appear finished before any data moved. Clear or acknowledge the relevant state in a controlled order, and protect the transfer routine from re-entry.
Reception is more subtle. On an interrupt, read the boundary and current-page values, then process every complete packet until the ring is empty. Validate the status, next-page pointer, and length before copying data. A malformed pointer must not be allowed to send the software cursor outside the configured ring; otherwise one damaged packet can turn into an endless interrupt loop or memory corruption.
After consuming a packet, update the boundary register to the page immediately preceding the next unread packet. The wraparound case deserves a dedicated test, because an incorrect comparison often remains hidden during light use. Test packets of minimum size, maximum normal size, back-to-back frames, and traffic that crosses the end of the receive ring.
| Driver area | RTL8019AS responsibility | Human68k-facing concern | Useful test |
|---|---|---|---|
| Reset and probe | Responds to register access and reset | Reports a clear hardware error | Repeated cold and warm resets |
| Initialization | Accepts ring, MAC, FIFO, and mode settings | Uses board-specific configuration safely | Read back all programmed registers |
| Transmit | Moves frame through remote DMA | Returns busy or failure predictably | Send minimum and maximum frames |
| Receive | Produces ring headers and status | Delivers complete frames without overruns | Burst traffic and ring wraparound |
| Interrupts | Raises events for transmit, receive, and errors | Preserves registers and returns quickly | Mask and unmask each event |
| Recovery | Indicates overflow, missed packet, or DMA fault | Resets without hanging Human68k | Disconnect cable during traffic |
Shape The Human68k Driver Interface
Human68k does not require every network driver to expose the same high-level API. A small resident driver can offer packet send and receive services, while a packet-driver-compatible interface can allow existing DOS networking software to use the hardware. A more ambitious implementation can integrate with a TCP/IP package, but that should come after the raw Ethernet path is stable.
Choose the interface according to the software you want to run. A private API is simpler and can be tailored to the X68000, but it creates another compatibility layer. A packet driver interface requires more precise conventions, yet it makes testing easier because established utilities can generate and inspect traffic. Separating the low-level controller code from the public entry points lets both options share the same engine.
On a 68000 system, register preservation is part of the interface contract. Define which data and address registers the caller may destroy, how error codes are returned, and whether buffers must be aligned. Do not assume that a compiler-generated calling convention matches an assembly caller or an existing Human68k utility. Write a short ABI document and test it independently.
Interrupt entry deserves the same discipline. Save the registers required by the 68000 exception environment, identify the active interrupt source, acknowledge it at the controller and any board-level interrupt latch, and leave quickly. The handler should record events or move packet data into a software queue rather than performing lengthy protocol processing while interrupts are blocked.
Make Interrupts And Recovery Predictable
The RTL8019AS can signal receive, transmit, receive-overflow, counter overflow, remote-DMA completion, and reset-related conditions through its interrupt status register. Enable only the sources that the current driver understands. During initialization, clear pending causes before enabling the interrupt mask; otherwise an old status bit may generate an immediate and confusing interrupt.
Receive overflow is not just a statistic. It means the controller could not preserve every packet in the configured ring, so the driver should record the event and reinitialize the receive path when necessary. A missed-packet condition may indicate that the host did not service the ring quickly enough or that the ring boundaries were programmed incorrectly. Keep separate counters for hardware errors, rejected frames, and software queue exhaustion.
Transmission needs a defined busy policy. The simplest driver permits one outstanding frame and returns a busy status to callers until the transmit interrupt arrives. A queued design can improve throughput, but it introduces ownership rules for packet buffers and more paths through the interrupt handler. On a slow retrocomputer, predictable behavior is usually more valuable than maximum throughput.
Provide a recovery routine that stops the controller, resets it, reconstructs the ring state, restores the MAC address, and resumes reception. Use it after a fatal DMA error, a corrupted ring pointer, or a board-level reset. The routine should preserve configuration in software so that recovery does not depend on a full machine reboot.
Test With Tools That Expose Real Faults
A loopback test is a useful first step, but it can hide problems in the cable, transceiver, or receive path. Test internal controller loopback to verify register programming and DMA, then use an external machine on the same network. A modern computer running packet capture software can reveal whether the X68000 is producing valid Ethernet headers, sensible lengths, and correct source and destination addresses.
Add diagnostic counters that can be displayed without disturbing the packet path. Useful values include transmitted frames, completed transmissions, receive packets, CRC or frame errors, ring overruns, remote-DMA failures, dropped packets, and interrupt counts. If the interrupt count rises while receive processing does not, the problem is probably in status handling or ring management rather than in the cable.
Test at different traffic rates. A single ping may validate the basic path while a file transfer exposes missed interrupts, an incorrect remote-DMA count, or a queue that never releases buffers. Generate packets with varying lengths and deliberately send traffic while resetting or disabling the interface. These tests reveal whether the driver can return to a known state.
Keep a hardware trace mode for development, but make it optional in the release build. Logging every register access from an interrupt handler can change timing enough to hide the original fault. A compact event counter or a fixed-size diagnostic buffer gives useful evidence without overwhelming the X68000’s limited resources.
Keep The Code Portable And Maintainable
Place controller-independent packet handling in one module and RTL8019AS operations in another. The hardware layer should provide operations such as reset, register read and write, remote-DMA transfer, transmit start, and ring inspection. The Human68k layer should deal with entry points, buffer ownership, return codes, and interrupt installation. This boundary also makes emulation or bench testing possible.
Use a configuration structure for I/O base, interrupt number, memory pages, MAC address, and feature flags. Avoid embedding board values in every routine. A command-line setup utility or a small configuration block can support multiple X68000 expansion boards without requiring separate driver binaries.
The driver should document timing assumptions and any board-specific wait states. The RTL8019AS data sheet describes the controller, but it cannot describe delays introduced by an X68000 bus adapter. If a reset requires a minimum delay or a register must be read back after a write, encode that requirement in a named function and explain why it exists.
A good release package includes source code, an assembled driver, a probe utility, a loopback test, configuration notes, and a change log. Preserve the original memory map and register traces from a known-good system. Retrocomputing projects benefit greatly from this kind of evidence because later repairs may involve replacement chips, revised boards, or a different monitor and compiler toolchain.
A practical development sequence is:
- Confirm reset, register pages, and MAC address reads with a standalone probe.
- Implement remote-DMA writes and transmit one controlled Ethernet frame.
- Add receive-ring parsing with strict pointer and length validation.
- Install interrupt handling and expose a small packet-oriented API.
- Stress-test recovery, overflow handling, and repeated warm starts before integrating TCP/IP.
The result should be judged by more than whether it can answer a ping. A dependable Human68k network driver makes hardware behavior visible, protects the rest of the system from malformed packets, and provides enough diagnostics to repair the next failure. That is especially important on an aging computer where documentation, replacement parts, and original development environments may be scarce.
Publishing the source alongside register notes and test results turns a one-off Ethernet modification into reusable preservation work. Install the driver on a real X68000, capture its behavior under controlled tests, and share the resulting implementation with the wider enthusiast community so future projects can build on a working foundation.
Nereid-X Expansion Board
A personally-produced LAN+USB+Memory expansion board for Sharp X68000 series computers. Multiple production runs were offered, including a final batch and a later revival reproduction run.
Power Supply Repair
X68 power supply repair and modification services were offered by the site owner, with documentation shared through diary entries spanning 2001–2006.
Server & Networking
Notes on FreeBSD administration, ISP changes, server migration, and networking topics. The site itself ran on FreeBSD with the hns diary system and Namazu search integration.
Get in touch
X68K.NET connects Sharp X68000 enthusiasts through community links and shared projects. Reach out with questions about the Nereid project or X68 resources.