Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gic.h File Reference

Driver for ARM Generic Interrupt Controller. More...

#include <zephyr/types.h>
#include <zephyr/device.h>

Go to the source code of this file.

Macros

#define GIC_DIST_BASE   DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0)
#define GIC_CPU_BASE   DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1)
#define GICD_CTLR   (GIC_DIST_BASE + 0x0)
 GIC Distributor Control Register.
#define GICD_TYPER   (GIC_DIST_BASE + 0x4)
 GIC Distributor Interrupt Controller Type Register.
#define GICD_IIDR   (GIC_DIST_BASE + 0x8)
 GIC Distributor Implementer Identification Register.
#define GICD_IGROUPRn   (GIC_DIST_BASE + 0x80)
 GIC Distributor Interrupt Group Registers.
#define GICD_IGROUPRnE   (GIC_DIST_BASE + 0x1000)
 GIC Distributor Interrupt Group Registers for Extended SPI Range.
#define GICD_ISENABLERn   (GIC_DIST_BASE + 0x100)
 GIC Distributor Interrupt Set-Enable Registers.
#define GICD_ISENABLERnE   (GIC_DIST_BASE + 0x1200)
 GIC Distributor Interrupt Set-Enable Registers for Extended SPI Range.
#define GICD_ICENABLERn   (GIC_DIST_BASE + 0x180)
 GIC Distributor Interrupt Clear-Enable Registers.
#define GICD_ICENABLERnE   (GIC_DIST_BASE + 0x1400)
 GIC Distributor Interrupt Clear-Enable Registers for Extended SPI Range.
#define GICD_ISPENDRn   (GIC_DIST_BASE + 0x200)
 GIC Distributor Interrupt Set-Pending Registers.
#define GICD_ISPENDRnE   (GIC_DIST_BASE + 0x1600)
 GIC Distributor Interrupt Set-Pending Registers for Extended SPI Range.
#define GICD_ICPENDRn   (GIC_DIST_BASE + 0x280)
 GIC Distributor Interrupt Clear-Pending Registers.
#define GICD_ICPENDRnE   (GIC_DIST_BASE + 0x1800)
 GIC Distributor Interrupt Clear-Pending Registers for Extended SPI Range.
#define GICD_ISACTIVERn   (GIC_DIST_BASE + 0x300)
 GIC Distributor Interrupt Set-Active Registers.
#define GICD_ISACTIVERnE   (GIC_DIST_BASE + 0x1A00)
 GIC Distributor Interrupt Set-Active Registers for Extended SPI Range.
#define GICD_ICACTIVERn   (GIC_DIST_BASE + 0x380)
 GIC Distributor Interrupt Clear-Active Registers.
#define GICD_ICACTIVERnE   (GIC_DIST_BASE + 0x1C00)
 GIC Distributor Interrupt Clear-Active Registers for Extended SPI Range.
#define GICD_IPRIORITYRn   (GIC_DIST_BASE + 0x400)
 GIC Distributor Interrupt Priority Registers.
#define GICD_IPRIORITYRnE   (GIC_DIST_BASE + 0x2000)
 GIC Distributor Interrupt Priority Registers for Extended SPI Range.
#define GICD_ITARGETSRn   (GIC_DIST_BASE + 0x800)
 GIC Distributor Interrupt Processor Targets Registers.
#define GICD_ICFGRn   (GIC_DIST_BASE + 0xc00)
 GIC Distributor Interrupt Configuration Registers.
#define GICD_ICFGRnE   (GIC_DIST_BASE + 0x3000)
 GIC Distributor Interrupt Configuration Registers for Extended SPI Range.
#define GICD_SGIR   (GIC_DIST_BASE + 0xf00)
 GIC Distributor Software Generated Interrupt Register.
#define GICD_CTLR_DS   BIT(6)
 Disable Security (DS) bit in GICD_CTLR.
