feat: Symmetric Multiprocessing, text editor improvements, merge doom libc, implement math functions
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "../Libraries/String.hpp"
|
||||
#include "../Libraries/Memory.hpp"
|
||||
#include <CppLib/CString.hpp>
|
||||
#include <CppLib/Spinlock.hpp>
|
||||
|
||||
namespace Kt {
|
||||
flanterm_context *ctx;
|
||||
@@ -22,6 +23,11 @@ namespace Kt {
|
||||
uint32_t g_kernelLogDepth = 0;
|
||||
bool g_suppressKernelLog = false;
|
||||
|
||||
// Protects flanterm writes from concurrent CPU access.
|
||||
// Mutex (not Spinlock) so interrupts stay enabled -- prevents dropped
|
||||
// PS/2 mouse/keyboard bytes during log output.
|
||||
kcp::Mutex g_termLock;
|
||||
|
||||
// 64KB ring buffer for kernel log messages
|
||||
static constexpr uint64_t KLOG_BUF_SIZE = 65536;
|
||||
static char g_klogBuf[KLOG_BUF_SIZE];
|
||||
@@ -228,6 +234,13 @@ namespace Kt {
|
||||
}
|
||||
}
|
||||
|
||||
// Once a graphical app takes over, suppress ALL flanterm writes
|
||||
// (SYS_PRINT from user processes, etc.) to avoid painting text
|
||||
// over the GUI framebuffer.
|
||||
if (g_suppressKernelLog && g_kernelLogDepth == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == '\n') {
|
||||
flanterm_write(ctx, "\r\n", 2);
|
||||
return;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <Libraries/String.hpp>
|
||||
#include <CppLib/Stream.hpp>
|
||||
#include <CppLib/Spinlock.hpp>
|
||||
|
||||
using namespace kcp;
|
||||
|
||||
@@ -42,6 +43,11 @@ namespace Kt
|
||||
void Putchar(char c);
|
||||
void Print(const char *text);
|
||||
|
||||
// Terminal mutex - protects flanterm from concurrent CPU access.
|
||||
// Uses Mutex (not Spinlock) to keep interrupts enabled while held,
|
||||
// preventing dropped PS/2 mouse/keyboard bytes during log output.
|
||||
extern kcp::Mutex g_termLock;
|
||||
|
||||
void UpdatePanelBar(const char* panelText);
|
||||
|
||||
void Rescale(std::size_t font_scale_x, std::size_t font_scale_y);
|
||||
@@ -138,7 +144,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
KernelLogStream(KernelLogLevel level, const char* desiredComponentName) { /* level for potential future rich event logging */
|
||||
KernelLogStream(KernelLogLevel level, const char* desiredComponentName) {
|
||||
g_termLock.Acquire();
|
||||
g_kernelLogDepth++;
|
||||
componentName = desiredComponentName;
|
||||
|
||||
@@ -148,6 +155,7 @@ public:
|
||||
~KernelLogStream() {
|
||||
localStream << newline;
|
||||
g_kernelLogDepth--;
|
||||
g_termLock.Release();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user