diff options
Diffstat (limited to 'Kernel')
22 files changed, 106 insertions, 19 deletions
diff --git a/Kernel/Arch/IRQController.h b/Kernel/Arch/IRQController.h new file mode 100644 index 0000000000..b48d352863 --- /dev/null +++ b/Kernel/Arch/IRQController.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Platform.h> + +#if ARCH(X86_64) || ARCH(I386) +# include <Kernel/Arch/x86/IRQController.h> +#elif ARCH(AARCH64) +# include <Kernel/Arch/aarch64/IRQController.h> +#else +# error "Unknown architecture" +#endif diff --git a/Kernel/Arch/InterruptManagement.h b/Kernel/Arch/InterruptManagement.h new file mode 100644 index 0000000000..b78fd5dc87 --- /dev/null +++ b/Kernel/Arch/InterruptManagement.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Platform.h> + +#if ARCH(X86_64) || ARCH(I386) +# include <Kernel/Arch/x86/InterruptManagement.h> +#elif ARCH(AARCH64) +# include <Kernel/Arch/aarch64/InterruptManagement.h> +#else +# error "Unknown architecture" +#endif diff --git a/Kernel/Arch/aarch64/Dummy.cpp b/Kernel/Arch/aarch64/Dummy.cpp index fb09e631f2..07dda5445a 100644 --- a/Kernel/Arch/aarch64/Dummy.cpp +++ b/Kernel/Arch/aarch64/Dummy.cpp @@ -7,8 +7,8 @@ #include <AK/Singleton.h> #include <AK/Types.h> +#include <Kernel/Arch/aarch64/InterruptManagement.h> #include <Kernel/FileSystem/Inode.h> -#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/KString.h> #include <Kernel/Locking/SpinlockProtected.h> #include <Kernel/Memory/SharedInodeVMObject.h> diff --git a/Kernel/Arch/aarch64/IRQController.h b/Kernel/Arch/aarch64/IRQController.h new file mode 100644 index 0000000000..35882a6ffc --- /dev/null +++ b/Kernel/Arch/aarch64/IRQController.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/RefCounted.h> +#include <AK/Types.h> + +namespace Kernel { + +class GenericInterruptHandler; + +class IRQController : public RefCounted<IRQController> { +public: + virtual ~IRQController() = default; + + virtual void enable(GenericInterruptHandler const&) = 0; + virtual void disable(GenericInterruptHandler const&) = 0; + + virtual void eoi(GenericInterruptHandler const&) const = 0; + + virtual StringView model() const = 0; + +protected: + IRQController() = default; +}; + +} diff --git a/Kernel/Arch/aarch64/InterruptManagement.h b/Kernel/Arch/aarch64/InterruptManagement.h new file mode 100644 index 0000000000..6c80429e67 --- /dev/null +++ b/Kernel/Arch/aarch64/InterruptManagement.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <Kernel/Arch/aarch64/IRQController.h> + +namespace Kernel { + +class InterruptManagement { +public: + static InterruptManagement& the(); + + static u8 acquire_mapped_interrupt_number(u8 original_irq); + + RefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector); +}; + +} diff --git a/Kernel/Interrupts/IRQController.h b/Kernel/Arch/x86/IRQController.h index 016fc80d23..43d12f561c 100644 --- a/Kernel/Interrupts/IRQController.h +++ b/Kernel/Arch/x86/IRQController.h @@ -11,6 +11,8 @@ namespace Kernel { +class GenericInterruptHandler; + enum class IRQControllerType { i8259 = 1, /* Intel 8259 Dual PIC */ i82093AA = 2 /* Intel 82093AA I/O ADVANCED PROGRAMMABLE INTERRUPT CONTROLLER (IOAPIC) */ diff --git a/Kernel/Interrupts/InterruptManagement.h b/Kernel/Arch/x86/InterruptManagement.h index 8d20b05e6a..b6fa990812 100644 --- a/Kernel/Interrupts/InterruptManagement.h +++ b/Kernel/Arch/x86/InterruptManagement.h @@ -12,10 +12,10 @@ #include <AK/RefCounted.h> #include <AK/RefPtr.h> #include <AK/Types.h> +#include <Kernel/Arch/x86/IRQController.h> #include <Kernel/Firmware/ACPI/Definitions.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> #include <Kernel/Interrupts/IOAPIC.h> -#include <Kernel/Interrupts/IRQController.h> namespace Kernel { diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Arch/x86/common/InterruptManagement.cpp index a63f90d94b..08174be0ec 100644 --- a/Kernel/Interrupts/InterruptManagement.cpp +++ b/Kernel/Arch/x86/common/InterruptManagement.cpp @@ -8,11 +8,11 @@ #include <Kernel/API/Syscall.h> #include <Kernel/Arch/InterruptDisabler.h> #include <Kernel/Arch/Interrupts.h> +#include <Kernel/Arch/x86/InterruptManagement.h> #include <Kernel/CommandLine.h> #include <Kernel/Firmware/MultiProcessor/Parser.h> #include <Kernel/Interrupts/APIC.h> #include <Kernel/Interrupts/IOAPIC.h> -#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/Interrupts/PIC.h> #include <Kernel/Interrupts/SharedIRQHandler.h> #include <Kernel/Interrupts/SpuriousInterruptHandler.h> diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 628edbbbdb..5daf2ca395 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -159,7 +159,6 @@ set(KERNEL_SOURCES Interrupts/GenericInterruptHandler.cpp Interrupts/IOAPIC.cpp Interrupts/IRQHandler.cpp - Interrupts/InterruptManagement.cpp Interrupts/PIC.cpp Interrupts/SharedIRQHandler.cpp Interrupts/SpuriousInterruptHandler.cpp @@ -331,9 +330,10 @@ if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64") ${KERNEL_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ASM_wrapper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CrashHandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPU.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPUID.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CrashHandler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/InterruptManagement.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Interrupts.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/PageDirectory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Processor.cpp diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index 91288c4531..8df53cbf6e 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -9,6 +9,7 @@ #include <AK/Try.h> #include <AK/UBSanitizer.h> #include <Kernel/Arch/InterruptDisabler.h> +#include <Kernel/Arch/InterruptManagement.h> #include <Kernel/Arch/x86/ProcessorInfo.h> #include <Kernel/Bus/PCI/API.h> #include <Kernel/Bus/PCI/Access.h> @@ -20,7 +21,6 @@ #include <Kernel/FileSystem/OpenFileDescription.h> #include <Kernel/Heap/kmalloc.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> -#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/KBufferBuilder.h> #include <Kernel/Net/LocalSocket.h> #include <Kernel/Net/NetworkingManagement.h> diff --git a/Kernel/Interrupts/GenericInterruptHandler.cpp b/Kernel/Interrupts/GenericInterruptHandler.cpp index 579e9c8101..62e859a37b 100644 --- a/Kernel/Interrupts/GenericInterruptHandler.cpp +++ b/Kernel/Interrupts/GenericInterruptHandler.cpp @@ -4,10 +4,10 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <Kernel/Arch/InterruptManagement.h> #include <Kernel/Arch/Interrupts.h> #include <Kernel/Assertions.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> -#include <Kernel/Interrupts/InterruptManagement.h> namespace Kernel { GenericInterruptHandler& GenericInterruptHandler::from(u8 interrupt_number) diff --git a/Kernel/Interrupts/IOAPIC.cpp b/Kernel/Interrupts/IOAPIC.cpp index 0b75722bfd..ff89921a07 100644 --- a/Kernel/Interrupts/IOAPIC.cpp +++ b/Kernel/Interrupts/IOAPIC.cpp @@ -6,10 +6,10 @@ #include <AK/Optional.h> #include <Kernel/Arch/InterruptDisabler.h> +#include <Kernel/Arch/x86/InterruptManagement.h> #include <Kernel/Debug.h> #include <Kernel/Interrupts/APIC.h> #include <Kernel/Interrupts/IOAPIC.h> -#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/Sections.h> #define IOAPIC_REDIRECTION_ENTRY_OFFSET 0x10 diff --git a/Kernel/Interrupts/IOAPIC.h b/Kernel/Interrupts/IOAPIC.h index 2c11987905..d2e82f55ef 100644 --- a/Kernel/Interrupts/IOAPIC.h +++ b/Kernel/Interrupts/IOAPIC.h @@ -6,7 +6,7 @@ #pragma once -#include <Kernel/Interrupts/IRQController.h> +#include <Kernel/Arch/x86/IRQController.h> #include <Kernel/Memory/TypedMapping.h> namespace Kernel { diff --git a/Kernel/Interrupts/IRQHandler.cpp b/Kernel/Interrupts/IRQHandler.cpp index 86e53a3404..015e51fdee 100644 --- a/Kernel/Interrupts/IRQHandler.cpp +++ b/Kernel/Interrupts/IRQHandler.cpp @@ -5,9 +5,9 @@ */ #include <Kernel/Arch/InterruptDisabler.h> +#include <Kernel/Arch/InterruptManagement.h> #include <Kernel/Debug.h> #include <Kernel/Interrupts/IRQHandler.h> -#include <Kernel/Interrupts/InterruptManagement.h> namespace Kernel { diff --git a/Kernel/Interrupts/IRQHandler.h b/Kernel/Interrupts/IRQHandler.h index 15661618e8..0804b95f13 100644 --- a/Kernel/Interrupts/IRQHandler.h +++ b/Kernel/Interrupts/IRQHandler.h @@ -8,8 +8,8 @@ #include <AK/RefPtr.h> #include <AK/Types.h> +#include <Kernel/Arch/IRQController.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> -#include <Kernel/Interrupts/IRQController.h> namespace Kernel { diff --git a/Kernel/Interrupts/PIC.h b/Kernel/Interrupts/PIC.h index 2e540e2991..25c3cb937b 100644 --- a/Kernel/Interrupts/PIC.h +++ b/Kernel/Interrupts/PIC.h @@ -7,7 +7,7 @@ #pragma once #include <AK/Types.h> -#include <Kernel/Interrupts/IRQController.h> +#include <Kernel/Arch/x86/IRQController.h> namespace Kernel { diff --git a/Kernel/Interrupts/SharedIRQHandler.cpp b/Kernel/Interrupts/SharedIRQHandler.cpp index 995a13309e..22e3994458 100644 --- a/Kernel/Interrupts/SharedIRQHandler.cpp +++ b/Kernel/Interrupts/SharedIRQHandler.cpp @@ -4,11 +4,10 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <Kernel/Arch/InterruptManagement.h> #include <Kernel/Assertions.h> #include <Kernel/Debug.h> #include <Kernel/Interrupts/IRQHandler.h> -#include <Kernel/Interrupts/InterruptManagement.h> -#include <Kernel/Interrupts/PIC.h> #include <Kernel/Interrupts/SharedIRQHandler.h> #include <Kernel/Sections.h> diff --git a/Kernel/Interrupts/SharedIRQHandler.h b/Kernel/Interrupts/SharedIRQHandler.h index 95623957aa..017d96b33e 100644 --- a/Kernel/Interrupts/SharedIRQHandler.h +++ b/Kernel/Interrupts/SharedIRQHandler.h @@ -9,8 +9,8 @@ #include <AK/NonnullOwnPtr.h> #include <AK/RefPtr.h> #include <AK/Types.h> +#include <Kernel/Arch/IRQController.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> -#include <Kernel/Interrupts/IRQController.h> namespace Kernel { class IRQHandler; diff --git a/Kernel/Interrupts/SpuriousInterruptHandler.cpp b/Kernel/Interrupts/SpuriousInterruptHandler.cpp index 6e78212a10..f67790fbfd 100644 --- a/Kernel/Interrupts/SpuriousInterruptHandler.cpp +++ b/Kernel/Interrupts/SpuriousInterruptHandler.cpp @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <Kernel/Arch/InterruptManagement.h> #include <Kernel/Arch/x86/Interrupts.h> -#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/Interrupts/PIC.h> #include <Kernel/Interrupts/SpuriousInterruptHandler.h> #include <Kernel/Sections.h> diff --git a/Kernel/Interrupts/SpuriousInterruptHandler.h b/Kernel/Interrupts/SpuriousInterruptHandler.h index f1c1e1ac54..9137e80312 100644 --- a/Kernel/Interrupts/SpuriousInterruptHandler.h +++ b/Kernel/Interrupts/SpuriousInterruptHandler.h @@ -8,8 +8,8 @@ #include <AK/OwnPtr.h> #include <AK/Types.h> +#include <Kernel/Arch/IRQController.h> #include <Kernel/Interrupts/GenericInterruptHandler.h> -#include <Kernel/Interrupts/IRQController.h> namespace Kernel { diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp index 231ce1065c..8493e40bb1 100644 --- a/Kernel/Time/HPET.cpp +++ b/Kernel/Time/HPET.cpp @@ -7,7 +7,6 @@ #include <AK/StringView.h> #include <Kernel/Debug.h> #include <Kernel/Firmware/ACPI/Parser.h> -#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/Memory/MemoryManager.h> #include <Kernel/Memory/TypedMapping.h> #include <Kernel/Sections.h> diff --git a/Kernel/init.cpp b/Kernel/init.cpp index d564b3bd7d..fd8ca7ee5a 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -5,6 +5,7 @@ */ #include <AK/Types.h> +#include <Kernel/Arch/InterruptManagement.h> #include <Kernel/Arch/Processor.h> #include <Kernel/BootInfo.h> #include <Kernel/Bus/PCI/Access.h> @@ -38,7 +39,6 @@ #include <Kernel/Graphics/GraphicsManagement.h> #include <Kernel/Heap/kmalloc.h> #include <Kernel/Interrupts/APIC.h> -#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/Interrupts/PIC.h> #include <Kernel/KSyms.h> #include <Kernel/Memory/MemoryManager.h> |