| Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
Besides address information, each PCI function also has associated
metadata. The function_info type carries the standard metadata for a PCI
function: vendor and device IDs, the class code 3-tuple, and the header
type. A bus scan reads those values when enumerating the PCI ECAM data,
and returns it.
The header type of the is stored in its raw form, encoding both the type
of the PCI function header, as well as the multi-function flag.
function_info provides two functions (type() and is_multifunction()) to
extract those pieces of information from the raw header type value. In
addition to the type extraction function, this change introduces an
enumeration type (kernel::devices::pci::header_type) representing the
standardized type values for PCI function headers. Unknown function
types are presented as opaque values.
Unit tests for derived attributes of a PCI function are provided.
|
|
A PCI function is identified system-wide by its segment group, bus,
device and function number. This identifier is represented by the new
function_address type. It encapsulates the identifying 4-tuple (segment
group, bus, device, function). This allows the kernel to reference a
specific PCI function unambiguously within the system. The type is
comparable and ordered by that tuple and formats as 'ssss:bb:dd.f'. The
ordering is lexicographical based on the tuple (segment group, bus,
device, function).
Unit tests for the API surface of function_address are included.
|
|
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.
|
|
In testing, the mmio_allocator gets replaced for every scenario
requiring all heap allocations to be properly cleaned up before the
replacement.
|
|
|
|
|
|
|
|
|
|
The x86_64 platform's higher half memory mapper currently has not
support for huge page mappings. However, the previous implementation did
not explicitly exclude huge page mappings, instead potentially
corrupting the contents of huge pages by treating them as regular pages.
The kernel now panics whenever an attempt is made to map a page inside
a region covered by a huge page, or when trying to unmap a huge page or
a range covered by a huge page.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Previously, the page mapper was expected to automatically free all
frames that had become unused. However, this only works if all mappings
refer to plain memory frames. In the case of MMIO frames, the mapper
would still try to release the frame via the global frame allocator,
which is incorrect, leading to undefined behavior in the worst case.
This problem was discovered during work the PCI/PCIe subsystem, since
we want to unmap any unused buses during enumeration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Previously, clang-tidy would fall back to the global GCC toolchain and
its include paths, meaning that any custom patches would be ignored. A
partial solution had already been implemented for header checks, but
the regular cpp file checks did not use the new flags.
This change extracts the GCC toolchain location determination into the
platform's CMake toolchain file and then applies those flags to both
header and cpp file checks consistently.
|
|
|
|
libs/acpi: implement MCFG table support
See merge request teachos/kernel!72
|
|
|
|
|
|
|
|
|
|
Previously, ACPI table addresses in both the RSDT and XSDT were
converted to pointers. However, this is not actually correct, since
within the object model of the kernel, pointers always refer to
objects by their linear address, and the addresses encoded in ACPI
tables are, by necessity, physical addresses. The API should therefore
be honest about the fact that the addresses returned by accessors of
the RSDT and XSDT are physical addresses, not pointers to live objects.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kstd: add Catch2 string makers for printable test output source from develop branch
See merge request teachos/kernel!69
|
|
- 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>
|
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
|
|
|
|
|
|
kstd: implement fixed-size ring_buffer
This patchset introduces a (non-standard) container to the kernel standard
library. The new container, `kstd::ring_buffer<T, N>`, is a fixed-size ring
buffer, with an LRU overwrite policy. This means, that the size of the buffer
is defined at compile-time. When a buffer is full, pushing further elements
into it will replace existing ones in a Least Recently Used manner.
The first target application of this new container is an extension to the
existing logging system, providing a kernel log buffer.
See merge request teachos/kernel!62
|