#define GICC_CTLR   (GIC_CPU_BASE + 0x0)
 GIC CPU Interface Control Register.
#define GICC_PMR   (GIC_CPU_BASE + 0x4)
 GIC CPU Interface Interrupt Priority Mask Register.
#define GICC_BPR   (GIC_CPU_BASE + 0x8)
 GIC CPU Interface Binary Point Register.
#define GICC_IAR   (GIC_CPU_BASE + 0xc)
 GIC CPU Interface Interrupt Acknowledge Register.
#define GICC_EOIR   (GIC_CPU_BASE + 0x10)
 GIC CPU Interface End of Interrupt Register.
#define GIC_SGI_INT_BASE   0
 Base ID of SGI interrupts.
#define GIC_PPI_INT_BASE   16
 Base ID of PPI interrupts.
#define GIC_IS_SGI(intid)
#define GIC_SPI_INT_BASE   32
 Base ID of SPI interrupts.
#define GIC_SPI_MAX_INTID   1019
 Max ID of SPI interrupts.
#define GIC_IDLE_PRIO   0xff
 GIC idle priority : value '0xff' will allow all interrupts.
#define GIC_PRI_MASK   0xff
 Priority levels 0:255.
#define GIC_INT_DEF_PRI_X4   0xa0a0a0a0
 Default priority initializer helper macro.
#define GIC_INTID_SPURIOUS   1023
 GIC special interrupt id.
#define GIC_NUM_CPU_IF   CONFIG_MP_MAX_NUM_CPUS
 Max number of supported CPUs in a SMP environment.

Functions

void arm_gic_irq_enable (unsigned int irq)
 Enable interrupt.
void arm_gic_irq_disable (unsigned int irq)
 Disable interrupt.
bool arm_gic_irq_is_enabled (unsigned int irq)
 Check if an interrupt is enabled.
bool arm_gic_irq_is_pending (unsigned int irq)
 Check if an interrupt is pending.
void arm_gic_irq_set_pending (unsigned int irq)
 Set interrupt as pending.
void arm_gic_irq_clear_pending (unsigned int irq)
 Clear the pending irq.
void arm_gic_irq_set_priority (unsigned int irq, unsigned int prio, unsigned int flags)
 Set interrupt priority.
void arm_gic_irq_set_affinity (unsigned int irq, uint64_t mpidr)
 Route an SPI/extended-SPI interrupt to a specific core.
unsigned int arm_gic_get_active (void)
 Get active interrupt ID.
void arm_gic_eoi (unsigned int irq)
 Signal end-of-interrupt.
void arm_gic_secondary_init (void)
 Initialize GIC of secondary cores.
void gic_raise_sgi (unsigned int sgi_id, uint64_t target_aff, uint16_t target_list)
 raise SGI to target cores

Detailed Description

Driver for ARM Generic Interrupt Controller.

The Generic Interrupt Controller (GIC) is the default interrupt controller for the ARM A and R profile cores. This driver is used by the ARM arch implementation to handle interrupts.

Macro Definition Documentation

◆ GIC_CPU_BASE

#define GIC_CPU_BASE   DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1)

◆ GIC_DIST_BASE

#define GIC_DIST_BASE   DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0)

◆ GIC_IDLE_PRIO

#define GIC_IDLE_PRIO   0xff

GIC idle priority : value '0xff' will allow all interrupts.

◆ GIC_INT_DEF_PRI_X4

#define GIC_INT_DEF_PRI_X4   0xa0a0a0a0

Default priority initializer helper macro.

'0xa0'is used to initialize each interrupt default priority. This is an arbitrary value in current context. Any value '0x80' to '0xff' will work for both NS and S state. The values of individual interrupt and default has to be chosen carefully if PMR and BPR based nesting and preemption has to be done.

◆ GIC_INTID_SPURIOUS

#define GIC_INTID_SPURIOUS   1023

GIC special interrupt id.

◆ GIC_IS_SGI

