/* gic.h — GIC-400 (Generic Interrupt Controller) for Raspberry Pi 5 * BCM2712 uses GIC-400 at 0xFF840000 */ #ifndef GIC_H #define GIC_H #include /* GIC-400 base addresses (BCM2712) */ #define GICD_BASE 0xFF841000UL /* Distributor */ #define GICC_BASE 0xFF842000UL /* CPU interface */ /* GIC Distributor registers */ #define GICD_CTLR (*(volatile uint32_t *)(GICD_BASE + 0x000)) #define GICD_TYPER (*(volatile uint32_t *)(GICD_BASE + 0x004)) #define GICD_ISENABLER(n) (*(volatile uint32_t *)(GICD_BASE + 0x100 + 4 * (n))) #define GICD_ICENABLER(n) (*(volatile uint32_t *)(GICD_BASE + 0x180 + 4 * (n))) #define GICD_IPRIORITYR(n) (*(volatile uint32_t *)(GICD_BASE + 0x400 + 4 * (n))) #define GICD_ITARGETSR(n) (*(volatile uint32_t *)(GICD_BASE + 0x800 + 4 * (n))) #define GICD_ICFGR(n) (*(volatile uint32_t *)(GICD_BASE + 0xC00 + 4 * (n))) #define GICD_ICACTIVER(n) (*(volatile uint32_t *)(GICD_BASE + 0x380 + 4 * (n))) /* GIC CPU interface registers */ #define GICC_CTLR (*(volatile uint32_t *)(GICC_BASE + 0x000)) #define GICC_PMR (*(volatile uint32_t *)(GICC_BASE + 0x004)) #define GICC_IAR (*(volatile uint32_t *)(GICC_BASE + 0x00C)) #define GICC_EOIR (*(volatile uint32_t *)(GICC_BASE + 0x010)) /* IRQ numbers for BCM2712 */ #define IRQ_TIMER_CNTP 30 /* ARM Generic Timer PPI 14 → IRQ 30 (16+14) */ #define IRQ_UART0 33 /* PL011 UART0 SPI → IRQ 33 (32+1 → check BCM2712 TRM) */ #define IRQ_UART1 34 /* PL011 UART1 (mini UART) */ /* Special IRQ values from GICC_IAR */ #define GIC_IRQ_SPURIOUS 1023 /* Initialize GIC-400 */ void gic_init(void); /* Enable an IRQ */ void gic_enable_irq(int irq); /* Disable an IRQ */ void gic_disable_irq(int irq); /* Acknowledge IRQ (returns IRQ number) */ int gic_acknowledge(void); /* End of interrupt */ void gic_eoi(int irq); #endif /* GIC_H */