Inter-Processor Interrupts (IPIs)
More...
Inter-Processor Interrupts (IPIs)
Inter-Processor Interrupts are a way to remotely interrupt another CPU, this could be done with any interrupt vector, but for the sake of simplicity we reserve a single interrupt vector VECTOR_IPI for IPIs which, when received, will cause the CPU to check its IPI queue for any pending IPIs to execute.
The actual remote interrupt invocation of the IPI is handled by a "IPI chip", usually the local APIC, which is implemented in a module.
◆ IPI_QUEUE_SIZE
| #define IPI_QUEUE_SIZE 16 |
IPI queue size.
Definition at line 83 of file ipi.h.
◆ ipi_func_t
IPI function type.
Definition at line 66 of file ipi.h.
◆ ipi_flags_t
IPI flags.
| Enumerator |
|---|
| IPI_SINGLE | Send the IPI to the specified CPU.
|
| IPI_BROADCAST | Send the IPI to all CPUs, specified CPU ignored.
|
| IPI_OTHERS | Send the IPI to all CPUs except the specified CPU.
|
Definition at line 103 of file ipi.h.
◆ ipi_cpu_ctx_init()
Initialize per-CPU IPI context.
- Parameters
-
| ctx | The IPI context to initialize. |
Definition at line 15 of file ipi.c.
◆ ipi_handle_pending()
Handle pending IPIs on the current CPU.
- Parameters
-
| frame | The interrupt frame. |
| self | The current CPU. |
Definition at line 23 of file ipi.c.
◆ ipi_chip_register()
Register an IPI chip.
There can only be a single IPI chip registered at a time.
- Parameters
-
| chip | The IPI chip to register. |
- Returns
- On success,
0. On failure, ERR and errno is set to:
EINVAL: Invalid parameters.
EBUSY: An IPI chip is already registered.
Definition at line 63 of file ipi.c.
◆ ipi_chip_unregister()
Unregister the IPI chip.
If the given chip is not the registered chip, this is a no-op.
- Parameters
-
| chip | The IPI chip to unregister, or NULL for no-op. |
Definition at line 84 of file ipi.c.
◆ ipi_chip_amount()
Get the number of registered IPI chips.
Will always be 0 or 1.
- Returns
- The number of registered IPI chips.
Definition at line 102 of file ipi.c.
◆ ipi_send()
Send an IPI to one or more CPUs.
The CPU(s) is notified of the IPI by receiving a VECTOR_IPI interrupt.
- Parameters
-
| cpu | The specified CPU, check ipi_flags_t. |
| flags | The flags for how to send the IPI. |
| func | The function to execute on target CPU(s). |
| private | The private data to pass to the function, will be found in irq_func_data_t->private. |
- Returns
- On success,
0. On failure, ERR and errno is set to:
EINVAL: Invalid parameters.
ENODEV: No IPI chip is registered.
ENOSYS: The registered IPI chip does not have a notify function.
EBUSY: The target CPU's IPI queue is full, some or all IPIs could not be sent.
- Other errors returned by the IPI chip's
notify function.
Definition at line 138 of file ipi.c.
◆ ipi_wake_up()
Wake up one or more CPUs.
A wake-up IPI is an IPI with no function to execute, used to wake up a CPU that may be idle or sleeping and to prompt it to check for pending IPIs, notes, etc.
- Parameters
-
| cpu | The specified CPU, check ipi_flags_t. |
| flags | The flags for how to send the IPI. |
Definition at line 213 of file ipi.c.
◆ ipi_invoke()
Invoke a IPI interrupt on the current CPU.
Will use IRQ_INVOKE(VECTOR_IPI) to trigger the IPI interrupt, causing the CPU to enter an interrupt context and handle any pending IPIs, notes and potentially scheduling.
Definition at line 267 of file ipi.c.