summaryrefslogtreecommitdiff
path: root/Kernel/Interrupts
AgeCommit message (Collapse)Author
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
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-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-12Kernel: Move ACPI and BIOS code into the new Firmware directoryLiav A
This will somwhat help unify them also under the same SysFS directory in the commit. Also, it feels much more like this change reflects the reality that both ACPI and the BIOS are part of the firmware on x86 computers.
2021-09-10AK+Everywhere: Reduce the number of template parameters of IntrusiveListAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-08Kernel/ACPI: Return Optional container after table searchLiav A
This is a better pattern than returning a PhysicalAddress with a zero value, so the code is more understandable now.
2021-09-06Kernel: Make kernel region allocators return KResultOr<NOP<Region>>Andreas Kling
This expands the reach of error propagation greatly throughout the kernel. Sadly, it also exposes the fact that we're allocating (and doing other fallible things) in constructors all over the place. This patch doesn't attempt to address that of course. That's work for our future selves.
2021-09-04Kernel: Add x2APIC supportTom
This allows addressing all cores on more modern processors. For now, we still have a hardcoded limit of 64 due to s_processors being a static array.