mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:17:35 +00:00
Kernel/Interrupts: Return boolean on whether we handled the interrupt
If we are in a shared interrupt handler, the called handlers might indicate it was not their interrupt, so we should not increment the call counter of these handlers.
This commit is contained in:
parent
7a6d5a7b8b
commit
b91df26d4a
43 changed files with 125 additions and 71 deletions
|
@ -129,25 +129,26 @@ UNMAP_AFTER_INIT void I8042Controller::detect_devices()
|
|||
m_mouse_device->enable_interrupts();
|
||||
}
|
||||
|
||||
void I8042Controller::irq_process_input_buffer(HIDDevice::Type)
|
||||
bool I8042Controller::irq_process_input_buffer(HIDDevice::Type)
|
||||
{
|
||||
VERIFY(Processor::current().in_irq());
|
||||
|
||||
u8 status = IO::in8(I8042_STATUS);
|
||||
if (!(status & I8042_BUFFER_FULL))
|
||||
return;
|
||||
return false;
|
||||
HIDDevice::Type data_for_device = ((status & I8042_WHICH_BUFFER) == I8042_MOUSE_BUFFER) ? HIDDevice::Type::Mouse : HIDDevice::Type::Keyboard;
|
||||
u8 byte = IO::in8(I8042_BUFFER);
|
||||
if (data_for_device == HIDDevice::Type::Mouse) {
|
||||
VERIFY(m_mouse_device);
|
||||
static_cast<PS2MouseDevice&>(*m_mouse_device).irq_handle_byte_read(byte);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (data_for_device == HIDDevice::Type::Keyboard) {
|
||||
VERIFY(m_keyboard_device);
|
||||
static_cast<PS2KeyboardDevice&>(*m_keyboard_device).irq_handle_byte_read(byte);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void I8042Controller::do_drain()
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
void prepare_for_output();
|
||||
void prepare_for_input(HIDDevice::Type);
|
||||
|
||||
void irq_process_input_buffer(HIDDevice::Type);
|
||||
bool irq_process_input_buffer(HIDDevice::Type);
|
||||
|
||||
RefPtr<MouseDevice> mouse() const;
|
||||
RefPtr<KeyboardDevice> keyboard() const;
|
||||
|
|
|
@ -85,11 +85,11 @@ void PS2KeyboardDevice::irq_handle_byte_read(u8 byte)
|
|||
}
|
||||
}
|
||||
|
||||
void PS2KeyboardDevice::handle_irq(const RegisterState&)
|
||||
bool PS2KeyboardDevice::handle_irq(const RegisterState&)
|
||||
{
|
||||
// The controller will read the data and call irq_handle_byte_read
|
||||
// for the appropriate device
|
||||
m_i8042_controller->irq_process_input_buffer(HIDDevice::Type::Keyboard);
|
||||
return m_i8042_controller->irq_process_input_buffer(HIDDevice::Type::Keyboard);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT RefPtr<PS2KeyboardDevice> PS2KeyboardDevice::try_to_initialize(const I8042Controller& ps2_controller)
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
explicit PS2KeyboardDevice(const I8042Controller&);
|
||||
|
||||
// ^IRQHandler
|
||||
virtual void handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual const char* class_name() const override { return "KeyboardDevice"; }
|
||||
|
|
|
@ -40,11 +40,11 @@ UNMAP_AFTER_INIT PS2MouseDevice::~PS2MouseDevice()
|
|||
{
|
||||
}
|
||||
|
||||
void PS2MouseDevice::handle_irq(const RegisterState&)
|
||||
bool PS2MouseDevice::handle_irq(const RegisterState&)
|
||||
{
|
||||
// The controller will read the data and call irq_handle_byte_read
|
||||
// for the appropriate device
|
||||
m_i8042_controller->irq_process_input_buffer(instrument_type());
|
||||
return m_i8042_controller->irq_process_input_buffer(instrument_type());
|
||||
}
|
||||
|
||||
void PS2MouseDevice::irq_handle_byte_read(u8 byte)
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
protected:
|
||||
explicit PS2MouseDevice(const I8042Controller&);
|
||||
// ^IRQHandler
|
||||
virtual void handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
|
||||
struct RawPacket {
|
||||
union {
|
||||
|
|
|
@ -205,8 +205,10 @@ void SB16::dma_start(uint32_t length)
|
|||
IO::out8(0xd4, (channel % 4));
|
||||
}
|
||||
|
||||
void SB16::handle_irq(const RegisterState&)
|
||||
bool SB16::handle_irq(const RegisterState&)
|
||||
{
|
||||
// FIXME: Check if the interrupt was actually for us or not... (shared IRQs)
|
||||
|
||||
// Stop sound output ready for the next block.
|
||||
dsp_write(0xd5);
|
||||
|
||||
|
@ -215,6 +217,7 @@ void SB16::handle_irq(const RegisterState&)
|
|||
IO::in8(DSP_R_ACK); // 16 bit interrupt
|
||||
|
||||
m_irq_queue.wake_all();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SB16::wait_for_irq()
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
private:
|
||||
// ^IRQHandler
|
||||
virtual void handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual const char* class_name() const override { return "SB16"; }
|
||||
|
|
|
@ -586,13 +586,13 @@ void UHCIController::spawn_port_proc()
|
|||
});
|
||||
}
|
||||
|
||||
void UHCIController::handle_irq(const RegisterState&)
|
||||
bool UHCIController::handle_irq(const RegisterState&)
|
||||
{
|
||||
u32 status = read_usbsts();
|
||||
|
||||
// Shared IRQ. Not ours!
|
||||
if (!status)
|
||||
return;
|
||||
return false;
|
||||
|
||||
if constexpr (UHCI_DEBUG) {
|
||||
dbgln("UHCI: Interrupt happened!");
|
||||
|
@ -601,6 +601,7 @@ void UHCIController::handle_irq(const RegisterState&)
|
|||
|
||||
// Write back USBSTS to clear bits
|
||||
write_usbsts(status);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
void write_portsc1(u16 value) { m_io_base.offset(0x10).out(value); }
|
||||
void write_portsc2(u16 value) { m_io_base.offset(0x12).out(value); }
|
||||
|
||||
virtual void handle_irq(const RegisterState&) override;
|
||||
virtual bool handle_irq(const RegisterState&) override;
|
||||
|
||||
void create_structures();
|
||||
void setup_schedule();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue