PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
IPI

Inter-Processor Interrupts (IPIs) More...

Collaboration diagram for IPI:

Detailed Description

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.

Data Structures

struct  ipi_chip_t
 Inter-Processor Interrupt (IPI) chip structure. More...
 
struct  ipi_func_data_t
 IPI function data structure. More...
 
struct  ipi_t
 IPI structure. More...
 
struct  ipi_cpu_ctx_t
 Per-CPU IPI context. More...
 

Macros

#define IPI_QUEUE_SIZE   16
 IPI queue size.
 

Typedefs

typedef void(* ipi_func_t) (ipi_func_data_t *data)
 IPI function type.
 

Enumerations

enum  ipi_flags_t { IPI_SINGLE = 0 << 0 , IPI_BROADCAST = 1 << 0 , IPI_OTHERS = 2 << 0 }
 IPI flags. More...
 

Functions

void ipi_cpu_ctx_init (ipi_cpu_ctx_t *ctx)
 Initialize per-CPU IPI context.
 
void ipi_handle_pending (interrupt_frame_t *frame, cpu_t *self)
 Handle pending IPIs on the current CPU.
 
uint64_t ipi_chip_register (ipi_chip_t *chip)
 Register an IPI chip.
 
void ipi_chip_unregister (ipi_chip_t *chip)
 Unregister the IPI chip.
 
uint64_t ipi_chip_amount (void)
 Get the number of registered IPI chips.
 
uint64_t ipi_send (cpu_t *cpu, ipi_flags_t flags, ipi_func_t func, void *private)
 Send an IPI to one or more CPUs.
 
void ipi_wake_up (cpu_t *cpu, ipi_flags_t flags)
 Wake up one or more CPUs.
 
void ipi_invoke (void)
 Invoke a IPI interrupt on the current CPU.
 

Macro Definition Documentation

◆ IPI_QUEUE_SIZE

#define IPI_QUEUE_SIZE   16

IPI queue size.

Definition at line 83 of file ipi.h.

Typedef Documentation

◆ ipi_func_t

typedef void(* ipi_func_t) (ipi_func_data_t *data)

IPI function type.

Definition at line 66 of file ipi.h.

Enumeration Type Documentation

◆ 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.

Function Documentation

◆ ipi_cpu_ctx_init()

void ipi_cpu_ctx_init ( ipi_cpu_ctx_t ctx)

Initialize per-CPU IPI context.

Parameters
ctxThe IPI context to initialize.

Definition at line 15 of file ipi.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ipi_handle_pending()

void ipi_handle_pending ( interrupt_frame_t frame,
cpu_t self 
)

Handle pending IPIs on the current CPU.

Parameters
frameThe interrupt frame.
selfThe current CPU.

Definition at line 23 of file ipi.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ipi_chip_register()

uint64_t ipi_chip_register ( ipi_chip_t chip)

Register an IPI chip.

There can only be a single IPI chip registered at a time.

Parameters
chipThe 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.

Here is the caller graph for this function:

◆ ipi_chip_unregister()

void ipi_chip_unregister ( ipi_chip_t chip)

Unregister the IPI chip.

If the given chip is not the registered chip, this is a no-op.

Parameters
chipThe IPI chip to unregister, or NULL for no-op.

Definition at line 84 of file ipi.c.

◆ ipi_chip_amount()

uint64_t ipi_chip_amount ( void  )

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.

Here is the caller graph for this function:

◆ ipi_send()

uint64_t ipi_send ( cpu_t cpu,
ipi_flags_t  flags,
ipi_func_t  func,
void *  private 
)

Send an IPI to one or more CPUs.

The CPU(s) is notified of the IPI by receiving a VECTOR_IPI interrupt.

Parameters
cpuThe specified CPU, check ipi_flags_t.
flagsThe flags for how to send the IPI.
funcThe function to execute on target CPU(s).
privateThe 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ipi_wake_up()

void ipi_wake_up ( cpu_t cpu,
ipi_flags_t  flags 
)

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
cpuThe specified CPU, check ipi_flags_t.
flagsThe flags for how to send the IPI.

Definition at line 213 of file ipi.c.

Here is the caller graph for this function:

◆ ipi_invoke()

void ipi_invoke ( void  )

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.

Here is the caller graph for this function: