summaryrefslogtreecommitdiff
path: root/Kernel/Bus
AgeCommit message (Collapse)Author
2022-01-13Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOrIdan Horowitz
This mostly just moved the problem, as a lot of the callers are not capable of propagating the errors themselves, but it's a step in the right direction.
2022-01-13Kernel: Use StringView instead of String in RingBuffer's constructorIdan Horowitz
This String was being copied into a KString internally anyways.
2022-01-12Kernel: Replace all usages of String::number with KString::numberIdan Horowitz
2022-01-09Kernel: Use DMA helper everywherePankaj Raghav
Port UCHI, AC97, SB16, BMIDEChannel and AHCIPort to use the helper to allocate DMA buffers.
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.
2022-01-07Everywhere: Fix many spelling errorsmjz19910
2022-01-03Kernel: Use `try_create` not `must_create` in SysFSUSB::createJesse Buhagiar
The function `KString::must_create()` can only be enforced during early boot (that is, when `g_in_early_boot` is true), hence the use of this function during runtime causes a `VERIFY` to assert, leading to a Kernel Panic. We should instead use `TRY()` along with `try_create()` to prevent this from crashing whenever a USB device is inserted into the system, and we don't have enough memory to allocate the device's KString.
2022-01-01Kernel/NVMe: Add initial NVMe driver supportPankaj Raghav
Add a basic NVMe driver support to serenity based on NVMe spec 1.4. The driver can support multiple NVMe drives (subsystems). But in a NVMe drive, the driver can support one controller with multiple namespaces. Each core will get a separate NVMe Queue. As the system lacks MSI support, PIN based interrupts are used for IO. Tested the NVMe support by replacing IDE driver with the NVMe driver :^)
2021-12-30Kernel: Tighten String-related includesDaniel Bertalan
2021-12-28Kernel: Propagate overflow errors from Memory::page_round_upGuilherme Goncalves
Fixes #11402.
2021-12-28Kernel: Remove the kmalloc_eternal heap :^)Andreas Kling
This was a premature optimization from the early days of SerenityOS. The eternal heap was a simple bump pointer allocator over a static byte array. My original idea was to avoid heap fragmentation and improve data locality, but both ideas were rooted in cargo culting, not data. We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting the rest. This patch replaces all kmalloc_eternal() usage by regular kmalloc().
2021-12-28Kernel: Remove the KString::try_create(String::formatted(...)) patternDaniel Bertalan
We can now directly create formatted KStrings with KString::formatted. :^)
2021-12-14Kernel/SysFS: Prevent allocation for component name during constructionLiav A
Instead, allocate before constructing the object and pass NonnullOwnPtr of KString to the object if needed. Some classes can determine their names as they have a known attribute to look for or have a static name.
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-09Kernel: Some clang-tidy fixes in Bus/VirtIOHendiadyoin1
2021-12-09Kernel: Some clang-tidy fixes in Bus/USBHendiadyoin1
2021-12-09Kernel: Mark USBTransfer's constructor as privateHendiadyoin1
We have a try_create method for that.
2021-12-09Kernel: Fix some clang-tidy warnings in PCI::AccessHendiadyoin1
2021-12-09Kernel: Use AK:any_of in PCI::Device capability checksHendiadyoin1
This is equivalent to std::any_of as clang-tidy suggests.
2021-12-09Kernel: Construct PCIDeviceAttributeSysFSComponent with StringViewsHendiadyoin1
There is no use to create a temporary String of a char const* to just cast it to a StringView on SysFSComponent construction again. Also this could have lead to a UAF bug.
2021-12-09Kernel: Pass capabilities as const reference in PCI::AddressHendiadyoin1
2021-12-09Kernel: Mark PCI::Address as trivially copyableHendiadyoin1
2021-12-05Kernel: Mark kernel smart-pointer classes as [[nodiscard]]Sam Atkins
And cast the unused return values to void.
2021-11-30Kernel: Handle string format errors in PCIDeviceAttributeSysFSComponentBrian Gianforcaro
2021-11-30Kernel: Register Virtio console ports with device managementJelle Raaijmakers
Previously, Virtio console ports would not show up in `/sys/dev/char/`. Also adds support to `SystemServer` to create more than one console port device in `/dev/` in the multiport case.
2021-11-23Kernel: Implement AC97 audio device driverJelle Raaijmakers
2021-11-21Everywhere: Fix spelling of "offsetted"Andreas Kling
This word is actually pretty awkward in context, but this patch merely fixes the spelling instead of finding a better word.
2021-11-18Kernel: Use DistinctNumeric for filesystem ID'sAndreas Kling
This patch adds the FileSystemID type, which is a distinct u32. This prevents accidental conversion from arbitrary integers.
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-11-10Kernel: Make Inode::traverse_as_directory() callback return ErrorOrAndreas Kling
This allows us to propagate errors from inside the callback with TRY().
2021-11-10Everywhere: Remove unused AK/Bitmap includesBen Wiederhake
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
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: Ensure m_domains is not empty if scanning with memory accessLiav A
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-10-23Kernel/PCI: Simplify detect_optimal_access_type functionLiav A
Instead of getting the kernel commandline argument as function parameter we just take internally in the function.
2021-10-14Kernel: Add per platform Processor.h headersJames Mintram
The platform independent Processor.h file includes the shared processor code and includes the specific platform header file. All references to the Arch/x86/Processor.h file have been replaced with a reference to Arch/Processor.h.
2021-10-14Kernel: Add header includes closer to their useJames Mintram
2021-10-03Kernel: Fix copy paste in VirtIO::RNG::class_name()Brian Gianforcaro
Ben noticed this copy paste error during code review. Co-authored-by: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
2021-10-03Kernel: Use `operator ""sv` in all purpose() implementationsBrian Gianforcaro
Previously there was a mix of returning plain strings and returning explicit string views using `operator ""sv`. This change switches them all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-03Kernel: Use `operator ""sv` in all class_name() implementationsBrian Gianforcaro
Previously there was a mix of returning plain strings and returning explicit string views using `operator ""sv`. This change switches them all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-01Kernel: Move x86 IO instructions code into the x86 specific folderLiav A
2021-10-01Kernel: Remove IO.h include from a bunch of placesLiav A
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/PCI: Cache interrupt line and interrupt pin of a deviceLiav A
This allows us to remove the PCI::get_interrupt_line API function. As a result, this removes a bunch of not so great patterns that we used to cache PCI interrupt line in many IRQHandler derived classes instead of just using interrupt_number method of IRQHandler class.
2021-09-29Kernel/PCI: Propagate usage of DeviceIdentifier everywhereLiav A
This allows us to remove a bunch of PCI API functions, and instead to leverage the cached data from DeviceIdentifier object in many places.
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.