From 9023944e92130496e39bea2ed8ea419ce4e1ddd2 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Jul 2025 13:33:01 +0200 Subject: [PATCH 1/3] remove second timer --- main.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/main.cc b/main.cc index ae4f153..a0f19ae 100644 --- a/main.cc +++ b/main.cc @@ -151,7 +151,6 @@ extern "C" int main_ap() { DBG << "App CPU " << static_cast(Core::getID()) << endl << flush; - LAPIC::Timer::setup(1000000); Core::Interrupt::enable(); LAPIC::Timer::activate(); From c175c4994595815b62e13bfbe850f3163c238cc8 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Jul 2025 13:46:02 +0200 Subject: [PATCH 2/3] works mostly --- arch/lapic_timer.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/lapic_timer.cc b/arch/lapic_timer.cc index 694c42b..4bbeed9 100644 --- a/arch/lapic_timer.cc +++ b/arch/lapic_timer.cc @@ -129,21 +129,23 @@ void set(uint32_t counter, uint8_t divide, uint8_t vector, bool periodic, LAPIC::write(TIMER_DIVIDE_CONFIGURATION, getClockDiv(divide)); LAPIC::write(TIMER_INITIAL_COUNTER, counter); } - +uint64_t time_tick; + +uint8_t dividender; + bool setup(uint32_t us) { - uint64_t timer_ticks = (static_cast(ticks()) * us) / 1000ULL; + time_tick = (static_cast(ticks()) * us) / 1000ULL; - uint8_t divisor = 1; - while (timer_ticks > UINT32_MAX) { + dividender = 1; + while (time_tick > UINT32_MAX) { // While timer_ticks is to large to fit in 32bits. - timer_ticks >>= 1; - divisor <<= 1; + time_tick >>= 1; + dividender <<= 1; } - if (divisor > 128) + if (dividender > 128) return false; // Timer interval is to large. // Setup Masked interrupts to effectively disable the timer. - set(static_cast(timer_ticks), divisor, Core::Interrupt::TIMER, true, true); return true; } @@ -156,15 +158,15 @@ uint32_t interval() { } void activate() { - uint32_t timer_ticks = LAPIC::read(TIMER_INITIAL_COUNTER); // Disable Counter to avoid spouriose interrupts. LAPIC::write(TIMER_INITIAL_COUNTER, 0); + set(static_cast(time_tick), dividender, Core::Interrupt::TIMER, true, true); // Activate Timer interrupts. setMasked(false); // enable counter with correct value. - LAPIC::write(TIMER_INITIAL_COUNTER, timer_ticks); + LAPIC::write(TIMER_INITIAL_COUNTER, time_tick); } void setMasked(bool masked) { From 5611b7f8865ea5972c12b03dd199b7d1f8f282a3 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Jul 2025 13:47:57 +0200 Subject: [PATCH 3/3] killing all bugs --- interrupt/guard.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interrupt/guard.cc b/interrupt/guard.cc index 13b1d3b..20c47ed 100644 --- a/interrupt/guard.cc +++ b/interrupt/guard.cc @@ -57,7 +57,7 @@ void Guard::relay(Epilogue handler) { Core::Interrupt::enable(); // goto level 0.5 if(epi_flag FOR_CURRENT_CORE){ - epilogue_queue->produce(handler); + epilogue_queue FOR_CURRENT_CORE.produce(handler); } else{ epi_flag FOR_CURRENT_CORE = true;