21 #include "pedigree/kernel/LockGuard.h" 22 #include "pedigree/kernel/Log.h" 23 #include "pedigree/kernel/compiler.h" 24 #include "pedigree/kernel/machine/Device.h" 25 #include "pedigree/kernel/machine/IrqHandler.h" 26 #include "pedigree/kernel/processor/InterruptManager.h" 27 #include "pedigree/kernel/utilities/Iterator.h" 28 #include "pedigree/kernel/utilities/utility.h" 32 #define BASE_INTERRUPT_VECTOR 0x20 37 #define DEFAULT_IRQ_MITIGATE_THRESHOLD 10 55 case MitigationThreshold:
84 return irq + BASE_INTERRUPT_VECTOR;
101 return irq + BASE_INTERRUPT_VECTOR;
105 uint8_t irq = Id - BASE_INTERRUPT_VECTOR;
113 uint8_t irq = Id - BASE_INTERRUPT_VECTOR;
153 for (
size_t i = 0; i < 16; i++)
155 i + BASE_INTERRUPT_VECTOR,
this) ==
false)
158 for (
size_t i = 0; i < 16; i++)
175 for (
size_t i = 0; i < 16; i++)
187 uint8_t mask = 1 << (irq - 8);
191 return (isr & mask) == 0;
196 uint8_t mask = 1 << irq;
200 return (isr & mask) == 0;
206 size_t irq = (interruptNumber - BASE_INTERRUPT_VECTOR);
226 bool bHandled =
false;
230 bool tmp = (*it)->irq(irq, state);
231 if ((!bHandled) && tmp)
247 NOTICE(
"PIC: unhandled irq #" << irq <<
" occurred");
251 void Pic::eoi(uint8_t irq)
266 void Pic::enable(uint8_t irq,
bool enable)
281 mask = mask & ~(1 << irq);
283 mask = mask | (1 << irq);
291 mask = mask & ~(1 << (irq - 8));
293 mask = mask | (1 << (irq - 8));
298 void Pic::enableAll(
bool enable)
virtual bool registerInterruptHandler(size_t nInterruptNumber, InterruptHandler *pHandler)=0
virtual irq_id_t registerPciIrqHandler(IrqHandler *handler, Device *pDevice)
void pushBack(const T &value)
virtual void acknowledgeIrq(irq_id_t Id)
Iterator erase(Iterator &Iter)
Handles interrupts and interrupt registrations from kernel components.
virtual uint8_t read8(size_t offset=0)
virtual bool control(uint8_t irq, ControlCode code, size_t argument)
virtual uintptr_t getInterruptNumber()
virtual void unregisterHandler(irq_id_t Id, IrqHandler *handler)
List< IrqHandler * > m_Handler[16]
bool spurious(size_t irq)
bool allocate(io_port_t ioPort, size_t size)
Pic() INITIALISATION_ONLY
virtual void interrupt(size_t interruptNumber, InterruptState &state)
static InterruptManager & instance()
virtual irq_id_t registerIsaIrqHandler(uint8_t irq, IrqHandler *handler, bool bEdge=false)
bool initialise() INITIALISATION_ONLY
size_t m_MitigationThreshold[16]
virtual void write8(uint8_t value, size_t offset=0)