Implement NE2000 ISA Ethernet NIC driver (AI)

Add a driver for NE2000-compatible ISA Ethernet cards based on the
DP8390 controller. Features:

- PROM-based MAC address detection and validation
- Programmed I/O (PIO) remote DMA for data transfers
- Ring buffer management for RX with wrap-around handling
- IRQ 9-driven packet reception and transmission
- Synchronous TX with timeout
- Character device registration as 'eth' class (/dev/ethN)

Probe verifies card presence by resetting the controller, configuring
it for PROM reading, and checking the MAC is not all-0xFF/all-0x00
(which would indicate no hardware at the I/O base).

NE2000 memory layout (16 KiB on-card RAM):
- Pages 0x40-0x45: TX buffer (1536 bytes, 1 MTU frame)
- Pages 0x46-0x7F: RX ring buffer (~14.5 KiB)

Tested with QEMU: `-device ne2k_isa,iobase=0x300,irq=9` correctly
detects the card and registers /dev/eth1. Without the NIC option,
probe correctly reports 'not found'.
This commit is contained in:
AI
2026-02-23 17:34:12 +00:00
parent 27b2042523
commit f87a4e3101
6 changed files with 819 additions and 5 deletions

View File

@@ -4,6 +4,7 @@
#include "syscall.h"
#include "keyboard.h"
#include "floppy.h"
#include "ne2000.h"
#include <stdint.h>
/* Forward declaration for kernel panic or similar */
@@ -68,6 +69,9 @@ void isr_handler(registers_t *regs)
} else if (regs->int_no == 38) {
/* Floppy IRQ */
floppy_irq();
} else if (regs->int_no == 41) {
/* NE2000 Ethernet IRQ (IRQ 9, vector 41) */
ne2k_irq();
}
return;
}