Platforms, device drivers, and virtualization¶
Platform services and device ownership¶
Firmware entry and resident payloads are described in Boot, platform handoff, and service recovery. The platform layer uses the Hardware description to discover devices and supplies interrupt controller, timer, and PCI/PCIe services. Architecture code handles CPU exceptions, context switching, memory translation, and interprocessor operations. Test firmware, board, CPU, and hardware-description support as an explicit combination.
Native device services own discovery and device lifecycle. Drivers run in userspace and receive scoped MMIO mappings, interrupt endpoints, and DMA buffer authority. The kernel controls interrupt delivery and hardware mappings. An IOMMU, where available, limits DMA to authorized buffers. A platform with unrestricted DMA has a weaker memory-isolation boundary even when driver code runs in a separate process.
Drivers must define how queues, DMA mappings, pending requests, and interrupt bindings are retired on exit or device removal. In the boot path, VirtIO block exercises shared buffers, interrupt completion, and replacement after service failure. VirtIO forms the initial virtual block, network, GPU, and input device families. Physical bring-up starts with storage such as NVMe and AHCI, Ethernet, USB and input, and expands to wireless, selected Intel/AMD GPUs, audio, and suspend/resume.
The RISC-V QEMU virt boot path binds block and Ethernet transports independently. The shared PLIC handler records each claimed source and only the driver with the corresponding device capability can acknowledge it. On driver exit the kernel resets that transport before releasing its pinned DMA page. Resetting one transport leaves the other active.
RISC-V PCI DMA translation¶
The native-disk QEMU configuration uses a PCI IOMMU and separate
modern VirtIO PCI requesters for block and Ethernet. The platform
validates their firmware-assigned BARs and delegates only the VirtIO
register pages. The kernel retains PCI configuration and bus mastering.
Each requester has a private Sv39 I/O page table and a distinct
process soft-context identifier. Both drivers use the same device-visible
address. Each mapping reaches only that driver’s pinned queue and
buffer page. Ethernet’s IPC packet page is outside the DMA window.
The device capability’s device_dma operation returns the address
as the driver must program it in the device’s registers and descriptors.
The VirtIO block driver accepts writes and flushes through a dedicated writer badge when the device advertises flush support and permits writes. The partition service fills a separate transfer page and the driver copies the sector into its own DMA buffer. The partition service maps the DMA page read-only and cannot change the queue descriptors.
The kernel installs and synchronizes translations before enabling bus mastering. To retire a driver, it disables bus mastering, resets the transport, invalidates the device directory and translation caches, and waits for the IOMMU completion fence before releasing the DMA frame. A replacement can then reuse the device-visible address.
An optional QEMU test endpoint checks writable, read-only, and unmapped addresses and remaps a previously used address to a new frame. The ISO runtime fixture still supports VirtIO-MMIO, which has no IOMMU enforcement on this platform. The PCI binding currently targets QEMU virt’s configured PCI slots and INTx routes.
Initial RISC-V PCI device DMA translation.
See the RISC-V IOMMU specification and the QEMU RISC-V IOMMU model.
AMD64 programmed I/O¶
The AMD64 QEMU PC native-disk and swap profiles validate the primary PIIX3 IDE channel before giving its driver a device capability. The capability permits the bound driver to access the channel’s task-file registers and read alternate status with the required port widths. The kernel masks IDE interrupts and resets the channel before reusing its resources. The userspace driver polls the drive, issues ATA commands, and publishes a block endpoint for GPT. Once the driver has checked data readiness, it can read one 512-byte sector from the data FIFO into its bound transfer frame in one kernel call. The kernel verifies the device owner, port, alignment, and frame bounds before performing the transfer.
ARM64 virtual swap disk¶
The ARM64 QEMU swap profile validates the VirtIO MMIO transport in the firmware device tree. It checks that the native page does not contain another populated transport before mapping it with Device memory attributes. The block driver polls the split queue for completion. The kernel resets the transport before releasing the pinned transfer frame. This opt-in QEMU fixture uses VirtIO MMIO without an IOMMU for the trusted resident driver.
Programmed I/O SD storage¶
The stock-firmware Pi profiles give the SD host driver a capability for programmed I/O to the BCM2711 eMMC2 or BCM2712 SD controller. Only the bound driver can read the controller registers or issue the allowed writes. The kernel keeps signal delivery masked and rejects commands that enable controller DMA. The userspace driver initializes the card, uses the SD data FIFO for sector reads and writes, and waits for card programming to finish before reporting a flush.
The PowerVM QEMU profile discovers the PCI SD host and its assigned memory BAR through Open Firmware. It uses RTAS to enable PCI memory decoding with bus mastering disabled, and PAPR cache-inhibited load and store calls to reach the controller. The PowerNV QEMU profile uses the OPAL device tree and PCI configuration calls. When firmware leaves the test controller’s BAR unassigned, the platform assigns a non-prefetchable memory window on its dedicated PHB and root port. The PowerNV path uses cache-inhibited real-mode loads and stores for register access. Both profiles give the userspace SD driver the same restricted register capability used on Raspberry Pi.
Native ACPI service¶
The kernel reads the firmware tables needed for early boot and owns privileged interrupt and resource enforcement. The planned native firmware service runs ACPICA in userspace for AML evaluation, namespace discovery, resource reporting, and event handling. Its OS Services Layer uses capabilities for firmware operation regions, including memory, port I/O, PCI configuration, and embedded-controller access as applicable. The kernel routes the ACPI system control interrupt to the service, which handles ACPI events and publishes device information to the native device service.
Verify this interface on an ACPI platform before implementing LinuxKPI’s ACPI adapters. The ACPI service and the device service own native enumeration and events that both native and Linux-derived drivers use.
See also
Essential peripheral drivers¶
SCSI¶
Use FreeBSD CAM as a reference for a userspace SCSI layer. Keep target and logical unit discovery, command queueing, sense handling, timeout, retry, and cancellation there. Give each host adapter driver its own resources and publish disk logical units as capability-scoped block providers under the Filesystems, block storage, and networking design. Start with VirtIO-SCSI in QEMU so the generic layer can be tested before selecting physical SCSI or SAS host adapters. USB mass storage reuses the same disk layer.
USB¶
The xHCI host controller driver runs in userspace. It owns controller register access, DMA rings, scheduling of controller transfers, and completion handling. A userspace USB bus service owns enumeration, hub and port state, device configuration, and interface binding. HID, mass-storage, and other class drivers use USB transfer capabilities scoped to their assigned device interfaces and endpoints. Controller registers and DMA authority belong to the controller driver.
The microkernel authorizes MMIO and bus mastering, routes and delegates interrupts, pins the DMA buffers, and enforces device mappings through an IOMMU where available. It can mask interrupts, revoke access, and stop device DMA during recovery. The controller driver and bus service own USB protocol operations, including descriptor parsing, address assignment, and endpoint reset. Board-level power, clocks, and PHY control use platform services with narrowly delegated resource access.
On unplug or driver failure, stop new submissions, invalidate affected transfer handles, and complete outstanding requests with an error. Quiesce controller DMA and wait for invalidation before releasing pinned frames. Keep frames pinned if the platform cannot confirm DMA has stopped. Re-enumerate after a controller restart and delegate fresh handles. USB class capabilities remain scoped per interface even when the hardware presents the whole controller as one DMA requester.
Exercise xHCI with HID and Bulk-Only Transport mass storage in QEMU before adding USB Attached SCSI. Test transfer completion, error reporting, hotplug, cancellation, and restart with I/O pending. For USB root, the firmware or loader makes the boot bundle resident. The supervisor starts the controller, bus, mass-storage, SCSI disk, and filesystem services before mounting the root volume. See Boot, platform handoff, and service recovery.
See also
Linux driver API¶
Bring up and verify native ACPI, USB, and SCSI before adding LinuxKPI. LinuxKPI translates Linux driver APIs to those native services. ACPI queries and events use the firmware service, USB transfers use delegated interface and endpoint handles, and SCSI host adapter drivers register their transports with the native SCSI layer. Device authority and lifecycle remain with the native services.
LinuxKPI has a userspace coordinator process and an in-process driver library. The coordinator maintains Linux-facing driver registration and device matching and coordinates binding and recovery with the native device service over IPC. The native device service remains responsible for device ownership and resource delegation. Each driver process receives its own capabilities for the MMIO, interrupts, and DMA buffers it uses.
Link the driver-side library, liblinuxkpi.a, statically into every
LinuxKPI driver process. Pin the Linux API baseline and build the driver
and library together from that baseline. The library implements
driver-local memory allocation, synchronization, workqueues, and timers
in the driver’s address space. Coordination crosses IPC using explicit
messages and capabilities. Linux pointers, locks, and driver-local
objects stay in the process that owns them.
Static linking is the supported LinuxKPI policy for all drivers. A supervisor can restart a driver from its resident image before VM or storage dependencies recover. A driver and its LinuxKPI implementation are updated and rolled back as one image. Version coordination between the coordinator and the driver uses their IPC protocol. FreeBSD LinuxKPI and Genode’s Linux driver environments are design and reuse references.
Isolate drivers by device or practical subsystem. Give each driver capabilities for its devices and memory and apply the native lifecycle and recovery rules. The driver API has its own supported surface. Filesystem ports use native service interfaces, and Linux applications use the separate personality described in Foreign executable and application ABIs. Native clients of device services can use suitable standard interfaces, such as DRM UAPI semantics, directly.
Hardware-assisted virtualization¶
A userspace VMM manages vCPUs, guest memory, exits, virtual interrupts and timers, and emulated devices. The kernel provides privileged mechanisms as required by the platform. Use bhyve and KVM as design and reuse references for a coherent native interface. Relevant CPU facilities include RISC-V H, AMD64 VMX/SVM, ARM64 virtualization, and suitable PPC64 facilities. Nested virtualization depends on the host configuration.
On RISC-V, the entry test discovers the H extension in the boot CPU’s device-tree properties. It runs a virtual supervisor with a temporary Sv39x4 G-stage table and checks both an environment call and the guest page fault for an unmapped physical read. It restores the supervisor trap state and releases the test page before starting native userspace.
The AMD64 entry test checks for SVM and nested paging through CPUID and checks the firmware’s SVM control before enabling it. A real-mode test guest exits through VMMCALL. A second entry performs a read from an unmapped guest physical page and verifies the nested fault address. The test restores host CPU state and releases its temporary pages.
The ARM64 entry checks exercise the boot CPU at EL2 when the firmware
enters there. The check enters a minimal EL1 guest, returns from an HVC,
and verifies the translation fault and IPA for an unmapped stage-2
address. It restores the incoming CPU register context before startup
continues. The same check runs on QEMU’s ARM virt machine with
virtualization enabled. The native kernel and VMM interface is a
separate milestone and uses these entry and isolation mechanisms.
PowerNV checks the hypervisor-to-guest transition with a supervisor
payload and returns by hypercall. Each byte order exercises this path.
PowerVM uses its hypervisor’s partition interfaces. When the hypervisor
advertises nested PAPR, the boot check negotiates a guest CPU capability,
creates a guest and one virtual CPU, then deletes the guest. The
powerpc-entry/nested test uses QEMU’s POWER10 pSeries model with nested
PAPR enabled in both byte orders. Guest execution and virtual I/O through
the native VMM are Stage 2.7 work.
Device passthrough requires isolation for device DMA, interrupts, and guest memory. Expose it where the hardware and IOMMU can enforce those boundaries. Full virtual machines are the path for workloads that need their original operating system kernel. Branded zones reuse System’s kernel and native services.