summaryrefslogtreecommitdiff
path: root/Kernel/Bus/PCI/Access.h
AgeCommit message (Collapse)Author
2022-01-08Kernel/PCI: Split host bridge code from the Access singletonLiav A
Two classes are added - HostBridge and MemoryBackedHostBridge, which both derive from HostController class. This allows the kernel to map different busses from different PCI domains in the same time. Each HostController implementation doesn't take the Address object to address PCI devices but instead we take distinct numbers of the PCI bus, device and function as it allows us to specify arbitrary PCI domains in the Address structure and still to get the correct PCI devices. This also matches the hardware behavior of PCI domains - the host bridge merely takes memory operations or IO operations and translates them to addressing of three components - PCI bus, device and function. These changes also greatly simplify how enumeration of Host Bridges work now - scanning of the hardware depends on what the Host bridges can do for us, so in case we have multiple host bridges that expose a memory mapped region or IO ports to access PCI configuration space, we simply let the code of the host bridge to figure out how to fetch data for us. Another semantical change is that a PCI domain structure is no longer attached to a PhysicalAddress, so even in the case that the machine doesn't implement PCI domains, we still treat that machine to contain 1 PCI domain to treat that one host bridge in the same way, like with a machine with one or more PCI domains.
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-09Kernel: Fix some clang-tidy warnings in PCI::AccessHendiadyoin1
2021-10-23Kernel/PCI: Remove InterruptDisabler usageLiav A
Instead, just ensure we pick the m_access_lock and then m_scan_lock when doing a scan/re-scan of the PCI configuration space so we know nobody can actually access the PCI configuration space during the scan. The m_scan_lock is now a Spinlock, to ensure we cannot yield to other process while we do the PCI configuration space scanning.
2021-10-23Kernel/PCI: Split Access::rescan_hardware methodLiav A
To ensure clarity, this method is essentially splitted to two methods to be called according to the access type being determined beforehand.
2021-10-23Kernel/PCI: Rename Access::scan_pci_domains methodLiav A
We rename it to scan_pci_domains_from_acpi_mcfg_table to ensure clarity, because this method relies on the ACPI MCFG table to work.
2021-09-29Kernel/PCI: Remove all macros and replace them with enum classesLiav A
2021-09-29Kernel/PCI: Remove Address from enumeration callbackLiav A
If we need that address, we can always get it from the DeviceIdentifier.
2021-09-29Kernel: Rename two PCI componentsLiav A
Rename ID => HardwareID, and PhysicalID => DeviceIdentifier. This change merely does that to clarify what these objects really are.
2021-09-29Kernel/PCI: Cache more details about PCI devices when enumerating themLiav A
There's no good reason to fetch these values each time we need them.
2021-09-07Kernel/PCI: Simplify the entire subsystemLiav A
A couple of things were changed: 1. Semantic changes - PCI segments are now called PCI domains, to better match what they are really. It's also the name that Linux gave, and it seems that Wikipedia also uses this name. We also remove PCI::ChangeableAddress, because it was used in the past but now it's no longer being used. 2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as they made a bunch of unnecessary complexity. Instead, Windowed access is removed entirely (this was tested, but never was benchmarked), so we are left with IO access and memory access options. The memory access option is essentially mapping the PCI bus (from the chosen PCI domain), to virtual memory as-is. This means that unless needed, at any time, there is only one PCI bus being mapped, and this is changed if access to another PCI bus in the same PCI domain is needed. For now, we don't support mapping of different PCI buses from different PCI domains at the same time, because basically it's still a non-issue for most machines out there. 2. OOM-safety is increased, especially when constructing the Access object. It means that we pre-allocating any needed resources, and we try to find PCI domains (if requested to initialize memory access) after we attempt to construct the Access object, so it's possible to fail at this point "gracefully". 3. All PCI API functions are now separated into a different header file, which means only "clients" of the PCI subsystem API will need to include that header file. 4. Functional changes - we only allow now to enumerate the bus after a hardware scan. This means that the old method "enumerate_hardware" is removed, so, when initializing an Access object, the initializing function must call rescan on it to force it to find devices. This makes it possible to fail rescan, and also to defer it after construction from both OOM-safety terms and hotplug capabilities.
2021-08-15Kernel/SysFS: Don't compute exact size of PCI filesAndreas Kling
There's no need for generated files in SysFS to tell you their precise file size when you stat() them. I noticed when profiling "find /" that we were spending a chunk of time generating and throwing away SysFS content just so we could tell you exactly how large it would be. :^)
2021-08-06Kernel: Remove unused PCI::Access::access_type()Andreas Kling
2021-07-11Kernel: Rename SysFS related classes in PCI codeAndreas Kling
Give them names that sound related to SysFS.
2021-07-11Kernel: Rename SystemExposedFolder => SysFSDirectoryAndreas Kling
"Folder" is a GUI concept, let's call this "Directory". Also, "System" is completely generic, so let's be more specific and call this "SysFS..."
2021-07-11Kernel: Rename SystemExposedComponent => SysFSComponentAndreas Kling
2021-07-02Kernel/PCI: Move the PCI components as a subfolder to the Bus directoryLiav A