feat: ACPI parsing improvements, username in process struct + syscalls
This commit is contained in:
@@ -120,6 +120,10 @@ namespace Montauk {
|
||||
static constexpr uint64_t SYS_SETTZ = 90;
|
||||
static constexpr uint64_t SYS_GETTZ = 91;
|
||||
|
||||
// User management
|
||||
static constexpr uint64_t SYS_SETUSER = 92;
|
||||
static constexpr uint64_t SYS_GETUSER = 93;
|
||||
|
||||
// Audio control commands (for SYS_AUDIOCTL)
|
||||
static constexpr int AUDIO_CTL_SET_VOLUME = 0;
|
||||
static constexpr int AUDIO_CTL_GET_VOLUME = 1;
|
||||
@@ -306,6 +310,12 @@ namespace Montauk {
|
||||
char name[64];
|
||||
};
|
||||
|
||||
struct ThermalInfo {
|
||||
char name[32]; // short zone name (e.g. "THRM", "TZ00")
|
||||
int32_t temperature; // tenths of degrees Celsius, or -1 if unavailable
|
||||
uint32_t _pad;
|
||||
};
|
||||
|
||||
struct ProcInfo {
|
||||
int32_t pid;
|
||||
int32_t parentPid;
|
||||
|
||||
@@ -120,6 +120,7 @@ struct DesktopState {
|
||||
SvgIcon icon_procmgr;
|
||||
SvgIcon icon_mandelbrot;
|
||||
SvgIcon icon_volume;
|
||||
SvgIcon icon_temperature;
|
||||
|
||||
// External apps discovered from 0:/apps/ manifests
|
||||
ExternalApp external_apps[MAX_EXTERNAL_APPS];
|
||||
@@ -141,6 +142,13 @@ struct DesktopState {
|
||||
bool vol_dragging; // slider drag in progress
|
||||
uint64_t vol_last_poll;
|
||||
|
||||
// Temperature monitoring
|
||||
static constexpr int MAX_THERMAL_ZONES = 8;
|
||||
Montauk::ThermalInfo thermal_zones[MAX_THERMAL_ZONES];
|
||||
int thermal_zone_count;
|
||||
uint64_t thermal_last_poll;
|
||||
Rect temp_icon_rect;
|
||||
|
||||
int screen_w, screen_h;
|
||||
|
||||
// IDs of external windows we've sent a close event to but that haven't
|
||||
|
||||
@@ -402,6 +402,14 @@ namespace montauk {
|
||||
// Kernel introspection
|
||||
inline void memstats(Montauk::MemStats* out) { syscall1(Montauk::SYS_MEMSTATS, (uint64_t)out); }
|
||||
|
||||
// User management
|
||||
inline int setuser(int pid, const char* name) {
|
||||
return (int)syscall2(Montauk::SYS_SETUSER, (uint64_t)pid, (uint64_t)name);
|
||||
}
|
||||
inline int getuser(char* buf, uint64_t maxLen) {
|
||||
return (int)syscall2(Montauk::SYS_GETUSER, (uint64_t)buf, maxLen);
|
||||
}
|
||||
|
||||
// Window server
|
||||
inline int win_create(const char* title, int w, int h, Montauk::WinCreateResult* result) {
|
||||
return (int)syscall4(Montauk::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
||||
|
||||
@@ -546,6 +546,7 @@ static void handle_key(LoginState* ls, const Montauk::KeyEvent& key) {
|
||||
// Spawn desktop with username
|
||||
int pid = montauk::spawn("0:/os/desktop.elf", ls->username);
|
||||
if (pid >= 0) {
|
||||
montauk::setuser(pid, ls->username);
|
||||
montauk::waitpid(pid);
|
||||
}
|
||||
// Desktop exited (logout) — clear session and fields
|
||||
@@ -688,6 +689,7 @@ static void handle_mouse(LoginState* ls) {
|
||||
if (try_login(ls)) {
|
||||
int pid = montauk::spawn("0:/os/desktop.elf", ls->username);
|
||||
if (pid >= 0) {
|
||||
montauk::setuser(pid, ls->username);
|
||||
montauk::waitpid(pid);
|
||||
}
|
||||
montauk::user::clear_session();
|
||||
@@ -772,6 +774,7 @@ extern "C" void _start() {
|
||||
// Launch desktop directly -- no login required
|
||||
int pid = montauk::spawn("0:/os/desktop.elf", user);
|
||||
if (pid >= 0) {
|
||||
montauk::setuser(pid, user);
|
||||
montauk::waitpid(pid);
|
||||
}
|
||||
// Desktop exited (reboot/shutdown expected in setup mode).
|
||||
|
||||
@@ -9,15 +9,14 @@
|
||||
#include <montauk/heap.h>
|
||||
#include <montauk/config.h>
|
||||
|
||||
/*
|
||||
Mar 24, 2026 - update to use getuser() syscall
|
||||
*/
|
||||
extern "C" void _start() {
|
||||
auto doc = montauk::config::load("session");
|
||||
const char* name = doc.get_string("session.username", "");
|
||||
if (name[0]) {
|
||||
montauk::print(name);
|
||||
montauk::putchar('\n');
|
||||
} else {
|
||||
montauk::print("unknown\n");
|
||||
}
|
||||
doc.destroy();
|
||||
char username[32] = { };
|
||||
montauk::getuser((char*)&username, 32);
|
||||
montauk::print((const char*)username);
|
||||
montauk::print("\n");
|
||||
|
||||
montauk::exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user