diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-26 14:10:34 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-26 14:11:17 -0400 |
commit | 47016cc15609864414d83f1a0745e95c1db04db5 (patch) | |
tree | e67668504aa83db4502178e54f19bbbe11faf97b /src/sys/include/arch/amd64 | |
parent | dc886721c6d3438dba49e817a2ebc8a49a5e3880 (diff) |
kern/amd64: Support APIC inter-processor interrupts
This commit introduces support for sending inter-processor interrupts on
the mainbus to other cores on the machine.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/include/arch/amd64')
-rw-r--r-- | src/sys/include/arch/amd64/lapic.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/sys/include/arch/amd64/lapic.h b/src/sys/include/arch/amd64/lapic.h index 3cb2f3a..c75e70c 100644 --- a/src/sys/include/arch/amd64/lapic.h +++ b/src/sys/include/arch/amd64/lapic.h @@ -34,6 +34,66 @@ #define LAPIC_TIMER_VEC 0x81 /* + * Represents the possible values for the ICR + * destination shorthand register for IPIs + * + * @IPI_SHAND_NONE: No shorthand + * @IPI_SHAND_SELF: Send IPI to self + * @IPI_SHAND_AIS: Send IPI to all including self + * @IPI_SHAND_AXS: Send IPI to all excluding self + */ +typedef enum { + IPI_SHAND_NONE, + IPI_SHAND_SELF, + IPI_SHAND_AIS, + IPI_SHAND_AXS +} ipi_shand_t; + +/* + * Represents the possible values for the ICR + * delivery mode + */ +#define IPI_DELMOD_FIXED 0x0 /* Fixed */ +#define IPI_DELMOD_LOWPRI 0x1 /* Lowest priority */ +#define IPI_DELMOD_INIT 0x5 /* Init (for bootstrap) */ +#define IPI_DELMOD_STARTUP 0x6 /* Startup (for bootstrap) */ + +/* See above */ +typedef uint8_t ipi_delmod_t; + +/* Destination mode */ +#define IPI_DESTMODE_PHYSICAL 0x0 +#define IPI_DESTMODE_LOGICAL 0x01 + +/* + * Represents parameters used for generating + * IPIs on the mainbus + * + * @shorthand: Destination shorthand + * @delmod: Delivery mode + * @vector: Interrupt vector to trigger + * @dest_mode: Destination mode + */ +struct lapic_ipi { + ipi_shand_t shorthand; + ipi_delmod_t delmod; + uint8_t vector; + uint8_t apic_id; + uint8_t dest_mode : 1; +}; + +/* + * Transmit an IPI on the main bus to another processor, + * self, or both + * + * @ipip: IPI descriptor + * + * Returns zero on success, otherwise a less than zero value + * on failure. + */ +int lapic_tx_ipi(const struct lapic_ipi *ipip); + +/* * Initialize the local APIC on the current * processor. */ |