summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2020-03-05 19:13:55 +0200
committerAndreas Kling <kling@serenityos.org>2020-03-06 11:19:51 +0100
commit773afefe7c44d8ebf75f9e3909c950214a3540f7 (patch)
treed304e12bbd03637969419af212ad67c798e38610
parent52954ccce6a44931d7454846d8730468dfdcb46a (diff)
downloadserenity-773afefe7c44d8ebf75f9e3909c950214a3540f7.zip
Kernel: Change HandlerPurpose to HandlerType
Also, GenericInterruptHandler class requires to implement two new methods.
-rw-r--r--Kernel/ACPI/ACPIDynamicParser.h1
-rw-r--r--Kernel/Arch/i386/CPU.cpp12
-rw-r--r--Kernel/Devices/FloppyDiskDevice.h2
-rw-r--r--Kernel/Devices/HardwareTimer.h1
-rw-r--r--Kernel/Devices/KeyboardDevice.h2
-rw-r--r--Kernel/Devices/PATAChannel.h2
-rw-r--r--Kernel/Devices/PIT.h2
-rw-r--r--Kernel/Devices/PS2MouseDevice.h2
-rw-r--r--Kernel/Devices/SB16.h2
-rw-r--r--Kernel/Interrupts/GenericInterruptHandler.h6
-rw-r--r--Kernel/Interrupts/IRQHandler.h4
-rw-r--r--Kernel/Interrupts/SharedIRQHandler.h4
-rw-r--r--Kernel/Interrupts/SpuriousInterruptHandler.h4
-rw-r--r--Kernel/Interrupts/UnhandledInterruptHandler.h4
-rw-r--r--Kernel/Net/E1000NetworkAdapter.h2
-rw-r--r--Kernel/Net/RTL8139NetworkAdapter.h2
16 files changed, 39 insertions, 13 deletions
diff --git a/Kernel/ACPI/ACPIDynamicParser.h b/Kernel/ACPI/ACPIDynamicParser.h
index ca548ec5a5..fe9642a688 100644
--- a/Kernel/ACPI/ACPIDynamicParser.h
+++ b/Kernel/ACPI/ACPIDynamicParser.h
@@ -47,6 +47,7 @@ namespace ACPI {
virtual void disable_aml_interpretation() override;
virtual void try_acpi_shutdown() override;
virtual bool can_shutdown() override { return true; }
+ virtual const char* purpose() const override { return "ACPI Parser"; }
protected:
DynamicParser();
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index b399f12d0c..cfe1888f9a 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -410,17 +410,17 @@ static void revert_to_unused_handler(u8 interrupt_number)
void register_generic_interrupt_handler(u8 interrupt_number, GenericInterruptHandler& handler)
{
if (s_interrupt_handler[interrupt_number] != nullptr) {
- if (s_interrupt_handler[interrupt_number]->purpose() == HandlerPurpose::UnhandledInterruptHandler) {
+ if (s_interrupt_handler[interrupt_number]->type() == HandlerType::UnhandledInterruptHandler) {
s_interrupt_handler[interrupt_number] = &handler;
return;
}
if (s_interrupt_handler[interrupt_number]->is_shared_handler() && !s_interrupt_handler[interrupt_number]->is_sharing_with_others()) {
- ASSERT(s_interrupt_handler[interrupt_number]->purpose() == HandlerPurpose::SharedIRQHandler);
+ ASSERT(s_interrupt_handler[interrupt_number]->type() == HandlerType::SharedIRQHandler);
static_cast<SharedIRQHandler*>(s_interrupt_handler[interrupt_number])->register_handler(handler);
return;
}
if (!s_interrupt_handler[interrupt_number]->is_shared_handler()) {
- ASSERT(s_interrupt_handler[interrupt_number]->purpose() == HandlerPurpose::IRQHandler);
+ ASSERT(s_interrupt_handler[interrupt_number]->type() == HandlerType::IRQHandler);
auto& previous_handler = *s_interrupt_handler[interrupt_number];
s_interrupt_handler[interrupt_number] = nullptr;
SharedIRQHandler::initialize(interrupt_number);
@@ -437,12 +437,12 @@ void register_generic_interrupt_handler(u8 interrupt_number, GenericInterruptHan
void unregister_generic_interrupt_handler(u8 interrupt_number, GenericInterruptHandler& handler)
{
ASSERT(s_interrupt_handler[interrupt_number] != nullptr);
- if (s_interrupt_handler[interrupt_number]->purpose() == HandlerPurpose::UnhandledInterruptHandler) {
+ if (s_interrupt_handler[interrupt_number]->type() == HandlerType::UnhandledInterruptHandler) {
dbg() << "Trying to unregister unused handler (?)";
return;
}
if (s_interrupt_handler[interrupt_number]->is_shared_handler() && !s_interrupt_handler[interrupt_number]->is_sharing_with_others()) {
- ASSERT(s_interrupt_handler[interrupt_number]->purpose() == HandlerPurpose::SharedIRQHandler);
+ ASSERT(s_interrupt_handler[interrupt_number]->type() == HandlerType::SharedIRQHandler);
static_cast<SharedIRQHandler*>(s_interrupt_handler[interrupt_number])->unregister_handler(handler);
if (!static_cast<SharedIRQHandler*>(s_interrupt_handler[interrupt_number])->sharing_devices_count()) {
revert_to_unused_handler(interrupt_number);
@@ -450,7 +450,7 @@ void unregister_generic_interrupt_handler(u8 interrupt_number, GenericInterruptH
return;
}
if (!s_interrupt_handler[interrupt_number]->is_shared_handler()) {
- ASSERT(s_interrupt_handler[interrupt_number]->purpose() == HandlerPurpose::IRQHandler);
+ ASSERT(s_interrupt_handler[interrupt_number]->type() == HandlerType::IRQHandler);
revert_to_unused_handler(interrupt_number);
return;
}
diff --git a/Kernel/Devices/FloppyDiskDevice.h b/Kernel/Devices/FloppyDiskDevice.h
index 607b9d474e..6471a6f66c 100644
--- a/Kernel/Devices/FloppyDiskDevice.h
+++ b/Kernel/Devices/FloppyDiskDevice.h
@@ -172,6 +172,8 @@ public:
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return 0; }
virtual bool can_write(const FileDescription&) const override { return true; }
+ virtual const char* purpose() const override { return "Floppy Disk Controller"; }
+
protected:
explicit FloppyDiskDevice(DriveType);
diff --git a/Kernel/Devices/HardwareTimer.h b/Kernel/Devices/HardwareTimer.h
index 1e6429f767..5dbb968c7b 100644
--- a/Kernel/Devices/HardwareTimer.h
+++ b/Kernel/Devices/HardwareTimer.h
@@ -32,7 +32,6 @@ namespace Kernel {
class HardwareTimer : public IRQHandler {
public:
u32 seconds_since_boot();
-
protected:
HardwareTimer(u8 irq_number);
u32 m_seconds_since_boot { 0 };
diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h
index 8ea872ac0a..1387d95928 100644
--- a/Kernel/Devices/KeyboardDevice.h
+++ b/Kernel/Devices/KeyboardDevice.h
@@ -57,6 +57,8 @@ public:
virtual ssize_t write(FileDescription&, const u8* buffer, ssize_t) override;
virtual bool can_write(const FileDescription&) const override { return true; }
+ virtual const char* purpose() const override { return class_name(); }
+
private:
// ^IRQHandler
virtual void handle_irq(RegisterState&) override;
diff --git a/Kernel/Devices/PATAChannel.h b/Kernel/Devices/PATAChannel.h
index 091e96b9e9..b7aabb808b 100644
--- a/Kernel/Devices/PATAChannel.h
+++ b/Kernel/Devices/PATAChannel.h
@@ -72,6 +72,8 @@ public:
RefPtr<PATADiskDevice> master_device() { return m_master; };
RefPtr<PATADiskDevice> slave_device() { return m_slave; };
+ virtual const char* purpose() const override { return "PATA Channel"; }
+
private:
//^ IRQHandler
virtual void handle_irq(RegisterState&) override;
diff --git a/Kernel/Devices/PIT.h b/Kernel/Devices/PIT.h
index bcb0d7a3f8..b60c39760d 100644
--- a/Kernel/Devices/PIT.h
+++ b/Kernel/Devices/PIT.h
@@ -58,6 +58,8 @@ public:
static PIT& the();
u32 ticks_this_second() const;
+ virtual const char* purpose() const override { return "System Timer"; }
+
private:
PIT();
// ^IRQHandler
diff --git a/Kernel/Devices/PS2MouseDevice.h b/Kernel/Devices/PS2MouseDevice.h
index 39fa48a5fe..60d1700e15 100644
--- a/Kernel/Devices/PS2MouseDevice.h
+++ b/Kernel/Devices/PS2MouseDevice.h
@@ -47,6 +47,8 @@ public:
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_write(const FileDescription&) const override { return true; }
+ virtual const char* purpose() const override { return class_name(); }
+
private:
// ^IRQHandler
void handle_vmmouse_absolute_pointer();
diff --git a/Kernel/Devices/SB16.h b/Kernel/Devices/SB16.h
index 71dd25c0c8..d438acc052 100644
--- a/Kernel/Devices/SB16.h
+++ b/Kernel/Devices/SB16.h
@@ -50,6 +50,8 @@ public:
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_write(const FileDescription&) const override { return true; }
+ virtual const char* purpose() const override { return class_name(); }
+
private:
// ^IRQHandler
virtual void handle_irq(RegisterState&) override;
diff --git a/Kernel/Interrupts/GenericInterruptHandler.h b/Kernel/Interrupts/GenericInterruptHandler.h
index 2fec083c67..9c7bfb3c6d 100644
--- a/Kernel/Interrupts/GenericInterruptHandler.h
+++ b/Kernel/Interrupts/GenericInterruptHandler.h
@@ -33,7 +33,7 @@
namespace Kernel {
-enum class HandlerPurpose : u8 {
+enum class HandlerType : u8 {
IRQHandler = 1,
SharedIRQHandler = 2,
UnhandledInterruptHandler = 3,
@@ -56,7 +56,9 @@ public:
virtual bool is_shared_handler() const = 0;
virtual bool is_sharing_with_others() const = 0;
- virtual HandlerPurpose purpose() const = 0;
+ virtual HandlerType type() const = 0;
+ virtual const char* purpose() const = 0;
+ virtual const char* controller() const = 0;
virtual bool eoi() = 0;
void increment_invoking_counter();
diff --git a/Kernel/Interrupts/IRQHandler.h b/Kernel/Interrupts/IRQHandler.h
index 4505a4327e..d753f5e7e2 100644
--- a/Kernel/Interrupts/IRQHandler.h
+++ b/Kernel/Interrupts/IRQHandler.h
@@ -47,7 +47,9 @@ public:
virtual bool eoi() override;
- virtual HandlerPurpose purpose() const override { return HandlerPurpose::IRQHandler; }
+ virtual HandlerType type() const override { return HandlerType::IRQHandler; }
+ virtual const char* purpose() const override { return "IRQ Handler"; }
+ virtual const char* controller() const override { return m_responsible_irq_controller->model(); }
virtual size_t sharing_devices_count() const override { return 0; }
virtual bool is_shared_handler() const override { return false; }
diff --git a/Kernel/Interrupts/SharedIRQHandler.h b/Kernel/Interrupts/SharedIRQHandler.h
index 56da1b5f3a..ca82e692db 100644
--- a/Kernel/Interrupts/SharedIRQHandler.h
+++ b/Kernel/Interrupts/SharedIRQHandler.h
@@ -50,7 +50,9 @@ public:
virtual bool is_shared_handler() const override { return true; }
virtual bool is_sharing_with_others() const override { return false; }
- virtual HandlerPurpose purpose() const override { return HandlerPurpose::SharedIRQHandler; }
+ virtual HandlerType type() const override { return HandlerType::SharedIRQHandler; }
+ virtual const char* purpose() const override { return "Shared IRQ Handler"; }
+ virtual const char* controller() const override { return m_responsible_irq_controller->model(); }
private:
void enable_interrupt_vector();
diff --git a/Kernel/Interrupts/SpuriousInterruptHandler.h b/Kernel/Interrupts/SpuriousInterruptHandler.h
index 92f36bdce0..046e6c8222 100644
--- a/Kernel/Interrupts/SpuriousInterruptHandler.h
+++ b/Kernel/Interrupts/SpuriousInterruptHandler.h
@@ -50,7 +50,9 @@ public:
virtual bool is_shared_handler() const override { return false; }
virtual bool is_sharing_with_others() const override { return false; }
- virtual HandlerPurpose purpose() const override { return HandlerPurpose::SpuriousInterruptHandler; }
+ virtual HandlerType type() const override { return HandlerType::SpuriousInterruptHandler; }
+ virtual const char* purpose() const override { return "Spurious Interrupt Handler"; }
+ virtual const char* controller() const override { return m_responsible_irq_controller->model(); }
private:
void enable_interrupt_vector();
diff --git a/Kernel/Interrupts/UnhandledInterruptHandler.h b/Kernel/Interrupts/UnhandledInterruptHandler.h
index 10732cdc8f..7155aafa0d 100644
--- a/Kernel/Interrupts/UnhandledInterruptHandler.h
+++ b/Kernel/Interrupts/UnhandledInterruptHandler.h
@@ -41,7 +41,9 @@ public:
virtual bool eoi() override;
- virtual HandlerPurpose purpose() const override { return HandlerPurpose::UnhandledInterruptHandler; }
+ virtual HandlerType type() const override { return HandlerType::UnhandledInterruptHandler; }
+ virtual const char* purpose() const override { return "Unhandled Interrupt Handler"; }
+ virtual const char* controller() const override { ASSERT_NOT_REACHED(); }
virtual size_t sharing_devices_count() const override { return 0; }
virtual bool is_shared_handler() const override { return false; }
diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h
index 51499816f3..3951429c13 100644
--- a/Kernel/Net/E1000NetworkAdapter.h
+++ b/Kernel/Net/E1000NetworkAdapter.h
@@ -46,6 +46,8 @@ public:
virtual void send_raw(const u8*, size_t) override;
virtual bool link_up() override;
+ virtual const char* purpose() const override { return class_name(); }
+
private:
virtual void handle_irq(RegisterState&) override;
virtual const char* class_name() const override { return "E1000NetworkAdapter"; }
diff --git a/Kernel/Net/RTL8139NetworkAdapter.h b/Kernel/Net/RTL8139NetworkAdapter.h
index 95e35d811c..d340a7bd66 100644
--- a/Kernel/Net/RTL8139NetworkAdapter.h
+++ b/Kernel/Net/RTL8139NetworkAdapter.h
@@ -47,6 +47,8 @@ public:
virtual void send_raw(const u8*, size_t) override;
virtual bool link_up() override { return m_link_up; }
+ virtual const char* purpose() const override { return class_name(); }
+
private:
virtual void handle_irq(RegisterState&) override;
virtual const char* class_name() const override { return "RTL8139NetworkAdapter"; }