mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Change HandlerPurpose to HandlerType
Also, GenericInterruptHandler class requires to implement two new methods.
This commit is contained in:
parent
52954ccce6
commit
773afefe7c
Notes:
sideshowbarker
2024-07-19 08:52:29 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/773afefe7c4 Pull-request: https://github.com/SerenityOS/serenity/pull/1353
16 changed files with 39 additions and 13 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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"; }
|
||||
|
|
|
@ -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"; }
|
||||
|
|
Loading…
Reference in a new issue