Overview

FreeWorld OS includes complete implementations of three major Ethernet driver families: Realtek RTL8139, Intel E1000, and VirtIO Network. These drivers provide full hardware-accelerated network connectivity with support for packet transmission, reception, statistics, and advanced features like promiscuous mode and multicast filtering.

RTL8139 Driver

The Realtek RTL8139 driver provides support for the popular RTL8139 network adapter chipset, commonly found in many systems.

Features

  • ✅ Full initialization and reset
  • ✅ MAC address reading
  • ✅ Packet transmission (4 TX descriptors)
  • ✅ Packet reception (8KB RX buffer)
  • ✅ Interrupt handling
  • ✅ Statistics tracking
  • ✅ Promiscuous mode support
  • ✅ Multicast filtering
  • ✅ DMA support

API Functions

; Initialize RTL8139
rtl8139_init_complete(io_base, mem_base, irq) -> status

; Read MAC address
rtl8139_read_mac_complete(io_base) -> status

; Send packet
rtl8139_send_packet_complete(packet_buffer, packet_length) -> status

; Receive packet
rtl8139_receive_packet_complete(buffer, buffer_size) -> packet_length

; Get statistics
rtl8139_get_stats(stats_buffer) -> status

; Reset chip
rtl8139_reset(io_base) -> status

; Set promiscuous mode
rtl8139_set_promiscuous(enable) -> status

; Set multicast filter
rtl8139_set_multicast(address_array, count) -> status

E1000 Driver

The Intel E1000 driver provides support for Intel 82540EM, 82573L, 82574L, and related network adapters, commonly used in servers and high-end systems.

Features

  • ✅ Full initialization and reset
  • ✅ MAC address reading
  • ✅ Descriptor ring-based TX/RX (256 descriptors each)
  • ✅ Interrupt handling
  • ✅ Statistics tracking
  • ✅ Promiscuous mode support
  • ✅ Multicast filtering (128-entry MTA)
  • ✅ Flow control support
  • ✅ VLAN support
  • ✅ Link status detection

API Functions

; Initialize E1000
e1000_init_complete(mem_base, irq) -> status

; Read MAC address
e1000_read_mac_complete() -> status

; Send packet
e1000_send_packet_complete(packet_buffer, packet_length) -> status

; Receive packet
e1000_receive_packet_complete(buffer, buffer_size) -> packet_length

; Get statistics
e1000_get_stats(stats_buffer) -> status

; Reset controller
e1000_reset() -> status

; Set promiscuous mode
e1000_set_promiscuous(enable) -> status

; Set multicast filter
e1000_set_multicast(address_array, count) -> status

VirtIO Net Driver

The VirtIO Network driver provides support for paravirtualized network devices in virtualized environments, offering high-performance networking for virtual machines.

Features

  • ✅ Full VirtIO 1.0+ protocol support
  • ✅ Feature negotiation
  • ✅ Queue-based TX/RX (256 descriptors each)
  • ✅ MAC address reading
  • ✅ Statistics tracking
  • ✅ Control queue support (structure ready)
  • ✅ Multi-queue support (structure ready)
  • ✅ Status reporting

API Functions

; Initialize VirtIO Net
virtio_net_init_complete(mmio_base, irq) -> status

; Read MAC address
virtio_net_read_mac_complete() -> status

; Send packet
virtio_net_send_packet_complete(packet_buffer, packet_length) -> status

; Receive packet
virtio_net_receive_packet_complete(buffer, buffer_size) -> packet_length

; Get statistics
virtio_net_get_stats(stats_buffer) -> status

; Set promiscuous mode
virtio_net_set_promiscuous(enable) -> status

; Set multicast filter
virtio_net_set_multicast(address_array, count) -> status

Statistics

All drivers provide comprehensive statistics tracking:

  • Received packets count
  • Transmitted packets count
  • Received bytes
  • Transmitted bytes
  • Receive errors
  • Transmit errors

Integration

Ethernet drivers integrate with:

  • PCI System - Automatic detection via PCI enumeration
  • Interrupt System - IRQ handling for packet events
  • Network Stack - Provides layer 2 (Ethernet) for IP stack
  • Memory Management - DMA buffer allocation

Build System

Ethernet drivers are built using the Makefile in kernel/drivers/ethernet/:

cd kernel/drivers/ethernet
make

This produces object files that are linked into the kernel:

  • rtl8139_complete.o - RTL8139 driver
  • e1000_complete.o - E1000 driver
  • virtio_net_complete.o - VirtIO Net driver