| Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
This change extracts the PCI bus scanning logic, which previously was
hidden inside an anonymous namespace, into a dedicated function. This
allows for the implementation to be tested independently.
|
|
Previously, ECAM access was implemented "in-place" inside the PCI scan
function. This meant that any checks were ad-hoc and not easily
reusable or testable. Therefore, this change introduces a dedicated,
reusable abstraction for ECAM segment access. It validates segment
descriptors received from the platform and ensures no out-of-bounds
buses are accessed at runtime.
Construction of an ecam_segment will always succeed. If the firmware or
platform data does not describe a valid segment, the ecam_segment will
behave as if it had a size of zero, with a kernel log indicating the
invalid segment.
Attempting to map a bus that is out-of-bounds for a given ecam_segment
will return a runtime error. If the system's MMIO space is insufficient
to accommodate the mapping of a valid bus in an ecam_segment, a runtime
error will be returned.
Furthermore, this change introduces the kernel::devices::pci namespace.
PCI initialization and scanning functionality, previously hosted in
kernel/kernel/devices/pci_express.{cpp,hpp}, has been relocated and
renamed to kernel/kernel/devices/pci/init.{cpp,hpp}. The initialization
function of the PCI subsystem has been renamed from
kernel::devices::init_pci_express_devices to kernel::devices::pci::init.
The observable behavior of the PCI scan remains unchanged.
Tests have been added to validate the behavior of ecam_segment against
its contract.
|
|
Previously, allocation and mapping of MMIO regions was a multi-step
process. The MMIO region API required its users to track and manage the
lifetime of an MMIO region allocation manually. The new MMIO window API
simplifies this by providing a single-step mapping interface and
automatic lifetime management.
Additionally, the new API adds strict bounds and alignment checks, to
ensure that all MMIO accesses are within the requested range. The new
API enforces these constraints at runtime via a system panic. Other
contract violations, such as zero-sized mappings, are handled via
runtime error codes.
The new kapi::memory::mmio_window preserves the in-page offset of the
hardware base within the window and bases all accesses on this offset.
This means no user intervention is required to handle hardware ranges
that are not aligned to a natural page boundary. The original pointer
adjustment logic has been moved into the mmio_window class.
Previous consumers of the region API (x86_64 LAPIC, PCIe) have been
updated to the new mmio_window API. The behavior of the PCIe scan
implementation has changed in that no windows are kept alive beyond the
execution of the scan, since there are no consumers that would require
persistent MMIO windows.
Tests for the new infrastructure have been added, including a test
support seam to allow for deinitialization of the MMIO subsystem in
tests.
|
|
|
|
|
|
|
|
- restrict the -include force-include flag to GCC and Clang
- drop the redundant explicit include in the kernel string maker tests
- apply clang-format
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|