|
ginnOS
The reference: libc, the libraries and the kernel
|
#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"). | |
| #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.
| #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 |
| 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.
| dev | the device. |
| handler | the 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). |
| context | passed to the handler. |
| name | a short name for /proc/interrupts. |
| bool pci_irq_info | ( | uint32_t | index, |
| pci_irq_info_t * | info ) |
the attached handler at an index.
send the messages of an attached handler to a core.
an INTx handler does not move here: its line moves with irq_set_cpu().
| index | the index of the handler, as for pci_irq_info(). |
| cpu | the index of the core (cpu_t.index). |
| const char * pci_irq_mode_name | ( | pci_irq_mode_t | mode | ) |
a short name for a mode ("MSI-X", "MSI", "INTx", "none").