#define GIC_IS_SGI ( intid)
Value:
(((intid) >= GIC_SGI_INT_BASE) && ((intid) < GIC_PPI_INT_BASE))
#define GIC_PPI_INT_BASE
Base ID of PPI interrupts.
Definition gic.h:327
#define GIC_SGI_INT_BASE
Base ID of SGI interrupts.
Definition gic.h:324

◆ GIC_NUM_CPU_IF

#define GIC_NUM_CPU_IF   CONFIG_MP_MAX_NUM_CPUS

Max number of supported CPUs in a SMP environment.

Fixme: update from platform specific define or dt DEPRECATED - Use CONFIG_MP_MAX_NUM_CPUS instead.

◆ GIC_PPI_INT_BASE

#define GIC_PPI_INT_BASE   16

Base ID of PPI interrupts.

◆ GIC_PRI_MASK

#define GIC_PRI_MASK   0xff

Priority levels 0:255.

◆ GIC_SGI_INT_BASE

#define GIC_SGI_INT_BASE   0

Base ID of SGI interrupts.

◆ GIC_SPI_INT_BASE

#define GIC_SPI_INT_BASE   32

Base ID of SPI interrupts.

◆ GIC_SPI_MAX_INTID

#define GIC_SPI_MAX_INTID   1019

Max ID of SPI interrupts.

◆ GICC_BPR

#define GICC_BPR   (GIC_CPU_BASE + 0x8)

GIC CPU Interface Binary Point Register.

v1 ICCBPR v2 GICC_BPR

◆ GICC_CTLR

#define GICC_CTLR   (GIC_CPU_BASE + 0x0)

GIC CPU Interface Control Register.

v1 ICCICR v2 GICC_CTLR

◆ GICC_EOIR

#define GICC_EOIR   (GIC_CPU_BASE + 0x10)

GIC CPU Interface End of Interrupt Register.

v1 ICCEOIR v2 GICC_EOIR

◆ GICC_IAR

#define GICC_IAR   (GIC_CPU_BASE + 0xc)

GIC CPU Interface Interrupt Acknowledge Register.

v1 ICCIAR v2 GICC_IAR

◆ GICC_PMR

#define GICC_PMR   (GIC_CPU_BASE + 0x4)

GIC CPU Interface Interrupt Priority Mask Register.

v1 ICCPMR v2 GICC_PMR

◆ GICD_CTLR

#define GICD_CTLR   (GIC_DIST_BASE + 0x0)

GIC Distributor Control Register.

v1 ICDDCR v2/v3 GICD_CTLR

◆ GICD_CTLR_DS

#define GICD_CTLR_DS   BIT(6)

Disable Security (DS) bit in GICD_CTLR.

v3/v3.1 See ARM GIC architecture spec, GICD_CTLR

◆ GICD_ICACTIVERn

#define GICD_ICACTIVERn   (GIC_DIST_BASE + 0x380)

GIC Distributor Interrupt Clear-Active Registers.

v2/v3 GICD_ICACTIVERn

◆ GICD_ICACTIVERnE

#define GICD_ICACTIVERnE   (GIC_DIST_BASE + 0x1C00)

GIC Distributor Interrupt Clear-Active Registers for Extended SPI Range.

v3.1 GICD_ICACTIVERnE

◆ GICD_ICENABLERn

#define GICD_ICENABLERn   (GIC_DIST_BASE + 0x180)

GIC Distributor Interrupt Clear-Enable Registers.

v1 ICDICERn v2/v3 GICD_ICENABLERn

◆ GICD_ICENABLERnE

#define GICD_ICENABLERnE   (GIC_DIST_BASE + 0x1400)

GIC Distributor Interrupt Clear-Enable Registers for Extended SPI Range.

v3.1 GICD_ICENABLERnE

◆ GICD_ICFGRn

#define GICD_ICFGRn   (GIC_DIST_BASE + 0xc00)

GIC Distributor Interrupt Configuration Registers.

