feat: disconnect Bluetooth devices, flush disks on shutdown/reboot, display progress in login.elf window

This commit is contained in:
2026-06-06 18:27:19 +02:00
parent b51ab42eb9
commit cee21738ee
24 changed files with 418 additions and 12 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 57
#define MONTAUK_BUILD_NUMBER 64
+20
View File
@@ -13,8 +13,28 @@
#include <ACPI/AcpiShutdown.hpp>
#include <ACPI/AcpiSleep.hpp>
#include "Syscall.hpp"
namespace Montauk {
// Pending graceful power-off request, set by the desktop and consumed by
// login.elf. Kernel-global IPC channel (one outstanding request system-wide).
// `inline` so the single definition is shared across translation units.
inline int g_pendingPowerAction = POWER_REQ_QUERY;
// SYS_POWER_REQUEST. action == POWER_REQ_QUERY reads and clears the pending
// action; any other value records it as the pending action. Returns the
// pending action for queries, or 0 when recording one.
static int64_t Sys_PowerRequest(int action) {
if (action == POWER_REQ_QUERY) {
int pending = g_pendingPowerAction;
g_pendingPowerAction = POWER_REQ_QUERY;
return (int64_t)pending;
}
g_pendingPowerAction = action;
return 0;
}
static void Sys_Reset() {
if (Efi::g_ResetSystem) {
/* Switch to kernel PML4 which has identity-mapped UEFI runtime regions */
+6
View File
@@ -109,6 +109,12 @@ namespace Montauk {
return (int64_t)Fs::FsProbe::MountPartition(partIndex, driveNum);
}
// Flush all block-device write caches and cleanly unmount disk-backed
// volumes ahead of power-off. Returns the number of volumes unmounted.
static int64_t Sys_FsSync() {
return (int64_t)Fs::FsProbe::SyncAndUnmountAll();
}
// Format a partition with a filesystem. Returns 0 on success, -1 on error.
static int64_t Sys_FsFormat(const FsFormatParams* params) {
if (params == nullptr) return -1;
+4
View File
@@ -145,6 +145,8 @@ namespace Montauk {
case SYS_SHUTDOWN:
Sys_Shutdown();
return 0;
case SYS_POWER_REQUEST:
return Sys_PowerRequest((int)frame->arg1);
case SYS_GETTIME:
if (!UserMemory::Writable<DateTime>(frame->arg1)) return -1;
Sys_GetTime((DateTime*)frame->arg1);
@@ -322,6 +324,8 @@ namespace Montauk {
return (int64_t)Sys_GptAdd((const GptAddParams*)frame->arg1);
case SYS_FSMOUNT:
return (int64_t)Sys_FsMount((int)frame->arg1, (int)frame->arg2);
case SYS_FS_SYNC:
return Sys_FsSync();
case SYS_FSFORMAT:
if (!UserMemory::Readable<FsFormatParams>(frame->arg1)) return -1;
return (int64_t)Sys_FsFormat((const FsFormatParams*)frame->arg1);
+15
View File
@@ -249,6 +249,21 @@ namespace Montauk {
static constexpr uint64_t SYS_THREAD_JOIN = 132;
static constexpr uint64_t SYS_THREAD_SELF = 133;
/* Storage.hpp -- flush + unmount persistent volumes for power-off */
static constexpr uint64_t SYS_FS_SYNC = 134;
/* Power.hpp -- cross-process graceful power-off request channel */
static constexpr uint64_t SYS_POWER_REQUEST = 135;
// Graceful power-off request actions (SYS_POWER_REQUEST). The desktop posts
// a pending action and exits; login.elf reads it, runs the shutdown stages,
// then issues the matching SYS_SHUTDOWN / SYS_RESET.
enum PowerRequestAction : int {
POWER_REQ_QUERY = 0, // read-and-clear the pending action
POWER_REQ_SHUTDOWN = 1,
POWER_REQ_REBOOT = 2,
};
static constexpr uint32_t CLIPBOARD_MAX_TEXT_BYTES = 256 * 1024;
static constexpr uint32_t IPC_SIGNAL_READABLE = 1u << 0;