-
Notifications
You must be signed in to change notification settings - Fork 0
Bus Drivers
Subsystem for enumerating and managing bus devices (PCI, USB, PCMCIA, SMBus).
JNode's Bus Drivers subsystem provides the infrastructure for discovering and managing devices on different system buses. Each bus type implements a common Bus base class and provides bus-specific protocols for device enumeration, resource allocation, and driver binding.
The system supports four bus types:
- PCI: Primary system bus for connecting expansion cards and integrated peripherals
- USB: Universal Serial Bus for external device connectivity
- PCMCIA/CardBus: Legacy bus for removable cards (laptops, embedded)
- SMBus: System Management Bus for hardware monitoring and smart battery communication
Each bus driver integrates with the DeviceManager to register discovered devices and bind appropriate drivers based on device identifiers.
| Class / File | Role |
|---|---|
core/src/driver/org/jnode/driver/bus/pci/PCIBus.java |
PCI bus implementation with device probing and bridge enumeration |
core/src/driver/org/jnode/driver/bus/pci/PCIBusAPI.java |
PCI bus device lookup interface |
core/src/driver/org/jnode/driver/bus/pci/PCIDriver.java |
PCI system driver, coordinates all PCI buses |
core/src/driver/org/jnode/driver/bus/pci/PCIDevice.java |
PCI device representation with configuration space access |
core/src/driver/org/jnode/driver/bus/usb/USBBus.java |
USB bus with device ID allocation |
core/src/driver/org/jnode/driver/bus/usb/USBDevice.java |
USB device with descriptor parsing |
core/src/driver/org/jnode/driver/bus/usb/USBHostControllerAPI.java |
Host controller hardware abstraction |
core/src/driver/org/jnode/driver/bus/usb/uhci/UHCIDriver.java |
UHCI USB controller driver |
core/src/driver/org/jnode/driver/bus/pcmcia/CardBusBus.java |
CardBus (PCMCIA) bus implementation |
core/src/driver/org/jnode/driver/bus/pcmcia/CardBusDriver.java |
CardBus controller driver |
core/src/driver/org/jnode/driver/bus/smbus/SMBus.java |
SMBus implementation with address constants |
core/src/driver/org/jnode/driver/bus/smbus/SMBusControler.java |
SMBus controller driver |
core/src/driver/org/jnode/driver/Bus.java |
Base class for all bus implementations |
The PCI bus driver performs a depth-first enumeration of the PCI hierarchy:
-
Probe:
PCIBus.probeDevices()scans bus device/function pairs (0-31/0-7) -
Configuration Access: Each present device is read via
PCIDeviceConfig(configuration space) - Multi-function Detection: If a device is multi-functional, each function is scanned
- Bridge Enumeration: PCI-to-PCI bridges trigger recursive probing of child buses
-
Driver Binding:
PCIDeviceToDriverMappermaps PCI class/code to appropriate drivers
// PCI enumeration pattern (PCIBus.java:79-100)
protected void probeDevices(List<PCIDevice> result) {
for (int i = 0; i < MAX_UNITS; i++) {
PCIDevice dev = createDevice(i, 0);
if (dev != null) {
list.add(dev);
if (dev.getConfig().isMultiFunctional()) {
for (int f = 1; f < MAX_FUNCTIONS; f++) {
dev = createDevice(i, f);
if (dev != null) list.add(dev);
}
}
}
}
// Probe bridges to child buses
for (PCIDevice dev : list) {
if (dev.isBridge()) {
createChildBus(dev).probeDevices(result);
}
}
}USB uses a tree topology with hub-based device discovery:
- Host Controller: USB host controller (UHCI/OHCI/EHCI) provides hardware access
- Root Hub: Each controller has an embedded root hub with ports
-
Hub Polling:
USBHubMonitorpolls hub status for device connect/disconnect -
Device Address Assignment:
USBBus.allocDeviceID()assigns 7-bit device addresses - Descriptor Retrieval: Device descriptors are read to identify supported configurations
-
Driver Binding: Device class/subclass matching via
DeviceToDriverMapper
CardBus bridges appear as PCI devices and are enumerated through the PCI layer:
- CardBus controller is a PCI device
- Cards are probed as child PCI buses
- Supports both 16-bit PCMCIA and 32-bit CardBus cards
SMBus uses a simple address-based protocol:
- Fixed address range for standard devices (host, batteries, chargers)
-
SMBusControlerperforms transactions (quick command, byte, word, block) - DIMM detection via
DIMMDriverfor memory module identification
- PCI configuration space: Access requires I/O port 0xCF8/0xCFC (legacy) or MMIO (newer)
- PCI bridges: Must enumerate child buses recursively; bridges have type-specific headers
- USB device IDs: Limited to 127 devices per controller; ID 0 reserved
- USB power: Hub ports may provide limited current; power management needed
- Hot-plug: USB supports dynamic connect/disconnect; PCMCIA/CardBus vary by hardware
- SMBus addresses: Some addresses are reserved; not all SMBus devices respond to standard protocols
- Resource conflicts: PCI BARs must not overlap; OS must track allocated I/O and memory ranges
- Multi-function PCI: Each function appears as separate device but shares slot resources
- PCI-Capability-Structure — PCI capability chain for MSI, power management, and hot-swap
- DeviceManager - Device registration and driver binding
- Driver-Framework - Driver framework overview
- Resource-Management - Hardware resource allocation (IRQ, I/O, memory)
- Device-Discovery - General device discovery mechanisms