feat: add userspace system logging, rename klog to syslog, rename relevant syscalls and API functions

This commit is contained in:
2026-08-14 18:37:27 +02:00
parent 8e45d43116
commit 724029cacb
26 changed files with 139 additions and 52 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ usable diagnostics once the desktop is up**, pending the unified syslog.
Worth understanding, because it catches out anything written as a daemon: Worth understanding, because it catches out anything written as a daemon:
`montauk::print` is `SYS_PRINT`, which writes the kernel *terminal*, not the `montauk::print` is `SYS_PRINT`, which writes the kernel *terminal*, not the
kernel *log*. Only in-kernel `KernelLogStream` writes raise `g_kernelLogDepth`, kernel *log*. Only in-kernel `KernelLogStream` writes raise `g_kernelLogDepth`,
and only those append to the ring buffer `SYS_KLOG` reads -- so daemon output and only those append to the ring buffer `SYS_LOG` reads -- so daemon output
never shows up in `klog`. On top of that, `Sys_Print` returns early once never shows up in `klog`. On top of that, `Sys_Print` returns early once
`g_suppressKernelLog` is set, which the desktop does at startup, so the output is `g_suppressKernelLog` is set, which the desktop does at startup, so the output is
discarded outright from then on. `init` spawns services with `spawn` rather than discarded outright from then on. `init` spawns services with `spawn` rather than
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once #pragma once
#define MONTAUK_BUILD_NUMBER 120 #define MONTAUK_BUILD_NUMBER 141
+15 -2
View File
@@ -53,6 +53,8 @@ namespace montauk::abi {
static constexpr uint64_t kMaxWindowTitleBytes = 256; static constexpr uint64_t kMaxWindowTitleBytes = 256;
static constexpr uint64_t kMaxHostnameBytes = 256; static constexpr uint64_t kMaxHostnameBytes = 256;
static constexpr uint64_t kMaxUserNameBytes = 32; static constexpr uint64_t kMaxUserNameBytes = 32;
static constexpr uint64_t kMaxUserspaceLogComponentNameBytes = 32;
static constexpr uint64_t kMaxUserspaceLogEntryBytes = 1024;
// ---- Dispatch ---- // ---- Dispatch ----
@@ -300,9 +302,9 @@ namespace montauk::abi {
case SYS_GETRANDOM: case SYS_GETRANDOM:
if (!UserMemory::Range(frame->arg1, frame->arg2, true)) return -1; if (!UserMemory::Range(frame->arg1, frame->arg2, true)) return -1;
return Sys_GetRandom((uint8_t*)frame->arg1, frame->arg2); return Sys_GetRandom((uint8_t*)frame->arg1, frame->arg2);
case SYS_KLOG: case SYS_LOG:
if (!UserMemory::Range(frame->arg1, frame->arg2, true)) return -1; if (!UserMemory::Range(frame->arg1, frame->arg2, true)) return -1;
return Kt::ReadKernelLog((char*)frame->arg1, frame->arg2); return Kt::ReadKernelLogBuffer((char*)frame->arg1, frame->arg2);
case SYS_MOUSESTATE: case SYS_MOUSESTATE:
if (!UserMemory::Writable<MouseState>(frame->arg1)) return -1; if (!UserMemory::Writable<MouseState>(frame->arg1)) return -1;
Sys_MouseState((MouseState*)frame->arg1); Sys_MouseState((MouseState*)frame->arg1);
@@ -609,6 +611,17 @@ namespace montauk::abi {
return Sys_ClipboardClear(); return Sys_ClipboardClear();
case SYS_INPUT_WAIT: case SYS_INPUT_WAIT:
return (int64_t)Sys_InputWait(frame->arg1, frame->arg2); return (int64_t)Sys_InputWait(frame->arg1, frame->arg2);
case SYS_LOG_WRITE: { // "init" <---- component name (arg1)
// "started service ..." <---- log message (arg2)
if (!UserMemory::String(frame->arg1, kMaxUserspaceLogComponentNameBytes)
|| !UserMemory::String(frame->arg2, kMaxUserspaceLogEntryBytes)
) return -1;
Kt::UserspaceLogStream((const char*)frame->arg1) << (const char*)frame->arg2;
return 0;
}
default: default:
return -1; return -1;
} }
+4 -1
View File
@@ -103,7 +103,7 @@ namespace montauk::abi {
/* Random.hpp */ /* Random.hpp */
static constexpr uint64_t SYS_GETRANDOM = 45; static constexpr uint64_t SYS_GETRANDOM = 45;
static constexpr uint64_t SYS_KLOG = 46; static constexpr uint64_t SYS_LOG = 46;
/* Mouse.hpp */ /* Mouse.hpp */
static constexpr uint64_t SYS_MOUSESTATE = 47; static constexpr uint64_t SYS_MOUSESTATE = 47;
@@ -157,6 +157,9 @@ namespace montauk::abi {
static constexpr uint64_t SYS_AUDIOWRITE = 82; static constexpr uint64_t SYS_AUDIOWRITE = 82;
static constexpr uint64_t SYS_AUDIOCTL = 83; static constexpr uint64_t SYS_AUDIOCTL = 83;
/* Userspace log */
static constexpr uint64_t SYS_LOG_WRITE = 176;
// Audio control commands (for SYS_AUDIOCTL). // Audio control commands (for SYS_AUDIOCTL).
// //
// Commands 0..3 act on the stream named by the handle argument. // Commands 0..3 act on the stream named by the handle argument.
+1 -1
View File
@@ -250,7 +250,7 @@ namespace Kt {
g_suppressKernelLog = false; g_suppressKernelLog = false;
} }
int64_t ReadKernelLog(char* buf, uint64_t size) { int64_t ReadKernelLogBuffer(char* buf, uint64_t size) {
if (buf == nullptr || size == 0) return 0; if (buf == nullptr || size == 0) return 0;
uint64_t toRead = g_klogCount; uint64_t toRead = g_klogCount;
+30 -2
View File
@@ -121,7 +121,7 @@ namespace Kt
// intentionally lock-free: a panic can occur while another CPU owns the // intentionally lock-free: a panic can occur while another CPU owns the
// terminal mutex, and the system is about to halt. // terminal mutex, and the system is about to halt.
void EnablePanicOutput(); void EnablePanicOutput();
int64_t ReadKernelLog(char* buf, uint64_t size); int64_t ReadKernelLogBuffer(char* buf, uint64_t size);
class KernelLogStream { class KernelLogStream {
KernelOutStream localStream{}; KernelOutStream localStream{};
@@ -151,7 +151,7 @@ public:
g_kernelLogDepth++; g_kernelLogDepth++;
componentName = desiredComponentName; componentName = desiredComponentName;
localStream << componentName << ": " << "[" << LogLevelToStringWithColor(level) << "] "; localStream << "[kernel/" << componentName << "] " << LogLevelToStringWithColor(level) << ": ";
} }
~KernelLogStream() { ~KernelLogStream() {
@@ -168,6 +168,34 @@ public:
} }
}; };
class UserspaceLogStream {
KernelOutStream localStream{};
const char* componentName = "";
public:
UserspaceLogStream(const char* desiredComponentName) {
g_termLock.Acquire();
g_kernelLogDepth++;
componentName = desiredComponentName;
localStream << "[userspace/" << componentName << "]" << ": ";
}
~UserspaceLogStream() {
localStream << newline;
g_kernelLogDepth--;
g_termLock.Release();
}
template<typename T>
UserspaceLogStream &operator<<(T item) {
localStream << item;
return *this;
}
};
}; };
extern Kt::KernelOutStream kout; extern Kt::KernelOutStream kout;
+2 -2
View File
@@ -487,9 +487,9 @@
// out: montauk::abi::PowerInfo* // out: montauk::abi::PowerInfo*
<strong>KERNEL LOG</strong> <strong>KERNEL LOG</strong>
<strong>SYS_KLOG (46)</strong> <strong>SYS_LOG (46)</strong>
Read from the kernel ring log buffer. Read from the kernel ring log buffer.
int64_t montauk::read_klog(char* buf, uint64_t size); int64_t montauk::read_log(char* buf, uint64_t size);
<strong>I/O REDIRECTION</strong> <strong>I/O REDIRECTION</strong>
Used by the terminal app and similar programs to run a child Used by the terminal app and similar programs to run a child
+7 -7
View File
@@ -49,7 +49,7 @@ BINDIR := bin
PROGRAMS := $(notdir $(wildcard src/*)) PROGRAMS := $(notdir $(wildcard src/*))
# Programs with custom Makefiles (built separately). # Programs with custom Makefiles (built separately).
CUSTOM_BUILDS := 2048 fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display keyboard sshserver terminal klog procmgr powermgr calculator charmap desktop login shell paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs libloader crashpad sshd CUSTOM_BUILDS := 2048 fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display keyboard sshserver terminal syslog procmgr powermgr calculator charmap desktop login shell paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs libloader crashpad sshd
SYSTEM_PROGRAMS := $(filter-out $(CUSTOM_BUILDS),$(PROGRAMS)) SYSTEM_PROGRAMS := $(filter-out $(CUSTOM_BUILDS),$(PROGRAMS))
# Build targets: system programs go to bin/os/, apps go to bin/apps/<name>/. # Build targets: system programs go to bin/os/, apps go to bin/apps/<name>/.
@@ -96,9 +96,9 @@ WPDIR := data/wallpapers
WPSRC := $(wildcard $(WPDIR)/*.jpg) WPSRC := $(wildcard $(WPDIR)/*.jpg)
WPDST := $(patsubst $(WPDIR)/%,$(BINDIR)/os/wallpapers/%,$(WPSRC)) WPDST := $(patsubst $(WPDIR)/%,$(BINDIR)/os/wallpapers/%,$(WPSRC))
.PHONY: all clean 2048 fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display keyboard sshserver sshd terminal klog procmgr powermgr calculator charmap login desktop shell paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs icons fonts configs osdata bearssl libc tls libjpeg libjpegwrite install-apps libloader crashpad check-syscalls gen-syscalls .PHONY: all clean 2048 fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display keyboard sshserver sshd terminal syslog procmgr powermgr calculator charmap login desktop shell paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs icons fonts configs osdata bearssl libc tls libjpeg libjpegwrite install-apps libloader crashpad check-syscalls gen-syscalls
all: bearssl libc libjpeg libjpegwrite tls libloader devkit $(TARGETS) fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display sshserver terminal klog procmgr powermgr calculator charmap 2048 paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs login desktop shell sshd icons fonts install-apps crashpad $(MANDST) $(WWWDST) $(CA_CERTS) $(CONFIGDST) $(OSDATADST) $(FWDST) $(LICDST) $(WPDST) all: bearssl libc libjpeg libjpegwrite tls libloader devkit $(TARGETS) fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display sshserver terminal syslog procmgr powermgr calculator charmap 2048 paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs login desktop shell sshd icons fonts install-apps crashpad $(MANDST) $(WWWDST) $(CA_CERTS) $(CONFIGDST) $(OSDATADST) $(FWDST) $(LICDST) $(WPDST)
# Build BearSSL static library (cross-compiled for freestanding x86_64). # Build BearSSL static library (cross-compiled for freestanding x86_64).
BEARSSL_INCLUDES := -isystem $(shell cd .. && pwd)/kernel/freestnd-c-hdrs/x86_64/include -isystem $(abspath include/libc) BEARSSL_INCLUDES := -isystem $(shell cd .. && pwd)/kernel/freestnd-c-hdrs/x86_64/include -isystem $(abspath include/libc)
@@ -236,8 +236,8 @@ terminal: libc
$(MAKE) -C src/terminal $(MAKE) -C src/terminal
# Build kernel log standalone GUI tool (depends on libc). # Build kernel log standalone GUI tool (depends on libc).
klog: libc syslog: libc
$(MAKE) -C src/klog $(MAKE) -C src/syslog
# Build process manager standalone GUI tool (depends on libc). # Build process manager standalone GUI tool (depends on libc).
procmgr: libc procmgr: libc
@@ -351,7 +351,7 @@ crashpad: libc
$(MAKE) -C src/crashpad $(MAKE) -C src/crashpad
# Install app bundles (manifests, icons, data files) into bin/apps/<name>/. # Install app bundles (manifests, icons, data files) into bin/apps/<name>/.
install-apps: 2048 paint spreadsheet wordprocessor weather wikipedia imageviewer fontpreview pdfviewer disks devexplorer installer audio music video bluetooth network display keyboard sshserver terminal klog procmgr powermgr calculator charmap screenshot texteditor mandelbrot printers timezone crashpad install-apps: 2048 paint spreadsheet wordprocessor weather wikipedia imageviewer fontpreview pdfviewer disks devexplorer installer audio music video bluetooth network display keyboard sshserver terminal syslog procmgr powermgr calculator charmap screenshot texteditor mandelbrot printers timezone crashpad
../scripts/install_apps.sh ../scripts/install_apps.sh
# Copy man pages into bin/man/ so mkramdisk.sh picks them up. # Copy man pages into bin/man/ so mkramdisk.sh picks them up.
@@ -506,7 +506,7 @@ clean:
$(MAKE) -C src/network clean $(MAKE) -C src/network clean
$(MAKE) -C src/keyboard clean $(MAKE) -C src/keyboard clean
$(MAKE) -C src/terminal clean $(MAKE) -C src/terminal clean
$(MAKE) -C src/klog clean $(MAKE) -C src/syslog clean
$(MAKE) -C src/procmgr clean $(MAKE) -C src/procmgr clean
$(MAKE) -C src/powermgr clean $(MAKE) -C src/powermgr clean
$(MAKE) -C src/calculator clean $(MAKE) -C src/calculator clean
+3 -1
View File
@@ -60,7 +60,7 @@ namespace montauk::abi {
static constexpr uint64_t SYS_TERMSCALE = 43; static constexpr uint64_t SYS_TERMSCALE = 43;
static constexpr uint64_t SYS_RESOLVE = 44; static constexpr uint64_t SYS_RESOLVE = 44;
static constexpr uint64_t SYS_GETRANDOM = 45; static constexpr uint64_t SYS_GETRANDOM = 45;
static constexpr uint64_t SYS_KLOG = 46; static constexpr uint64_t SYS_LOG = 46;
static constexpr uint64_t SYS_MOUSESTATE = 47; static constexpr uint64_t SYS_MOUSESTATE = 47;
static constexpr uint64_t SYS_SETMOUSEBOUNDS = 48; static constexpr uint64_t SYS_SETMOUSEBOUNDS = 48;
static constexpr uint64_t SYS_SPAWN_REDIR = 49; static constexpr uint64_t SYS_SPAWN_REDIR = 49;
@@ -239,6 +239,8 @@ namespace montauk::abi {
static constexpr uint64_t SYS_SETENVIRON = 172; static constexpr uint64_t SYS_SETENVIRON = 172;
static constexpr uint64_t SYS_SPAWN_ENV = 173; static constexpr uint64_t SYS_SPAWN_ENV = 173;
static constexpr uint64_t SYS_LOG_WRITE = 176; // (componentName, logMessage) -> 0
// Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM). // Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM).
static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz
static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz
+7 -6
View File
@@ -69,15 +69,10 @@ extern "C" {
#define MTK_SYS_TERMSCALE 43 #define MTK_SYS_TERMSCALE 43
#define MTK_SYS_RESOLVE 44 #define MTK_SYS_RESOLVE 44
#define MTK_SYS_GETRANDOM 45 #define MTK_SYS_GETRANDOM 45
#define MTK_SYS_KLOG 46 #define MTK_SYS_LOG 46
#define MTK_SYS_MOUSESTATE 47 #define MTK_SYS_MOUSESTATE 47
#define MTK_SYS_SETMOUSEBOUNDS 48 #define MTK_SYS_SETMOUSEBOUNDS 48
#define MTK_SYS_SPAWN_REDIR 49 #define MTK_SYS_SPAWN_REDIR 49
#define MTK_SYS_GETENVIRON 171
#define MTK_SYS_SETENVIRON 172
#define MTK_SYS_SPAWN_ENV 173
#define MTK_SYS_SETSESSION 174
#define MTK_SYS_KILLSESSION 175
#define MTK_SYS_CHILDIO_READ 50 #define MTK_SYS_CHILDIO_READ 50
#define MTK_SYS_CHILDIO_WRITE 51 #define MTK_SYS_CHILDIO_WRITE 51
#define MTK_SYS_CHILDIO_WRITEKEY 52 #define MTK_SYS_CHILDIO_WRITEKEY 52
@@ -199,6 +194,12 @@ extern "C" {
#define MTK_SYS_MMAP_ANON 168 #define MTK_SYS_MMAP_ANON 168
#define MTK_SYS_MUNMAP 169 #define MTK_SYS_MUNMAP 169
#define MTK_SYS_MPROTECT 170 #define MTK_SYS_MPROTECT 170
#define MTK_SYS_GETENVIRON 171
#define MTK_SYS_SETENVIRON 172
#define MTK_SYS_SPAWN_ENV 173
#define MTK_SYS_SETSESSION 174
#define MTK_SYS_KILLSESSION 175
#define MTK_SYS_LOG_WRITE 176
/* @SYSCALLS-END */ /* @SYSCALLS-END */
#define MTK_SOCK_TCP 1 #define MTK_SOCK_TCP 1
+6 -2
View File
@@ -430,8 +430,12 @@ namespace montauk {
} }
// Kernel log // Kernel log
inline int64_t read_klog(char* buf, uint64_t size) { inline int64_t read_log(char* buf, uint64_t size) {
return syscall2(montauk::abi::SYS_KLOG, (uint64_t)buf, size); return syscall2(montauk::abi::SYS_LOG, (uint64_t)buf, size);
}
inline int64_t write_log(const char* userspaceComponent, const char* logMessage) {
return syscall2(montauk::abi::SYS_LOG_WRITE, (uint64_t)userspaceComponent, (uint64_t)logMessage);
} }
// I/O redirection // I/O redirection
+2 -2
View File
@@ -418,9 +418,9 @@
// out: montauk::abi::PowerInfo* // out: montauk::abi::PowerInfo*
.SH KERNEL LOG .SH KERNEL LOG
.B SYS_KLOG (46) .B SYS_LOG (46)
Read from the kernel ring log buffer. Read from the kernel ring log buffer.
int64_t montauk::read_klog(char* buf, uint64_t size); int64_t montauk::read_log(char* buf, uint64_t size);
.SH I/O REDIRECTION .SH I/O REDIRECTION
Used by the terminal app and similar programs to run a child Used by the terminal app and similar programs to run a child
@@ -27,9 +27,9 @@ void open_texteditor(DesktopState* ds) {
spawn_app("0:/apps/texteditor/texteditor.elf"); spawn_app("0:/apps/texteditor/texteditor.elf");
} }
void open_klog(DesktopState* ds) { void open_syslog(DesktopState* ds) {
(void)ds; (void)ds;
spawn_app("0:/apps/klog/klog.elf"); spawn_app("0:/apps/klog/syslog.elf");
} }
void open_wordprocessor(DesktopState* ds) { void open_wordprocessor(DesktopState* ds) {
+1 -1
View File
@@ -249,7 +249,7 @@ void open_system_configuration(DesktopState* ds);
void ensure_filemanager_icons_loaded(DesktopState* ds); void ensure_filemanager_icons_loaded(DesktopState* ds);
void open_calculator(DesktopState* ds); void open_calculator(DesktopState* ds);
void open_texteditor(DesktopState* ds); void open_texteditor(DesktopState* ds);
void open_klog(DesktopState* ds); void open_syslog(DesktopState* ds);
void open_settings(DesktopState* ds); void open_settings(DesktopState* ds);
void open_user_manager(DesktopState* ds); void open_user_manager(DesktopState* ds);
void open_reboot_dialog(DesktopState* ds); void open_reboot_dialog(DesktopState* ds);
+1 -1
View File
@@ -897,7 +897,7 @@ void gui::desktop_handle_keyboard(DesktopState* ds, const montauk::abi::KeyEvent
return; return;
} }
if (routed_key.ascii == 'k' || routed_key.ascii == 'K') { if (routed_key.ascii == 'k' || routed_key.ascii == 'K') {
open_klog(ds); open_syslog(ds);
return; return;
} }
} }
+32 -7
View File
@@ -21,6 +21,15 @@
#define C_CYAN "\033[36m" #define C_CYAN "\033[36m"
#define C_WHITE "\033[37m" #define C_WHITE "\033[37m"
// ---- Process scan ----
static bool system_already_initialized() {
/* A valid init will always be PID 0 */
if (montauk::getpid() != 0) return true;
return false;
}
// ---- Logging ---- // ---- Logging ----
static void log_timestamp(char* buf, int size) { static void log_timestamp(char* buf, int size) {
@@ -39,16 +48,16 @@ static void log(LogLevel level, const char* msg) {
const char* tag; const char* tag;
const char* color; const char* color;
switch (level) { switch (level) {
case LOG_OK: tag = " OK "; color = C_GREEN; break; case LOG_OK: tag = "OK:"; color = C_GREEN; break;
case LOG_INFO: tag = " INFO "; color = C_CYAN; break; case LOG_INFO: tag = "INFO:"; color = C_CYAN; break;
case LOG_WARN: tag = " WARN "; color = C_YELLOW; break; case LOG_WARN: tag = "WARN:"; color = C_YELLOW; break;
case LOG_ERR: tag = " FAIL "; color = C_RED; break; case LOG_ERR: tag = "FAIL:"; color = C_RED; break;
} }
snprintf(line, sizeof(line), snprintf(line, sizeof(line),
C_DIM "%s" C_RESET " %s%s" C_RESET " " C_BOLD "init" C_RESET " %s\n", C_DIM "%s" C_RESET " %s%s" C_RESET " %s",
ts, color, tag, msg); ts, color, tag, msg);
montauk::print(line); montauk::write_log("init", line);
} }
static void log_ok(const char* msg) { log(LOG_OK, msg); } static void log_ok(const char* msg) { log(LOG_OK, msg); }
@@ -178,11 +187,27 @@ static bool run_configured_service(const montauk::toml::Doc& doc,
return run_configured_service(doc, fallback_service, fallback_depth + 1); return run_configured_service(doc, fallback_service, fallback_depth + 1);
} }
const char* getReleaseString(char* buffer, int n) {
montauk::abi::SysInfo info;
montauk::get_info(&info);
snprintf(buffer, n, "The Montauk Operating System, version %s (build %u)",
info.osVersion, info.buildNumber);
return buffer;
}
// ---- Main ---- // ---- Main ----
extern "C" void _start() { extern "C" void _start() {
if (system_already_initialized()) {
montauk::exit(1);
}
log_info("The Montauk Operating System"); char releaseString[128] = "";
getReleaseString(releaseString, 128);
log_info(releaseString);
auto config = montauk::config::load("init"); auto config = montauk::config::load("init");
int discovered = 0; int discovered = 0;
+8
View File
@@ -0,0 +1,8 @@
#include <montauk/syscall.h>
extern "C" void _start() {
montauk::write_log("testapp", "hello, logging world!");
montauk::exit(0);
}
@@ -1,4 +1,4 @@
# Makefile for klog (standalone Window Server app) on MontaukOS # Makefile for syslog (standalone Window Server app) on MontaukOS
# Copyright (c) 2026 Daniel Hammer # Copyright (c) 2026 Daniel Hammer
MAKEFLAGS += -rR MAKEFLAGS += -rR
@@ -45,14 +45,14 @@ SRCS := main.cpp stb_truetype_impl.cpp font_data.cpp
OBJS := $(addprefix $(OBJDIR)/,$(SRCS:.cpp=.o)) OBJS := $(addprefix $(OBJDIR)/,$(SRCS:.cpp=.o))
DEPS := $(OBJS:.o=.d) DEPS := $(OBJS:.o=.d)
TARGET := $(BINDIR)/apps/klog/klog.elf TARGET := $(BINDIR)/apps/syslog/syslog.elf
.PHONY: all clean .PHONY: all clean
all: $(TARGET) all: $(TARGET)
$(TARGET): $(OBJS) $(LINK_LD) Makefile $(LIBDIR)/libc/liblibc.a $(TARGET): $(OBJS) $(LINK_LD) Makefile $(LIBDIR)/libc/liblibc.a
mkdir -p $(BINDIR)/apps/klog mkdir -p $(BINDIR)/apps/syslog
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(LIBDIR)/libc/liblibc.a -o $@ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(LIBDIR)/libc/liblibc.a -o $@
$(OBJDIR)/%.o: %.cpp Makefile $(OBJDIR)/%.o: %.cpp Makefile
@@ -68,7 +68,7 @@ static bool klog_poll() {
if (now - g_klog.last_poll_ms < KLOG_POLL_MS) return false; if (now - g_klog.last_poll_ms < KLOG_POLL_MS) return false;
g_klog.last_poll_ms = now; g_klog.last_poll_ms = now;
int n = (int)montauk::read_klog(g_klog.klog_buf, KLOG_READ_SIZE); int n = (int)montauk::read_log(g_klog.klog_buf, KLOG_READ_SIZE);
if (n <= 0 && g_klog.last_len <= 0) return false; if (n <= 0 && g_klog.last_len <= 0) return false;
if (n > g_klog.last_len) { if (n > g_klog.last_len) {
@@ -157,7 +157,7 @@ extern "C" void _start() {
if (!fonts::init()) if (!fonts::init())
montauk::exit(1); montauk::exit(1);
if (!g_win.create("Kernel Log", INIT_W, INIT_H)) if (!g_win.create("System Log", INIT_W, INIT_H))
montauk::exit(1); montauk::exit(1);
int cols = g_win.width / mono_cell_width(); int cols = g_win.width / mono_cell_width();
@@ -180,7 +180,7 @@ extern "C" void _start() {
g_klog.last_pixels = g_win.pixels; g_klog.last_pixels = g_win.pixels;
int n = (int)montauk::read_klog(g_klog.klog_buf, KLOG_READ_SIZE); int n = (int)montauk::read_log(g_klog.klog_buf, KLOG_READ_SIZE);
if (n > 0) { if (n > 0) {
klog_refeed(n); klog_refeed(n);
g_klog.last_len = n; g_klog.last_len = n;
@@ -1,6 +1,6 @@
[app] [app]
name = "Kernel Log" name = "System Log"
binary = "klog.elf" binary = "syslog.elf"
icon = "utilities-terminal.svg" icon = "utilities-terminal.svg"
[menu] [menu]
+1 -1
View File
@@ -35,7 +35,7 @@ APPS=(
"keyboard|categories/scalable/preferences-keyboard.svg" "keyboard|categories/scalable/preferences-keyboard.svg"
"sshserver|apps/scalable/utilities-terminal.svg" "sshserver|apps/scalable/utilities-terminal.svg"
"terminal|apps/scalable/utilities-terminal.svg" "terminal|apps/scalable/utilities-terminal.svg"
"klog|apps/scalable/utilities-terminal.svg" "syslog|apps/scalable/utilities-terminal.svg"
"procmgr|apps/scalable/system-monitor.svg" "procmgr|apps/scalable/system-monitor.svg"
"powermgr|apps/scalable/gnome-power-statistics.svg" "powermgr|apps/scalable/gnome-power-statistics.svg"
"calculator|apps/scalable/accessories-calculator.svg" "calculator|apps/scalable/accessories-calculator.svg"
+3 -1
View File
@@ -60,7 +60,7 @@ namespace montauk::abi {
static constexpr uint64_t SYS_TERMSCALE = 43; static constexpr uint64_t SYS_TERMSCALE = 43;
static constexpr uint64_t SYS_RESOLVE = 44; static constexpr uint64_t SYS_RESOLVE = 44;
static constexpr uint64_t SYS_GETRANDOM = 45; static constexpr uint64_t SYS_GETRANDOM = 45;
static constexpr uint64_t SYS_KLOG = 46; static constexpr uint64_t SYS_LOG = 46;
static constexpr uint64_t SYS_MOUSESTATE = 47; static constexpr uint64_t SYS_MOUSESTATE = 47;
static constexpr uint64_t SYS_SETMOUSEBOUNDS = 48; static constexpr uint64_t SYS_SETMOUSEBOUNDS = 48;
static constexpr uint64_t SYS_SPAWN_REDIR = 49; static constexpr uint64_t SYS_SPAWN_REDIR = 49;
@@ -234,6 +234,8 @@ namespace montauk::abi {
static constexpr uint64_t SYS_WIFI_CONNECT_ASYNC = 164; // (ssid, password) -> 0 accepted, <0 on error static constexpr uint64_t SYS_WIFI_CONNECT_ASYNC = 164; // (ssid, password) -> 0 accepted, <0 on error
static constexpr uint64_t SYS_NETIFS = 165; // (NetIfInfo*, maxCount) -> count static constexpr uint64_t SYS_NETIFS = 165; // (NetIfInfo*, maxCount) -> count
static constexpr uint64_t SYS_LOG_WRITE = 176; // (componentName, logMessage) -> 0
// Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM). // Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM).
static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz
static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz
+2 -1
View File
@@ -69,7 +69,7 @@ extern "C" {
#define MTK_SYS_TERMSCALE 43 #define MTK_SYS_TERMSCALE 43
#define MTK_SYS_RESOLVE 44 #define MTK_SYS_RESOLVE 44
#define MTK_SYS_GETRANDOM 45 #define MTK_SYS_GETRANDOM 45
#define MTK_SYS_KLOG 46 #define MTK_SYS_LOG 46
#define MTK_SYS_MOUSESTATE 47 #define MTK_SYS_MOUSESTATE 47
#define MTK_SYS_SETMOUSEBOUNDS 48 #define MTK_SYS_SETMOUSEBOUNDS 48
#define MTK_SYS_SPAWN_REDIR 49 #define MTK_SYS_SPAWN_REDIR 49
@@ -194,6 +194,7 @@ extern "C" {
#define MTK_SYS_WIFI_RESULTS 163 #define MTK_SYS_WIFI_RESULTS 163
#define MTK_SYS_WIFI_CONNECT_ASYNC 164 #define MTK_SYS_WIFI_CONNECT_ASYNC 164
#define MTK_SYS_NETIFS 165 #define MTK_SYS_NETIFS 165
#define MTK_SYS_LOG_WRITE 176
/* @SYSCALLS-END */ /* @SYSCALLS-END */
#define MTK_SOCK_TCP 1 #define MTK_SOCK_TCP 1
+2 -2
View File
@@ -428,8 +428,8 @@ namespace montauk {
} }
// Kernel log // Kernel log
inline int64_t read_klog(char* buf, uint64_t size) { inline int64_t read_log(char* buf, uint64_t size) {
return syscall2(montauk::abi::SYS_KLOG, (uint64_t)buf, size); return syscall2(montauk::abi::SYS_LOG, (uint64_t)buf, size);
} }
// I/O redirection // I/O redirection