From 1fb8c165149314f5833c7483582cf18250809fef Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Fri, 29 Nov 2019 00:46:42 -0800 Subject: [PATCH] timer wait behavior is really fucked and debugging this is an awful pain so juust check todos --- pit.c | 8 ++++++-- pit.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pit.c b/pit.c index 35c2d43..8dc2125 100644 --- a/pit.c +++ b/pit.c @@ -4,7 +4,7 @@ #include "serial.h" #include "stlio.h" -u32 timer_ticks = 0; +volatile u32 timer_ticks = 0; void inc_ticks(struct cpu_reg_state* cpu) { timer_ticks++; @@ -13,6 +13,10 @@ void inc_ticks(struct cpu_reg_state* cpu) { } } +void timer_wait(u32 time) { + u32 ticks = time + timer_ticks; + while(timer_ticks < ticks); +} void pit_install_timer(void) { init_irq_handler(0, inc_ticks); // timer interrupt request falls into int 0 -} \ No newline at end of file +} diff --git a/pit.h b/pit.h index 5aeea57..336fba2 100644 --- a/pit.h +++ b/pit.h @@ -9,4 +9,6 @@ void inc_ticks(struct cpu_reg_state*); -void pit_install_timer(void); \ No newline at end of file +void timer_wait(u32); + +void pit_install_timer(void);