|
Kernelite 0.1.0
Kernelite is a minimalist, educational operating system kernel built from scratch. The project aims to recreate core components of the Linux architecture to explore the fundamentals of operating system design and hardware-software interaction.
|
Implementation of the ARM generic system timer driver (CNTP). More...
#include "arm_timer.h"#include "asm/asm_helper.h"#include "fdt/fdt.h"#include "utils/kprintf.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Data Structures | |
| union | cntp_ctl_el0_t |
| CNTP_CTL_EL0 (EL1 Physical Timer Control Register) layout. More... | |
Typedefs | |
| typedef union cntp_ctl_el0_t | cntp_ctl_el0_t |
| CNTP_CTL_EL0 (EL1 Physical Timer Control Register) layout. | |
Functions | |
| static void | timer_isr (void *priv) |
| ISR for the EL1 physical timer interrupt. | |
| static bool | set_period (uint64_t period_ms) |
| Compute and store the CNTP_TVAL_EL0 tick count for a tick period. | |
| static bool | setup_isr (uint32_t int_id, handler_data_t handler) |
| Register the tick handler and enable the EL1 physical timer. | |
| bool | setup_arm64_sys_timer (const void *fdt, int node_offset, uint64_t milliseconds, handler_data_t handler) |
| Configure the system timer's tick period and interrupt handler. | |
Variables | |
| static uint64_t | period_ticks |
| Number of ticks CNTP_TVAL_EL0 must be loaded with to fire once per configured tick period; set by set_period() and consumed by timer_isr() to re-arm the timer after each interrupt. | |
| static handler_data_t | tick_handler |
| Handler registered by the caller of setup_arm64_sys_timer(), invoked from timer_isr() on every tick. | |
Implementation of the ARM generic system timer driver (CNTP).
|
static |
Compute and store the CNTP_TVAL_EL0 tick count for a tick period.
| period_ms | Desired tick period in milliseconds. |
| bool setup_arm64_sys_timer | ( | const void * | fdt, |
| int | node_offset, | ||
| uint64_t | milliseconds, | ||
| handler_data_t | handler | ||
| ) |
Configure the system timer's tick period and interrupt handler.
| fdt | Pointer to the Flattened Device Tree (FDT) blob, which may be used to discover timer properties and configuration. |
| node_offset | Offset of the timer node in the FDT. |
| milliseconds | Desired tick period in milliseconds. |
| handler | Handler function and private data to invoke when the timer interrupt fires. |
|
static |
Register the tick handler and enable the EL1 physical timer.
| int_id | GIC INTID of the EL1 physical timer interrupt. |
| handler | Handler function and private data to invoke on each tick. |
|
static |
ISR for the EL1 physical timer interrupt.
Masks the timer, invokes the registered tick handler if the timer condition was actually met, reloads CNTP_TVAL_EL0 for the next period, and unmasks/re-enables the timer.
| priv | Unused; registered with NULL private data via icu_register_irq(). |