morpheus_network::device

Module pci

Source
Expand description

PCI bus enumeration and device discovery.

This module provides utilities for scanning the PCI bus to find VirtIO and other network devices. Supports both:

  • ECAM (Enhanced Configuration Access Mechanism) - Modern PCIe
  • Legacy I/O ports - Older PCI (0xCF8/0xCFC)

§Usage

use morpheus_network::device::pci::{PciScanner, EcamAccess};

// For QEMU with PCIe ECAM at 0xB000_0000
let ecam = unsafe { EcamAccess::new(0xB000_0000 as *mut u8) };
let scanner = PciScanner::new(ecam);

for device in scanner.scan_bus(0) {
    if device.is_virtio_net() {
        // Found VirtIO network device!
    }
}

Modules§

  • Diagnostic utilities for PCI debugging.
  • Common ECAM base addresses for different platforms.

Structs§

Constants§

Traits§

Functions§

  • Read 32-bit value from PCI configuration space. Args: bus, device, function, offset (must be 4-byte aligned)
  • Write 32-bit value to PCI configuration space. Args: bus, device, function, offset, value
  • Test if PCI I/O ports are accessible. Returns the value read back from 0xCF8 (should have bit 31 set).
  • Read CPU timestamp counter. Returns 64-bit TSC value.
  • Delay for approximately the given number of microseconds using TSC. Assumes ~2.5 GHz CPU (adjust TSC_MHZ for your platform).