AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
virt.h
Go to the documentation of this file.
1
#ifndef _PLATFORM_VIRT_H
2
#define _PLATFORM_VIRT_H
3
4
#include <
core/system.h
>
5
#include <
mm/mm.h
>
6
7
/*
8
* QEMU's virt machine (hw/arm/virt.c): where its devices are, as its
9
* devicetree also says. They are in the first GiB of physical memory,
10
* which is device memory, mapped in the direct map from boot
11
* (boot/head.S).
12
*/
13
#define VIRT_GICD 0x08000000
/* GICv2 distributor */
14
#define VIRT_GICC 0x08010000
/* GICv2 CPU interface */
15
#define VIRT_UART 0x09000000
/* PL011 */
16
#define VIRT_RTC 0x09010000
/* PL031 */
17
#define VIRT_PCIE_MMIO 0x10000000
/* PCIe: memory for BARs (the same bus addresses) */
18
#define VIRT_PCIE_MMIO_SIZE 0x2EFF0000
19
#define VIRT_PCIE_PIO 0x3EFF0000
/* PCIe: its I/O ports, 64 KiB */
20
#define VIRT_PCIE_ECAM 0x4010000000ULL
/* PCIe: configuration space */
21
22
/* Interrupt IDs: the SPIs (shared) start at 32, and the PPIs (a CPU's
23
* own) are 16 to 31. */
24
#define VIRT_UART_IRQ (32 + 1)
25
#define VIRT_PCIE_IRQ (32 + 3)
/* INTA# to INTD#: the 4 from here, level-triggered */
26
#define VIRT_TIMER_IRQ 27
/* the virtual timer (EL1) */
27
28
/* A device's registers, in the direct map: the boot tables map the
29
* devices there (arch_mmio_map() maps them elsewhere). */
30
#define VIRT_REG(base) ((uintptr_t) (ARCH_DMAP_BASE + (base)))
31
32
/* Sets up the platform: the interrupt controller, PCI (init.c). */
33
int
platform_init
(
void
);
34
35
/* The GICv2 interrupt controller (gic.c). */
36
void
gic_setup
(
void
);
37
void
gic_enable
(
unsigned
irq);
38
void
gic_disable
(
unsigned
irq);
39
unsigned
gic_ack
(
void
);
/* the interrupt that came, or 1023 for none */
40
void
gic_eoi
(
unsigned
irq);
41
42
/* The interrupts' handlers (irq.c; irq_install() is in dev/irq.h). */
43
#define IRQ_NR 128
44
void
irq_handle
(
void
);
/* runs the handlers of the interrupt that came */
45
46
/* Starts the generic timer's tick, every `period_ns` (timer.c). */
47
uint64_t
timer_setup
(
uint64_t
period_ns,
void
(*
handler
)(
void
));
48
49
#endif
/* ! _PLATFORM_VIRT_H */
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
gic.c:38
gic_eoi
void gic_eoi(unsigned irq)
Tells the GIC that an interrupt has been handled (end of interrupt).
Definition
gic.c:95
gic_ack
unsigned gic_ack(void)
Acknowledges the interrupt that came.
Definition
gic.c:85
gic_disable
void gic_disable(unsigned irq)
Disables (masks) an interrupt.
Definition
gic.c:75
gic_enable
void gic_enable(unsigned irq)
Enables (unmasks) an interrupt.
Definition
gic.c:65
system.h
mm.h
uint64_t
unsigned long long int uint64_t
Definition
stddef.h:23
handler
An installed handler, on its interrupt's list.
Definition
irq.c:19
platform_init
int platform_init(void)
Definition
init.c:31
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,...
Definition
irq.c:84
timer_setup
uint64_t timer_setup(uint64_t period_ns, void(*handler)(void))
Starts the tick.
Definition
timer.c:37
kernel
arch
aarch64
platform
virt
include
platform
virt.h
Generated by
1.18.0