PatchworkOS
Loading...
Searching...
No Matches
IRQ

Interrupt Request handling. More...

Data Structures

struct  irq_callback_t
 Structure to hold an IRQ callback and its data. More...
 
struct  irq_handler_t
 Structure to hold all callbacks for an IRQ. More...
 

Macros

#define IRQ_MAX_CALLBACK   16
 Maximum amount of callbacks per IRQ.
 

Typedefs

typedef void(* irq_callback_func_t) (irq_t irq, void *data)
 Callback function type for IRQs.
 

Enumerations

enum  irq_t {
  IRQ_PIT = 0x0 ,
  IRQ_PS2_FIRST_DEVICE = 0x1 ,
  IRQ_CASCADE = 0x2 ,
  IRQ_COM2 = 0x3 ,
  IRQ_COM1 = 0x4 ,
  IRQ_LPT2 = 0x5 ,
  IRQ_FLOPPY = 0x6 ,
  IRQ_LPT1 = 0x7 ,
  IRQ_CMOS = 0x8 ,
  IRQ_FREE1 = 0x9 ,
  IRQ_FREE2 = 0xA ,
  IRQ_FREE3 = 0xB ,
  IRQ_PS2_SECOND_DEVICE = 0xC ,
  IRQ_FPU = 0xD ,
  IRQ_PRIMARY_ATA_HARD_DRIVE = 0xE ,
  IRQ_SECONDARY_ATA_HARD_DRIVE = 0xF ,
  IRQ_AMOUNT = 0x10
}
 IRQ numbers. More...
 

Functions

void irq_dispatch (interrupt_frame_t *frame)
 Dispatch an IRQ.
 
void irq_install (irq_t irq, irq_callback_func_t func, void *data)
 Install an IRQ handler.
 
void irq_uninstall (irq_t irq, irq_callback_func_t func)
 Uninstall an IRQ handler.
 

Detailed Description

Interrupt Request handling.

Macro Definition Documentation

◆ IRQ_MAX_CALLBACK

#define IRQ_MAX_CALLBACK   16

Maximum amount of callbacks per IRQ.

Definition at line 46 of file irq.h.

Typedef Documentation

◆ irq_callback_func_t

typedef void(* irq_callback_func_t) (irq_t irq, void *data)

Callback function type for IRQs.

Definition at line 51 of file irq.h.

Enumeration Type Documentation

◆ irq_t

enum irq_t

IRQ numbers.

These all start from EXTERNAL_INTERRUPT_BASE.

Enumerator
IRQ_PIT 
IRQ_PS2_FIRST_DEVICE 
IRQ_CASCADE 
IRQ_COM2 
IRQ_COM1 
IRQ_LPT2 
IRQ_FLOPPY 
IRQ_LPT1 
IRQ_CMOS 
IRQ_FREE1 
IRQ_FREE2 
IRQ_FREE3 
IRQ_PS2_SECOND_DEVICE 
IRQ_FPU 
IRQ_PRIMARY_ATA_HARD_DRIVE 
IRQ_SECONDARY_ATA_HARD_DRIVE 
IRQ_AMOUNT 

Definition at line 22 of file irq.h.

Function Documentation

◆ irq_dispatch()

void irq_dispatch ( interrupt_frame_t frame)

Dispatch an IRQ.

This function is called from interrupt_handler() when an IRQ is received. It will call all registered callbacks for the IRQ.

Parameters
frameThe interrupt frame of the IRQ.

Definition at line 13 of file irq.c.

References irq_handler_t::callbackAmount, irq_handler_t::callbacks, irq_callback_t::data, EXTERNAL_INTERRUPT_BASE, irq_callback_t::func, handlers, lapic_eoi(), lock, LOG_WARN, NULL, RWLOCK_READ_SCOPE, and interrupt_frame_t::vector.

Referenced by interrupt_handler().

◆ irq_install()

void irq_install ( irq_t  irq,
irq_callback_func_t  func,
void *  data 
)

Install an IRQ handler.

Installs the provided callback function to be called when the specified IRQ is received. The data pointer will be passed to the callback when it is called.

If the interrupt has not yet been redirected the ioapic will be set to redirect the vector.

Parameters
irqThe IRQ number to install the handler for.
funcThe callback function to call when the IRQ is received.
dataThe data pointer to pass to the callback function.

Definition at line 39 of file irq.c.

References irq_handler_t::callbackAmount, irq_handler_t::callbacks, irq_callback_t::data, data, EXTERNAL_INTERRUPT_BASE, irq_callback_t::func, handlers, IOAPIC_DELIVERY_NORMAL, IOAPIC_POLARITY_HIGH, ioapic_set_redirect(), IOAPIC_TRIGGER_EDGE, IRQ_MAX_CALLBACK, lock, LOG_INFO, NULL, panic(), irq_handler_t::redirected, RWLOCK_WRITE_SCOPE, and smp_self_unsafe().

Referenced by ps2_kbd_init(), and ps2_mouse_init().

◆ irq_uninstall()

void irq_uninstall ( irq_t  irq,
irq_callback_func_t  func 
)

Uninstall an IRQ handler.

Uninstalls the provided callback function from the specified IRQ. If the function is not found, nothing happens.

Parameters
irqThe IRQ number to uninstall the handler from.
funcThe callback function to uninstall.

Definition at line 63 of file irq.c.

References irq_handler_t::callbackAmount, irq_handler_t::callbacks, irq_callback_t::data, irq_callback_t::func, handlers, IRQ_MAX_CALLBACK, lock, LOG_INFO, NULL, and RWLOCK_WRITE_SCOPE.