AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
gic.c File Reference

The virt machine's interrupt controller: ARM's GICv2. More...

#include <core/system.h>
#include <cpu/io.h>
#include <platform/virt.h>

Go to the source code of this file.

Macros

#define GICD_CTLR   0x000
#define GICD_ISENABLER(n)
#define GICD_ICENABLER(n)
#define GICD_IPRIORITYR(n)
#define GICD_ITARGETSR(n)
#define GICD_ICFGR(n)
#define GICC_CTLR   0x000
#define GICC_PMR   0x004
#define GICC_IAR   0x00C
#define GICC_EOIR   0x010

Functions

void gic_setup (void)
 Sets up the GIC at boot: every interrupt masked, of the same priority, and sent to CPU 0.
void gic_enable (unsigned irq)
 Enables (unmasks) an interrupt.
void gic_disable (unsigned irq)
 Disables (masks) an interrupt.
unsigned gic_ack (void)
 Acknowledges the interrupt that came.
void gic_eoi (unsigned irq)
 Tells the GIC that an interrupt has been handled (end of interrupt).

Variables

static uintptr_t gicd = VIRT_REG(VIRT_GICD)
static uintptr_t gicc = VIRT_REG(VIRT_GICC)

Detailed Description

The virt machine's interrupt controller: ARM's GICv2.

References: [1] - ARM Generic Interrupt Controller Architecture Specification, version 2.0 (IHI 0048B): the distributor (GICD_*), the CPU interface (GICC_*)

The distributor takes the interrupts (SPIs, the devices'; PPIs, a CPU's own, such as its timer's) and sends them to the CPUs' interfaces. A CPU reads GICC_IAR to learn which interrupt came (which acknowledges it), and writes it to GICC_EOIR once it's handled. Every interrupt goes to the boot CPU, and all have the same priority.

Definition in file gic.c.

Macro Definition Documentation

◆ GICC_CTLR

#define GICC_CTLR   0x000

Definition at line 28 of file gic.c.

Referenced by gic_setup().

◆ GICC_EOIR

#define GICC_EOIR   0x010

Definition at line 31 of file gic.c.

Referenced by gic_eoi().

◆ GICC_IAR

#define GICC_IAR   0x00C

Definition at line 30 of file gic.c.

Referenced by gic_ack().

◆ GICC_PMR

#define GICC_PMR   0x004

Definition at line 29 of file gic.c.

Referenced by gic_setup().

◆ GICD_CTLR

#define GICD_CTLR   0x000

Definition at line 21 of file gic.c.

Referenced by gic_setup().

◆ GICD_ICENABLER

#define GICD_ICENABLER ( n)
Value:
(0x180 + 4 * (n))

Definition at line 23 of file gic.c.

Referenced by gic_disable(), and gic_setup().

◆ GICD_ICFGR

#define GICD_ICFGR ( n)
Value:
(0xC00 + 4 * (n))

Definition at line 26 of file gic.c.

◆ GICD_IPRIORITYR

#define GICD_IPRIORITYR ( n)
Value:
(0x400 + 4 * (n))

Definition at line 24 of file gic.c.

Referenced by gic_setup().

◆ GICD_ISENABLER

#define GICD_ISENABLER ( n)
Value:
(0x100 + 4 * (n))

Definition at line 22 of file gic.c.

Referenced by gic_enable().

◆ GICD_ITARGETSR

#define GICD_ITARGETSR ( n)
Value:
(0x800 + 4 * (n))

Definition at line 25 of file gic.c.

Referenced by gic_setup().

Function Documentation

◆ gic_ack()

unsigned gic_ack ( void )

Acknowledges the interrupt that came.

Returns
its interrupt ID, or 1023 if there was none (a spurious one)

Definition at line 85 of file gic.c.

References gic_ack(), gicc, and GICC_IAR.

Referenced by gic_ack(), and irq_handle().

◆ gic_disable()

void gic_disable ( unsigned irq)

Disables (masks) an interrupt.

Parameters
irqits interrupt ID

Definition at line 75 of file gic.c.

References gic_disable(), gicd, and GICD_ICENABLER.

Referenced by gic_disable(), and irq_uninstall().

◆ gic_enable()

void gic_enable ( unsigned irq)

Enables (unmasks) an interrupt.

Parameters
irqits interrupt ID

Definition at line 65 of file gic.c.

References gic_enable(), gicd, and GICD_ISENABLER.

Referenced by gic_enable(), and irq_install().

◆ gic_eoi()

void gic_eoi ( unsigned irq)

Tells the GIC that an interrupt has been handled (end of interrupt).

Parameters
irqits interrupt ID

Definition at line 95 of file gic.c.

References gic_eoi(), gicc, and GICC_EOIR.

Referenced by gic_eoi(), and irq_handle().

◆ gic_setup()

void gic_setup ( void )

Sets up the GIC at boot: every interrupt masked, of the same priority, and sent to CPU 0.

Definition at line 38 of file gic.c.

References gic_setup(), gicc, GICC_CTLR, GICC_PMR, gicd, GICD_CTLR, GICD_ICENABLER, GICD_IPRIORITYR, GICD_ITARGETSR, and IRQ_NR.

Referenced by gic_setup(), and platform_init().

Variable Documentation

◆ gicc

uintptr_t gicc = VIRT_REG(VIRT_GICC)
static

Definition at line 34 of file gic.c.

Referenced by gic_ack(), gic_eoi(), and gic_setup().

◆ gicd

uintptr_t gicd = VIRT_REG(VIRT_GICD)
static

Definition at line 33 of file gic.c.

Referenced by gic_disable(), gic_enable(), and gic_setup().