From 2b2fb619966bf63c0c862a35d769ca48a1ed98b3 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 24 Nov 2026 13:38:48 +0100 Subject: kernel/bus: add PCI matching contract This change implements the PCI matching contract for devices and drivers. Device-driver pairings are ranked based on the specificity of the match between a pci_id and a function_info object. An exact match of the vendor_id and device_id of a pci_id and a function_info object scores 0x10. Each matching class_code, subclass_code, and programming_interface adds 1 point to the score. Matching is performed independently for each entry in a driver's match table, with the highest scoring entry determining the final match score for a single driver. Any malformed entries in the match tables are ignored. Specifically, an entry is considered malformed if it names a vendor_id without a device_id or vice versa. An entry is also considered malformed if it names a programming_interface without a subclass_code or a subclass_code without a class_code. An entry naming no fields is also considered malformed. This change also introduces the following types for PCI devices, drivers, and buses: pci_id, pci_claim, pci_signature, and pci_protocol. pci_protocol is an abstract class because the host bridge and PCI-to-PCI bridges will differ in their implementations of pci_protocol::enumerate. Both bridge types will share the same ranking algorithm for device-driver pairings. The included tests exercise the PCI matching algorithm, including scoring of valid matches, malformed entries, and driver selection through the global driver registry. --- kernel/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'kernel/CMakeLists.txt') diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 7f418c61..e8ba16eb 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -51,6 +51,7 @@ target_sources("kernel_lib" PRIVATE # Bus Sumbsystem "kernel/bus/boot_modules.cpp" + "kernel/bus/pci.cpp" "kernel/bus/pseudo.cpp" "kernel/bus/root.cpp" -- cgit v1.2.3