The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
pci_irq.c File Reference
#include "pci_irq.h"
#include "kernel/irq/irq.h"
#include "kernel/klog/klog.h"
#include "kernel/memory/mmio.h"

Macros

#define MSI_CONTROL   0x02
 interrupts for PCI devices (PCI Local Bus 3.0, section 6.8: MSI and MSI-X).
#define MSI_ADDRESS_LOW   0x04
#define MSI_ADDRESS_HIGH   0x08
#define MSI_DATA_32   0x08
#define MSI_DATA_64   0x0C
#define MSI_CONTROL_ENABLE   0x0001u
#define MSI_CONTROL_MME_MASK   0x0070u
#define MSI_CONTROL_64BIT   0x0080u
#define MSIX_CONTROL   0x02
#define MSIX_TABLE   0x04
#define MSIX_CONTROL_ENABLE   0x8000u
#define MSIX_CONTROL_FUNC_MASK   0x4000u
#define MSIX_TABLE_SIZE(c)
#define MSIX_ENTRY_SIZE   16u
#define MSIX_VECTOR_MASKED   0x1u

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").

Macro Definition Documentation

◆ MSI_CONTROL

#define MSI_CONTROL   0x02

interrupts for PCI devices (PCI Local Bus 3.0, section 6.8: MSI and MSI-X).

MSI: the capability holds one message address and data; the device writes the data to the address to raise the interrupt. MSI-X: the capability points to a table in a BAR, with one 16-byte entry (address, data, vector control) per message. the driver uses entry 0. INTx: the device asserts its interrupt pin until the cause is cleared. the line is shared, so each handler on it is called on each interrupt.

every handler goes through dispatch(), which counts the interrupts for /proc/interrupts.

◆ MSI_ADDRESS_LOW

#define MSI_ADDRESS_LOW   0x04

◆ MSI_ADDRESS_HIGH

#define MSI_ADDRESS_HIGH   0x08

◆ MSI_DATA_32

#define MSI_DATA_32   0x08

◆ MSI_DATA_64

#define MSI_DATA_64   0x0C

◆ MSI_CONTROL_ENABLE

#define MSI_CONTROL_ENABLE   0x0001u

◆ MSI_CONTROL_MME_MASK

#define MSI_CONTROL_MME_MASK   0x0070u

◆ MSI_CONTROL_64BIT

#define MSI_CONTROL_64BIT   0x0080u

◆ MSIX_CONTROL

#define MSIX_CONTROL   0x02

◆ MSIX_TABLE

#define MSIX_TABLE   0x04

◆ MSIX_CONTROL_ENABLE

#define MSIX_CONTROL_ENABLE   0x8000u

◆ MSIX_CONTROL_FUNC_MASK

#define MSIX_CONTROL_FUNC_MASK   0x4000u

◆ MSIX_TABLE_SIZE

#define MSIX_TABLE_SIZE ( c)
Value:
(((c) & 0x07FFu) + 1)

◆ MSIX_ENTRY_SIZE

#define MSIX_ENTRY_SIZE   16u

◆ MSIX_VECTOR_MASKED

#define MSIX_VECTOR_MASKED   0x1u

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").