Kernel: Stop using 'int's for indices in interrupt handling

This commit is contained in:
Idan Horowitz 2022-09-25 15:29:24 +03:00
parent 6f6211c5e6
commit 04b1d32b70
Notes: sideshowbarker 2024-07-17 06:38:38 +09:00
4 changed files with 14 additions and 15 deletions

View file

@ -60,7 +60,7 @@ public:
u8 get_irq_vector(u8 mapped_interrupt_vector);
void enumerate_interrupt_handlers(Function<void(GenericInterruptHandler&)>);
IRQController& get_interrupt_controller(int index);
IRQController& get_interrupt_controller(size_t index);
protected:
virtual ~InterruptManagement() = default;

View file

@ -51,7 +51,7 @@ UNMAP_AFTER_INIT void InterruptManagement::initialize()
void InterruptManagement::enumerate_interrupt_handlers(Function<void(GenericInterruptHandler&)> callback)
{
for (int i = 0; i < GENERIC_INTERRUPT_HANDLERS_COUNT; i++) {
for (size_t i = 0; i < GENERIC_INTERRUPT_HANDLERS_COUNT; i++) {
auto& handler = get_interrupt_handler(i);
if (handler.type() == HandlerType::SharedIRQHandler) {
static_cast<SharedIRQHandler&>(handler).enumerate_handlers(callback);
@ -62,9 +62,8 @@ void InterruptManagement::enumerate_interrupt_handlers(Function<void(GenericInte
}
}
IRQController& InterruptManagement::get_interrupt_controller(int index)
IRQController& InterruptManagement::get_interrupt_controller(size_t index)
{
VERIFY(index >= 0);
return *m_interrupt_controllers[index];
}

View file

@ -85,7 +85,7 @@ void IOAPIC::map_interrupt_redirection(u8 interrupt_vector)
isa_identity_map(interrupt_vector);
}
void IOAPIC::isa_identity_map(int index)
void IOAPIC::isa_identity_map(size_t index)
{
InterruptDisabler disabler;
configure_redirection_entry(index, InterruptManagement::acquire_mapped_interrupt_number(index) + IRQ_VECTOR_BASE, DeliveryMode::Normal, false, false, false, true, 0);
@ -165,16 +165,16 @@ void IOAPIC::hard_disable()
IRQController::hard_disable();
}
void IOAPIC::reset_redirection_entry(int index) const
void IOAPIC::reset_redirection_entry(size_t index) const
{
InterruptDisabler disabler;
configure_redirection_entry(index, 0, 0, false, false, false, true, 0);
}
void IOAPIC::configure_redirection_entry(int index, u8 interrupt_vector, u8 delivery_mode, bool logical_destination, bool active_low, bool trigger_level_mode, bool masked, u8 destination) const
void IOAPIC::configure_redirection_entry(size_t index, u8 interrupt_vector, u8 delivery_mode, bool logical_destination, bool active_low, bool trigger_level_mode, bool masked, u8 destination) const
{
InterruptDisabler disabler;
VERIFY((u32)index < m_redirection_entries_count);
VERIFY(index < m_redirection_entries_count);
u32 redirection_entry1 = interrupt_vector | (delivery_mode & 0b111) << 8 | logical_destination << 11 | active_low << 13 | trigger_level_mode << 15 | masked << 16;
u32 redirection_entry2 = destination << 24;
write_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET, redirection_entry1);
@ -197,7 +197,7 @@ void IOAPIC::mask_all_redirection_entries() const
void IOAPIC::mask_redirection_entry(u8 index) const
{
VERIFY((u32)index < m_redirection_entries_count);
VERIFY(index < m_redirection_entries_count);
u32 redirection_entry = read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET);
if (redirection_entry & (1 << 16))
return;
@ -206,13 +206,13 @@ void IOAPIC::mask_redirection_entry(u8 index) const
bool IOAPIC::is_redirection_entry_masked(u8 index) const
{
VERIFY((u32)index < m_redirection_entries_count);
VERIFY(index < m_redirection_entries_count);
return (read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET) & (1 << 16)) != 0;
}
void IOAPIC::unmask_redirection_entry(u8 index) const
{
VERIFY((u32)index < m_redirection_entries_count);
VERIFY(index < m_redirection_entries_count);
u32 redirection_entry = read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET);
if (!(redirection_entry & (1 << 16)))
return;
@ -227,7 +227,7 @@ bool IOAPIC::is_vector_enabled(u8 interrupt_vector) const
u8 IOAPIC::read_redirection_entry_vector(u8 index) const
{
VERIFY((u32)index < m_redirection_entries_count);
VERIFY(index < m_redirection_entries_count);
return (read_register((index << 1) + IOAPIC_REDIRECTION_ENTRY_OFFSET) & 0xFF);
}

View file

@ -55,8 +55,8 @@ public:
virtual IRQControllerType type() const override { return IRQControllerType::i82093AA; }
private:
void configure_redirection_entry(int index, u8 interrupt_vector, u8 delivery_mode, bool logical_destination, bool active_low, bool trigger_level_mode, bool masked, u8 destination) const;
void reset_redirection_entry(int index) const;
void configure_redirection_entry(size_t index, u8 interrupt_vector, u8 delivery_mode, bool logical_destination, bool active_low, bool trigger_level_mode, bool masked, u8 destination) const;
void reset_redirection_entry(size_t index) const;
void map_interrupt_redirection(u8 interrupt_vector);
void reset_all_redirection_entries() const;
@ -75,7 +75,7 @@ private:
virtual void initialize() override;
void map_isa_interrupts();
void map_pci_interrupts();
void isa_identity_map(int index);
void isa_identity_map(size_t index);
PhysicalAddress m_address;
mutable Memory::TypedMapping<ioapic_mmio_regs> m_regs;