fix: various fixes

This commit is contained in:
2026-02-22 10:53:30 +01:00
parent e0bfc97f0f
commit 99f231acd2
11 changed files with 50176 additions and 10 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ namespace Hal {
InterruptSourceOverride Overrides[MaxOverrides]; InterruptSourceOverride Overrides[MaxOverrides];
int OverrideCount; int OverrideCount;
static constexpr int MaxLocalApics = 16; static constexpr int MaxLocalApics = 64;
LocalApicEntry LocalApics[MaxLocalApics]; LocalApicEntry LocalApics[MaxLocalApics];
int LocalApicCount; int LocalApicCount;
}; };
+11 -1
View File
@@ -789,6 +789,13 @@ namespace Zenith {
return count; return count;
} }
// ---- Kernel introspection syscalls ----
static void Sys_MemStats(MemStats* out) {
if (out == nullptr) return;
Memory::g_pfa->GetStats(out);
}
// ---- Window scale syscalls ---- // ---- Window scale syscalls ----
static int Sys_WinSetScale(int scale) { static int Sys_WinSetScale(int scale) {
@@ -818,7 +825,7 @@ namespace Zenith {
return WinServer::Destroy(windowId, Sched::GetCurrentPid()); return WinServer::Destroy(windowId, Sched::GetCurrentPid());
} }
static int Sys_WinPresent(int windowId) { static uint64_t Sys_WinPresent(int windowId) {
return WinServer::Present(windowId, Sched::GetCurrentPid()); return WinServer::Present(windowId, Sched::GetCurrentPid());
} }
@@ -1017,6 +1024,9 @@ namespace Zenith {
return (int64_t)Sys_WinSetScale((int)frame->arg1); return (int64_t)Sys_WinSetScale((int)frame->arg1);
case SYS_WINGETSCALE: case SYS_WINGETSCALE:
return (int64_t)Sys_WinGetScale(); return (int64_t)Sys_WinGetScale();
case SYS_MEMSTATS:
Sys_MemStats((MemStats*)frame->arg1);
return 0;
default: default:
return -1; return -1;
} }
+10
View File
@@ -83,6 +83,9 @@ namespace Zenith {
static constexpr uint64_t SYS_KILL = 62; static constexpr uint64_t SYS_KILL = 62;
static constexpr uint64_t SYS_DEVLIST = 63; static constexpr uint64_t SYS_DEVLIST = 63;
// Kernel introspection syscalls
static constexpr uint64_t SYS_MEMSTATS = 67;
static constexpr int SOCK_TCP = 1; static constexpr int SOCK_TCP = 1;
static constexpr int SOCK_UDP = 2; static constexpr int SOCK_UDP = 2;
@@ -162,6 +165,13 @@ namespace Zenith {
uint64_t pixelVa; // VA of pixel buffer in caller's address space uint64_t pixelVa; // VA of pixel buffer in caller's address space
}; };
struct MemStats {
uint64_t totalBytes;
uint64_t freeBytes;
uint64_t usedBytes;
uint64_t pageSize;
};
struct DevInfo { struct DevInfo {
uint8_t category; // 0=CPU, 1=Interrupt, 2=Timer, 3=Input, 4=USB, 5=Network, 6=Display, 7=PCI uint8_t category; // 0=CPU, 1=Interrupt, 2=Timer, 3=Input, 4=USB, 5=Network, 6=Display, 7=PCI
uint8_t _pad[3]; uint8_t _pad[3];
+3 -1
View File
@@ -8,7 +8,9 @@
namespace kcp { namespace kcp {
void Spinlock::Acquire() { void Spinlock::Acquire() {
while (atomic_flag.test_and_set(std::memory_order_acquire)); while (atomic_flag.test_and_set(std::memory_order_acquire)) {
asm volatile("pause");
}
} }
void Spinlock::Release() { void Spinlock::Release() {
+17
View File
@@ -105,4 +105,21 @@ namespace Memory {
Free((void*)(uint64_t)ptr + (0x1000 * n)); Free((void*)(uint64_t)ptr + (0x1000 * n));
} }
} }
void PageFrameAllocator::GetStats(Zenith::MemStats* out) {
if (!out) return;
Lock.Acquire();
uint64_t freeBytes = 0;
Page* current = head.next;
while (current != nullptr) {
freeBytes += current->size;
current = current->next;
}
Lock.Release();
out->totalBytes = g_section.size;
out->freeBytes = freeBytes;
out->usedBytes = g_section.size > freeBytes ? g_section.size - freeBytes : 0;
out->pageSize = 0x1000;
}
}; };
+3
View File
@@ -6,6 +6,7 @@
#pragma once #pragma once
#include "Memmap.hpp" #include "Memmap.hpp"
#include <Api/Syscall.hpp>
#include <CppLib/Spinlock.hpp> #include <CppLib/Spinlock.hpp>
@@ -27,6 +28,8 @@ public:
void* ReallocConsecutive(void* ptr, int n); void* ReallocConsecutive(void* ptr, int n);
void Free(void* ptr); void Free(void* ptr);
void Free(void* ptr, int n); void Free(void* ptr, int n);
void GetStats(Zenith::MemStats* out);
}; };
extern PageFrameAllocator* g_pfa; extern PageFrameAllocator* g_pfa;
+50109
View File
File diff suppressed because it is too large Load Diff
+10
View File
@@ -83,6 +83,9 @@ namespace Zenith {
static constexpr uint64_t SYS_KILL = 62; static constexpr uint64_t SYS_KILL = 62;
static constexpr uint64_t SYS_DEVLIST = 63; static constexpr uint64_t SYS_DEVLIST = 63;
// Kernel introspection syscalls
static constexpr uint64_t SYS_MEMSTATS = 67;
static constexpr int SOCK_TCP = 1; static constexpr int SOCK_TCP = 1;
static constexpr int SOCK_UDP = 2; static constexpr int SOCK_UDP = 2;
@@ -178,4 +181,11 @@ namespace Zenith {
uint64_t heapUsed; // heapNext - UserHeapBase (bytes) uint64_t heapUsed; // heapNext - UserHeapBase (bytes)
}; };
struct MemStats {
uint64_t totalBytes;
uint64_t freeBytes;
uint64_t usedBytes;
uint64_t pageSize;
};
} }
+5 -2
View File
@@ -295,6 +295,9 @@ namespace zenith {
return (int)syscall2(Zenith::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max); return (int)syscall2(Zenith::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
} }
// Kernel introspection
inline void memstats(Zenith::MemStats* out) { syscall1(Zenith::SYS_MEMSTATS, (uint64_t)out); }
// Window server // Window server
inline int win_create(const char* title, int w, int h, Zenith::WinCreateResult* result) { inline int win_create(const char* title, int w, int h, Zenith::WinCreateResult* result) {
return (int)syscall4(Zenith::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result); return (int)syscall4(Zenith::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
@@ -302,8 +305,8 @@ namespace zenith {
inline int win_destroy(int id) { inline int win_destroy(int id) {
return (int)syscall1(Zenith::SYS_WINDESTROY, (uint64_t)id); return (int)syscall1(Zenith::SYS_WINDESTROY, (uint64_t)id);
} }
inline int win_present(int id) { inline uint64_t win_present(int id) {
return (int)syscall1(Zenith::SYS_WINPRESENT, (uint64_t)id); return (uint64_t)syscall1(Zenith::SYS_WINPRESENT, (uint64_t)id);
} }
inline int win_poll(int id, Zenith::WinEvent* event) { inline int win_poll(int id, Zenith::WinEvent* event) {
return (int)syscall2(Zenith::SYS_WINPOLL, (uint64_t)id, (uint64_t)event); return (int)syscall2(Zenith::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
BIN
View File
Binary file not shown.
+2
View File
@@ -81,6 +81,8 @@ ICONS=(
"panel/weather-windy.svg" "panel/weather-windy.svg"
"panel/weather-severe-alert.svg" "panel/weather-severe-alert.svg"
"panel/weather-none-available.svg" "panel/weather-none-available.svg"
"apps/symbolic/utilities-system-monitor-symbolic.svg" # system monitor
"apps/scalable/utilities-system-monitor.svg" # system monitor
) )
copied=0 copied=0