From c4d7ca3cf07635a6d9ecc7f6adc3cf303b2f8548 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Sun, 25 May 2025 17:02:28 +0200 Subject: [PATCH] changes --- compile_flags.txt | 1 + interrupt/epilogues.cc | 6 +++++- interrupt/guard.cc | 1 + interrupt/guard.h | 2 ++ interrupt/handlers.cc | 9 ++++++--- user/app1/appl.cc | 9 +++++++-- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/compile_flags.txt b/compile_flags.txt index 664c608..966d5a0 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,2 +1,3 @@ -Iarch -xc++ +-std=gnu++2b diff --git a/interrupt/epilogues.cc b/interrupt/epilogues.cc index f0f9c9b..f9e3b86 100644 --- a/interrupt/epilogues.cc +++ b/interrupt/epilogues.cc @@ -2,10 +2,14 @@ #include "guard.h" +extern Key kout_key; +extern TextStream kout; + namespace Epilogues { void keyboard(Vault& g) { - + (void)g; + kout << kout_key.ascii() << endl << flush ; } void timer(Vault& g) { (void)g; } diff --git a/interrupt/guard.cc b/interrupt/guard.cc index 63631a7..9c337c6 100644 --- a/interrupt/guard.cc +++ b/interrupt/guard.cc @@ -26,6 +26,7 @@ Guarded Guard::enter() { epi_flag FOR_CURRENT_CORE = true; Core::Interrupt::enable(); global_lock.lock(); + return Guarded(global_vault); } void Guard::leave() { diff --git a/interrupt/guard.h b/interrupt/guard.h index a15647a..fcaaa38 100644 --- a/interrupt/guard.h +++ b/interrupt/guard.h @@ -7,11 +7,13 @@ #include "../object/key.h" #include "../types.h" #include "epilogues.h" +#include "../device/textstream.h" //! \brief The epilogue vault contains the protected data for the epilogue level struct Vault { Vault(); // no copy + //TextStream kout; Vault(const Vault&) = delete; Vault& operator=(const Vault&) = delete; }; diff --git a/interrupt/handlers.cc b/interrupt/handlers.cc index d2bd0f2..68265e4 100644 --- a/interrupt/handlers.cc +++ b/interrupt/handlers.cc @@ -13,6 +13,8 @@ #include "epilogues.h" #include "guard.h" +Key kout_key = Key(); + void printContext(const InterruptContext *context) { DBG << "ip: " << hex << context->cs << ':' << context->ip << " sp: " << context->ss << ':' << context->sp << " flags" << bin @@ -74,15 +76,16 @@ enum PAGE_FAULT_ERROR { extern TextStream kout; extern Ticketlock koutlock; extern Vault keyboard_vault; + void handle_keyboard() { - Key key = Key(); - if (PS2Controller::fetch(key)) { + //Key key = Key(); + if (PS2Controller::fetch(kout_key)) { Guard::relay(Epilogues::keyboard); //koutlock.lock(); //kout << key.ascii() << endl << flush ; //koutlock.unlock(); } - else if (key.ctrl() && key.alt() && key.scancode == Key::KEY_DEL) + else if (kout_key.ctrl() && kout_key.alt() && kout_key.scancode == Key::KEY_DEL) System::reboot(); LAPIC::endOfInterrupt(); diff --git a/user/app1/appl.cc b/user/app1/appl.cc index 4ce24b5..67c3392 100644 --- a/user/app1/appl.cc +++ b/user/app1/appl.cc @@ -6,6 +6,8 @@ #include "../../device/textstream.h" #include "../../sync/ticketlock.h" #include "../../arch/core.h" +#include "../../interrupt/guard.h" + char text[] = "Ich mag\n\ Saftige Pflaumen voller Aroma\n\ Ich knuddel jede Oma ins Koma\n\ @@ -34,12 +36,15 @@ void activeWaitDelay(uint64_t cycles) { void Application::action() { // NOLINT uint16_t cnt = 0; while (1) { - koutlock.lock(); + //koutlock.lock(); + Guarded g = Guard::enter(); + //g.vault(); while(text[cnt++] != '\n'){ kout << text[cnt-1]; } kout << endl << flush; - koutlock.unlock(); + Guard::leave(); + //koutlock.unlock(); activeWaitDelay(1000000000); if(cnt >= sizeof(text)-1)