CeDOS - Commit a58cdc49

kernel: Added ticks
Celina Sophie Kalus
Sun, 26 Nov 2023 22:22:12 +0100
8 files changed, 43 insertions(+), 3 deletions(-)
M include/cedos/sched/sched.hinclude/cedos/sched/sched.h

@@ -10,7 +10,8 @@ #include "cedos/sched/process.h"

#include "cedos/mm/paging.h" -#define SCHED_INTERVAL (0xFFFF) +// 11928 ~ 10ms per interval +#define SCHED_INTERVAL (11928) /*! * Structure of the process stack when the scheduler is executed.
A include/cedos/time.h

@@ -0,0 +1,8 @@

+#ifndef __TIME_H +#define __TIME_H + +void time_tick(void); + +int time_get_ticks(void); + +#endif
M src/kernel/sched/sched.ssrc/kernel/sched/sched.s

@@ -16,6 +16,7 @@ // pass process stack as arguments

push %ebx push %eax xor %eax, %eax + call time_tick call sched_interrupt_c pop %eax pop %ebx
M src/kernel/syscall.csrc/kernel/syscall.c

@@ -3,6 +3,7 @@ #include "cedos/core.h"

#include "cedos/sched/sched.h" #include "cedos/file.h" #include "cedos/drivers/graphics.h" +#include "cedos/time.h" void test(uint32_t ebx, uint32_t ecx, uint32_t edx) { printk("SYSCALL 0x01: EBX=%i ECX=%X EDX=%X\n", ebx, ecx, edx);

@@ -20,7 +21,8 @@ graphics_set_mode,

hard_reset, file_dir_next, file_lseek, - file_tell + file_tell, + time_get_ticks, }; extern void syscall_interrupt(void);
A src/kernel/time.c

@@ -0,0 +1,11 @@

+#include "cedos/time.h" + +int ticks = 0; + +void time_tick(void) { + ticks++; +} + +int time_get_ticks(void) { + return ticks; +}
M src/libcedos/cedos.csrc/libcedos/cedos.c

@@ -82,4 +82,11 @@ void *pointer = (void*)(0);

volatile uint32_t res = 0; interrupt(0x30, res, 9, fd, index, fname_buffer); return res; -}+} + +int sc_time_get_ticks(void) { + volatile int res = 0; + interrupt(0x30, res, 12, 0, 0, 0); + return res; +} +
M src/libcedos/include/cedos.hsrc/libcedos/include/cedos.h

@@ -24,5 +24,6 @@ void hard_reset();

int dir_next(int fd, int index, char *fname_buffer); +int sc_time_get_ticks(void); #endif
A src/shell/ticks.c

@@ -0,0 +1,9 @@

+#include "cedos.h" +#include "stdio.h" + +#include <stdint.h> + +void main(char *args) { + int ticks = sc_time_get_ticks(); + printf("%i\n", ticks); +}