PatchworkOS
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1#pragma once
2
4#include <kernel/sync/lock.h>
5
6#include <sys/proc.h>
7#include <time.h>
8
9typedef struct cpu cpu_t;
10
24#define TIMER_MAX_CALLBACK 16
25
29typedef void (*timer_callback_t)(interrupt_frame_t* frame, cpu_t* self);
30
52
61
68
75
83
93
103
122void timer_one_shot(cpu_t* self, clock_t uptime, clock_t timeout);
123
131void timer_notify(cpu_t* cpu);
132
138void timer_notify_self(void);
139
void timer_interrupt_handler(interrupt_frame_t *frame, cpu_t *self)
Handle timer interrupt.
Definition timer.c:96
time_t timer_unix_epoch(void)
The unix epoch.
Definition timer.c:86
void(* timer_callback_t)(interrupt_frame_t *frame, cpu_t *self)
Timer callback function type.
Definition timer.h:29
void timer_notify_self(void)
Trigger timer interrupt on self.
Definition timer.c:202
#define TIMER_MAX_CALLBACK
Maximum amount of timer callbacks.
Definition timer.h:24
void timer_one_shot(cpu_t *self, clock_t uptime, clock_t timeout)
Schedule a one-shot timer interrupt.
Definition timer.c:153
void timer_unsubscribe(timer_ctx_t *ctx, timer_callback_t callback)
Unsubscribe from timer interrupts.
Definition timer.c:132
void timer_subscribe(timer_ctx_t *ctx, timer_callback_t callback)
Subscribe to timer interrupts.
Definition timer.c:111
void timer_notify(cpu_t *cpu)
Trigger timer interrupt on cpu.
Definition timer.c:197
clock_t timer_uptime(void)
Time since boot.
Definition timer.c:73
void timer_ctx_init(timer_ctx_t *ctx)
Initialize per-CPU timer context.
Definition timer.c:51
clock_t uptime(void)
System call for retreving the time since boot.
Definition uptime.c:6
__UINT64_TYPE__ clock_t
A nanosecond time.
Definition clock_t.h:13
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
CPU structure.
Definition cpu.h:42
Trap Frame Structure.
Definition interrupt.h:42
A simple ticket lock implementation.
Definition lock.h:43
Per-CPU system time context.
Definition timer.h:35
clock_t nextDeadline
The next time the owner cpus apic timer will fire, specified in nanoseconds since boot,...
Definition timer.h:45
lock_t lock
Definition timer.h:50
uint64_t apicTicksPerNs
The amount of ticks in the owner cpus apic timer that occur every nanosecond, stored using fixed poin...
Definition timer.h:40
long long unsigned time_t
Definition time_t.h:4