aboutsummaryrefslogtreecommitdiff
path: root/kernel/inc
diff options
context:
space:
mode:
authorMarvin Borner2021-07-01 21:13:01 +0200
committerMarvin Borner2021-07-01 22:32:16 +0200
commitf3e85eedc434da973267f360abdbb79cb6f24100 (patch)
tree9fd71ec70454474a0a2cff479c7d9b949e779c74 /kernel/inc
parent340e841772eb13d9087235b8707c1cfeff8710cb (diff)
Timing is everything
Diffstat (limited to 'kernel/inc')
-rw-r--r--kernel/inc/drivers/int.h2
-rw-r--r--kernel/inc/drivers/pit.h8
-rw-r--r--kernel/inc/proc.h7
-rw-r--r--kernel/inc/timer.h (renamed from kernel/inc/drivers/timer.h)7
4 files changed, 24 insertions, 0 deletions
diff --git a/kernel/inc/drivers/int.h b/kernel/inc/drivers/int.h
index 8146898..9dd4a6f 100644
--- a/kernel/inc/drivers/int.h
+++ b/kernel/inc/drivers/int.h
@@ -44,6 +44,8 @@ struct idt_ptr {
} PACKED;
void idt_install(void);
+void int_enable(void);
+void int_disable(void);
void int_trap_handler_add(u32 int_no, void (*handler)(u32 esp));
void int_event_handler_add(u32 int_no, void (*handler)(void));
diff --git a/kernel/inc/drivers/pit.h b/kernel/inc/drivers/pit.h
new file mode 100644
index 0000000..b3cd507
--- /dev/null
+++ b/kernel/inc/drivers/pit.h
@@ -0,0 +1,8 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef PIT_H
+#define PIT_H
+
+void pit_install(void);
+
+#endif
diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h
index 42ff75d..5cc1fef 100644
--- a/kernel/inc/proc.h
+++ b/kernel/inc/proc.h
@@ -8,6 +8,7 @@
#include <list.h>
#include <stack.h>
#include <sys.h>
+#include <timer.h>
#define PROC_QUANTUM 15 // Milliseconds or something // TODO
#define PROC_STACK_SIZE 0x4000 // 16KiB
@@ -51,6 +52,11 @@ struct proc {
u8 val;
u8 cnt;
} quantum;
+
+ struct {
+ enum timer_mode mode;
+ u32 data;
+ } timer;
};
u32 scheduler(u32 esp);
@@ -62,6 +68,7 @@ u8 proc_idle(void);
struct proc *proc_from_pid(u32 pid);
void proc_exit(s32 status);
void proc_yield(void);
+void proc_timer_check(u32 time);
void proc_set_quantum(struct proc *proc, u32 value) NONNULL;
void proc_reset_quantum(struct proc *proc) NONNULL;
void proc_state(struct proc *proc, enum proc_state state) NONNULL;
diff --git a/kernel/inc/drivers/timer.h b/kernel/inc/timer.h
index ea1643b..1233f6e 100644
--- a/kernel/inc/drivers/timer.h
+++ b/kernel/inc/timer.h
@@ -5,6 +5,13 @@
#include <def.h>
+enum timer_mode {
+ TIMER_MODE_DEFAULT,
+ TIMER_MODE_SLEEP,
+};
+
+void timer_install_handler(void);
+
u32 timer_get(void);
void timer_wait(u32 ticks);
void timer_install(void);