AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
virt.h File Reference
#include <core/system.h>
#include <mm/mm.h>

Go to the source code of this file.

Macros

#define VIRT_GICD   0x08000000
#define VIRT_GICC   0x08010000
#define VIRT_UART   0x09000000
#define VIRT_RTC   0x09010000
#define VIRT_PCIE_MMIO   0x10000000
#define VIRT_PCIE_MMIO_SIZE   0x2EFF0000
#define VIRT_PCIE_PIO   0x3EFF0000
#define VIRT_PCIE_ECAM   0x4010000000ULL
#define VIRT_UART_IRQ   (32 + 1)
#define VIRT_PCIE_IRQ   (32 + 3)
#define VIRT_TIMER_IRQ   27
#define VIRT_REG(base)
#define IRQ_NR   128

Functions

int platform_init (void)
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).
void irq_handle (void)
 Runs the handlers of the interrupt that came, then tells the GIC it's done, before any thread switch, so that the next interrupts keep coming.
uint64_t timer_setup (uint64_t period_ns, void(*handler)(void))
 Starts the tick.

Macro Definition Documentation

◆ IRQ_NR

#define IRQ_NR   128

Definition at line 43 of file virt.h.

Referenced by arch_interrupts_info(), gic_setup(), irq_handle(), irq_install(), and irq_uninstall().

◆ VIRT_GICC

#define VIRT_GICC   0x08010000

Definition at line 14 of file virt.h.

◆ VIRT_GICD

#define VIRT_GICD   0x08000000

Definition at line 13 of file virt.h.

◆ VIRT_PCIE_ECAM

#define VIRT_PCIE_ECAM   0x4010000000ULL

Definition at line 20 of file virt.h.

◆ VIRT_PCIE_IRQ

#define VIRT_PCIE_IRQ   (32 + 3)

Definition at line 25 of file virt.h.

◆ VIRT_PCIE_MMIO

#define VIRT_PCIE_MMIO   0x10000000

Definition at line 17 of file virt.h.

◆ VIRT_PCIE_MMIO_SIZE

#define VIRT_PCIE_MMIO_SIZE   0x2EFF0000

Definition at line 18 of file virt.h.

◆ VIRT_PCIE_PIO

#define VIRT_PCIE_PIO   0x3EFF0000

Definition at line 19 of file virt.h.

◆ VIRT_REG

#define VIRT_REG ( base)
Value:
((uintptr_t) (ARCH_DMAP_BASE + (base)))
#define ARCH_DMAP_BASE
Definition mm.h:14
__SIZE_TYPE__ uintptr_t
Definition stddef.h:12

Definition at line 30 of file virt.h.

Referenced by arch_time_get().

◆ VIRT_RTC

#define VIRT_RTC   0x09010000

Definition at line 16 of file virt.h.

Referenced by arch_time_get().

◆ VIRT_TIMER_IRQ

#define VIRT_TIMER_IRQ   27

Definition at line 26 of file virt.h.

Referenced by timer_setup().

◆ VIRT_UART

#define VIRT_UART   0x09000000

Definition at line 15 of file virt.h.

◆ VIRT_UART_IRQ

#define VIRT_UART_IRQ   (32 + 1)

Definition at line 24 of file virt.h.

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().

◆ irq_handle()

void irq_handle ( void )

Runs the handlers of the interrupt that came, then tells the GIC it's done, before any thread switch, so that the next interrupts keep coming.

Definition at line 84 of file irq.c.

References counts, gic_ack(), gic_eoi(), handlers, irq_handle(), IRQ_NR, and handler::next.

Referenced by __x86_irq_handler(), aarch64_irq(), irq_dispatch(), irq_handle(), and irq_handle().

◆ platform_init()

◆ timer_setup()

uint64_t timer_setup ( uint64_t period_ns,
void(* handler )(void) )

Starts the tick.

Parameters
period_nshow often it comes, in ns
handlerwhat it calls
Returns
the period it really has, in ns (a whole number of counts)

Definition at line 37 of file timer.c.

References freq, interval, irq_install(), isb, NULL, printk(), read_sysreg, tick, timer_irq(), timer_setup(), VIRT_TIMER_IRQ, and write_sysreg.

Referenced by arch_sched_init(), and timer_setup().