The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
pci_irq.h File Reference

interrupts for PCI devices: MSI-X, MSI, or the legacy INTx line. More...

#include "common/stdint.h"
#include "arch/arch_irq.h"
#include "drivers/pci/pci.h"

Go to the source code of this file.

Data Structures

struct  pci_irq_info_t
 one attached handler, for /proc/interrupts. More...

Macros

#define PCI_IRQ_MAX   16

Enumerations

enum  pci_irq_mode_t { PCI_IRQ_NONE , PCI_IRQ_INTX , PCI_IRQ_MSI , PCI_IRQ_MSIX }

Functions

pci_irq_mode_t pci_irq_attach (pci_device_t *dev, device_irq_handler_t handler, void *context, const char *name)
 attach an interrupt handler to a device and enable its interrupt.
bool pci_irq_info (uint32_t index, pci_irq_info_t *info)
 the attached handler at an index.
bool pci_irq_set_cpu (uint32_t index, uint32_t cpu)
 send the messages of an attached handler to a core.
const char * pci_irq_mode_name (pci_irq_mode_t mode)
 a short name for a mode ("MSI-X", "MSI", "INTx", "none").

Detailed Description

interrupts for PCI devices: MSI-X, MSI, or the legacy INTx line.

a driver attaches one handler to its device. pci_irq_attach uses the best way the device and the CPU support: MSI-X (entry 0), then MSI (one message), then the interrupt line the firmware routed (INTx, shared, level-triggered). MSI and MSI-X need the local APIC; with the 8259 PICs only INTx is possible.

limits: without an AML interpreter the kernel cannot read the ACPI _PRT, so INTx uses the ISA line from the configuration space (irq_line). this works with the 8259 PICs and on QEMU with the I/O APIC, but on real machines with the I/O APIC a device without MSI can stay without interrupts. drivers must keep a polled path for this case.

Macro Definition Documentation

◆ PCI_IRQ_MAX

#define PCI_IRQ_MAX   16

Enumeration Type Documentation

◆ pci_irq_mode_t

Enumerator
PCI_IRQ_NONE 
PCI_IRQ_INTX 
PCI_IRQ_MSI 
PCI_IRQ_MSIX 

Function Documentation

◆ pci_irq_attach()

pci_irq_mode_t pci_irq_attach ( pci_device_t * dev,
device_irq_handler_t handler,
void * context,
const char * name )

attach an interrupt handler to a device and enable its interrupt.

call it once per device, before the device is told to raise interrupts.

Parameters
devthe device.
handlerthe function to call; it must clear the cause in the device, and for INTx it must return quickly when its device has nothing to report (the line can be shared).
contextpassed to the handler.
namea short name for /proc/interrupts.
Returns
the mode in use, or PCI_IRQ_NONE if no interrupt is possible.

◆ pci_irq_info()

bool pci_irq_info ( uint32_t index,
pci_irq_info_t * info )

the attached handler at an index.

Returns
false if index is out of range.

◆ pci_irq_set_cpu()

bool pci_irq_set_cpu ( uint32_t index,
uint32_t cpu )

send the messages of an attached handler to a core.

an INTx handler does not move here: its line moves with irq_set_cpu().

Parameters
indexthe index of the handler, as for pci_irq_info().
cputhe index of the core (cpu_t.index).
Returns
false if index is out of range or the handler does not use MSI or MSI-X.

◆ pci_irq_mode_name()

const char * pci_irq_mode_name ( pci_irq_mode_t mode)

a short name for a mode ("MSI-X", "MSI", "INTx", "none").