From cc412f49020c984a6d900d728dcfd855cce16658 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Tue, 8 Jul 2025 02:40:29 +0200 Subject: [PATCH] test2 --- device/ps2controller.cc | 5 +++++ interrupt/epilogues.cc | 4 ++-- main.cc | 21 +++++++-------------- thread/dispatcher.cc | 5 +++-- thread/thread.cc | 5 ++--- user/app1/appl.cc | 2 +- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/device/ps2controller.cc b/device/ps2controller.cc index e2c493d..c22f71a 100644 --- a/device/ps2controller.cc +++ b/device/ps2controller.cc @@ -3,6 +3,7 @@ #include "../arch/system.h" #include "../arch/core_interrupt.h" #include "../arch/ioport.h" +#include "../arch/ioapic.h" #include "../compiler/fix.h" #include "../debug/output.h" #include "keydecoder.h" @@ -106,6 +107,10 @@ void init() { // Set to maximum speed & minimum delay setRepeatRate(SPEED_30_0CPS, DELAY_250MS); + + IOAPIC::config(1, Core::Interrupt::KEYBOARD); + IOAPIC::allow(1); + PS2Controller::drainBuffer(); } bool fetch(Key &pressed) { diff --git a/interrupt/epilogues.cc b/interrupt/epilogues.cc index 85cce97..c18918c 100644 --- a/interrupt/epilogues.cc +++ b/interrupt/epilogues.cc @@ -19,8 +19,8 @@ void timer(Vault& v) { int x, y; if(Core::getID() == 0) { v.kout.getPos(x, y); - v.kout.setPos(65U, 0U); - v.kout << counter++ << " " << flush; + v.kout.setPos(65, 0); + v.kout << counter++ << flush; v.kout.setPos(x, y); } diff --git a/main.cc b/main.cc index a581c0d..ae4f153 100644 --- a/main.cc +++ b/main.cc @@ -121,27 +121,17 @@ extern "C" int main() { } LAPIC::Timer::setup(1000000); - - ApplicationProcessor::boot(); - - PS2Controller::init(); - IOAPIC::init(); - IOAPIC::config(1, Core::Interrupt::KEYBOARD); - IOAPIC::allow(1); - + PS2Controller::init(); + ApplicationProcessor::boot(); Core::Interrupt::enable(); - LAPIC::Timer::activate(); - PS2Controller::drainBuffer(); DBG << "Main CPU " << static_cast(LAPIC::getID()) << endl << flush; - - { Guarded g = Guard::enter(); - g.vault().sch.schedule(); + g.vault().sch.schedule(); } @@ -158,10 +148,13 @@ extern "C" int main() { extern "C" int main_ap() { DBG_VERBOSE << "CPU core " << static_cast(Core::getID()) << " / LAPIC " << static_cast(LAPIC::getID()) << " in main_ap()" << endl; - Core::Interrupt::enable(); DBG << "App CPU " << static_cast(Core::getID()) << endl << flush; + LAPIC::Timer::setup(1000000); + Core::Interrupt::enable(); + LAPIC::Timer::activate(); + { Guarded g = Guard::enter(); g.vault().sch.schedule(); diff --git a/thread/dispatcher.cc b/thread/dispatcher.cc index 085d2ad..9474203 100644 --- a/thread/dispatcher.cc +++ b/thread/dispatcher.cc @@ -27,6 +27,7 @@ void Dispatcher::go(Thread *first) { } void Dispatcher::dispatch(Thread *next) { - //lifePointer[Core::getID()] = next; - lifePointer[Core::getID()]->resume(next); + Thread* tmp = lifePointer[Core::getID()]; + lifePointer[Core::getID()] = next; + tmp->resume(next); } diff --git a/thread/thread.cc b/thread/thread.cc index 7d487e1..3886cba 100644 --- a/thread/thread.cc +++ b/thread/thread.cc @@ -18,11 +18,10 @@ Thread::Thread(void* tos) { #include "../thread/scheduler.h" void Thread::resume(Thread* next) { - Guarded g = Guard::enter(); - Context *from = &g.vault().sch.active()->context; + Context *from = &this->context; Context *to = &next->context; - g.vault().sch.dispatcher.lifePointer[Core::getID()] = next; + //g.vault().sch.dispatcher.lifePointer[Core::getID()] = next; DBG << "from: " << hex << from << endl; DBG << "to : " << hex << to << endl << flush; context_switch(to, from); diff --git a/user/app1/appl.cc b/user/app1/appl.cc index 3ca2ed8..6e5e3c0 100644 --- a/user/app1/appl.cc +++ b/user/app1/appl.cc @@ -45,7 +45,7 @@ void Application::action() { // NOLINT { Guarded g = Guard::enter(); //g.vault(); - g.vault().kout.setPos((unsigned)10*row,(unsigned)/*Core::getID()*2+*/1); + g.vault().kout.setPos((unsigned)8*row,(unsigned)/*Core::getID()*2+*/1); g.vault().kout << cnt++ << flush; //g.vault().kout << endl << flush;