From 51e38b76145a8570ed144822178f23f2748257a3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 29 Feb 2024 13:06:36 +0200 Subject: [PATCH] Kernel: Replace CriticalScope with SpinLock in SerialTTY --- kernel/include/kernel/Terminal/Serial.h | 1 + kernel/kernel/Terminal/Serial.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/include/kernel/Terminal/Serial.h b/kernel/include/kernel/Terminal/Serial.h index d666bbf4d0..3df9250b68 100644 --- a/kernel/include/kernel/Terminal/Serial.h +++ b/kernel/include/kernel/Terminal/Serial.h @@ -62,6 +62,7 @@ namespace Kernel BAN::String m_name; Serial m_serial; BAN::CircularQueue m_input; + SpinLock m_input_lock; public: virtual dev_t rdev() const override { return m_rdev; } diff --git a/kernel/kernel/Terminal/Serial.cpp b/kernel/kernel/Terminal/Serial.cpp index c7c64ba0f1..e60b8021dc 100644 --- a/kernel/kernel/Terminal/Serial.cpp +++ b/kernel/kernel/Terminal/Serial.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -219,6 +218,8 @@ namespace Kernel void SerialTTY::handle_irq() { uint8_t ch = IO::inb(m_serial.port()); + + SpinLockGuard _(m_input_lock); if (m_input.full()) { dwarnln("Serial buffer full"); @@ -235,7 +236,7 @@ namespace Kernel uint8_t buffer[128]; { - CriticalScope _; + SpinLockGuard _(m_input_lock); if (m_input.empty()) return; uint8_t* ptr = buffer;