v1 ICDICRn v2/v3 GICD_ICFGRn

◆ GICD_ICFGRnE

#define GICD_ICFGRnE   (GIC_DIST_BASE + 0x3000)

GIC Distributor Interrupt Configuration Registers for Extended SPI Range.

v3.1 GICD_ICFGRnE

◆ GICD_ICPENDRn

#define GICD_ICPENDRn   (GIC_DIST_BASE + 0x280)

GIC Distributor Interrupt Clear-Pending Registers.

v1 ICDICPRn v2/v3 GICD_ICPENDRn

◆ GICD_ICPENDRnE

#define GICD_ICPENDRnE   (GIC_DIST_BASE + 0x1800)

GIC Distributor Interrupt Clear-Pending Registers for Extended SPI Range.

v3.1 GICD_ICPENDRnE

◆ GICD_IGROUPRn

#define GICD_IGROUPRn   (GIC_DIST_BASE + 0x80)

GIC Distributor Interrupt Group Registers.

v1 ICDISRn v2/v3 GICD_IGROUPRn

◆ GICD_IGROUPRnE

#define GICD_IGROUPRnE   (GIC_DIST_BASE + 0x1000)

GIC Distributor Interrupt Group Registers for Extended SPI Range.

v3.1 GICD_IGROUPRnE

◆ GICD_IIDR

#define GICD_IIDR   (GIC_DIST_BASE + 0x8)

GIC Distributor Implementer Identification Register.

v1 ICDIIDR v2/v3 GICD_IIDR

◆ GICD_IPRIORITYRn

#define GICD_IPRIORITYRn   (GIC_DIST_BASE + 0x400)

GIC Distributor Interrupt Priority Registers.

v1 ICDIPRn v2/v3 GICD_IPRIORITYRn

◆ GICD_IPRIORITYRnE

#define GICD_IPRIORITYRnE   (GIC_DIST_BASE + 0x2000)

GIC Distributor Interrupt Priority Registers for Extended SPI Range.

v3.1 GICD_IPRIORITYRnE

◆ GICD_ISACTIVERn

#define GICD_ISACTIVERn   (GIC_DIST_BASE + 0x300)

GIC Distributor Interrupt Set-Active Registers.

v1 ICDABRn v2/v3 GICD_ISACTIVERn

◆ GICD_ISACTIVERnE

#define GICD_ISACTIVERnE   (GIC_DIST_BASE + 0x1A00)

GIC Distributor Interrupt Set-Active Registers for Extended SPI Range.

v3.1 GICD_ISACTIVERnE

◆ GICD_ISENABLERn

#define GICD_ISENABLERn   (GIC_DIST_BASE + 0x100)

GIC Distributor Interrupt Set-Enable Registers.

v1 ICDISERn v2/v3 GICD_ISENABLERn

◆ GICD_ISENABLERnE

#define GICD_ISENABLERnE   (GIC_DIST_BASE + 0x1200)

GIC Distributor Interrupt Set-Enable Registers for Extended SPI Range.

v3.1 GICD_ISENABLERnE

◆ GICD_ISPENDRn

#define GICD_ISPENDRn   (GIC_DIST_BASE + 0x200)

GIC Distributor Interrupt Set-Pending Registers.

v1 ICDISPRn v2/v3 GICD_ISPENDRn

◆ GICD_ISPENDRnE

#define GICD_ISPENDRnE   (GIC_DIST_BASE + 0x1600)

GIC Distributor Interrupt Set-Pending Registers for Extended SPI Range.

v3.1 GICD_ISPENDRnE

◆ GICD_ITARGETSRn

#define GICD_ITARGETSRn   (GIC_DIST_BASE + 0x800)

GIC Distributor Interrupt Processor Targets Registers.

v1 ICDIPTRn v2/v3 GICD_ITARGETSRn

◆ GICD_SGIR

#define GICD_SGIR   (GIC_DIST_BASE + 0xf00)

