SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Functions | Variables
sys-gic.c File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <log.h>
#include <mmu.h>
#include <reg-ncat.h>
#include <sys-gic.h>
Include dependency graph for sys-gic.c:

Functions

static int interrupts_is_open (void)
 Get interrupts state.
 
static void gic_spi_set_target (int irq_no, int cpu_id)
 Set the target CPU for a specific SPI interrupt.
 
static void gic_distributor_init (void)
 Initialize the GIC distributor controller.
 
static void gic_cpuif_init (void)
 
static void default_isr (void *data)
 
static void gic_sgi_handler (uint32_t irq_no)
 
static void gic_ppi_handler (uint32_t irq_no)
 
static void gic_spi_handler (uint32_t irq_no)
 
static void gic_clear_pending (uint32_t irq_no)
 Clears the pending status of the specified IRQ in the GIC.
 
int arch_interrupt_init (void)
 Initializes the interrupt mechanism.
 
int arch_interrupt_exit (void)
 Exits the interrupt mechanism.
 
int sunxi_gic_cpu_interface_init (int cpu)
 Initializes the Sunxi GIC CPU interface.
 
int sunxi_gic_cpu_interface_exit (void)
 Exits the Sunxi GIC CPU interface.
 
void do_irq (struct arm_regs_t *regs)
 Handles the IRQ with ARM registers.
 
void irq_free_handler (int irq)
 Frees the resources associated with the specified IRQ handler.
 
int irq_enable (int irq_no)
 Enables the specified IRQ.
 
int irq_disable (int irq_no)
 Disables the specified IRQ.
 
void irq_install_handler (int irq, interrupt_handler_t handle_irq, void *data)
 Installs a handler for the specified IRQ.
 

Variables

static irq_handler_t sunxi_int_handlers [GIC_IRQ_NUM]
 

Function Documentation

◆ arch_interrupt_exit()

int arch_interrupt_exit ( void  )

Exits the interrupt mechanism.

Returns
0 on success, or an error code

◆ arch_interrupt_init()

int arch_interrupt_init ( void  )

Initializes the interrupt mechanism.

Returns
0 on success, or an error code

◆ default_isr()

static void default_isr ( void *  data)
static

◆ do_irq()

void do_irq ( struct arm_regs_t regs)

Handles the IRQ with ARM registers.

Parameters
regsPointer to the ARM registers

◆ gic_clear_pending()

static void gic_clear_pending ( uint32_t  irq_no)
static

Clears the pending status of the specified IRQ in the GIC.

Parameters
irq_noIRQ number to clear pending status

◆ gic_cpuif_init()

static void gic_cpuif_init ( void  )
static

◆ gic_distributor_init()

static void gic_distributor_init ( void  )
static

Initialize the GIC distributor controller.

Parameters
void
Returns
void

◆ gic_ppi_handler()

static void gic_ppi_handler ( uint32_t  irq_no)
static

◆ gic_sgi_handler()

static void gic_sgi_handler ( uint32_t  irq_no)
static

◆ gic_spi_handler()

static void gic_spi_handler ( uint32_t  irq_no)
static

◆ gic_spi_set_target()

static void gic_spi_set_target ( int  irq_no,
int  cpu_id 
)
inlinestatic

Set the target CPU for a specific SPI interrupt.

This inline function sets the target CPU for a specific SPI interrupt. It calculates the address of the target register based on the interrupt number, reads the current value of the register, modifies it to set the target CPU, and writes the modified value back to the register. The function assumes that the interrupt number is offset by 32 and that the maximum CPU ID is 15.

Parameters
irq_noThe interrupt number.
cpu_idThe CPU ID of the target CPU.

◆ interrupts_is_open()

static int interrupts_is_open ( void  )
inlinestatic

Get interrupts state.

This inline function checks the state of interrupts. It reads the value of the CPSR register using assembly instructions and returns 1 if interrupts are open (CPSR bit 7 is cleared), otherwise it returns 0.

Returns
int Returns 1 if interrupts are open, otherwise returns 0.

◆ irq_disable()

int irq_disable ( int  irq_no)

Disables the specified IRQ.

Parameters
irq_noIRQ number to be disabled
Returns
0 on success, or an error code

◆ irq_enable()

int irq_enable ( int  irq_no)

Enables the specified IRQ.

Parameters
irq_noIRQ number to be enabled
Returns
0 on success, or an error code

◆ irq_free_handler()

void irq_free_handler ( int  irq)

Frees the resources associated with the specified IRQ handler.

Parameters
irqIRQ number

◆ irq_install_handler()

void irq_install_handler ( int  irq,
interrupt_handler_t  handle_irq,
void *  data 
)

Installs a handler for the specified IRQ.

Parameters
irqIRQ number
handle_irqFunction pointer to the interrupt handler function
dataPointer to data associated with the interrupt handler

◆ sunxi_gic_cpu_interface_exit()

int sunxi_gic_cpu_interface_exit ( void  )

Exits the Sunxi GIC CPU interface.

Returns
0 on success, or an error code

◆ sunxi_gic_cpu_interface_init()

int sunxi_gic_cpu_interface_init ( int  cpu)

Initializes the Sunxi GIC CPU interface.

Parameters
cpuCPU identifier
Returns
0 on success, or an error code

Variable Documentation

◆ sunxi_int_handlers

irq_handler_t sunxi_int_handlers[GIC_IRQ_NUM]
static