summaryrefslogtreecommitdiff
path: root/Kernel/Interrupts
AgeCommit message (Collapse)Author
2023-05-21Kernel: Move handle_interrupt out-of-line in PCIIRQHandlerPankaj Raghav
Upgrade to GCC 13.1.0 triggered an UBSAN in PCIIRQHandler. Moving the handle_interrupt() function out-of-line fixes this issue.
2023-05-07Kernel: Introduce PCIIRQHandlerPankaj Raghav
PCIIRQHandler is a generic IRQ handler that the device driver can inherit to use either Pin or MSI(x) based interrupt mechanism. The PCIIRQHandler can do what the existing IRQHandler can do for pin based interrupts but also deal with MSI based interrupts. We can hopefully convert all the PCI based devices to use this handler so that MSI(x) can be used.
2023-05-07Kernel: Add m_reserved private variable to GenericInterruptHandlerPankaj Raghav
Pin-based PCI device are allocated an IRQ, and it could be shared with multiple devices. An interrupt handler with an IRQ for a PCI device will get registered only during the driver initialization. For MSI(x) interrupts, the driver has to allocate IRQs and this field can be used to skip IRQs that have already been reserved by pin-based interrupts so that we don't have to share IRQs, which generally will reduce the performance.
2023-04-25Kernel: Remove is_sharing_with_others API from GenericInterruptHandlerPankaj Raghav
is_sharing_with_others API was never really put to use properly since it was introduced. The only place where it is used in Interrupts.cpp is in conjuction with is_shared_handler() which is only true for SharedIRQHandler and is_sharing_with_others will always return false. Remove that API.
2023-04-25Kernel: Use SpinlockProtected list in SharedIRQHandlerPankaj Raghav
Adding handlers to the SharedIRQHandler without any lock is not thread safe. Use SpinlockProtected list instead.
2023-04-25Kernel: Set IRQHandler m_shared_with_others when the irq is sharedPankaj Raghav
If IRQHandler's IRQ is shared, then disable_irq() should not call the controller to disable that IRQ as some other device might be using it. IRQHandler had a private variable to indicate if it is being shared: m_shared_with_others but it was never modified even if the IRQ was shared. Add a new member function set_shared_with_others() to enable/disable m_shared_with_others member of IRQHandler class. This function is called when an IRQHandler is being added/removed as a part of SharedIRQHandler.
2023-02-08Everywhere: Use ReadonlySpan<T> instead of Span<T const>MacDue
2022-12-28Kernel: Reorganize Arch/x86 directory to Arch/x86_64 after i686 removalLiav A
No functional change.
2022-11-19Kernel+lsirq: Track per-CPU IRQ handler call countsAndreas Kling
Each GenericInterruptHandler now tracks the number of calls that each CPU has serviced. This takes care of a FIXME in the /sys/kernel/interrupts generator. Also, the lsirq command line tool now displays per-CPU call counts.
2022-11-19Kernel: Rename GenericInterruptHandler "invoking count" to "call count"Andreas Kling
2022-10-17Kernel: Move InterruptDisabler out of Arch directoryTimon Kruiper
The code in this file is not architecture specific, so it can be moved to the base Kernel directory.
2022-09-25Kernel: Store IRQControllers in NonnullRefPtrs instead of RefPtrsIdan Horowitz
These are always non-null, so there's no point in storing them in a nullable container.
2022-09-20Kernel: Move x86-specific IRQ controller code to Arch/x86 directoryLiav A
The PIC and APIC code are specific to x86 platforms, so move them out of the general Interrupts directory to Arch/x86/common/Interrupts directory instead.
2022-09-20Kernel: Move IO delay code to x86 architecture subdirectoryLiav A
Many code patterns and hardware procedures rely on reliable delay in the microseconds granularity, and since they are using such delays which are valid cases, but should not rely on x86 specific code, we allow to determine in compile time the proper platform-specific code to use to invoke such delays.
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-07-12Everywhere: Use default StringView constructor over nullptrsin-ack
While null StringViews are just as bad, these prevent the removal of StringView(char const*) as that constructor accepts a nullptr. No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-06-02Kernel: Move IRQController and InterruptManagement to Arch directoryTimon Kruiper
These 2 classes currently contain much code that is x86(_64) specific. Move them to the architecture specific directory. This also allows for a simpler implementation for aarch64.
2022-06-02Kernel: Implement InterruptDisabler using generic Processor functionsTimon Kruiper
Now that the code does not use architectural specific code, it is moved to the generic Arch directory and the paths are modified accordingly.
2022-06-02Kernel: Add GenericInterruptHandler.cpp to aarch64 buildTimon Kruiper
This requires us to add an Interrupts.h file in the Kernel/Arch directory, which includes the architecture specific files. The commit also stubs out the functions to be able to compile the aarch64 Kernel.
2022-04-05Kernel: Move create_identity_mapped_region() to MemoryManagerAndreas Kling
This had no business being in RegionTree, since RegionTree doesn't track identity-mapped regions anyway. (We allow *any* address to be identity mapped, not just the ones that are part of the RegionTree's range.)
2022-04-05Kernel: Remove unused ShouldDeallocateVirtualRange parametersAndreas Kling
Since there is no separate virtual range allocator anymore, this is no longer used for anything.
2022-04-03Kernel: Make VM allocation atomic for userspace regionsAndreas Kling
This patch move AddressSpace (the per-process memory manager) to using the new atomic "place" APIs in RegionTree as well, just like we did for MemoryManager in the previous commit. This required updating quite a few places where VM allocation and actually committing a Region object to the AddressSpace were separated by other code. All you have to do now is call into AddressSpace once and it'll take care of everything for you.
2022-04-03LibWeb: Make VM allocation atomic for kernel regionsAndreas Kling
Instead of first allocating the VM range, and then inserting a region with that range into the MM region tree, we now do both things in a single atomic operation: - RegionTree::place_anywhere(Region&, size, alignment) - RegionTree::place_specifically(Region&, address, size) To reduce the number of things we do while locking the region tree, we also require callers to provide a constructed Region object.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-17Kernel: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-02-21Kernel: Fix allocating identity-mapped APIC memory on x86_64Tom
We were not allocating enough memory due to using u32 instead of FlatPtr for each AP's stack pointer.
2022-02-21Kernel: Implement booting all CPU cores on x86_64Tom
The AP boot code was partially adapted to build on x86_64 but didn't properly jump into 64 bit mode. Furthermore, the APIC code was still using 32 bit pointers. Fixes #12662
2022-02-05Kernel/Interrupts: Remove stale MSIHandler classLiav A
When we implement MSI support, we can rely on the IRQHandler class for installing IRQ handlers at the right location.
2022-02-03Kernel: Stop using the make<T> factory method in the KernelIdan Horowitz
As make<T> is infallible, it really should not be used anywhere in the Kernel. Instead replace with fallible `new (nothrow)` calls, that will eventually be error-propagated.
2022-02-02Kernel: Add conditional call to disable_irq in IRQHandler constructorPankaj Raghav
There is no use in calling disable_irq function in the IRQHandler constructor if irq was not registered before. So add a condition where we call disable_irq only if the irq was registered before.
2022-01-30Kernel/Interrupts: Initialize two spurious handlers when PIC is disabledLiav A
Even if the PIC was disabled it can still generate noise (spurious IRQs) so we need to register two handlers for handling such cases. Also, we declare interrupt service routine offset 0x20 to 0x2f as reserved, so when the PIC is disabled, we can handle spurious IRQs from the PIC at separate handlers.
2022-01-30Kernel: Use a constexpr declaration for the disabled PIC IRQ baseLiav A
2022-01-30Kernel: Remove unnecessary includes from Thread.hAndreas Kling
...and deal with the fallout by adding missing includes everywhere.
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-07Everywhere: Fix many spelling errorsmjz19910
2022-01-05Kernel: Use MUST + Vector::try_empend instead of Vector::empendBrian Gianforcaro
In preparation for making Vector::empend unavailable during compilation of the Kernel.
2021-12-28Kernel: Propagate overflow errors from Memory::page_round_upGuilherme Goncalves
Fixes #11402.
2021-12-26Kernel: Encapsulate APIC initialization inside InterruptManagementPankaj Raghav
Currently the APIC class is constructed irrespective of whether it is used or not. So, move APIC initialization from init to the InterruptManagement class and construct the APIC class only when it is needed.
2021-12-23Kernel: Move Multi Processor Parser code to a separate directoryLiav A
2021-12-22Kernel: Initialize SupriousInterruptHandler::m_enabled on constructionBrian Gianforcaro
Found by PVS Studio Static Analysis
2021-12-22Kernel: Move userspace virtual address range base to 0x10000Idan Horowitz
Now that the shared bottom 2 MiB virtual address mappings are gone userspace can use lower virtual addresses.
2021-12-22Kernel: Setup APIC AP cores boot environment before init_stage2Idan Horowitz
Since this range is mapped in already in the kernel page directory, we can initialize it before jumping into the first kernel process which lets us avoid mapping in the range into init_stage2's address space. This brings us half-way to removing the shared bottom 2 MiB mapping in every process, leaving only the Prekernel.
2021-12-20Kernel: Ensure SMP mode is not enabled if IOAPIC mode is disabledLiav A
We need to use the IOAPIC in SMP mode, so if the user requested to disable it, we can't enable SMP mode either.
2021-12-14Kernel: Allow switching to IOAPIC mode even without enabling SMPLiav A
This small change allows to use the IOAPIC by default without to enable SMP mode, which emulates Uni-Processor setup with IOAPIC instead of using the PIC. This opens the opportunity to utilize other types of interrupts like MSI and MSI-X interrupts.
2021-12-14Kernel/Interrupts: Add ByteReaders to read possible unaligned MADT dataLiav A
The MADT data could be on unaligned boundary - for example, a GSI number (u32) on unaligned address which leads to a KUBSAN error and halting the system.
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
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-15Kernel: Add cross platform RegisterState header and Aarch64 versionJames Mintram
A new RegisterState header includes the platform specific RegisterState header based on the platform being compiled. The Aarch64 RegisterState header contains stubs for Debug
2021-10-06Kernel: Don't retrieve possibly nonexistent APIC tableTim Schumacher