GIC Distributor Software Generated Interrupt Register.

v1 ICDSGIR v2/v3 GICD_SGIR

◆ GICD_TYPER

#define GICD_TYPER   (GIC_DIST_BASE + 0x4)

GIC Distributor Interrupt Controller Type Register.

v1 ICDICTR v2/v3 GICD_TYPER

Function Documentation

◆ arm_gic_eoi()

void arm_gic_eoi ( unsigned int irq)

Signal end-of-interrupt.

Parameters
irqinterrupt ID

◆ arm_gic_get_active()

unsigned int arm_gic_get_active ( void )

Get active interrupt ID.

Returns
Returns the ID of an active interrupt

◆ arm_gic_irq_clear_pending()

void arm_gic_irq_clear_pending ( unsigned int irq)

Clear the pending irq.

Parameters
irqinterrupt ID

◆ arm_gic_irq_disable()

void arm_gic_irq_disable ( unsigned int irq)

Disable interrupt.

Parameters
irqinterrupt ID

◆ arm_gic_irq_enable()

void arm_gic_irq_enable ( unsigned int irq)

Enable interrupt.

Parameters
irqinterrupt ID

◆ arm_gic_irq_is_enabled()

bool arm_gic_irq_is_enabled ( unsigned int irq)

Check if an interrupt is enabled.

Parameters
irqinterrupt ID
Returns
Returns true if interrupt is enabled, false otherwise

◆ arm_gic_irq_is_pending()

bool arm_gic_irq_is_pending ( unsigned int irq)

Check if an interrupt is pending.

Parameters
irqinterrupt ID
Returns
Returns true if interrupt is pending, false otherwise

◆ arm_gic_irq_set_affinity()

void arm_gic_irq_set_affinity ( unsigned int irq,
uint64_t mpidr )

Route an SPI/extended-SPI interrupt to a specific core.

Programs GICD_IROUTER for irq with specific-affinity routing (IRM=0) targeting the core identified by mpidr, analogous to pinning a thread to a CPU with k_thread_cpu_pin(). Only valid for SPIs/extended SPIs, and only takes effect once GICv3 affinity routing itself is enabled (GICD_CTLR.ARE_S/ARE_NS) - true by default on builds with CONFIG_ARMV8_A_NS or CONFIG_GIC_SINGLE_SECURITY_STATE, and on any SoC whose own EL3/Secure pre-init already enables it.

Callable at any time after the interrupt is connected, from any core - unlike arm_gic_irq_enable()'s implicit self-affinity (which always targets whichever core is calling it), this can target an arbitrary core. If called after arm_gic_irq_enable(), this call's target wins.

Parameters
irqinterrupt ID (must be an SPI or extended SPI)
mpidrtarget core's MPIDR affinity value. On arm64 this can come from a specific CPU's devicetree node (DT_REG_ADDR(DT_NODELABEL(cpuX))), or, for the core the caller is currently pinned to, from MPIDR_TO_CORE(GET_MPIDR())

◆ arm_gic_irq_set_pending()

void arm_gic_irq_set_pending ( unsigned int irq)

Set interrupt as pending.

Parameters
irqinterrupt ID

◆ arm_gic_irq_set_priority()

void arm_gic_irq_set_priority ( unsigned int irq,
unsigned int prio,
unsigned int flags )

Set interrupt priority.

Parameters
irqinterrupt ID
priointerrupt priority
flagsinterrupt flags

◆ arm_gic_secondary_init()

void arm_gic_secondary_init ( void )

Initialize GIC of secondary cores.

◆ gic_raise_sgi()

void gic_raise_sgi ( unsigned int sgi_id,
uint64_t target_aff,
uint16_t target_list )

raise SGI to target cores

Parameters
sgi_idSGI ID 0 to 15
target_afftarget affinity in mpidr form. Aff level 1 2 3 will be extracted by api.
target_listbitmask of target cores