blob: ada63ecc0f4a5d52c136dbcb9354d8ba3c516f89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
* Copyright (c) 2023, Pankaj R <dev@pankajraghav.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/InterruptManagement.h>
#include <Kernel/Arch/PCIMSI.h>
#include <Kernel/Debug.h>
#include <Kernel/Interrupts/PCIIRQHandler.h>
namespace Kernel {
PCIIRQHandler::PCIIRQHandler(PCI::Device& device, u8 irq)
: GenericInterruptHandler(irq)
, device(device)
{
auto type = device.get_interrupt_type();
if (type == PCI::InterruptType::PIN)
m_responsible_irq_controller = InterruptManagement::the().get_responsible_irq_controller(irq);
if (is_registered())
disable_irq();
}
bool PCIIRQHandler::eoi()
{
dbgln_if(IRQ_DEBUG, "EOI IRQ {}", interrupt_number());
if (m_shared_with_others)
return false;
if (!m_responsible_irq_controller.is_null())
m_responsible_irq_controller->eoi(*this);
else
msi_signal_eoi();
return true;
}
void PCIIRQHandler::enable_irq()
{
dbgln_if(IRQ_DEBUG, "Enable IRQ {}", interrupt_number());
if (!is_registered())
register_interrupt_handler();
m_enabled = true;
if (m_shared_with_others)
return;
if (!m_responsible_irq_controller.is_null())
m_responsible_irq_controller->enable(*this);
else
device.enable_interrupt(interrupt_number());
}
void PCIIRQHandler::disable_irq()
{
dbgln_if(IRQ_DEBUG, "Disable IRQ {}", interrupt_number());
m_enabled = false;
if (m_shared_with_others)
return;
if (!m_responsible_irq_controller.is_null())
m_responsible_irq_controller->disable(*this);
else
device.disable_interrupt(interrupt_number());
}
}
|