cleanup: namespace Montauk (capital M) => montauk::abi
This commit is contained in:
@@ -424,7 +424,7 @@ namespace Hal {
|
|||||||
reinitProgress(0x02); // TSS
|
reinitProgress(0x02); // TSS
|
||||||
Hal::LoadTSS();
|
Hal::LoadTSS();
|
||||||
reinitProgress(0x03); // Syscalls
|
reinitProgress(0x03); // Syscalls
|
||||||
Montauk::InitializeSyscalls();
|
montauk::abi::InitializeSyscalls();
|
||||||
// Re-set GS base for BSP (lost during S3)
|
// Re-set GS base for BSP (lost during S3)
|
||||||
{
|
{
|
||||||
auto* bsp = Smp::GetCpuData(0);
|
auto* bsp = Smp::GetCpuData(0);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
// Audio handle convention:
|
// Audio handle convention:
|
||||||
// 0x00 - 0x07 : Mixer virtual streams (one per opened audio handle)
|
// 0x00 - 0x07 : Mixer virtual streams (one per opened audio handle)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static int64_t Sys_BtScan(BtScanResult* buf, int maxCount, uint32_t timeoutMs) {
|
static int64_t Sys_BtScan(BtScanResult* buf, int maxCount, uint32_t timeoutMs) {
|
||||||
if (!buf || maxCount <= 0) return -1;
|
if (!buf || maxCount <= 0) return -1;
|
||||||
|
|||||||
@@ -12,4 +12,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MONTAUK_BUILD_NUMBER 24
|
#define MONTAUK_BUILD_NUMBER 25
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static constexpr int ClipboardMaxSlots = 32;
|
static constexpr int ClipboardMaxSlots = 32;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <Sched/Scheduler.hpp>
|
#include <Sched/Scheduler.hpp>
|
||||||
#include <Ipc/Ipc.hpp>
|
#include <Ipc/Ipc.hpp>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static Sched::Process* GetRedirTarget(Sched::Process* proc) {
|
static Sched::Process* GetRedirTarget(Sched::Process* proc) {
|
||||||
if (!proc || !proc->redirected) return nullptr;
|
if (!proc || !proc->redirected) return nullptr;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
#include "../Sched/CrashReport.hpp"
|
#include "../Sched/CrashReport.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static int64_t Sys_CrashReport(CrashReportInfo* out) {
|
static int64_t Sys_CrashReport(CrashReportInfo* out) {
|
||||||
if (!out) return 0;
|
if (!out) return 0;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include <Drivers/Storage/BlockDevice.hpp>
|
#include <Drivers/Storage/BlockDevice.hpp>
|
||||||
#include <Drivers/Storage/Nvme.hpp>
|
#include <Drivers/Storage/Nvme.hpp>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static void dl_strcpy(char* dst, const char* src, int max) {
|
static void dl_strcpy(char* dst, const char* src, int max) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
#include <Ipc/Ipc.hpp>
|
#include <Ipc/Ipc.hpp>
|
||||||
#include "Path.hpp"
|
#include "Path.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
static int Sys_Open(const char* path) {
|
static int Sys_Open(const char* path) {
|
||||||
char resolved[256];
|
char resolved[256];
|
||||||
if (!ResolveProcessPath(path, resolved, sizeof(resolved))) return -1;
|
if (!ResolveProcessPath(path, resolved, sizeof(resolved))) return -1;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
#include "../Libraries/flanterm/src/flanterm.h"
|
#include "../Libraries/flanterm/src/flanterm.h"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static void Sys_FbInfo(FbInfo* out) {
|
static void Sys_FbInfo(FbInfo* out) {
|
||||||
if (out == nullptr) return;
|
if (out == nullptr) return;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <Memory/HHDM.hpp>
|
#include <Memory/HHDM.hpp>
|
||||||
#include <Memory/PageFrameAllocator.hpp>
|
#include <Memory/PageFrameAllocator.hpp>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
// Per-process heap allocation tracking (separate from Process struct to avoid bloating it)
|
// Per-process heap allocation tracking (separate from Process struct to avoid bloating it)
|
||||||
struct HeapAlloc {
|
struct HeapAlloc {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "BuildNo.hpp"
|
#include "BuildNo.hpp"
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static void Sys_GetInfo(SysInfo* outInfo) {
|
static void Sys_GetInfo(SysInfo* outInfo) {
|
||||||
if (outInfo == nullptr) return;
|
if (outInfo == nullptr) return;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Drivers/Input/InputEvents.hpp>
|
#include <Drivers/Input/InputEvents.hpp>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static uint64_t Sys_InputWait(uint64_t observedSerial, uint64_t timeoutMs) {
|
static uint64_t Sys_InputWait(uint64_t observedSerial, uint64_t timeoutMs) {
|
||||||
return Drivers::InputEvents::WaitForChange(observedSerial, timeoutMs);
|
return Drivers::InputEvents::WaitForChange(observedSerial, timeoutMs);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
#include "Path.hpp"
|
#include "Path.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static constexpr uint32_t RedirOutputStreamCapacity = 64 * 1024;
|
static constexpr uint32_t RedirOutputStreamCapacity = 64 * 1024;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <Sched/Scheduler.hpp>
|
#include <Sched/Scheduler.hpp>
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static int Sys_DupHandle(int handle) {
|
static int Sys_DupHandle(int handle) {
|
||||||
return Ipc::DupHandle(handle);
|
return Ipc::DupHandle(handle);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
static bool Sys_IsKeyAvailable() {
|
static bool Sys_IsKeyAvailable() {
|
||||||
auto* proc = Sched::GetCurrentProcessPtr();
|
auto* proc = Sched::GetCurrentProcessPtr();
|
||||||
if (proc && proc->redirected) {
|
if (proc && proc->redirected) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <Libraries/Memory.hpp>
|
#include <Libraries/Memory.hpp>
|
||||||
#include <Libraries/String.hpp>
|
#include <Libraries/String.hpp>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
// Maximum libraries per process
|
// Maximum libraries per process
|
||||||
static constexpr int MaxLibsPerProcess = 8;
|
static constexpr int MaxLibsPerProcess = 8;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static void Sys_MemStats(MemStats* out) {
|
static void Sys_MemStats(MemStats* out) {
|
||||||
if (out == nullptr) return;
|
if (out == nullptr) return;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static void Sys_MouseState(MouseState* out) {
|
static void Sys_MouseState(MouseState* out) {
|
||||||
if (out == nullptr) return;
|
if (out == nullptr) return;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static uint16_t g_pingSeq = 0;
|
static uint16_t g_pingSeq = 0;
|
||||||
static constexpr uint16_t PING_ID = 0x2E01; // "ZE"
|
static constexpr uint16_t PING_ID = 0x2E01; // "ZE"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <Sched/Scheduler.hpp>
|
#include <Sched/Scheduler.hpp>
|
||||||
#include <Libraries/Memory.hpp>
|
#include <Libraries/Memory.hpp>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static int ParseDrivePrefix(const char* path, int* outPrefixLen = nullptr) {
|
static int ParseDrivePrefix(const char* path, int* outPrefixLen = nullptr) {
|
||||||
if (path == nullptr || path[0] < '0' || path[0] > '9') return -1;
|
if (path == nullptr || path[0] < '0' || path[0] > '9') return -1;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
// Pending graceful power-off request, set by the desktop and consumed by
|
// Pending graceful power-off request, set by the desktop and consumed by
|
||||||
// login.elf. Kernel-global IPC channel (one outstanding request system-wide).
|
// login.elf. Kernel-global IPC channel (one outstanding request system-wide).
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "WinServer.hpp"
|
#include "WinServer.hpp"
|
||||||
#include "Path.hpp"
|
#include "Path.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
static void Sys_Exit(int exitCode) {
|
static void Sys_Exit(int exitCode) {
|
||||||
(void)exitCode;
|
(void)exitCode;
|
||||||
Sched::ExitProcess();
|
Sched::ExitProcess();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
// ---- Random number generation ----
|
// ---- Random number generation ----
|
||||||
// Uses RDTSC mixed with xorshift64* PRNG for entropy.
|
// Uses RDTSC mixed with xorshift64* PRNG for entropy.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static void dl_strcpy_s(char* dst, const char* src, int max) {
|
static void dl_strcpy_s(char* dst, const char* src, int max) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
// Assembly entry point
|
// Assembly entry point
|
||||||
extern "C" void SyscallEntry();
|
extern "C" void SyscallEntry();
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static constexpr uint64_t kMaxPrintableStringBytes = 4096;
|
static constexpr uint64_t kMaxPrintableStringBytes = 4096;
|
||||||
static constexpr uint64_t kMaxPathBytes = 256;
|
static constexpr uint64_t kMaxPathBytes = 256;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
// Syscall numbers
|
// Syscall numbers
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static void Sys_Print(const char* text) {
|
static void Sys_Print(const char* text) {
|
||||||
auto* proc = Sched::GetCurrentProcessPtr();
|
auto* proc = Sched::GetCurrentProcessPtr();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
static uint64_t Sys_GetTicks() {
|
static uint64_t Sys_GetTicks() {
|
||||||
return Timekeeping::GetTicks();
|
return Timekeeping::GetTicks();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <Sched/Scheduler.hpp>
|
#include <Sched/Scheduler.hpp>
|
||||||
#include <Memory/Paging.hpp>
|
#include <Memory/Paging.hpp>
|
||||||
|
|
||||||
namespace Montauk::UserMemory {
|
namespace montauk::abi::UserMemory {
|
||||||
|
|
||||||
static constexpr uint64_t USER_SPACE_END = 0x0000800000000000ULL;
|
static constexpr uint64_t USER_SPACE_END = 0x0000800000000000ULL;
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace WinServer {
|
|||||||
ResetSlotLocked(slot);
|
ResetSlotLocked(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SendEventLocked(int windowId, const Montauk::WinEvent* event) {
|
static int SendEventLocked(int windowId, const montauk::abi::WinEvent* event) {
|
||||||
if (windowId < 0 || windowId >= MaxWindows || event == nullptr) return -1;
|
if (windowId < 0 || windowId >= MaxWindows || event == nullptr) return -1;
|
||||||
WindowSlot& slot = g_slots[windowId];
|
WindowSlot& slot = g_slots[windowId];
|
||||||
if (!slot.used || slot.eventMailbox == nullptr) return -1;
|
if (!slot.used || slot.eventMailbox == nullptr) return -1;
|
||||||
@@ -200,7 +200,7 @@ namespace WinServer {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Poll(int windowId, int callerPid, Montauk::WinEvent* outEvent) {
|
int Poll(int windowId, int callerPid, montauk::abi::WinEvent* outEvent) {
|
||||||
WsGuard guard;
|
WsGuard guard;
|
||||||
if (windowId < 0 || windowId >= MaxWindows || outEvent == nullptr) return -1;
|
if (windowId < 0 || windowId >= MaxWindows || outEvent == nullptr) return -1;
|
||||||
|
|
||||||
@@ -213,13 +213,13 @@ namespace WinServer {
|
|||||||
return rc > 0 ? 1 : 0;
|
return rc > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Enumerate(Montauk::WinInfo* outArray, int maxCount) {
|
int Enumerate(montauk::abi::WinInfo* outArray, int maxCount) {
|
||||||
WsGuard guard;
|
WsGuard guard;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < MaxWindows && count < maxCount; i++) {
|
for (int i = 0; i < MaxWindows && count < maxCount; i++) {
|
||||||
if (!g_slots[i].used) continue;
|
if (!g_slots[i].used) continue;
|
||||||
|
|
||||||
Montauk::WinInfo& info = outArray[count];
|
montauk::abi::WinInfo& info = outArray[count];
|
||||||
info.id = i;
|
info.id = i;
|
||||||
info.ownerPid = g_slots[i].ownerPid;
|
info.ownerPid = g_slots[i].ownerPid;
|
||||||
for (int j = 0; j < 64; j++) info.title[j] = g_slots[i].title[j];
|
for (int j = 0; j < 64; j++) info.title[j] = g_slots[i].title[j];
|
||||||
@@ -263,7 +263,7 @@ namespace WinServer {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SendEvent(int windowId, const Montauk::WinEvent* event) {
|
int SendEvent(int windowId, const montauk::abi::WinEvent* event) {
|
||||||
WsGuard guard;
|
WsGuard guard;
|
||||||
return SendEventLocked(windowId, event);
|
return SendEventLocked(windowId, event);
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ namespace WinServer {
|
|||||||
|
|
||||||
WindowSlot& slot = g_slots[windowId];
|
WindowSlot& slot = g_slots[windowId];
|
||||||
if (!slot.used || slot.ownerPid != callerPid) return -1;
|
if (!slot.used || slot.ownerPid != callerPid) return -1;
|
||||||
slot.flags = flags & Montauk::WIN_FLAG_FULLSCREEN;
|
slot.flags = flags & montauk::abi::WIN_FLAG_FULLSCREEN;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ namespace WinServer {
|
|||||||
if (scale > 2) scale = 2;
|
if (scale > 2) scale = 2;
|
||||||
g_uiScale = scale;
|
g_uiScale = scale;
|
||||||
|
|
||||||
Montauk::WinEvent ev{};
|
montauk::abi::WinEvent ev{};
|
||||||
ev.type = 4;
|
ev.type = 4;
|
||||||
ev.scale.scale = scale;
|
ev.scale.scale = scale;
|
||||||
for (int i = 0; i < MaxWindows; i++) {
|
for (int i = 0; i < MaxWindows; i++) {
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ namespace WinServer {
|
|||||||
uint64_t& heapNext, uint64_t& outVa);
|
uint64_t& heapNext, uint64_t& outVa);
|
||||||
int Destroy(int windowId, int callerPid);
|
int Destroy(int windowId, int callerPid);
|
||||||
int Present(int windowId, int callerPid);
|
int Present(int windowId, int callerPid);
|
||||||
int Poll(int windowId, int callerPid, Montauk::WinEvent* outEvent);
|
int Poll(int windowId, int callerPid, montauk::abi::WinEvent* outEvent);
|
||||||
int Enumerate(Montauk::WinInfo* outArray, int maxCount);
|
int Enumerate(montauk::abi::WinInfo* outArray, int maxCount);
|
||||||
uint64_t Map(int windowId, int callerPid, uint64_t callerPml4, uint64_t& heapNext);
|
uint64_t Map(int windowId, int callerPid, uint64_t callerPml4, uint64_t& heapNext);
|
||||||
int Unmap(int windowId, int callerPid, uint64_t callerPml4);
|
int Unmap(int windowId, int callerPid, uint64_t callerPml4);
|
||||||
int SendEvent(int windowId, const Montauk::WinEvent* event);
|
int SendEvent(int windowId, const montauk::abi::WinEvent* event);
|
||||||
int Resize(int windowId, int callerPid, uint64_t ownerPml4, int newW, int newH,
|
int Resize(int windowId, int callerPid, uint64_t ownerPml4, int newW, int newH,
|
||||||
uint64_t& heapNext, uint64_t& outVa);
|
uint64_t& heapNext, uint64_t& outVa);
|
||||||
void CleanupProcess(int pid);
|
void CleanupProcess(int pid);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "Syscall.hpp"
|
#include "Syscall.hpp"
|
||||||
#include "WinServer.hpp"
|
#include "WinServer.hpp"
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
static int Sys_WinCreate(const char* title, int w, int h, WinCreateResult* result) {
|
static int Sys_WinCreate(const char* title, int w, int h, WinCreateResult* result) {
|
||||||
if (result == nullptr || title == nullptr) return -1;
|
if (result == nullptr || title == nullptr) return -1;
|
||||||
|
|||||||
@@ -437,15 +437,15 @@ namespace Drivers::Audio::Mixer {
|
|||||||
int Control(int handle, int cmd, int value) {
|
int Control(int handle, int cmd, int value) {
|
||||||
// Master-scope commands ignore the handle.
|
// Master-scope commands ignore the handle.
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case Montauk::AUDIO_CTL_SET_MASTER_VOLUME:
|
case montauk::abi::AUDIO_CTL_SET_MASTER_VOLUME:
|
||||||
SetMasterVolume(value);
|
SetMasterVolume(value);
|
||||||
return 0;
|
return 0;
|
||||||
case Montauk::AUDIO_CTL_GET_MASTER_VOLUME:
|
case montauk::abi::AUDIO_CTL_GET_MASTER_VOLUME:
|
||||||
return GetMasterVolume();
|
return GetMasterVolume();
|
||||||
case Montauk::AUDIO_CTL_SET_MASTER_MUTE:
|
case montauk::abi::AUDIO_CTL_SET_MASTER_MUTE:
|
||||||
SetMasterMute(value != 0);
|
SetMasterMute(value != 0);
|
||||||
return 0;
|
return 0;
|
||||||
case Montauk::AUDIO_CTL_GET_MASTER_MUTE:
|
case montauk::abi::AUDIO_CTL_GET_MASTER_MUTE:
|
||||||
return GetMasterMute() ? 1 : 0;
|
return GetMasterMute() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,27 +458,27 @@ namespace Drivers::Audio::Mixer {
|
|||||||
int rv = -1;
|
int rv = -1;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case Montauk::AUDIO_CTL_SET_VOLUME: {
|
case montauk::abi::AUDIO_CTL_SET_VOLUME: {
|
||||||
int v = value; if (v < 0) v = 0; if (v > 100) v = 100;
|
int v = value; if (v < 0) v = 0; if (v > 100) v = 100;
|
||||||
if (s.volume != (uint8_t)v) { s.volume = (uint8_t)v; changed = true; }
|
if (s.volume != (uint8_t)v) { s.volume = (uint8_t)v; changed = true; }
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Montauk::AUDIO_CTL_GET_VOLUME:
|
case montauk::abi::AUDIO_CTL_GET_VOLUME:
|
||||||
rv = s.volume;
|
rv = s.volume;
|
||||||
break;
|
break;
|
||||||
case Montauk::AUDIO_CTL_GET_POS:
|
case montauk::abi::AUDIO_CTL_GET_POS:
|
||||||
rv = (int)(s.consumedInputBytes & 0x7FFFFFFF);
|
rv = (int)(s.consumedInputBytes & 0x7FFFFFFF);
|
||||||
break;
|
break;
|
||||||
case Montauk::AUDIO_CTL_PAUSE:
|
case montauk::abi::AUDIO_CTL_PAUSE:
|
||||||
if (s.paused != (value != 0)) { s.paused = (value != 0); changed = true; }
|
if (s.paused != (value != 0)) { s.paused = (value != 0); changed = true; }
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
case Montauk::AUDIO_CTL_SET_MUTE:
|
case montauk::abi::AUDIO_CTL_SET_MUTE:
|
||||||
if (s.muted != (value != 0)) { s.muted = (value != 0); changed = true; }
|
if (s.muted != (value != 0)) { s.muted = (value != 0); changed = true; }
|
||||||
rv = 0;
|
rv = 0;
|
||||||
break;
|
break;
|
||||||
case Montauk::AUDIO_CTL_GET_MUTE:
|
case montauk::abi::AUDIO_CTL_GET_MUTE:
|
||||||
rv = s.muted ? 1 : 0;
|
rv = s.muted ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -491,7 +491,7 @@ namespace Drivers::Audio::Mixer {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int List(Montauk::AudioStreamInfo* buf, int maxCount) {
|
int List(montauk::abi::AudioStreamInfo* buf, int maxCount) {
|
||||||
if (!buf || maxCount <= 0) return 0;
|
if (!buf || maxCount <= 0) return 0;
|
||||||
g_lock.Acquire();
|
g_lock.Acquire();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Drivers::Audio::Mixer {
|
|||||||
int Control(int handle, int cmd, int value);
|
int Control(int handle, int cmd, int value);
|
||||||
|
|
||||||
// Enumerate all currently-active streams.
|
// Enumerate all currently-active streams.
|
||||||
int List(Montauk::AudioStreamInfo* buf, int maxCount);
|
int List(montauk::abi::AudioStreamInfo* buf, int maxCount);
|
||||||
|
|
||||||
// Close every stream owned by `pid`. Called from the scheduler on process
|
// Close every stream owned by `pid`. Called from the scheduler on process
|
||||||
// exit / kill so leaked handles do not occupy mixer slots.
|
// exit / kill so leaked handles do not occupy mixer slots.
|
||||||
|
|||||||
+18
-18
@@ -808,7 +808,7 @@ namespace Ipc {
|
|||||||
|
|
||||||
int StreamReadHandle(int handle, uint8_t* out, int maxLen) {
|
int StreamReadHandle(int handle, uint8_t* out, int maxLen) {
|
||||||
if (out == nullptr) return -1;
|
if (out == nullptr) return -1;
|
||||||
if (maxLen > 0 && !Montauk::UserMemory::Range((uint64_t)out, (uint64_t)maxLen, true)) return -1;
|
if (maxLen > 0 && !montauk::abi::UserMemory::Range((uint64_t)out, (uint64_t)maxLen, true)) return -1;
|
||||||
|
|
||||||
HandleType type = HandleType::None;
|
HandleType type = HandleType::None;
|
||||||
Object* object = nullptr;
|
Object* object = nullptr;
|
||||||
@@ -820,7 +820,7 @@ namespace Ipc {
|
|||||||
|
|
||||||
int StreamWriteHandle(int handle, const uint8_t* data, int len) {
|
int StreamWriteHandle(int handle, const uint8_t* data, int len) {
|
||||||
if (data == nullptr) return -1;
|
if (data == nullptr) return -1;
|
||||||
if (len > 0 && !Montauk::UserMemory::Range((uint64_t)data, (uint64_t)len, false)) return -1;
|
if (len > 0 && !montauk::abi::UserMemory::Range((uint64_t)data, (uint64_t)len, false)) return -1;
|
||||||
|
|
||||||
HandleType type = HandleType::None;
|
HandleType type = HandleType::None;
|
||||||
Object* object = nullptr;
|
Object* object = nullptr;
|
||||||
@@ -963,9 +963,9 @@ namespace Ipc {
|
|||||||
|
|
||||||
int MailboxSendCoalescedMouse(Mailbox* mailbox, uint32_t msgType, const void* data, uint16_t len) {
|
int MailboxSendCoalescedMouse(Mailbox* mailbox, uint32_t msgType, const void* data, uint16_t len) {
|
||||||
if (mailbox == nullptr || data == nullptr) return -1;
|
if (mailbox == nullptr || data == nullptr) return -1;
|
||||||
if (len != sizeof(Montauk::WinEvent)) return MailboxSend(mailbox, msgType, data, len);
|
if (len != sizeof(montauk::abi::WinEvent)) return MailboxSend(mailbox, msgType, data, len);
|
||||||
|
|
||||||
const Montauk::WinEvent* incoming = (const Montauk::WinEvent*)data;
|
const montauk::abi::WinEvent* incoming = (const montauk::abi::WinEvent*)data;
|
||||||
if (incoming->type != 1 || incoming->mouse.scroll != 0)
|
if (incoming->type != 1 || incoming->mouse.scroll != 0)
|
||||||
return MailboxSend(mailbox, msgType, data, len);
|
return MailboxSend(mailbox, msgType, data, len);
|
||||||
|
|
||||||
@@ -983,7 +983,7 @@ namespace Ipc {
|
|||||||
uint32_t idx = (mailbox->head + MaxMailboxMessages - 1) % MaxMailboxMessages;
|
uint32_t idx = (mailbox->head + MaxMailboxMessages - 1) % MaxMailboxMessages;
|
||||||
MailboxMessage& latest = mailbox->messages[idx];
|
MailboxMessage& latest = mailbox->messages[idx];
|
||||||
if (latest.type == msgType && latest.size == len && !latest.hasAttachment) {
|
if (latest.type == msgType && latest.size == len && !latest.hasAttachment) {
|
||||||
const Montauk::WinEvent* queued = (const Montauk::WinEvent*)latest.data;
|
const montauk::abi::WinEvent* queued = (const montauk::abi::WinEvent*)latest.data;
|
||||||
bool queuedTransition = queued->type != 1 ||
|
bool queuedTransition = queued->type != 1 ||
|
||||||
queued->mouse.scroll != 0 ||
|
queued->mouse.scroll != 0 ||
|
||||||
queued->mouse.buttons != queued->mouse.prev_buttons;
|
queued->mouse.buttons != queued->mouse.prev_buttons;
|
||||||
@@ -1060,7 +1060,7 @@ namespace Ipc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int MailboxSendHandle(int handle, uint32_t msgType, const void* data, uint16_t len, int attachHandle) {
|
int MailboxSendHandle(int handle, uint32_t msgType, const void* data, uint16_t len, int attachHandle) {
|
||||||
if (len > 0 && (data == nullptr || !Montauk::UserMemory::Range((uint64_t)data, len, false))) return -1;
|
if (len > 0 && (data == nullptr || !montauk::abi::UserMemory::Range((uint64_t)data, len, false))) return -1;
|
||||||
|
|
||||||
HandleType type = HandleType::None;
|
HandleType type = HandleType::None;
|
||||||
Object* object = nullptr;
|
Object* object = nullptr;
|
||||||
@@ -1072,12 +1072,12 @@ namespace Ipc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int MailboxRecvHandle(int handle, uint32_t* msgType, void* data, uint16_t* inOutLen, int* outAttachHandle) {
|
int MailboxRecvHandle(int handle, uint32_t* msgType, void* data, uint16_t* inOutLen, int* outAttachHandle) {
|
||||||
if (inOutLen == nullptr || !Montauk::UserMemory::Writable<uint16_t>((uint64_t)inOutLen)) return -1;
|
if (inOutLen == nullptr || !montauk::abi::UserMemory::Writable<uint16_t>((uint64_t)inOutLen)) return -1;
|
||||||
|
|
||||||
uint16_t requestedLen = *inOutLen;
|
uint16_t requestedLen = *inOutLen;
|
||||||
if (msgType != nullptr && !Montauk::UserMemory::Writable<uint32_t>((uint64_t)msgType)) return -1;
|
if (msgType != nullptr && !montauk::abi::UserMemory::Writable<uint32_t>((uint64_t)msgType)) return -1;
|
||||||
if (requestedLen > 0 && (data == nullptr || !Montauk::UserMemory::Range((uint64_t)data, requestedLen, true))) return -1;
|
if (requestedLen > 0 && (data == nullptr || !montauk::abi::UserMemory::Range((uint64_t)data, requestedLen, true))) return -1;
|
||||||
if (outAttachHandle != nullptr && !Montauk::UserMemory::Writable<int>((uint64_t)outAttachHandle)) return -1;
|
if (outAttachHandle != nullptr && !montauk::abi::UserMemory::Writable<int>((uint64_t)outAttachHandle)) return -1;
|
||||||
|
|
||||||
HandleType type = HandleType::None;
|
HandleType type = HandleType::None;
|
||||||
Object* object = nullptr;
|
Object* object = nullptr;
|
||||||
@@ -1139,7 +1139,7 @@ namespace Ipc {
|
|||||||
|
|
||||||
int FileReadHandle(int handle, uint8_t* buffer, uint64_t offset, uint64_t size) {
|
int FileReadHandle(int handle, uint8_t* buffer, uint64_t offset, uint64_t size) {
|
||||||
if (buffer == nullptr) return -1;
|
if (buffer == nullptr) return -1;
|
||||||
if (size > 0 && !Montauk::UserMemory::Range((uint64_t)buffer, size, true)) return -1;
|
if (size > 0 && !montauk::abi::UserMemory::Range((uint64_t)buffer, size, true)) return -1;
|
||||||
|
|
||||||
HandleType type = HandleType::None;
|
HandleType type = HandleType::None;
|
||||||
Object* object = nullptr;
|
Object* object = nullptr;
|
||||||
@@ -1151,7 +1151,7 @@ namespace Ipc {
|
|||||||
|
|
||||||
int FileWriteHandle(int handle, const uint8_t* buffer, uint64_t offset, uint64_t size) {
|
int FileWriteHandle(int handle, const uint8_t* buffer, uint64_t offset, uint64_t size) {
|
||||||
if (buffer == nullptr) return -1;
|
if (buffer == nullptr) return -1;
|
||||||
if (size > 0 && !Montauk::UserMemory::Range((uint64_t)buffer, size, false)) return -1;
|
if (size > 0 && !montauk::abi::UserMemory::Range((uint64_t)buffer, size, false)) return -1;
|
||||||
|
|
||||||
HandleType type = HandleType::None;
|
HandleType type = HandleType::None;
|
||||||
Object* object = nullptr;
|
Object* object = nullptr;
|
||||||
@@ -1371,7 +1371,7 @@ namespace Ipc {
|
|||||||
|
|
||||||
int SocketSendHandle(int handle, const uint8_t* data, uint32_t len) {
|
int SocketSendHandle(int handle, const uint8_t* data, uint32_t len) {
|
||||||
if (data == nullptr) return -1;
|
if (data == nullptr) return -1;
|
||||||
if (len > 0 && !Montauk::UserMemory::Range((uint64_t)data, len, false)) return -1;
|
if (len > 0 && !montauk::abi::UserMemory::Range((uint64_t)data, len, false)) return -1;
|
||||||
|
|
||||||
Socket* socket = nullptr;
|
Socket* socket = nullptr;
|
||||||
uint32_t rights = 0;
|
uint32_t rights = 0;
|
||||||
@@ -1387,7 +1387,7 @@ namespace Ipc {
|
|||||||
|
|
||||||
int SocketRecvHandle(int handle, uint8_t* buffer, uint32_t maxLen) {
|
int SocketRecvHandle(int handle, uint8_t* buffer, uint32_t maxLen) {
|
||||||
if (buffer == nullptr) return -1;
|
if (buffer == nullptr) return -1;
|
||||||
if (maxLen > 0 && !Montauk::UserMemory::Range((uint64_t)buffer, maxLen, true)) return -1;
|
if (maxLen > 0 && !montauk::abi::UserMemory::Range((uint64_t)buffer, maxLen, true)) return -1;
|
||||||
|
|
||||||
Socket* socket = nullptr;
|
Socket* socket = nullptr;
|
||||||
uint32_t rights = 0;
|
uint32_t rights = 0;
|
||||||
@@ -1406,7 +1406,7 @@ namespace Ipc {
|
|||||||
|
|
||||||
int SocketSendToHandle(int handle, const uint8_t* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
int SocketSendToHandle(int handle, const uint8_t* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
||||||
if (data == nullptr) return -1;
|
if (data == nullptr) return -1;
|
||||||
if (len > 0 && !Montauk::UserMemory::Range((uint64_t)data, len, false)) return -1;
|
if (len > 0 && !montauk::abi::UserMemory::Range((uint64_t)data, len, false)) return -1;
|
||||||
|
|
||||||
Socket* socket = nullptr;
|
Socket* socket = nullptr;
|
||||||
uint32_t rights = 0;
|
uint32_t rights = 0;
|
||||||
@@ -1437,9 +1437,9 @@ namespace Ipc {
|
|||||||
|
|
||||||
int SocketRecvFromHandle(int handle, uint8_t* buffer, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort) {
|
int SocketRecvFromHandle(int handle, uint8_t* buffer, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort) {
|
||||||
if (buffer == nullptr) return -1;
|
if (buffer == nullptr) return -1;
|
||||||
if (maxLen > 0 && !Montauk::UserMemory::Range((uint64_t)buffer, maxLen, true)) return -1;
|
if (maxLen > 0 && !montauk::abi::UserMemory::Range((uint64_t)buffer, maxLen, true)) return -1;
|
||||||
if (srcIp != nullptr && !Montauk::UserMemory::Writable<uint32_t>((uint64_t)srcIp)) return -1;
|
if (srcIp != nullptr && !montauk::abi::UserMemory::Writable<uint32_t>((uint64_t)srcIp)) return -1;
|
||||||
if (srcPort != nullptr && !Montauk::UserMemory::Writable<uint16_t>((uint64_t)srcPort)) return -1;
|
if (srcPort != nullptr && !montauk::abi::UserMemory::Writable<uint16_t>((uint64_t)srcPort)) return -1;
|
||||||
|
|
||||||
Socket* socket = nullptr;
|
Socket* socket = nullptr;
|
||||||
uint32_t rights = 0;
|
uint32_t rights = 0;
|
||||||
|
|||||||
+1
-1
@@ -185,7 +185,7 @@ extern "C" void kmain() {
|
|||||||
Drivers::USB::Bluetooth::ServiceDeferredInit();
|
Drivers::USB::Bluetooth::ServiceDeferredInit();
|
||||||
|
|
||||||
Hal::LoadTSS();
|
Hal::LoadTSS();
|
||||||
Montauk::InitializeSyscalls();
|
montauk::abi::InitializeSyscalls();
|
||||||
|
|
||||||
Sched::Initialize();
|
Sched::Initialize();
|
||||||
Ipc::Initialize();
|
Ipc::Initialize();
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ namespace Memory {
|
|||||||
FreeRange(ptr, (size_t)n * 0x1000);
|
FreeRange(ptr, (size_t)n * 0x1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageFrameAllocator::GetStats(Montauk::MemStats* out) {
|
void PageFrameAllocator::GetStats(montauk::abi::MemStats* out) {
|
||||||
if (!out) return;
|
if (!out) return;
|
||||||
Lock.Acquire();
|
Lock.Acquire();
|
||||||
uint64_t freeBytes = 0;
|
uint64_t freeBytes = 0;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
void Free(void* ptr);
|
void Free(void* ptr);
|
||||||
void Free(void* ptr, int n);
|
void Free(void* ptr, int n);
|
||||||
|
|
||||||
void GetStats(Montauk::MemStats* out);
|
void GetStats(montauk::abi::MemStats* out);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PageFrameAllocator* g_pfa;
|
extern PageFrameAllocator* g_pfa;
|
||||||
|
|||||||
@@ -1089,8 +1089,8 @@ namespace Sched {
|
|||||||
|
|
||||||
// Release process-scoped IPC handles/mappings before tearing down the address space.
|
// Release process-scoped IPC handles/mappings before tearing down the address space.
|
||||||
Ipc::CleanupProcessSlot(slot, exitingPid, proc.pml4Phys);
|
Ipc::CleanupProcessSlot(slot, exitingPid, proc.pml4Phys);
|
||||||
Montauk::CleanupHeapForSlot(slot, proc.pml4Phys);
|
montauk::abi::CleanupHeapForSlot(slot, proc.pml4Phys);
|
||||||
Montauk::CleanupLibTable(slot);
|
montauk::abi::CleanupLibTable(slot);
|
||||||
|
|
||||||
proc.waitingForPid = -1;
|
proc.waitingForPid = -1;
|
||||||
proc.sleepUntilTick = 0;
|
proc.sleepUntilTick = 0;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace Sched {
|
|||||||
uint8_t* inBuf = nullptr; // 4KB ring: parent writes, child reads (getchar)
|
uint8_t* inBuf = nullptr; // 4KB ring: parent writes, child reads (getchar)
|
||||||
volatile uint32_t inHead = 0;
|
volatile uint32_t inHead = 0;
|
||||||
volatile uint32_t inTail = 0;
|
volatile uint32_t inTail = 0;
|
||||||
Montauk::KeyEvent keyBuf[64]; // parent injects, child reads (getkey/iskeyavailable)
|
montauk::abi::KeyEvent keyBuf[64]; // parent injects, child reads (getkey/iskeyavailable)
|
||||||
volatile uint32_t keyHead = 0;
|
volatile uint32_t keyHead = 0;
|
||||||
volatile uint32_t keyTail = 0;
|
volatile uint32_t keyTail = 0;
|
||||||
static constexpr uint32_t IoBufSize = 4096;
|
static constexpr uint32_t IoBufSize = 4096;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Montauk {
|
namespace montauk::abi {
|
||||||
|
|
||||||
// Syscall numbers
|
// Syscall numbers
|
||||||
static constexpr uint64_t SYS_EXIT = 0;
|
static constexpr uint64_t SYS_EXIT = 0;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ struct Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create window
|
// Create window
|
||||||
Montauk::WinCreateResult wres;
|
montauk::abi::WinCreateResult wres;
|
||||||
if (montauk::win_create(title, w, h, &wres) < 0 || wres.id < 0)
|
if (montauk::win_create(title, w, h, &wres) < 0 || wres.id < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ struct Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Poll one window event. Returns true if an event was received.
|
// Poll one window event. Returns true if an event was received.
|
||||||
bool poll(Montauk::WinEvent* ev) {
|
bool poll(montauk::abi::WinEvent* ev) {
|
||||||
int r = montauk::win_poll(win_id, ev);
|
int r = montauk::win_poll(win_id, ev);
|
||||||
if (r < 0) { running = false; return false; }
|
if (r < 0) { running = false; return false; }
|
||||||
if (r == 0) return false;
|
if (r == 0) return false;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ struct InputState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process a window event
|
// Process a window event
|
||||||
void handle_event(const Montauk::WinEvent& ev) {
|
void handle_event(const montauk::abi::WinEvent& ev) {
|
||||||
if (ev.type == 0) { // keyboard
|
if (ev.type == 0) { // keyboard
|
||||||
// PS/2 scan code set 1: release codes have bit 7 set.
|
// PS/2 scan code set 1: release codes have bit 7 set.
|
||||||
// Mask to base scancode so press and release map to the same index.
|
// Mask to base scancode so press and release map to the same index.
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ namespace gui {
|
|||||||
return clipboard_set_text(text, text ? montauk::slen(text) : 0);
|
return clipboard_set_text(text, text ? montauk::slen(text) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool clipboard_get_info(Montauk::ClipboardInfo* out) {
|
inline bool clipboard_get_info(montauk::abi::ClipboardInfo* out) {
|
||||||
if (out == nullptr) return false;
|
if (out == nullptr) return false;
|
||||||
return montauk::clipboard_get_info(out) == 0;
|
return montauk::clipboard_get_info(out) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool clipboard_has_text() {
|
inline bool clipboard_has_text() {
|
||||||
Montauk::ClipboardInfo info = {};
|
montauk::abi::ClipboardInfo info = {};
|
||||||
return clipboard_get_info(&info) && info.textBytes > 0;
|
return clipboard_get_info(&info) && info.textBytes > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ namespace gui {
|
|||||||
if (out_len) *out_len = 0;
|
if (out_len) *out_len = 0;
|
||||||
if (out_serial) *out_serial = 0;
|
if (out_serial) *out_serial = 0;
|
||||||
|
|
||||||
Montauk::ClipboardInfo info = {};
|
montauk::abi::ClipboardInfo info = {};
|
||||||
if (!clipboard_get_info(&info) || info.textBytes == 0)
|
if (!clipboard_get_info(&info) || info.textBytes == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ struct DesktopState {
|
|||||||
char user_config_dir[128]; // "0:/users/<username>/config"
|
char user_config_dir[128]; // "0:/users/<username>/config"
|
||||||
bool is_admin;
|
bool is_admin;
|
||||||
|
|
||||||
Montauk::MouseState mouse;
|
montauk::abi::MouseState mouse;
|
||||||
uint8_t prev_buttons;
|
uint8_t prev_buttons;
|
||||||
|
|
||||||
bool app_menu_open;
|
bool app_menu_open;
|
||||||
@@ -160,7 +160,7 @@ struct DesktopState {
|
|||||||
int ctx_menu_x, ctx_menu_y;
|
int ctx_menu_x, ctx_menu_y;
|
||||||
|
|
||||||
bool net_popup_open;
|
bool net_popup_open;
|
||||||
Montauk::NetCfg cached_net_cfg;
|
montauk::abi::NetCfg cached_net_cfg;
|
||||||
uint64_t net_cfg_last_poll;
|
uint64_t net_cfg_last_poll;
|
||||||
Rect net_icon_rect;
|
Rect net_icon_rect;
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ struct DesktopState {
|
|||||||
|
|
||||||
// Temperature monitoring
|
// Temperature monitoring
|
||||||
static constexpr int MAX_THERMAL_ZONES = 8;
|
static constexpr int MAX_THERMAL_ZONES = 8;
|
||||||
Montauk::ThermalInfo thermal_zones[MAX_THERMAL_ZONES];
|
montauk::abi::ThermalInfo thermal_zones[MAX_THERMAL_ZONES];
|
||||||
int thermal_zone_count;
|
int thermal_zone_count;
|
||||||
uint64_t thermal_last_poll;
|
uint64_t thermal_last_poll;
|
||||||
Rect temp_icon_rect;
|
Rect temp_icon_rect;
|
||||||
@@ -214,6 +214,6 @@ void desktop_raise_window(DesktopState* ds, int idx);
|
|||||||
void desktop_draw_panel(DesktopState* ds);
|
void desktop_draw_panel(DesktopState* ds);
|
||||||
void desktop_draw_window(DesktopState* ds, int idx);
|
void desktop_draw_window(DesktopState* ds, int idx);
|
||||||
void desktop_handle_mouse(DesktopState* ds);
|
void desktop_handle_mouse(DesktopState* ds);
|
||||||
void desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key);
|
void desktop_handle_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key);
|
||||||
|
|
||||||
} // namespace gui
|
} // namespace gui
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class Framebuffer {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Framebuffer() : hw_fb(nullptr), back_buf(nullptr), fb_width(0), fb_height(0), fb_pitch(0) {
|
Framebuffer() : hw_fb(nullptr), back_buf(nullptr), fb_width(0), fb_height(0), fb_pitch(0) {
|
||||||
Montauk::FbInfo info;
|
montauk::abi::FbInfo info;
|
||||||
montauk::fb_info(&info);
|
montauk::fb_info(&info);
|
||||||
|
|
||||||
fb_width = (int)info.width;
|
fb_width = (int)info.width;
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ inline int text_input_handle_mouse(TextInputState& state,
|
|||||||
inline int text_input_key(TextInputState& state,
|
inline int text_input_key(TextInputState& state,
|
||||||
char* text,
|
char* text,
|
||||||
int cap,
|
int cap,
|
||||||
const Montauk::KeyEvent& key,
|
const montauk::abi::KeyEvent& key,
|
||||||
TextInputCharFilter filter = nullptr,
|
TextInputCharFilter filter = nullptr,
|
||||||
void* userdata = nullptr,
|
void* userdata = nullptr,
|
||||||
bool masked = false) {
|
bool masked = false) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ struct WsWindow {
|
|||||||
: id(-1), pixels(nullptr), width(0), height(0), scale_factor(1), closed(false) {}
|
: id(-1), pixels(nullptr), width(0), height(0), scale_factor(1), closed(false) {}
|
||||||
|
|
||||||
bool create(const char* title, int w, int h) {
|
bool create(const char* title, int w, int h) {
|
||||||
Montauk::WinCreateResult wres;
|
montauk::abi::WinCreateResult wres;
|
||||||
if (montauk::win_create(title, w, h, &wres) < 0 || wres.id < 0)
|
if (montauk::win_create(title, w, h, &wres) < 0 || wres.id < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ struct WsWindow {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int poll(Montauk::WinEvent* ev) {
|
int poll(montauk::abi::WinEvent* ev) {
|
||||||
if (id < 0 || closed) return -1;
|
if (id < 0 || closed) return -1;
|
||||||
|
|
||||||
int r = montauk::win_poll(id, ev);
|
int r = montauk::win_poll(id, ev);
|
||||||
|
|||||||
@@ -831,7 +831,7 @@ static inline void terminal_resize(TerminalState* t, int new_cols, int new_rows)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void terminal_handle_key(TerminalState* t, const Montauk::KeyEvent& key) {
|
static inline void terminal_handle_key(TerminalState* t, const montauk::abi::KeyEvent& key) {
|
||||||
// Snap to live on any keyboard input
|
// Snap to live on any keyboard input
|
||||||
if (t->view_offset > 0) {
|
if (t->view_offset > 0) {
|
||||||
t->view_offset = 0;
|
t->view_offset = 0;
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ struct TextBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_key(const Montauk::KeyEvent& key) {
|
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!focused || !key.pressed) return;
|
if (!focused || !key.pressed) return;
|
||||||
|
|
||||||
if (key.ascii == '\b' || key.scancode == 0x0E) {
|
if (key.ascii == '\b' || key.scancode == 0x0E) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ static constexpr int MIN_WINDOW_H = 80;
|
|||||||
struct Window;
|
struct Window;
|
||||||
using WindowDrawCallback = void (*)(Window* win, Framebuffer& fb);
|
using WindowDrawCallback = void (*)(Window* win, Framebuffer& fb);
|
||||||
using WindowMouseCallback = void (*)(Window* win, MouseEvent& ev);
|
using WindowMouseCallback = void (*)(Window* win, MouseEvent& ev);
|
||||||
using WindowKeyCallback = void (*)(Window* win, const Montauk::KeyEvent& key);
|
using WindowKeyCallback = void (*)(Window* win, const montauk::abi::KeyEvent& key);
|
||||||
using WindowCloseCallback = void (*)(Window* win);
|
using WindowCloseCallback = void (*)(Window* win);
|
||||||
using WindowPollCallback = void (*)(Window* win);
|
using WindowPollCallback = void (*)(Window* win);
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ inline Response get_plain(const char* host, const char* path,
|
|||||||
int reqLen = build_request(req, sizeof(req), "GET", host, path,
|
int reqLen = build_request(req, sizeof(req), "GET", host, path,
|
||||||
nullptr, nullptr, 0, extra_headers);
|
nullptr, nullptr, 0, extra_headers);
|
||||||
|
|
||||||
int sock = montauk::socket(Montauk::SOCK_TCP);
|
int sock = montauk::socket(montauk::abi::SOCK_TCP);
|
||||||
if (sock < 0) return resp;
|
if (sock < 0) return resp;
|
||||||
if (montauk::connect(sock, ip, 80) < 0) { montauk::closesocket(sock); return resp; }
|
if (montauk::connect(sock, ip, 80) < 0) { montauk::closesocket(sock); return resp; }
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace heap_detail {
|
|||||||
|
|
||||||
static inline void heap_lock_acquire() {
|
static inline void heap_lock_acquire() {
|
||||||
while (__atomic_exchange_n(&g_heap_lock, 1, __ATOMIC_ACQUIRE) != 0) {
|
while (__atomic_exchange_n(&g_heap_lock, 1, __ATOMIC_ACQUIRE) != 0) {
|
||||||
syscall0(Montauk::SYS_YIELD);
|
syscall0(montauk::abi::SYS_YIELD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline void heap_lock_release() {
|
static inline void heap_lock_release() {
|
||||||
|
|||||||
+170
-170
@@ -110,519 +110,519 @@ namespace montauk {
|
|||||||
|
|
||||||
// Process
|
// Process
|
||||||
[[noreturn]] inline void exit(int code = 0) {
|
[[noreturn]] inline void exit(int code = 0) {
|
||||||
syscall1(Montauk::SYS_EXIT, (uint64_t)code);
|
syscall1(montauk::abi::SYS_EXIT, (uint64_t)code);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void yield() { syscall0(Montauk::SYS_YIELD); }
|
inline void yield() { syscall0(montauk::abi::SYS_YIELD); }
|
||||||
inline void sleep_ms(uint64_t ms) { syscall1(Montauk::SYS_SLEEP_MS, ms); }
|
inline void sleep_ms(uint64_t ms) { syscall1(montauk::abi::SYS_SLEEP_MS, ms); }
|
||||||
inline int getpid() { return (int)syscall0(Montauk::SYS_GETPID); }
|
inline int getpid() { return (int)syscall0(montauk::abi::SYS_GETPID); }
|
||||||
inline int spawn(const char* path, const char* args = nullptr) {
|
inline int spawn(const char* path, const char* args = nullptr) {
|
||||||
return (int)syscall2(Montauk::SYS_SPAWN, (uint64_t)path, (uint64_t)args);
|
return (int)syscall2(montauk::abi::SYS_SPAWN, (uint64_t)path, (uint64_t)args);
|
||||||
}
|
}
|
||||||
inline int chdir(const char* path) {
|
inline int chdir(const char* path) {
|
||||||
return (int)syscall1(Montauk::SYS_CHDIR, (uint64_t)path);
|
return (int)syscall1(montauk::abi::SYS_CHDIR, (uint64_t)path);
|
||||||
}
|
}
|
||||||
inline int getcwd(char* buf, uint64_t maxLen) {
|
inline int getcwd(char* buf, uint64_t maxLen) {
|
||||||
return (int)syscall2(Montauk::SYS_GETCWD, (uint64_t)buf, maxLen);
|
return (int)syscall2(montauk::abi::SYS_GETCWD, (uint64_t)buf, maxLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Console
|
// Console
|
||||||
inline void print(const char* text) { syscall1(Montauk::SYS_PRINT, (uint64_t)text); }
|
inline void print(const char* text) { syscall1(montauk::abi::SYS_PRINT, (uint64_t)text); }
|
||||||
inline void putchar(char c) { syscall1(Montauk::SYS_PUTCHAR, (uint64_t)c); }
|
inline void putchar(char c) { syscall1(montauk::abi::SYS_PUTCHAR, (uint64_t)c); }
|
||||||
|
|
||||||
// File I/O
|
// File I/O
|
||||||
inline int open(const char* path) { return (int)syscall1(Montauk::SYS_OPEN, (uint64_t)path); }
|
inline int open(const char* path) { return (int)syscall1(montauk::abi::SYS_OPEN, (uint64_t)path); }
|
||||||
inline int read(int handle, uint8_t* buf, uint64_t off, uint64_t size) {
|
inline int read(int handle, uint8_t* buf, uint64_t off, uint64_t size) {
|
||||||
return (int)syscall4(Montauk::SYS_READ, (uint64_t)handle, (uint64_t)buf, off, size);
|
return (int)syscall4(montauk::abi::SYS_READ, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||||
}
|
}
|
||||||
inline uint64_t getsize(int handle) { return (uint64_t)syscall1(Montauk::SYS_GETSIZE, (uint64_t)handle); }
|
inline uint64_t getsize(int handle) { return (uint64_t)syscall1(montauk::abi::SYS_GETSIZE, (uint64_t)handle); }
|
||||||
inline void close(int handle) { syscall1(Montauk::SYS_CLOSE, (uint64_t)handle); }
|
inline void close(int handle) { syscall1(montauk::abi::SYS_CLOSE, (uint64_t)handle); }
|
||||||
inline int readdir(const char* path, const char** names, int max) {
|
inline int readdir(const char* path, const char** names, int max) {
|
||||||
return (int)syscall3(Montauk::SYS_READDIR, (uint64_t)path, (uint64_t)names, (uint64_t)max);
|
return (int)syscall3(montauk::abi::SYS_READDIR, (uint64_t)path, (uint64_t)names, (uint64_t)max);
|
||||||
}
|
}
|
||||||
// Paginated directory read: returns entries [startIndex, startIndex+max).
|
// Paginated directory read: returns entries [startIndex, startIndex+max).
|
||||||
// Call repeatedly with increasing startIndex (advancing by the returned
|
// Call repeatedly with increasing startIndex (advancing by the returned
|
||||||
// count) until it returns 0 to enumerate directories of any size.
|
// count) until it returns 0 to enumerate directories of any size.
|
||||||
inline int readdir_at(const char* path, const char** names, int max, int startIndex) {
|
inline int readdir_at(const char* path, const char** names, int max, int startIndex) {
|
||||||
return (int)syscall4(Montauk::SYS_READDIR_AT, (uint64_t)path, (uint64_t)names,
|
return (int)syscall4(montauk::abi::SYS_READDIR_AT, (uint64_t)path, (uint64_t)names,
|
||||||
(uint64_t)max, (uint64_t)startIndex);
|
(uint64_t)max, (uint64_t)startIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// File write/create
|
// File write/create
|
||||||
inline int fwrite(int handle, const uint8_t* buf, uint64_t off, uint64_t size) {
|
inline int fwrite(int handle, const uint8_t* buf, uint64_t off, uint64_t size) {
|
||||||
return (int)syscall4(Montauk::SYS_FWRITE, (uint64_t)handle, (uint64_t)buf, off, size);
|
return (int)syscall4(montauk::abi::SYS_FWRITE, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||||
}
|
}
|
||||||
inline int fcreate(const char* path) {
|
inline int fcreate(const char* path) {
|
||||||
return (int)syscall1(Montauk::SYS_FCREATE, (uint64_t)path);
|
return (int)syscall1(montauk::abi::SYS_FCREATE, (uint64_t)path);
|
||||||
}
|
}
|
||||||
inline int fdelete(const char* path) {
|
inline int fdelete(const char* path) {
|
||||||
return (int)syscall1(Montauk::SYS_FDELETE, (uint64_t)path);
|
return (int)syscall1(montauk::abi::SYS_FDELETE, (uint64_t)path);
|
||||||
}
|
}
|
||||||
inline int fmkdir(const char* path) {
|
inline int fmkdir(const char* path) {
|
||||||
return (int)syscall1(Montauk::SYS_FMKDIR, (uint64_t)path);
|
return (int)syscall1(montauk::abi::SYS_FMKDIR, (uint64_t)path);
|
||||||
}
|
}
|
||||||
inline int frename(const char* oldPath, const char* newPath) {
|
inline int frename(const char* oldPath, const char* newPath) {
|
||||||
return (int)syscall2(Montauk::SYS_FRENAME, (uint64_t)oldPath, (uint64_t)newPath);
|
return (int)syscall2(montauk::abi::SYS_FRENAME, (uint64_t)oldPath, (uint64_t)newPath);
|
||||||
}
|
}
|
||||||
inline int drivelist(int* outDrives, int max) {
|
inline int drivelist(int* outDrives, int max) {
|
||||||
return (int)syscall2(Montauk::SYS_DRIVELIST, (uint64_t)outDrives, (uint64_t)max);
|
return (int)syscall2(montauk::abi::SYS_DRIVELIST, (uint64_t)outDrives, (uint64_t)max);
|
||||||
}
|
}
|
||||||
inline int drivelabel(int drive, char* outLabel, int maxLen) {
|
inline int drivelabel(int drive, char* outLabel, int maxLen) {
|
||||||
return (int)syscall3(Montauk::SYS_DRIVELABEL, (uint64_t)drive, (uint64_t)outLabel, (uint64_t)maxLen);
|
return (int)syscall3(montauk::abi::SYS_DRIVELABEL, (uint64_t)drive, (uint64_t)outLabel, (uint64_t)maxLen);
|
||||||
}
|
}
|
||||||
// Returns the kernel BlockDeviceKind backing the drive: 0=unknown/ramdisk,
|
// Returns the kernel BlockDeviceKind backing the drive: 0=unknown/ramdisk,
|
||||||
// 1=SATA, 2=SATAPI, 3=NVMe, 4=USB MSC.
|
// 1=SATA, 2=SATAPI, 3=NVMe, 4=USB MSC.
|
||||||
inline int drivekind(int drive) {
|
inline int drivekind(int drive) {
|
||||||
return (int)syscall1(Montauk::SYS_DRIVEKIND, (uint64_t)drive);
|
return (int)syscall1(montauk::abi::SYS_DRIVEKIND, (uint64_t)drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
inline void* alloc(uint64_t size) { return (void*)syscall1(Montauk::SYS_ALLOC, size); }
|
inline void* alloc(uint64_t size) { return (void*)syscall1(montauk::abi::SYS_ALLOC, size); }
|
||||||
inline void free(void* ptr) { syscall1(Montauk::SYS_FREE, (uint64_t)ptr); }
|
inline void free(void* ptr) { syscall1(montauk::abi::SYS_FREE, (uint64_t)ptr); }
|
||||||
|
|
||||||
// Timekeeping
|
// Timekeeping
|
||||||
inline uint64_t get_ticks() { return (uint64_t)syscall0(Montauk::SYS_GETTICKS); }
|
inline uint64_t get_ticks() { return (uint64_t)syscall0(montauk::abi::SYS_GETTICKS); }
|
||||||
inline uint64_t get_milliseconds() { return (uint64_t)syscall0(Montauk::SYS_GETMILLISECONDS); }
|
inline uint64_t get_milliseconds() { return (uint64_t)syscall0(montauk::abi::SYS_GETMILLISECONDS); }
|
||||||
|
|
||||||
// System
|
// System
|
||||||
inline void get_info(Montauk::SysInfo* info) { syscall1(Montauk::SYS_GETINFO, (uint64_t)info); }
|
inline void get_info(montauk::abi::SysInfo* info) { syscall1(montauk::abi::SYS_GETINFO, (uint64_t)info); }
|
||||||
|
|
||||||
// Keyboard
|
// Keyboard
|
||||||
inline bool is_key_available() { return (bool)syscall0(Montauk::SYS_ISKEYAVAILABLE); }
|
inline bool is_key_available() { return (bool)syscall0(montauk::abi::SYS_ISKEYAVAILABLE); }
|
||||||
inline void getkey(Montauk::KeyEvent* out) { syscall1(Montauk::SYS_GETKEY, (uint64_t)out); }
|
inline void getkey(montauk::abi::KeyEvent* out) { syscall1(montauk::abi::SYS_GETKEY, (uint64_t)out); }
|
||||||
inline char getchar() { return (char)syscall0(Montauk::SYS_GETCHAR); }
|
inline char getchar() { return (char)syscall0(montauk::abi::SYS_GETCHAR); }
|
||||||
inline uint64_t input_wait(uint64_t observedSerial, uint64_t timeoutMs) {
|
inline uint64_t input_wait(uint64_t observedSerial, uint64_t timeoutMs) {
|
||||||
return (uint64_t)syscall2(Montauk::SYS_INPUT_WAIT, observedSerial, timeoutMs);
|
return (uint64_t)syscall2(montauk::abi::SYS_INPUT_WAIT, observedSerial, timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Networking
|
// Networking
|
||||||
inline int32_t ping(uint32_t ip, uint32_t timeoutMs = 3000) {
|
inline int32_t ping(uint32_t ip, uint32_t timeoutMs = 3000) {
|
||||||
return (int32_t)syscall2(Montauk::SYS_PING, (uint64_t)ip, (uint64_t)timeoutMs);
|
return (int32_t)syscall2(montauk::abi::SYS_PING, (uint64_t)ip, (uint64_t)timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNS resolve: returns IP in network byte order, or 0 on failure
|
// DNS resolve: returns IP in network byte order, or 0 on failure
|
||||||
inline uint32_t resolve(const char* hostname) {
|
inline uint32_t resolve(const char* hostname) {
|
||||||
return (uint32_t)syscall1(Montauk::SYS_RESOLVE, (uint64_t)hostname);
|
return (uint32_t)syscall1(montauk::abi::SYS_RESOLVE, (uint64_t)hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network configuration
|
// Network configuration
|
||||||
inline void get_netcfg(Montauk::NetCfg* out) { syscall1(Montauk::SYS_GETNETCFG, (uint64_t)out); }
|
inline void get_netcfg(montauk::abi::NetCfg* out) { syscall1(montauk::abi::SYS_GETNETCFG, (uint64_t)out); }
|
||||||
inline int set_netcfg(const Montauk::NetCfg* cfg) { return (int)syscall1(Montauk::SYS_SETNETCFG, (uint64_t)cfg); }
|
inline int set_netcfg(const montauk::abi::NetCfg* cfg) { return (int)syscall1(montauk::abi::SYS_SETNETCFG, (uint64_t)cfg); }
|
||||||
inline int net_status(Montauk::NetStatus* out) { return (int)syscall1(Montauk::SYS_NETSTATUS, (uint64_t)out); }
|
inline int net_status(montauk::abi::NetStatus* out) { return (int)syscall1(montauk::abi::SYS_NETSTATUS, (uint64_t)out); }
|
||||||
|
|
||||||
// Sockets
|
// Sockets
|
||||||
inline int socket(int type) {
|
inline int socket(int type) {
|
||||||
return (int)syscall1(Montauk::SYS_SOCKET, (uint64_t)type);
|
return (int)syscall1(montauk::abi::SYS_SOCKET, (uint64_t)type);
|
||||||
}
|
}
|
||||||
inline int connect(int fd, uint32_t ip, uint16_t port) {
|
inline int connect(int fd, uint32_t ip, uint16_t port) {
|
||||||
return (int)syscall3(Montauk::SYS_CONNECT, (uint64_t)fd, (uint64_t)ip, (uint64_t)port);
|
return (int)syscall3(montauk::abi::SYS_CONNECT, (uint64_t)fd, (uint64_t)ip, (uint64_t)port);
|
||||||
}
|
}
|
||||||
inline int bind(int fd, uint16_t port) {
|
inline int bind(int fd, uint16_t port) {
|
||||||
return (int)syscall2(Montauk::SYS_BIND, (uint64_t)fd, (uint64_t)port);
|
return (int)syscall2(montauk::abi::SYS_BIND, (uint64_t)fd, (uint64_t)port);
|
||||||
}
|
}
|
||||||
inline int listen(int fd) {
|
inline int listen(int fd) {
|
||||||
return (int)syscall1(Montauk::SYS_LISTEN, (uint64_t)fd);
|
return (int)syscall1(montauk::abi::SYS_LISTEN, (uint64_t)fd);
|
||||||
}
|
}
|
||||||
inline int accept(int fd) {
|
inline int accept(int fd) {
|
||||||
return (int)syscall1(Montauk::SYS_ACCEPT, (uint64_t)fd);
|
return (int)syscall1(montauk::abi::SYS_ACCEPT, (uint64_t)fd);
|
||||||
}
|
}
|
||||||
inline int send(int fd, const void* data, uint32_t len) {
|
inline int send(int fd, const void* data, uint32_t len) {
|
||||||
return (int)syscall3(Montauk::SYS_SEND, (uint64_t)fd, (uint64_t)data, (uint64_t)len);
|
return (int)syscall3(montauk::abi::SYS_SEND, (uint64_t)fd, (uint64_t)data, (uint64_t)len);
|
||||||
}
|
}
|
||||||
inline int recv(int fd, void* buf, uint32_t maxLen) {
|
inline int recv(int fd, void* buf, uint32_t maxLen) {
|
||||||
return (int)syscall3(Montauk::SYS_RECV, (uint64_t)fd, (uint64_t)buf, (uint64_t)maxLen);
|
return (int)syscall3(montauk::abi::SYS_RECV, (uint64_t)fd, (uint64_t)buf, (uint64_t)maxLen);
|
||||||
}
|
}
|
||||||
inline int closesocket(int fd) {
|
inline int closesocket(int fd) {
|
||||||
return (int)syscall1(Montauk::SYS_CLOSESOCK, (uint64_t)fd);
|
return (int)syscall1(montauk::abi::SYS_CLOSESOCK, (uint64_t)fd);
|
||||||
}
|
}
|
||||||
inline int sendto(int fd, const void* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
inline int sendto(int fd, const void* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
||||||
return (int)syscall5(Montauk::SYS_SENDTO, (uint64_t)fd, (uint64_t)data,
|
return (int)syscall5(montauk::abi::SYS_SENDTO, (uint64_t)fd, (uint64_t)data,
|
||||||
(uint64_t)len, (uint64_t)destIp, (uint64_t)destPort);
|
(uint64_t)len, (uint64_t)destIp, (uint64_t)destPort);
|
||||||
}
|
}
|
||||||
inline int recvfrom(int fd, void* buf, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort) {
|
inline int recvfrom(int fd, void* buf, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort) {
|
||||||
return (int)syscall5(Montauk::SYS_RECVFROM, (uint64_t)fd, (uint64_t)buf,
|
return (int)syscall5(montauk::abi::SYS_RECVFROM, (uint64_t)fd, (uint64_t)buf,
|
||||||
(uint64_t)maxLen, (uint64_t)srcIp, (uint64_t)srcPort);
|
(uint64_t)maxLen, (uint64_t)srcIp, (uint64_t)srcPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic IPC
|
// Generic IPC
|
||||||
inline int dup_handle(int handle) {
|
inline int dup_handle(int handle) {
|
||||||
return (int)syscall1(Montauk::SYS_DUPHANDLE, (uint64_t)handle);
|
return (int)syscall1(montauk::abi::SYS_DUPHANDLE, (uint64_t)handle);
|
||||||
}
|
}
|
||||||
inline uint32_t wait_handle(int handle, uint32_t wantedSignals, uint64_t timeoutMs = ~0ULL) {
|
inline uint32_t wait_handle(int handle, uint32_t wantedSignals, uint64_t timeoutMs = ~0ULL) {
|
||||||
return (uint32_t)syscall3(Montauk::SYS_WAIT_HANDLE, (uint64_t)handle,
|
return (uint32_t)syscall3(montauk::abi::SYS_WAIT_HANDLE, (uint64_t)handle,
|
||||||
(uint64_t)wantedSignals, timeoutMs);
|
(uint64_t)wantedSignals, timeoutMs);
|
||||||
}
|
}
|
||||||
inline int stream_create(int* outReadHandle, int* outWriteHandle, uint32_t capacity = 0) {
|
inline int stream_create(int* outReadHandle, int* outWriteHandle, uint32_t capacity = 0) {
|
||||||
return (int)syscall3(Montauk::SYS_STREAM_CREATE, (uint64_t)outReadHandle,
|
return (int)syscall3(montauk::abi::SYS_STREAM_CREATE, (uint64_t)outReadHandle,
|
||||||
(uint64_t)outWriteHandle, (uint64_t)capacity);
|
(uint64_t)outWriteHandle, (uint64_t)capacity);
|
||||||
}
|
}
|
||||||
inline int stream_read(int handle, void* buf, int maxLen) {
|
inline int stream_read(int handle, void* buf, int maxLen) {
|
||||||
return (int)syscall3(Montauk::SYS_STREAM_READ, (uint64_t)handle, (uint64_t)buf, (uint64_t)maxLen);
|
return (int)syscall3(montauk::abi::SYS_STREAM_READ, (uint64_t)handle, (uint64_t)buf, (uint64_t)maxLen);
|
||||||
}
|
}
|
||||||
inline int stream_write(int handle, const void* data, int len) {
|
inline int stream_write(int handle, const void* data, int len) {
|
||||||
return (int)syscall3(Montauk::SYS_STREAM_WRITE, (uint64_t)handle, (uint64_t)data, (uint64_t)len);
|
return (int)syscall3(montauk::abi::SYS_STREAM_WRITE, (uint64_t)handle, (uint64_t)data, (uint64_t)len);
|
||||||
}
|
}
|
||||||
inline int mailbox_create(int* outSendHandle, int* outRecvHandle) {
|
inline int mailbox_create(int* outSendHandle, int* outRecvHandle) {
|
||||||
return (int)syscall2(Montauk::SYS_MAILBOX_CREATE, (uint64_t)outSendHandle, (uint64_t)outRecvHandle);
|
return (int)syscall2(montauk::abi::SYS_MAILBOX_CREATE, (uint64_t)outSendHandle, (uint64_t)outRecvHandle);
|
||||||
}
|
}
|
||||||
inline int mailbox_send(int handle, uint32_t msgType, const void* data, uint16_t len, int attachHandle = -1) {
|
inline int mailbox_send(int handle, uint32_t msgType, const void* data, uint16_t len, int attachHandle = -1) {
|
||||||
return (int)syscall5(Montauk::SYS_MAILBOX_SEND, (uint64_t)handle, (uint64_t)msgType,
|
return (int)syscall5(montauk::abi::SYS_MAILBOX_SEND, (uint64_t)handle, (uint64_t)msgType,
|
||||||
(uint64_t)data, (uint64_t)len, (uint64_t)(int64_t)attachHandle);
|
(uint64_t)data, (uint64_t)len, (uint64_t)(int64_t)attachHandle);
|
||||||
}
|
}
|
||||||
inline int mailbox_recv(int handle, uint32_t* outMsgType, void* data,
|
inline int mailbox_recv(int handle, uint32_t* outMsgType, void* data,
|
||||||
uint16_t* inOutLen, int* outAttachHandle = nullptr) {
|
uint16_t* inOutLen, int* outAttachHandle = nullptr) {
|
||||||
return (int)syscall5(Montauk::SYS_MAILBOX_RECV, (uint64_t)handle, (uint64_t)outMsgType,
|
return (int)syscall5(montauk::abi::SYS_MAILBOX_RECV, (uint64_t)handle, (uint64_t)outMsgType,
|
||||||
(uint64_t)data, (uint64_t)inOutLen, (uint64_t)outAttachHandle);
|
(uint64_t)data, (uint64_t)inOutLen, (uint64_t)outAttachHandle);
|
||||||
}
|
}
|
||||||
inline int waitset_create() {
|
inline int waitset_create() {
|
||||||
return (int)syscall0(Montauk::SYS_WAITSET_CREATE);
|
return (int)syscall0(montauk::abi::SYS_WAITSET_CREATE);
|
||||||
}
|
}
|
||||||
inline int waitset_add(int waitsetHandle, int targetHandle, uint32_t signals) {
|
inline int waitset_add(int waitsetHandle, int targetHandle, uint32_t signals) {
|
||||||
return (int)syscall3(Montauk::SYS_WAITSET_ADD, (uint64_t)waitsetHandle,
|
return (int)syscall3(montauk::abi::SYS_WAITSET_ADD, (uint64_t)waitsetHandle,
|
||||||
(uint64_t)targetHandle, (uint64_t)signals);
|
(uint64_t)targetHandle, (uint64_t)signals);
|
||||||
}
|
}
|
||||||
inline int waitset_remove(int waitsetHandle, int index) {
|
inline int waitset_remove(int waitsetHandle, int index) {
|
||||||
return (int)syscall2(Montauk::SYS_WAITSET_REMOVE, (uint64_t)waitsetHandle, (uint64_t)index);
|
return (int)syscall2(montauk::abi::SYS_WAITSET_REMOVE, (uint64_t)waitsetHandle, (uint64_t)index);
|
||||||
}
|
}
|
||||||
inline int waitset_wait(int waitsetHandle, Montauk::IpcWaitResult* outReady, uint64_t timeoutMs = ~0ULL) {
|
inline int waitset_wait(int waitsetHandle, montauk::abi::IpcWaitResult* outReady, uint64_t timeoutMs = ~0ULL) {
|
||||||
return (int)syscall3(Montauk::SYS_WAITSET_WAIT, (uint64_t)waitsetHandle, (uint64_t)outReady, timeoutMs);
|
return (int)syscall3(montauk::abi::SYS_WAITSET_WAIT, (uint64_t)waitsetHandle, (uint64_t)outReady, timeoutMs);
|
||||||
}
|
}
|
||||||
inline int proc_open(int pid) {
|
inline int proc_open(int pid) {
|
||||||
return (int)syscall1(Montauk::SYS_PROC_OPEN, (uint64_t)pid);
|
return (int)syscall1(montauk::abi::SYS_PROC_OPEN, (uint64_t)pid);
|
||||||
}
|
}
|
||||||
inline int surface_create(uint64_t byteSize) {
|
inline int surface_create(uint64_t byteSize) {
|
||||||
return (int)syscall1(Montauk::SYS_SURFACE_CREATE, byteSize);
|
return (int)syscall1(montauk::abi::SYS_SURFACE_CREATE, byteSize);
|
||||||
}
|
}
|
||||||
inline void* surface_map(int handle) {
|
inline void* surface_map(int handle) {
|
||||||
return (void*)syscall1(Montauk::SYS_SURFACE_MAP, (uint64_t)handle);
|
return (void*)syscall1(montauk::abi::SYS_SURFACE_MAP, (uint64_t)handle);
|
||||||
}
|
}
|
||||||
inline int surface_resize(int handle, uint64_t newSize) {
|
inline int surface_resize(int handle, uint64_t newSize) {
|
||||||
return (int)syscall2(Montauk::SYS_SURFACE_RESIZE, (uint64_t)handle, newSize);
|
return (int)syscall2(montauk::abi::SYS_SURFACE_RESIZE, (uint64_t)handle, newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shared library support
|
// Shared library support
|
||||||
inline int load_lib(const char* path) {
|
inline int load_lib(const char* path) {
|
||||||
return (int)syscall1(Montauk::SYS_LOAD_LIB, (uint64_t)path);
|
return (int)syscall1(montauk::abi::SYS_LOAD_LIB, (uint64_t)path);
|
||||||
}
|
}
|
||||||
inline int unload_lib(int handle) {
|
inline int unload_lib(int handle) {
|
||||||
return (int)syscall1(Montauk::SYS_UNLOAD_LIB, (uint64_t)handle);
|
return (int)syscall1(montauk::abi::SYS_UNLOAD_LIB, (uint64_t)handle);
|
||||||
}
|
}
|
||||||
inline void* dlsym(int handle, uint64_t symbolOffset) {
|
inline void* dlsym(int handle, uint64_t symbolOffset) {
|
||||||
return (void*)syscall2(Montauk::SYS_DLSYM, (uint64_t)handle, symbolOffset);
|
return (void*)syscall2(montauk::abi::SYS_DLSYM, (uint64_t)handle, symbolOffset);
|
||||||
}
|
}
|
||||||
inline uint64_t get_libbase(int handle) {
|
inline uint64_t get_libbase(int handle) {
|
||||||
return (uint64_t)syscall1(Montauk::SYS_GETLIBBASE, (uint64_t)handle);
|
return (uint64_t)syscall1(montauk::abi::SYS_GETLIBBASE, (uint64_t)handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crash report retrieval
|
// Crash report retrieval
|
||||||
inline int crash_report(Montauk::CrashReportInfo* out) {
|
inline int crash_report(montauk::abi::CrashReportInfo* out) {
|
||||||
return (int)syscall1(Montauk::SYS_CRASH_REPORT, (uint64_t)out);
|
return (int)syscall1(montauk::abi::SYS_CRASH_REPORT, (uint64_t)out);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process management
|
// Process management
|
||||||
inline void waitpid(int pid) { syscall1(Montauk::SYS_WAITPID, (uint64_t)pid); }
|
inline void waitpid(int pid) { syscall1(montauk::abi::SYS_WAITPID, (uint64_t)pid); }
|
||||||
|
|
||||||
// Framebuffer
|
// Framebuffer
|
||||||
inline void fb_info(Montauk::FbInfo* info) { syscall1(Montauk::SYS_FBINFO, (uint64_t)info); }
|
inline void fb_info(montauk::abi::FbInfo* info) { syscall1(montauk::abi::SYS_FBINFO, (uint64_t)info); }
|
||||||
inline void* fb_map() { return (void*)syscall0(Montauk::SYS_FBMAP); }
|
inline void* fb_map() { return (void*)syscall0(montauk::abi::SYS_FBMAP); }
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
inline int getargs(char* buf, uint64_t maxLen) {
|
inline int getargs(char* buf, uint64_t maxLen) {
|
||||||
return (int)syscall2(Montauk::SYS_GETARGS, (uint64_t)buf, maxLen);
|
return (int)syscall2(montauk::abi::SYS_GETARGS, (uint64_t)buf, maxLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terminal
|
// Terminal
|
||||||
inline void termsize(int* cols, int* rows) {
|
inline void termsize(int* cols, int* rows) {
|
||||||
uint64_t r = (uint64_t)syscall0(Montauk::SYS_TERMSIZE);
|
uint64_t r = (uint64_t)syscall0(montauk::abi::SYS_TERMSIZE);
|
||||||
if (cols) *cols = (int)(r & 0xFFFFFFFF);
|
if (cols) *cols = (int)(r & 0xFFFFFFFF);
|
||||||
if (rows) *rows = (int)(r >> 32);
|
if (rows) *rows = (int)(r >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void termscale(int scale_x, int scale_y) {
|
inline void termscale(int scale_x, int scale_y) {
|
||||||
syscall2(Montauk::SYS_TERMSCALE, (uint64_t)scale_x, (uint64_t)scale_y);
|
syscall2(montauk::abi::SYS_TERMSCALE, (uint64_t)scale_x, (uint64_t)scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void get_termscale(int* scale_x, int* scale_y) {
|
inline void get_termscale(int* scale_x, int* scale_y) {
|
||||||
uint64_t r = (uint64_t)syscall2(Montauk::SYS_TERMSCALE, 0, 0);
|
uint64_t r = (uint64_t)syscall2(montauk::abi::SYS_TERMSCALE, 0, 0);
|
||||||
if (scale_x) *scale_x = (int)(r & 0xFFFFFFFF);
|
if (scale_x) *scale_x = (int)(r & 0xFFFFFFFF);
|
||||||
if (scale_y) *scale_y = (int)(r >> 32);
|
if (scale_y) *scale_y = (int)(r >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timekeeping (wall-clock)
|
// Timekeeping (wall-clock)
|
||||||
inline void gettime(Montauk::DateTime* out) { syscall1(Montauk::SYS_GETTIME, (uint64_t)out); }
|
inline void gettime(montauk::abi::DateTime* out) { syscall1(montauk::abi::SYS_GETTIME, (uint64_t)out); }
|
||||||
|
|
||||||
// Timezone offset (total minutes from UTC)
|
// Timezone offset (total minutes from UTC)
|
||||||
inline void settz(int offset_minutes) { syscall1(Montauk::SYS_SETTZ, (uint64_t)(int64_t)offset_minutes); }
|
inline void settz(int offset_minutes) { syscall1(montauk::abi::SYS_SETTZ, (uint64_t)(int64_t)offset_minutes); }
|
||||||
inline int gettz() { return (int)syscall0(Montauk::SYS_GETTZ); }
|
inline int gettz() { return (int)syscall0(montauk::abi::SYS_GETTZ); }
|
||||||
|
|
||||||
// Random number generation
|
// Random number generation
|
||||||
inline int64_t getrandom(void* buf, uint32_t len) {
|
inline int64_t getrandom(void* buf, uint32_t len) {
|
||||||
return syscall2(Montauk::SYS_GETRANDOM, (uint64_t)buf, (uint64_t)len);
|
return syscall2(montauk::abi::SYS_GETRANDOM, (uint64_t)buf, (uint64_t)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Power management
|
// Power management
|
||||||
[[noreturn]] inline void reset() {
|
[[noreturn]] inline void reset() {
|
||||||
syscall0(Montauk::SYS_RESET);
|
syscall0(montauk::abi::SYS_RESET);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]] inline void shutdown() {
|
[[noreturn]] inline void shutdown() {
|
||||||
syscall0(Montauk::SYS_SHUTDOWN);
|
syscall0(montauk::abi::SYS_SHUTDOWN);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int suspend() {
|
inline int suspend() {
|
||||||
return (int)syscall0(Montauk::SYS_SUSPEND);
|
return (int)syscall0(montauk::abi::SYS_SUSPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Graceful power-off request channel. The desktop posts a pending action
|
// Graceful power-off request channel. The desktop posts a pending action
|
||||||
// (Montauk::POWER_REQ_SHUTDOWN / POWER_REQ_REBOOT) then exits; login.elf
|
// (montauk::abi::POWER_REQ_SHUTDOWN / POWER_REQ_REBOOT) then exits; login.elf
|
||||||
// reads it with POWER_REQ_QUERY (read-and-clear), runs the shutdown stages,
|
// reads it with POWER_REQ_QUERY (read-and-clear), runs the shutdown stages,
|
||||||
// and finally calls shutdown()/reset(). Returns the pending action for a
|
// and finally calls shutdown()/reset(). Returns the pending action for a
|
||||||
// query, or 0 when posting one.
|
// query, or 0 when posting one.
|
||||||
inline int power_request(int action) {
|
inline int power_request(int action) {
|
||||||
return (int)syscall1(Montauk::SYS_POWER_REQUEST, (uint64_t)(int64_t)action);
|
return (int)syscall1(montauk::abi::SYS_POWER_REQUEST, (uint64_t)(int64_t)action);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mouse
|
// Mouse
|
||||||
inline void mouse_state(Montauk::MouseState* out) { syscall1(Montauk::SYS_MOUSESTATE, (uint64_t)out); }
|
inline void mouse_state(montauk::abi::MouseState* out) { syscall1(montauk::abi::SYS_MOUSESTATE, (uint64_t)out); }
|
||||||
inline void set_mouse_bounds(int32_t maxX, int32_t maxY) {
|
inline void set_mouse_bounds(int32_t maxX, int32_t maxY) {
|
||||||
syscall2(Montauk::SYS_SETMOUSEBOUNDS, (uint64_t)maxX, (uint64_t)maxY);
|
syscall2(montauk::abi::SYS_SETMOUSEBOUNDS, (uint64_t)maxX, (uint64_t)maxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kernel log
|
// Kernel log
|
||||||
inline int64_t read_klog(char* buf, uint64_t size) {
|
inline int64_t read_klog(char* buf, uint64_t size) {
|
||||||
return syscall2(Montauk::SYS_KLOG, (uint64_t)buf, size);
|
return syscall2(montauk::abi::SYS_KLOG, (uint64_t)buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I/O redirection
|
// I/O redirection
|
||||||
inline int spawn_redir(const char* path, const char* args = nullptr) {
|
inline int spawn_redir(const char* path, const char* args = nullptr) {
|
||||||
return (int)syscall2(Montauk::SYS_SPAWN_REDIR, (uint64_t)path, (uint64_t)args);
|
return (int)syscall2(montauk::abi::SYS_SPAWN_REDIR, (uint64_t)path, (uint64_t)args);
|
||||||
}
|
}
|
||||||
inline int childio_read(int childPid, char* buf, int maxLen) {
|
inline int childio_read(int childPid, char* buf, int maxLen) {
|
||||||
return (int)syscall3(Montauk::SYS_CHILDIO_READ, (uint64_t)childPid, (uint64_t)buf, (uint64_t)maxLen);
|
return (int)syscall3(montauk::abi::SYS_CHILDIO_READ, (uint64_t)childPid, (uint64_t)buf, (uint64_t)maxLen);
|
||||||
}
|
}
|
||||||
inline int childio_write(int childPid, const char* data, int len) {
|
inline int childio_write(int childPid, const char* data, int len) {
|
||||||
return (int)syscall3(Montauk::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
return (int)syscall3(montauk::abi::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
||||||
}
|
}
|
||||||
inline int childio_writekey(int childPid, const Montauk::KeyEvent* key) {
|
inline int childio_writekey(int childPid, const montauk::abi::KeyEvent* key) {
|
||||||
return (int)syscall2(Montauk::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
return (int)syscall2(montauk::abi::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
||||||
}
|
}
|
||||||
inline int childio_settermsz(int childPid, int cols, int rows) {
|
inline int childio_settermsz(int childPid, int cols, int rows) {
|
||||||
return (int)syscall3(Montauk::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
return (int)syscall3(montauk::abi::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process listing / kill
|
// Process listing / kill
|
||||||
inline int proclist(Montauk::ProcInfo* buf, int max) {
|
inline int proclist(montauk::abi::ProcInfo* buf, int max) {
|
||||||
return (int)syscall2(Montauk::SYS_PROCLIST, (uint64_t)buf, (uint64_t)max);
|
return (int)syscall2(montauk::abi::SYS_PROCLIST, (uint64_t)buf, (uint64_t)max);
|
||||||
}
|
}
|
||||||
inline int kill(int pid) {
|
inline int kill(int pid) {
|
||||||
return (int)syscall1(Montauk::SYS_KILL, (uint64_t)pid);
|
return (int)syscall1(montauk::abi::SYS_KILL, (uint64_t)pid);
|
||||||
}
|
}
|
||||||
inline int devlist(Montauk::DevInfo* buf, int max) {
|
inline int devlist(montauk::abi::DevInfo* buf, int max) {
|
||||||
return (int)syscall2(Montauk::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
|
return (int)syscall2(montauk::abi::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
|
||||||
}
|
}
|
||||||
inline int diskinfo(Montauk::DiskInfo* buf, int port) {
|
inline int diskinfo(montauk::abi::DiskInfo* buf, int port) {
|
||||||
return (int)syscall2(Montauk::SYS_DISKINFO, (uint64_t)buf, (uint64_t)port);
|
return (int)syscall2(montauk::abi::SYS_DISKINFO, (uint64_t)buf, (uint64_t)port);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Partition table
|
// Partition table
|
||||||
inline int partlist(Montauk::PartInfo* buf, int max) {
|
inline int partlist(montauk::abi::PartInfo* buf, int max) {
|
||||||
return (int)syscall2(Montauk::SYS_PARTLIST, (uint64_t)buf, (uint64_t)max);
|
return (int)syscall2(montauk::abi::SYS_PARTLIST, (uint64_t)buf, (uint64_t)max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw block device I/O (driver-agnostic)
|
// Raw block device I/O (driver-agnostic)
|
||||||
inline int64_t disk_read(int blockDev, uint64_t lba, uint32_t sectorCount, void* buf) {
|
inline int64_t disk_read(int blockDev, uint64_t lba, uint32_t sectorCount, void* buf) {
|
||||||
return syscall4(Montauk::SYS_DISKREAD, (uint64_t)blockDev, lba,
|
return syscall4(montauk::abi::SYS_DISKREAD, (uint64_t)blockDev, lba,
|
||||||
(uint64_t)sectorCount, (uint64_t)buf);
|
(uint64_t)sectorCount, (uint64_t)buf);
|
||||||
}
|
}
|
||||||
inline int64_t disk_write(int blockDev, uint64_t lba, uint32_t sectorCount, const void* buf) {
|
inline int64_t disk_write(int blockDev, uint64_t lba, uint32_t sectorCount, const void* buf) {
|
||||||
return syscall4(Montauk::SYS_DISKWRITE, (uint64_t)blockDev, lba,
|
return syscall4(montauk::abi::SYS_DISKWRITE, (uint64_t)blockDev, lba,
|
||||||
(uint64_t)sectorCount, (uint64_t)buf);
|
(uint64_t)sectorCount, (uint64_t)buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPT management
|
// GPT management
|
||||||
inline int gpt_init(int blockDev) {
|
inline int gpt_init(int blockDev) {
|
||||||
return (int)syscall1(Montauk::SYS_GPTINIT, (uint64_t)blockDev);
|
return (int)syscall1(montauk::abi::SYS_GPTINIT, (uint64_t)blockDev);
|
||||||
}
|
}
|
||||||
inline int gpt_add(const Montauk::GptAddParams* params) {
|
inline int gpt_add(const montauk::abi::GptAddParams* params) {
|
||||||
return (int)syscall1(Montauk::SYS_GPTADD, (uint64_t)params);
|
return (int)syscall1(montauk::abi::SYS_GPTADD, (uint64_t)params);
|
||||||
}
|
}
|
||||||
inline int fs_mount(int partIndex, int driveNum) {
|
inline int fs_mount(int partIndex, int driveNum) {
|
||||||
return (int)syscall2(Montauk::SYS_FSMOUNT, (uint64_t)partIndex, (uint64_t)driveNum);
|
return (int)syscall2(montauk::abi::SYS_FSMOUNT, (uint64_t)partIndex, (uint64_t)driveNum);
|
||||||
}
|
}
|
||||||
// Flush all block-device write caches and cleanly unmount disk-backed
|
// Flush all block-device write caches and cleanly unmount disk-backed
|
||||||
// volumes ahead of power-off. Returns the number of volumes unmounted.
|
// volumes ahead of power-off. Returns the number of volumes unmounted.
|
||||||
inline int fs_sync() {
|
inline int fs_sync() {
|
||||||
return (int)syscall0(Montauk::SYS_FS_SYNC);
|
return (int)syscall0(montauk::abi::SYS_FS_SYNC);
|
||||||
}
|
}
|
||||||
inline int fs_format(const Montauk::FsFormatParams* params) {
|
inline int fs_format(const montauk::abi::FsFormatParams* params) {
|
||||||
return (int)syscall1(Montauk::SYS_FSFORMAT, (uint64_t)params);
|
return (int)syscall1(montauk::abi::SYS_FSFORMAT, (uint64_t)params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
inline int audio_open(uint32_t sampleRate, uint8_t channels, uint8_t bitsPerSample) {
|
inline int audio_open(uint32_t sampleRate, uint8_t channels, uint8_t bitsPerSample) {
|
||||||
return (int)syscall3(Montauk::SYS_AUDIOOPEN, (uint64_t)sampleRate,
|
return (int)syscall3(montauk::abi::SYS_AUDIOOPEN, (uint64_t)sampleRate,
|
||||||
(uint64_t)channels, (uint64_t)bitsPerSample);
|
(uint64_t)channels, (uint64_t)bitsPerSample);
|
||||||
}
|
}
|
||||||
inline void audio_close(int handle) {
|
inline void audio_close(int handle) {
|
||||||
syscall1(Montauk::SYS_AUDIOCLOSE, (uint64_t)handle);
|
syscall1(montauk::abi::SYS_AUDIOCLOSE, (uint64_t)handle);
|
||||||
}
|
}
|
||||||
inline int audio_write(int handle, const void* data, uint32_t size) {
|
inline int audio_write(int handle, const void* data, uint32_t size) {
|
||||||
return (int)syscall3(Montauk::SYS_AUDIOWRITE, (uint64_t)handle,
|
return (int)syscall3(montauk::abi::SYS_AUDIOWRITE, (uint64_t)handle,
|
||||||
(uint64_t)data, (uint64_t)size);
|
(uint64_t)data, (uint64_t)size);
|
||||||
}
|
}
|
||||||
inline int audio_ctl(int handle, int cmd, int value) {
|
inline int audio_ctl(int handle, int cmd, int value) {
|
||||||
return (int)syscall3(Montauk::SYS_AUDIOCTL, (uint64_t)handle,
|
return (int)syscall3(montauk::abi::SYS_AUDIOCTL, (uint64_t)handle,
|
||||||
(uint64_t)cmd, (uint64_t)value);
|
(uint64_t)cmd, (uint64_t)value);
|
||||||
}
|
}
|
||||||
inline int audio_set_volume(int handle, int percent) {
|
inline int audio_set_volume(int handle, int percent) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_SET_VOLUME, percent);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_SET_VOLUME, percent);
|
||||||
}
|
}
|
||||||
inline int audio_get_volume(int handle) {
|
inline int audio_get_volume(int handle) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_VOLUME, 0);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_VOLUME, 0);
|
||||||
}
|
}
|
||||||
inline int audio_get_pos(int handle) {
|
inline int audio_get_pos(int handle) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_POS, 0);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_POS, 0);
|
||||||
}
|
}
|
||||||
inline int audio_pause(int handle) {
|
inline int audio_pause(int handle) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_PAUSE, 1);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_PAUSE, 1);
|
||||||
}
|
}
|
||||||
inline int audio_resume(int handle) {
|
inline int audio_resume(int handle) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_PAUSE, 0);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_PAUSE, 0);
|
||||||
}
|
}
|
||||||
inline int audio_get_output(int handle) {
|
inline int audio_get_output(int handle) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_OUTPUT, 0);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_OUTPUT, 0);
|
||||||
}
|
}
|
||||||
inline int audio_bt_status(int handle) {
|
inline int audio_bt_status(int handle) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_BT_STATUS, 0);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_BT_STATUS, 0);
|
||||||
}
|
}
|
||||||
inline int audio_set_master_volume(int percent) {
|
inline int audio_set_master_volume(int percent) {
|
||||||
return audio_ctl(-1, Montauk::AUDIO_CTL_SET_MASTER_VOLUME, percent);
|
return audio_ctl(-1, montauk::abi::AUDIO_CTL_SET_MASTER_VOLUME, percent);
|
||||||
}
|
}
|
||||||
inline int audio_get_master_volume() {
|
inline int audio_get_master_volume() {
|
||||||
return audio_ctl(-1, Montauk::AUDIO_CTL_GET_MASTER_VOLUME, 0);
|
return audio_ctl(-1, montauk::abi::AUDIO_CTL_GET_MASTER_VOLUME, 0);
|
||||||
}
|
}
|
||||||
inline int audio_set_master_mute(bool muted) {
|
inline int audio_set_master_mute(bool muted) {
|
||||||
return audio_ctl(-1, Montauk::AUDIO_CTL_SET_MASTER_MUTE, muted ? 1 : 0);
|
return audio_ctl(-1, montauk::abi::AUDIO_CTL_SET_MASTER_MUTE, muted ? 1 : 0);
|
||||||
}
|
}
|
||||||
inline int audio_get_master_mute() {
|
inline int audio_get_master_mute() {
|
||||||
return audio_ctl(-1, Montauk::AUDIO_CTL_GET_MASTER_MUTE, 0);
|
return audio_ctl(-1, montauk::abi::AUDIO_CTL_GET_MASTER_MUTE, 0);
|
||||||
}
|
}
|
||||||
inline int audio_set_mute(int handle, bool muted) {
|
inline int audio_set_mute(int handle, bool muted) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_SET_MUTE, muted ? 1 : 0);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_SET_MUTE, muted ? 1 : 0);
|
||||||
}
|
}
|
||||||
inline int audio_get_mute(int handle) {
|
inline int audio_get_mute(int handle) {
|
||||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_MUTE, 0);
|
return audio_ctl(handle, montauk::abi::AUDIO_CTL_GET_MUTE, 0);
|
||||||
}
|
}
|
||||||
inline int audio_list(Montauk::AudioStreamInfo* buf, int maxCount) {
|
inline int audio_list(montauk::abi::AudioStreamInfo* buf, int maxCount) {
|
||||||
return (int)syscall2(Montauk::SYS_AUDIOLIST, (uint64_t)buf, (uint64_t)maxCount);
|
return (int)syscall2(montauk::abi::SYS_AUDIOLIST, (uint64_t)buf, (uint64_t)maxCount);
|
||||||
}
|
}
|
||||||
// Returns the current mixer state serial. With timeoutMs > 0 the call
|
// Returns the current mixer state serial. With timeoutMs > 0 the call
|
||||||
// blocks until the serial differs from `prevSerial` or the timeout
|
// blocks until the serial differs from `prevSerial` or the timeout
|
||||||
// elapses. With timeoutMs == 0 it returns immediately (cheap snapshot).
|
// elapses. With timeoutMs == 0 it returns immediately (cheap snapshot).
|
||||||
inline uint64_t audio_wait(uint64_t prevSerial, uint64_t timeoutMs) {
|
inline uint64_t audio_wait(uint64_t prevSerial, uint64_t timeoutMs) {
|
||||||
return syscall2(Montauk::SYS_AUDIOWAIT, prevSerial, timeoutMs);
|
return syscall2(montauk::abi::SYS_AUDIOWAIT, prevSerial, timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bluetooth
|
// Bluetooth
|
||||||
inline int bt_scan(Montauk::BtScanResult* buf, int maxCount, uint32_t timeoutMs) {
|
inline int bt_scan(montauk::abi::BtScanResult* buf, int maxCount, uint32_t timeoutMs) {
|
||||||
return (int)syscall3(Montauk::SYS_BTSCAN, (uint64_t)buf, (uint64_t)maxCount, (uint64_t)timeoutMs);
|
return (int)syscall3(montauk::abi::SYS_BTSCAN, (uint64_t)buf, (uint64_t)maxCount, (uint64_t)timeoutMs);
|
||||||
}
|
}
|
||||||
inline int bt_connect(const uint8_t* bdAddr) {
|
inline int bt_connect(const uint8_t* bdAddr) {
|
||||||
return (int)syscall1(Montauk::SYS_BTCONNECT, (uint64_t)bdAddr);
|
return (int)syscall1(montauk::abi::SYS_BTCONNECT, (uint64_t)bdAddr);
|
||||||
}
|
}
|
||||||
inline int bt_disconnect(const uint8_t* bdAddr) {
|
inline int bt_disconnect(const uint8_t* bdAddr) {
|
||||||
return (int)syscall1(Montauk::SYS_BTDISCONNECT, (uint64_t)bdAddr);
|
return (int)syscall1(montauk::abi::SYS_BTDISCONNECT, (uint64_t)bdAddr);
|
||||||
}
|
}
|
||||||
// Change the adapter's BD_ADDR. bdAddr is a 6-byte buffer with bdAddr[0] as
|
// Change the adapter's BD_ADDR. bdAddr is a 6-byte buffer with bdAddr[0] as
|
||||||
// the least-significant octet (same order as BtAdapterInfo::bdAddr). Returns
|
// the least-significant octet (same order as BtAdapterInfo::bdAddr). Returns
|
||||||
// 0 on success, negative on failure. Persist separately to bluetooth.toml.
|
// 0 on success, negative on failure. Persist separately to bluetooth.toml.
|
||||||
inline int bt_set_addr(const uint8_t* bdAddr) {
|
inline int bt_set_addr(const uint8_t* bdAddr) {
|
||||||
return (int)syscall1(Montauk::SYS_BTSETADDR, (uint64_t)bdAddr);
|
return (int)syscall1(montauk::abi::SYS_BTSETADDR, (uint64_t)bdAddr);
|
||||||
}
|
}
|
||||||
// List bonded (paired) devices. Returns count written to buf (may be 0).
|
// List bonded (paired) devices. Returns count written to buf (may be 0).
|
||||||
inline int bt_bonds(Montauk::BtBondInfo* buf, int maxCount) {
|
inline int bt_bonds(montauk::abi::BtBondInfo* buf, int maxCount) {
|
||||||
return (int)syscall2(Montauk::SYS_BTBONDS, (uint64_t)buf, (uint64_t)maxCount);
|
return (int)syscall2(montauk::abi::SYS_BTBONDS, (uint64_t)buf, (uint64_t)maxCount);
|
||||||
}
|
}
|
||||||
// Forget a paired device (removes the bond; it must re-pair next time).
|
// Forget a paired device (removes the bond; it must re-pair next time).
|
||||||
inline int bt_forget(const uint8_t* bdAddr) {
|
inline int bt_forget(const uint8_t* bdAddr) {
|
||||||
return (int)syscall1(Montauk::SYS_BTFORGET, (uint64_t)bdAddr);
|
return (int)syscall1(montauk::abi::SYS_BTFORGET, (uint64_t)bdAddr);
|
||||||
}
|
}
|
||||||
inline int bt_list(Montauk::BtDevInfo* buf, int maxCount) {
|
inline int bt_list(montauk::abi::BtDevInfo* buf, int maxCount) {
|
||||||
return (int)syscall2(Montauk::SYS_BTLIST, (uint64_t)buf, (uint64_t)maxCount);
|
return (int)syscall2(montauk::abi::SYS_BTLIST, (uint64_t)buf, (uint64_t)maxCount);
|
||||||
}
|
}
|
||||||
inline int bt_info(Montauk::BtAdapterInfo* buf) {
|
inline int bt_info(montauk::abi::BtAdapterInfo* buf) {
|
||||||
return (int)syscall1(Montauk::SYS_BTINFO, (uint64_t)buf);
|
return (int)syscall1(montauk::abi::SYS_BTINFO, (uint64_t)buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kernel introspection
|
// Kernel introspection
|
||||||
inline void memstats(Montauk::MemStats* out) { syscall1(Montauk::SYS_MEMSTATS, (uint64_t)out); }
|
inline void memstats(montauk::abi::MemStats* out) { syscall1(montauk::abi::SYS_MEMSTATS, (uint64_t)out); }
|
||||||
|
|
||||||
// User management
|
// User management
|
||||||
inline int setuser(int pid, const char* name) {
|
inline int setuser(int pid, const char* name) {
|
||||||
return (int)syscall2(Montauk::SYS_SETUSER, (uint64_t)pid, (uint64_t)name);
|
return (int)syscall2(montauk::abi::SYS_SETUSER, (uint64_t)pid, (uint64_t)name);
|
||||||
}
|
}
|
||||||
inline int getuser(char* buf, uint64_t maxLen) {
|
inline int getuser(char* buf, uint64_t maxLen) {
|
||||||
return (int)syscall2(Montauk::SYS_GETUSER, (uint64_t)buf, maxLen);
|
return (int)syscall2(montauk::abi::SYS_GETUSER, (uint64_t)buf, maxLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clipboard
|
// Clipboard
|
||||||
inline int clipboard_set_text(const char* data, uint32_t len) {
|
inline int clipboard_set_text(const char* data, uint32_t len) {
|
||||||
return (int)syscall2(Montauk::SYS_CLIPBOARD_SET_TEXT, (uint64_t)data, (uint64_t)len);
|
return (int)syscall2(montauk::abi::SYS_CLIPBOARD_SET_TEXT, (uint64_t)data, (uint64_t)len);
|
||||||
}
|
}
|
||||||
inline int clipboard_get_info(Montauk::ClipboardInfo* out) {
|
inline int clipboard_get_info(montauk::abi::ClipboardInfo* out) {
|
||||||
return (int)syscall1(Montauk::SYS_CLIPBOARD_GET_INFO, (uint64_t)out);
|
return (int)syscall1(montauk::abi::SYS_CLIPBOARD_GET_INFO, (uint64_t)out);
|
||||||
}
|
}
|
||||||
inline int clipboard_get_text(char* buf, uint32_t bufLen, uint32_t* outLen,
|
inline int clipboard_get_text(char* buf, uint32_t bufLen, uint32_t* outLen,
|
||||||
uint64_t* outSerial = nullptr) {
|
uint64_t* outSerial = nullptr) {
|
||||||
return (int)syscall4(Montauk::SYS_CLIPBOARD_GET_TEXT, (uint64_t)buf, (uint64_t)bufLen,
|
return (int)syscall4(montauk::abi::SYS_CLIPBOARD_GET_TEXT, (uint64_t)buf, (uint64_t)bufLen,
|
||||||
(uint64_t)outLen, (uint64_t)outSerial);
|
(uint64_t)outLen, (uint64_t)outSerial);
|
||||||
}
|
}
|
||||||
inline int clipboard_clear() {
|
inline int clipboard_clear() {
|
||||||
return (int)syscall0(Montauk::SYS_CLIPBOARD_CLEAR);
|
return (int)syscall0(montauk::abi::SYS_CLIPBOARD_CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window server
|
// Window server
|
||||||
inline int win_create(const char* title, int w, int h, Montauk::WinCreateResult* result) {
|
inline int win_create(const char* title, int w, int h, montauk::abi::WinCreateResult* result) {
|
||||||
return (int)syscall4(Montauk::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
return (int)syscall4(montauk::abi::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
||||||
}
|
}
|
||||||
inline int win_destroy(int id) {
|
inline int win_destroy(int id) {
|
||||||
return (int)syscall1(Montauk::SYS_WINDESTROY, (uint64_t)id);
|
return (int)syscall1(montauk::abi::SYS_WINDESTROY, (uint64_t)id);
|
||||||
}
|
}
|
||||||
inline uint64_t win_present(int id) {
|
inline uint64_t win_present(int id) {
|
||||||
return (uint64_t)syscall1(Montauk::SYS_WINPRESENT, (uint64_t)id);
|
return (uint64_t)syscall1(montauk::abi::SYS_WINPRESENT, (uint64_t)id);
|
||||||
}
|
}
|
||||||
inline int win_poll(int id, Montauk::WinEvent* event) {
|
inline int win_poll(int id, montauk::abi::WinEvent* event) {
|
||||||
return (int)syscall2(Montauk::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
|
return (int)syscall2(montauk::abi::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
|
||||||
}
|
}
|
||||||
inline int win_enumerate(Montauk::WinInfo* info, int max) {
|
inline int win_enumerate(montauk::abi::WinInfo* info, int max) {
|
||||||
return (int)syscall2(Montauk::SYS_WINENUM, (uint64_t)info, (uint64_t)max);
|
return (int)syscall2(montauk::abi::SYS_WINENUM, (uint64_t)info, (uint64_t)max);
|
||||||
}
|
}
|
||||||
inline uint64_t win_map(int id) {
|
inline uint64_t win_map(int id) {
|
||||||
return (uint64_t)syscall1(Montauk::SYS_WINMAP, (uint64_t)id);
|
return (uint64_t)syscall1(montauk::abi::SYS_WINMAP, (uint64_t)id);
|
||||||
}
|
}
|
||||||
inline int win_unmap(int id) {
|
inline int win_unmap(int id) {
|
||||||
return (int)syscall1(Montauk::SYS_WINUNMAP, (uint64_t)id);
|
return (int)syscall1(montauk::abi::SYS_WINUNMAP, (uint64_t)id);
|
||||||
}
|
}
|
||||||
inline int win_sendevent(int id, const Montauk::WinEvent* event) {
|
inline int win_sendevent(int id, const montauk::abi::WinEvent* event) {
|
||||||
return (int)syscall2(Montauk::SYS_WINSENDEVENT, (uint64_t)id, (uint64_t)event);
|
return (int)syscall2(montauk::abi::SYS_WINSENDEVENT, (uint64_t)id, (uint64_t)event);
|
||||||
}
|
}
|
||||||
inline uint64_t win_resize(int id, int w, int h) {
|
inline uint64_t win_resize(int id, int w, int h) {
|
||||||
return (uint64_t)syscall3(Montauk::SYS_WINRESIZE, (uint64_t)id, (uint64_t)w, (uint64_t)h);
|
return (uint64_t)syscall3(montauk::abi::SYS_WINRESIZE, (uint64_t)id, (uint64_t)w, (uint64_t)h);
|
||||||
}
|
}
|
||||||
inline int win_setscale(int scale) {
|
inline int win_setscale(int scale) {
|
||||||
return (int)syscall1(Montauk::SYS_WINSETSCALE, (uint64_t)scale);
|
return (int)syscall1(montauk::abi::SYS_WINSETSCALE, (uint64_t)scale);
|
||||||
}
|
}
|
||||||
inline int win_getscale() {
|
inline int win_getscale() {
|
||||||
return (int)syscall0(Montauk::SYS_WINGETSCALE);
|
return (int)syscall0(montauk::abi::SYS_WINGETSCALE);
|
||||||
}
|
}
|
||||||
inline int win_setcursor(int id, int cursor) {
|
inline int win_setcursor(int id, int cursor) {
|
||||||
return (int)syscall2(Montauk::SYS_WINSETCURSOR, (uint64_t)id, (uint64_t)cursor);
|
return (int)syscall2(montauk::abi::SYS_WINSETCURSOR, (uint64_t)id, (uint64_t)cursor);
|
||||||
}
|
}
|
||||||
inline int win_setflags(int id, uint32_t flags) {
|
inline int win_setflags(int id, uint32_t flags) {
|
||||||
return (int)syscall2(Montauk::SYS_WINSETFLAGS, (uint64_t)id, (uint64_t)flags);
|
return (int)syscall2(montauk::abi::SYS_WINSETFLAGS, (uint64_t)id, (uint64_t)flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace montauk {
|
|||||||
// Terminate the calling thread. Never returns. If called by the main
|
// Terminate the calling thread. Never returns. If called by the main
|
||||||
// thread this is equivalent to exit() (the whole process exits).
|
// thread this is equivalent to exit() (the whole process exits).
|
||||||
[[noreturn]] inline void thread_exit(int code = 0) {
|
[[noreturn]] inline void thread_exit(int code = 0) {
|
||||||
syscall1(Montauk::SYS_THREAD_EXIT, (uint64_t)code);
|
syscall1(montauk::abi::SYS_THREAD_EXIT, (uint64_t)code);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ namespace montauk {
|
|||||||
ctx->stack_base = stack;
|
ctx->stack_base = stack;
|
||||||
|
|
||||||
uint64_t stack_top = ((uint64_t)stack + stack_bytes) & ~0xFULL;
|
uint64_t stack_top = ((uint64_t)stack + stack_bytes) & ~0xFULL;
|
||||||
int tid = (int)syscall3(Montauk::SYS_THREAD_SPAWN,
|
int tid = (int)syscall3(montauk::abi::SYS_THREAD_SPAWN,
|
||||||
(uint64_t)&detail::thread_trampoline,
|
(uint64_t)&detail::thread_trampoline,
|
||||||
(uint64_t)ctx, stack_top);
|
(uint64_t)ctx, stack_top);
|
||||||
if (tid < 0) {
|
if (tid < 0) {
|
||||||
@@ -101,13 +101,13 @@ namespace montauk {
|
|||||||
// success (with the thread's exit code in *out_code if non-null) or
|
// success (with the thread's exit code in *out_code if non-null) or
|
||||||
// -1 if `tid` is not a joinable sibling.
|
// -1 if `tid` is not a joinable sibling.
|
||||||
inline int thread_join(int tid, int* out_code = nullptr) {
|
inline int thread_join(int tid, int* out_code = nullptr) {
|
||||||
return (int)syscall2(Montauk::SYS_THREAD_JOIN,
|
return (int)syscall2(montauk::abi::SYS_THREAD_JOIN,
|
||||||
(uint64_t)tid, (uint64_t)out_code);
|
(uint64_t)tid, (uint64_t)out_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the calling thread's TID (== getpid() for the main thread).
|
// Return the calling thread's TID (== getpid() for the main thread).
|
||||||
inline int thread_self() {
|
inline int thread_self() {
|
||||||
return (int)syscall0(Montauk::SYS_THREAD_SELF);
|
return (int)syscall0(montauk::abi::SYS_THREAD_SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lightweight mutex backed by a single atomic word + the kernel
|
// Lightweight mutex backed by a single atomic word + the kernel
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ inline void parse_key_value_lines(char* text, Fn fn) {
|
|||||||
|
|
||||||
inline void now_string(char* out, int out_len) {
|
inline void now_string(char* out, int out_len) {
|
||||||
if (out == nullptr || out_len <= 0) return;
|
if (out == nullptr || out_len <= 0) return;
|
||||||
Montauk::DateTime dt = {};
|
montauk::abi::DateTime dt = {};
|
||||||
montauk::gettime(&dt);
|
montauk::gettime(&dt);
|
||||||
snprintf(out, (size_t)out_len, "%04d-%02d-%02d %02d:%02d:%02d",
|
snprintf(out, (size_t)out_len, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||||
(int)dt.Year, (int)dt.Month, (int)dt.Day,
|
(int)dt.Year, (int)dt.Month, (int)dt.Day,
|
||||||
@@ -1010,11 +1010,11 @@ inline bool daemon_is_running(int* out_pid) {
|
|||||||
|
|
||||||
int handle = montauk::proc_open(pid);
|
int handle = montauk::proc_open(pid);
|
||||||
if (handle < 0) return false;
|
if (handle < 0) return false;
|
||||||
uint32_t sig = montauk::wait_handle(handle, Montauk::IPC_SIGNAL_EXITED, 0);
|
uint32_t sig = montauk::wait_handle(handle, montauk::abi::IPC_SIGNAL_EXITED, 0);
|
||||||
montauk::close(handle);
|
montauk::close(handle);
|
||||||
if (sig & Montauk::IPC_SIGNAL_EXITED) return false;
|
if (sig & montauk::abi::IPC_SIGNAL_EXITED) return false;
|
||||||
|
|
||||||
Montauk::ProcInfo procs[128];
|
montauk::abi::ProcInfo procs[128];
|
||||||
int proc_count = montauk::proclist(procs, (int)(sizeof(procs) / sizeof(procs[0])));
|
int proc_count = montauk::proclist(procs, (int)(sizeof(procs) / sizeof(procs[0])));
|
||||||
bool matched = false;
|
bool matched = false;
|
||||||
for (int i = 0; i < proc_count; i++) {
|
for (int i = 0; i < proc_count; i++) {
|
||||||
@@ -1289,9 +1289,9 @@ inline int send_all_plain(int fd, const uint8_t* data, int len) {
|
|||||||
if (n < 0) return -1;
|
if (n < 0) return -1;
|
||||||
|
|
||||||
uint32_t sig = montauk::wait_handle(fd,
|
uint32_t sig = montauk::wait_handle(fd,
|
||||||
Montauk::IPC_SIGNAL_WRITABLE | Montauk::IPC_SIGNAL_PEER_CLOSED,
|
montauk::abi::IPC_SIGNAL_WRITABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED,
|
||||||
1000);
|
1000);
|
||||||
if (sig & Montauk::IPC_SIGNAL_PEER_CLOSED) return -1;
|
if (sig & montauk::abi::IPC_SIGNAL_PEER_CLOSED) return -1;
|
||||||
if (montauk::get_milliseconds() >= deadline) return -1;
|
if (montauk::get_milliseconds() >= deadline) return -1;
|
||||||
montauk::sleep_ms(1);
|
montauk::sleep_ms(1);
|
||||||
}
|
}
|
||||||
@@ -1379,13 +1379,13 @@ inline int recv_http_plain(int fd, char* buf, int cap) {
|
|||||||
if (montauk::get_milliseconds() >= deadline) break;
|
if (montauk::get_milliseconds() >= deadline) break;
|
||||||
|
|
||||||
uint32_t sig = montauk::wait_handle(fd,
|
uint32_t sig = montauk::wait_handle(fd,
|
||||||
Montauk::IPC_SIGNAL_READABLE | Montauk::IPC_SIGNAL_PEER_CLOSED,
|
montauk::abi::IPC_SIGNAL_READABLE | montauk::abi::IPC_SIGNAL_PEER_CLOSED,
|
||||||
1000);
|
1000);
|
||||||
if (sig == 0) continue;
|
if (sig == 0) continue;
|
||||||
|
|
||||||
if (sig & Montauk::IPC_SIGNAL_PEER_CLOSED)
|
if (sig & montauk::abi::IPC_SIGNAL_PEER_CLOSED)
|
||||||
peer_closed = true;
|
peer_closed = true;
|
||||||
if (!(sig & Montauk::IPC_SIGNAL_READABLE)) {
|
if (!(sig & montauk::abi::IPC_SIGNAL_READABLE)) {
|
||||||
if (peer_closed) break;
|
if (peer_closed) break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1525,7 +1525,7 @@ inline bool ipp_http_post(const IppUri* uri,
|
|||||||
tas, raw, HTTP_RESPONSE_MAX - 1);
|
tas, raw, HTTP_RESPONSE_MAX - 1);
|
||||||
if (tas.anchors) free(tas.anchors);
|
if (tas.anchors) free(tas.anchors);
|
||||||
} else {
|
} else {
|
||||||
int fd = montauk::socket(Montauk::SOCK_TCP);
|
int fd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
free(raw);
|
free(raw);
|
||||||
free(req);
|
free(req);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -147,7 +147,7 @@ TrustAnchors load_trust_anchors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void get_bearssl_time(uint32_t* days, uint32_t* seconds) {
|
void get_bearssl_time(uint32_t* days, uint32_t* seconds) {
|
||||||
Montauk::DateTime dt;
|
montauk::abi::DateTime dt;
|
||||||
montauk::gettime(&dt);
|
montauk::gettime(&dt);
|
||||||
int y = dt.Year, m = dt.Month, d = dt.Day;
|
int y = dt.Year, m = dt.Month, d = dt.Day;
|
||||||
uint32_t total = 365u * (uint32_t)y
|
uint32_t total = 365u * (uint32_t)y
|
||||||
@@ -244,7 +244,7 @@ int https_fetch(const char* host, uint32_t ip, uint16_t port,
|
|||||||
const TrustAnchors& tas,
|
const TrustAnchors& tas,
|
||||||
char* respBuf, int respMax,
|
char* respBuf, int respMax,
|
||||||
AbortCheckFn abort_check) {
|
AbortCheckFn abort_check) {
|
||||||
int fd = montauk::socket(Montauk::SOCK_TCP);
|
int fd = montauk::socket(montauk::abi::SOCK_TCP);
|
||||||
if (fd < 0) return -1;
|
if (fd < 0) return -1;
|
||||||
if (montauk::connect(fd, ip, port) < 0) { montauk::closesocket(fd); return -1; }
|
if (montauk::connect(fd, ip, port) < 0) { montauk::closesocket(fd); return -1; }
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ extern "C" int hello_run() {
|
|||||||
static constexpr int kInitialWidth = 320;
|
static constexpr int kInitialWidth = 320;
|
||||||
static constexpr int kInitialHeight = 200;
|
static constexpr int kInitialHeight = 200;
|
||||||
static constexpr uint32_t kBackgroundColor = 0xFFFFFFFF;
|
static constexpr uint32_t kBackgroundColor = 0xFFFFFFFF;
|
||||||
Montauk::WinCreateResult wres;
|
montauk::abi::WinCreateResult wres;
|
||||||
if (montauk::win_create("libhello Demo", kInitialWidth, kInitialHeight, &wres) < 0 || wres.id < 0) {
|
if (montauk::win_create("libhello Demo", kInitialWidth, kInitialHeight, &wres) < 0 || wres.id < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ extern "C" int hello_run() {
|
|||||||
|
|
||||||
// Event loop
|
// Event loop
|
||||||
while (true) {
|
while (true) {
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
int r = montauk::win_poll(winId, &ev);
|
int r = montauk::win_poll(winId, &ev);
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@
|
|||||||
fb_info, fb_map - direct framebuffer access
|
fb_info, fb_map - direct framebuffer access
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.BI void montauk::fb_info(Montauk::FbInfo* info);
|
.BI void montauk::fb_info(montauk::abi::FbInfo* info);
|
||||||
.BI void* montauk::fb_map();
|
.BI void* montauk::fb_map();
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
.SS fb_info
|
.SS fb_info
|
||||||
Fills in an FbInfo structure with the framebuffer geometry:
|
Fills in an FbInfo structure with the framebuffer geometry:
|
||||||
|
|
||||||
Montauk::FbInfo fb;
|
montauk::abi::FbInfo fb;
|
||||||
montauk::fb_info(&fb);
|
montauk::fb_info(&fb);
|
||||||
// fb.width, fb.height, fb.pitch, fb.bpp
|
// fb.width, fb.height, fb.pitch, fb.bpp
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
Fill the screen with blue:
|
Fill the screen with blue:
|
||||||
|
|
||||||
Montauk::FbInfo fb;
|
montauk::abi::FbInfo fb;
|
||||||
montauk::fb_info(&fb);
|
montauk::fb_info(&fb);
|
||||||
uint32_t* pixels = (uint32_t*)montauk::fb_map();
|
uint32_t* pixels = (uint32_t*)montauk::fb_map();
|
||||||
|
|
||||||
|
|||||||
@@ -93,14 +93,14 @@
|
|||||||
|
|
||||||
.B SYS_GETTIME (28)
|
.B SYS_GETTIME (28)
|
||||||
Get the current wall-clock date and time (UTC).
|
Get the current wall-clock date and time (UTC).
|
||||||
Fills a Montauk::DateTime struct with Year, Month, Day,
|
Fills a montauk::abi::DateTime struct with Year, Month, Day,
|
||||||
Hour, Minute, and Second fields.
|
Hour, Minute, and Second fields.
|
||||||
void montauk::gettime(Montauk::DateTime* out);
|
void montauk::gettime(montauk::abi::DateTime* out);
|
||||||
|
|
||||||
.SH SYSTEM
|
.SH SYSTEM
|
||||||
.B SYS_GETINFO (15)
|
.B SYS_GETINFO (15)
|
||||||
Get OS name, version, and configuration.
|
Get OS name, version, and configuration.
|
||||||
void montauk::get_info(Montauk::SysInfo* info);
|
void montauk::get_info(montauk::abi::SysInfo* info);
|
||||||
|
|
||||||
.SH KEYBOARD
|
.SH KEYBOARD
|
||||||
.B SYS_ISKEYAVAILABLE (16)
|
.B SYS_ISKEYAVAILABLE (16)
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
|
|
||||||
.B SYS_GETKEY (17)
|
.B SYS_GETKEY (17)
|
||||||
Get the next key event (press or release).
|
Get the next key event (press or release).
|
||||||
void montauk::getkey(Montauk::KeyEvent* out);
|
void montauk::getkey(montauk::abi::KeyEvent* out);
|
||||||
|
|
||||||
.B SYS_GETCHAR (18)
|
.B SYS_GETCHAR (18)
|
||||||
Block until a printable character is typed.
|
Block until a printable character is typed.
|
||||||
@@ -123,16 +123,16 @@
|
|||||||
.B SYS_GETNETCFG (37)
|
.B SYS_GETNETCFG (37)
|
||||||
Get the current network configuration (IP, mask, gateway, MAC,
|
Get the current network configuration (IP, mask, gateway, MAC,
|
||||||
DNS server).
|
DNS server).
|
||||||
void montauk::get_netcfg(Montauk::NetCfg* out);
|
void montauk::get_netcfg(montauk::abi::NetCfg* out);
|
||||||
|
|
||||||
.B SYS_SETNETCFG (38)
|
.B SYS_SETNETCFG (38)
|
||||||
Set the network configuration (IP, mask, gateway, DNS server).
|
Set the network configuration (IP, mask, gateway, DNS server).
|
||||||
int montauk::set_netcfg(const Montauk::NetCfg* cfg);
|
int montauk::set_netcfg(const montauk::abi::NetCfg* cfg);
|
||||||
|
|
||||||
.B SYS_NETSTATUS (125)
|
.B SYS_NETSTATUS (125)
|
||||||
Get adapter status including driver name, link state, polling mode,
|
Get adapter status including driver name, link state, polling mode,
|
||||||
and RX/TX packet counters.
|
and RX/TX packet counters.
|
||||||
int montauk::net_status(Montauk::NetStatus* out);
|
int montauk::net_status(montauk::abi::NetStatus* out);
|
||||||
|
|
||||||
.B SYS_RESOLVE (44)
|
.B SYS_RESOLVE (44)
|
||||||
Resolve a hostname to an IPv4 address via DNS. Sends a UDP
|
Resolve a hostname to an IPv4 address via DNS. Sends a UDP
|
||||||
@@ -202,7 +202,7 @@
|
|||||||
.SH FRAMEBUFFER
|
.SH FRAMEBUFFER
|
||||||
.B SYS_FBINFO (21)
|
.B SYS_FBINFO (21)
|
||||||
Get framebuffer dimensions and format.
|
Get framebuffer dimensions and format.
|
||||||
void montauk::fb_info(Montauk::FbInfo* info);
|
void montauk::fb_info(montauk::abi::FbInfo* info);
|
||||||
|
|
||||||
.B SYS_FBMAP (22)
|
.B SYS_FBMAP (22)
|
||||||
Map the framebuffer into process memory at 0x50000000.
|
Map the framebuffer into process memory at 0x50000000.
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ static bool apply_move(MoveDir dir) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return false;
|
if (!key.pressed) return false;
|
||||||
|
|
||||||
if (key.scancode == 0x01)
|
if (key.scancode == 0x01)
|
||||||
@@ -478,7 +478,7 @@ static bool handle_key(const Montauk::KeyEvent& key) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_mouse(const Montauk::WinEvent& ev) {
|
static bool handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
int old_x = g_mouse_x;
|
int old_x = g_mouse_x;
|
||||||
int old_y = g_mouse_y;
|
int old_y = g_mouse_y;
|
||||||
g_mouse_x = ev.mouse.x;
|
g_mouse_x = ev.mouse.x;
|
||||||
@@ -511,7 +511,7 @@ extern "C" void _start() {
|
|||||||
render();
|
render();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
int r = g_win.poll(&ev);
|
int r = g_win.poll(&ev);
|
||||||
|
|
||||||
if (r < 0) break;
|
if (r < 0) break;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ static WsWindow g_win;
|
|||||||
static int g_master_vol = 80;
|
static int g_master_vol = 80;
|
||||||
static bool g_master_muted = false;
|
static bool g_master_muted = false;
|
||||||
|
|
||||||
static Montauk::AudioStreamInfo g_streams[8];
|
static montauk::abi::AudioStreamInfo g_streams[8];
|
||||||
static int g_stream_count = 0;
|
static int g_stream_count = 0;
|
||||||
|
|
||||||
// Drag target: -2 = none, -1 = master, 0..N-1 = stream slot in g_streams.
|
// Drag target: -2 = none, -1 = master, 0..N-1 = stream slot in g_streams.
|
||||||
@@ -385,7 +385,7 @@ static bool handle_mouse(int mx, int my, uint8_t buttons, uint8_t prev) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return false;
|
if (!key.pressed) return false;
|
||||||
if (key.scancode == 0x01) {
|
if (key.scancode == 0x01) {
|
||||||
g_win.closed = true;
|
g_win.closed = true;
|
||||||
@@ -428,7 +428,7 @@ extern "C" void _start() {
|
|||||||
render();
|
render();
|
||||||
|
|
||||||
while (g_win.id >= 0 && !g_win.closed) {
|
while (g_win.id >= 0 && !g_win.closed) {
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
int r = g_win.poll(&ev);
|
int r = g_win.poll(&ev);
|
||||||
|
|
||||||
bool redraw = false;
|
bool redraw = false;
|
||||||
|
|||||||
@@ -76,16 +76,16 @@ static int g_mouse_y = -1;
|
|||||||
static int g_hover_row = -1;
|
static int g_hover_row = -1;
|
||||||
|
|
||||||
// Adapter info
|
// Adapter info
|
||||||
static Montauk::BtAdapterInfo g_adapter;
|
static montauk::abi::BtAdapterInfo g_adapter;
|
||||||
static bool g_adapter_ok = false;
|
static bool g_adapter_ok = false;
|
||||||
|
|
||||||
// Connected/paired devices
|
// Connected/paired devices
|
||||||
static Montauk::BtDevInfo g_devices[MAX_CONNECTED];
|
static montauk::abi::BtDevInfo g_devices[MAX_CONNECTED];
|
||||||
static char g_device_names[MAX_CONNECTED][64];
|
static char g_device_names[MAX_CONNECTED][64];
|
||||||
static int g_device_count = 0;
|
static int g_device_count = 0;
|
||||||
|
|
||||||
// Scan results
|
// Scan results
|
||||||
static Montauk::BtScanResult g_scan[MAX_SCAN];
|
static montauk::abi::BtScanResult g_scan[MAX_SCAN];
|
||||||
static int g_scan_count = 0;
|
static int g_scan_count = 0;
|
||||||
static bool g_scanning = false;
|
static bool g_scanning = false;
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ static void refresh_devices() {
|
|||||||
|
|
||||||
// Append bonded (paired) devices that aren't currently connected, so the
|
// Append bonded (paired) devices that aren't currently connected, so the
|
||||||
// Devices tab remembers them across sessions/reboots.
|
// Devices tab remembers them across sessions/reboots.
|
||||||
Montauk::BtBondInfo bonds[8];
|
montauk::abi::BtBondInfo bonds[8];
|
||||||
int nb = montauk::bt_bonds(bonds, 8);
|
int nb = montauk::bt_bonds(bonds, 8);
|
||||||
for (int i = 0; i < nb && g_device_count < MAX_CONNECTED; i++) {
|
for (int i = 0; i < nb && g_device_count < MAX_CONNECTED; i++) {
|
||||||
bool already = false;
|
bool already = false;
|
||||||
@@ -277,7 +277,7 @@ static void refresh_devices() {
|
|||||||
}
|
}
|
||||||
if (already) continue;
|
if (already) continue;
|
||||||
|
|
||||||
Montauk::BtDevInfo d = {};
|
montauk::abi::BtDevInfo d = {};
|
||||||
montauk::memcpy(d.bdAddr, bonds[i].bdAddr, 6);
|
montauk::memcpy(d.bdAddr, bonds[i].bdAddr, 6);
|
||||||
d.connected = 0; // paired but not connected
|
d.connected = 0; // paired but not connected
|
||||||
d.encrypted = 0;
|
d.encrypted = 0;
|
||||||
@@ -642,7 +642,7 @@ static bool handle_adapter_mouse(int mx, int my, uint8_t buttons,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_adapter_key(const Montauk::KeyEvent& key) {
|
static bool handle_adapter_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (key.ascii == '\n' || key.ascii == '\r') { apply_mac(); return true; }
|
if (key.ascii == '\n' || key.ascii == '\r') { apply_mac(); return true; }
|
||||||
if (key.ascii == '\t') { g_mac_focus = !g_mac_focus; return true; }
|
if (key.ascii == '\t') { g_mac_focus = !g_mac_focus; return true; }
|
||||||
|
|
||||||
@@ -883,7 +883,7 @@ extern "C" void _start() {
|
|||||||
uint64_t last_refresh = montauk::get_milliseconds();
|
uint64_t last_refresh = montauk::get_milliseconds();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
int r = win.poll(&ev);
|
int r = win.poll(&ev);
|
||||||
|
|
||||||
if (r < 0) break;
|
if (r < 0) break;
|
||||||
|
|||||||
@@ -530,7 +530,7 @@ static void render(Canvas& c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_mouse(const Montauk::WinEvent& ev, int win_w, int win_h) {
|
static bool handle_mouse(const montauk::abi::WinEvent& ev, int win_w, int win_h) {
|
||||||
CalcLayout layout;
|
CalcLayout layout;
|
||||||
calc_build_layout(win_w, win_h, &layout);
|
calc_build_layout(win_w, win_h, &layout);
|
||||||
|
|
||||||
@@ -558,7 +558,7 @@ static bool handle_mouse(const Montauk::WinEvent& ev, int win_w, int win_h) {
|
|||||||
return redraw;
|
return redraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return false;
|
if (!key.pressed) return false;
|
||||||
|
|
||||||
if (key.ascii >= '0' && key.ascii <= '9') {
|
if (key.ascii >= '0' && key.ascii <= '9') {
|
||||||
@@ -602,7 +602,7 @@ extern "C" void _start() {
|
|||||||
win.present();
|
win.present();
|
||||||
|
|
||||||
while (win.id >= 0 && !win.closed) {
|
while (win.id >= 0 && !win.closed) {
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
int r = win.poll(&ev);
|
int r = win.poll(&ev);
|
||||||
|
|
||||||
if (r < 0) break;
|
if (r < 0) break;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ static constexpr int COL1_W = 200;
|
|||||||
static constexpr int SECTION_GAP = 10;
|
static constexpr int SECTION_GAP = 10;
|
||||||
|
|
||||||
WsWindow g_win;
|
WsWindow g_win;
|
||||||
Montauk::CrashReportInfo g_report = {};
|
montauk::abi::CrashReportInfo g_report = {};
|
||||||
int g_scroll = 0;
|
int g_scroll = 0;
|
||||||
|
|
||||||
// Colors - light theme matching DiskDetail
|
// Colors - light theme matching DiskDetail
|
||||||
@@ -213,7 +213,7 @@ extern "C" void _start() {
|
|||||||
render();
|
render();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
int r = g_win.poll(&ev);
|
int r = g_win.poll(&ev);
|
||||||
if (r < 0) break;
|
if (r < 0) break;
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static const char* month_name(int m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void _start() {
|
extern "C" void _start() {
|
||||||
Montauk::DateTime dt;
|
montauk::abi::DateTime dt;
|
||||||
montauk::gettime(&dt);
|
montauk::gettime(&dt);
|
||||||
|
|
||||||
print_int(dt.Day);
|
print_int(dt.Day);
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ void open_sleep_dialog(DesktopState* ds);
|
|||||||
// Hand a graceful power-off request to login.elf and exit the desktop so the
|
// Hand a graceful power-off request to login.elf and exit the desktop so the
|
||||||
// user returns to the login screen, where the shutdown stages run (Bluetooth
|
// user returns to the login screen, where the shutdown stages run (Bluetooth
|
||||||
// teardown, filesystem flush) before the final ACPI power-off / reset. Pass
|
// teardown, filesystem flush) before the final ACPI power-off / reset. Pass
|
||||||
// Montauk::POWER_REQ_SHUTDOWN or Montauk::POWER_REQ_REBOOT.
|
// montauk::abi::POWER_REQ_SHUTDOWN or montauk::abi::POWER_REQ_REBOOT.
|
||||||
[[noreturn]] inline void desktop_request_power(int action) {
|
[[noreturn]] inline void desktop_request_power(int action) {
|
||||||
montauk::power_request(action);
|
montauk::power_request(action);
|
||||||
montauk::exit(0);
|
montauk::exit(0);
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ void filemanager_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void filemanager_on_key(Window* win, const Montauk::KeyEvent& key) {
|
void filemanager_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
FileManagerState* fm = (FileManagerState*)win->app_data;
|
FileManagerState* fm = (FileManagerState*)win->app_data;
|
||||||
if (!fm || !key.pressed) return;
|
if (!fm || !key.pressed) return;
|
||||||
|
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ int filemanager_collect_selection(const FileManagerState* fm, int* out, int max
|
|||||||
void filemanager_draw_header(Canvas& c, FileManagerState* fm, Color toolbar_color, Color btn_bg);
|
void filemanager_draw_header(Canvas& c, FileManagerState* fm, Color toolbar_color, Color btn_bg);
|
||||||
void filemanager_on_draw(Window* win, Framebuffer& fb);
|
void filemanager_on_draw(Window* win, Framebuffer& fb);
|
||||||
void filemanager_on_mouse(Window* win, MouseEvent& ev);
|
void filemanager_on_mouse(Window* win, MouseEvent& ev);
|
||||||
void filemanager_on_key(Window* win, const Montauk::KeyEvent& key);
|
void filemanager_on_key(Window* win, const montauk::abi::KeyEvent& key);
|
||||||
void filemanager_on_close(Window* win);
|
void filemanager_on_close(Window* win);
|
||||||
|
|
||||||
} // namespace filemanager
|
} // namespace filemanager
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ static void fileop_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fileop_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void fileop_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
FileOpJob* job = (FileOpJob*)win->app_data;
|
FileOpJob* job = (FileOpJob*)win->app_data;
|
||||||
if (!job || !key.pressed) return;
|
if (!job || !key.pressed) return;
|
||||||
if (key.scancode == 0x01) job->cancel = 1; // Escape requests cancel
|
if (key.scancode == 0x01) job->cancel = 1; // Escape requests cancel
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ static void props_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
props_close_self(st->desktop, st);
|
props_close_self(st->desktop, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void props_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void props_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
FilePropertiesDialogState* st = (FilePropertiesDialogState*)win->app_data;
|
FilePropertiesDialogState* st = (FilePropertiesDialogState*)win->app_data;
|
||||||
if (!st || !key.pressed) return;
|
if (!st || !key.pressed) return;
|
||||||
if (key.scancode == 0x01 || key.ascii == '\n' || key.ascii == '\r')
|
if (key.scancode == 0x01 || key.ascii == '\n' || key.ascii == '\r')
|
||||||
@@ -576,7 +576,7 @@ static void delete_confirm_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_confirm_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void delete_confirm_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
FileDeleteConfirmDialogState* st = (FileDeleteConfirmDialogState*)win->app_data;
|
FileDeleteConfirmDialogState* st = (FileDeleteConfirmDialogState*)win->app_data;
|
||||||
if (!st || !key.pressed) return;
|
if (!st || !key.pressed) return;
|
||||||
|
|
||||||
@@ -820,7 +820,7 @@ static void multi_props_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
props_close_self(st->desktop, st);
|
props_close_self(st->desktop, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void multi_props_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void multi_props_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
MultiPropertiesDialogState* st = (MultiPropertiesDialogState*)win->app_data;
|
MultiPropertiesDialogState* st = (MultiPropertiesDialogState*)win->app_data;
|
||||||
if (!st || !key.pressed) return;
|
if (!st || !key.pressed) return;
|
||||||
if (key.scancode == 0x01 || key.ascii == '\n' || key.ascii == '\r')
|
if (key.scancode == 0x01 || key.ascii == '\n' || key.ascii == '\r')
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ static void settings_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void settings_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void settings_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
// Settings main window no longer needs keyboard handling.
|
// Settings main window no longer needs keyboard handling.
|
||||||
(void)win;
|
(void)win;
|
||||||
(void)key;
|
(void)key;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace settings_app {
|
|||||||
struct SettingsState {
|
struct SettingsState {
|
||||||
DesktopState* desktop;
|
DesktopState* desktop;
|
||||||
int active_tab; // 0=Appearance, 1=Display, 2=About
|
int active_tab; // 0=Appearance, 1=Display, 2=About
|
||||||
Montauk::SysInfo sys_info;
|
montauk::abi::SysInfo sys_info;
|
||||||
uint64_t uptime_ms;
|
uint64_t uptime_ms;
|
||||||
WallpaperFileList wp_files;
|
WallpaperFileList wp_files;
|
||||||
bool wp_scanned;
|
bool wp_scanned;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ static void usermanager_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usermanager_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void usermanager_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
(void)win;
|
(void)win;
|
||||||
(void)key;
|
(void)key;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ static void adduser_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void adduser_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void adduser_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
AddUserDialogState* st = (AddUserDialogState*)win->app_data;
|
AddUserDialogState* st = (AddUserDialogState*)win->app_data;
|
||||||
if (!st || !key.pressed) return;
|
if (!st || !key.pressed) return;
|
||||||
|
|
||||||
@@ -495,7 +495,7 @@ static void chpwd_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chpwd_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void chpwd_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
ChPwdDialogState* st = (ChPwdDialogState*)win->app_data;
|
ChPwdDialogState* st = (ChPwdDialogState*)win->app_data;
|
||||||
if (!st || !key.pressed) return;
|
if (!st || !key.pressed) return;
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ static void deluser_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deluser_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void deluser_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
DeleteUserDialogState* st = (DeleteUserDialogState*)win->app_data;
|
DeleteUserDialogState* st = (DeleteUserDialogState*)win->app_data;
|
||||||
if (!st || !key.pressed) return;
|
if (!st || !key.pressed) return;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ void desktop_draw_lock_screen(DesktopState* ds) {
|
|||||||
fb.fill_rect_alpha(0, 0, sw, sh, Color::from_rgba(0, 0, 0, 0x80));
|
fb.fill_rect_alpha(0, 0, sw, sh, Color::from_rgba(0, 0, 0, 0x80));
|
||||||
|
|
||||||
// Clock display above card
|
// Clock display above card
|
||||||
Montauk::DateTime dt;
|
montauk::abi::DateTime dt;
|
||||||
montauk::gettime(&dt);
|
montauk::gettime(&dt);
|
||||||
char time_str[12];
|
char time_str[12];
|
||||||
snprintf(time_str, sizeof(time_str), "%02d:%02d", (int)dt.Hour, (int)dt.Minute);
|
snprintf(time_str, sizeof(time_str), "%02d:%02d", (int)dt.Hour, (int)dt.Minute);
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ inline int menu_add_external(const char* label, const char* binary, SvgIcon* ico
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
inline bool desktop_window_fullscreen(const gui::Window* win) {
|
inline bool desktop_window_fullscreen(const gui::Window* win) {
|
||||||
return win && win->external && (win->ext_flags & Montauk::WIN_FLAG_FULLSCREEN);
|
return win && win->external && (win->ext_flags & montauk::abi::WIN_FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline gui::Rect desktop_content_rect(const gui::Window* win) {
|
inline gui::Rect desktop_content_rect(const gui::Window* win) {
|
||||||
@@ -160,7 +160,7 @@ inline const char* month_names[] = {
|
|||||||
|
|
||||||
// launcher.cpp
|
// launcher.cpp
|
||||||
void desktop_init_launcher(gui::DesktopState* ds);
|
void desktop_init_launcher(gui::DesktopState* ds);
|
||||||
bool desktop_handle_launcher_keyboard(gui::DesktopState* ds, const Montauk::KeyEvent& key);
|
bool desktop_handle_launcher_keyboard(gui::DesktopState* ds, const montauk::abi::KeyEvent& key);
|
||||||
void desktop_handle_launcher_mouse(gui::DesktopState* ds);
|
void desktop_handle_launcher_mouse(gui::DesktopState* ds);
|
||||||
void desktop_draw_launcher(gui::DesktopState* ds);
|
void desktop_draw_launcher(gui::DesktopState* ds);
|
||||||
uint64_t desktop_launcher_blink_token(const gui::DesktopState* ds, uint64_t now);
|
uint64_t desktop_launcher_blink_token(const gui::DesktopState* ds, uint64_t now);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ static void reboot_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
rs->hover_cancel = cb.contains(lx, ly);
|
rs->hover_cancel = cb.contains(lx, ly);
|
||||||
|
|
||||||
if (ev.left_pressed()) {
|
if (ev.left_pressed()) {
|
||||||
if (rs->hover_reboot) desktop_request_power(Montauk::POWER_REQ_REBOOT);
|
if (rs->hover_reboot) desktop_request_power(montauk::abi::POWER_REQ_REBOOT);
|
||||||
if (rs->hover_cancel) {
|
if (rs->hover_cancel) {
|
||||||
for (int i = 0; i < rs->ds->window_count; i++) {
|
for (int i = 0; i < rs->ds->window_count; i++) {
|
||||||
if (rs->ds->windows[i].app_data == rs) {
|
if (rs->ds->windows[i].app_data == rs) {
|
||||||
@@ -81,12 +81,12 @@ static void reboot_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reboot_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void reboot_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
RebootDialogState* rs = (RebootDialogState*)win->app_data;
|
RebootDialogState* rs = (RebootDialogState*)win->app_data;
|
||||||
if (!rs || !key.pressed) return;
|
if (!rs || !key.pressed) return;
|
||||||
|
|
||||||
if (key.ascii == '\n' || key.ascii == '\r') {
|
if (key.ascii == '\n' || key.ascii == '\r') {
|
||||||
desktop_request_power(Montauk::POWER_REQ_REBOOT);
|
desktop_request_power(montauk::abi::POWER_REQ_REBOOT);
|
||||||
}
|
}
|
||||||
if (key.scancode == 0x01) { // Escape
|
if (key.scancode == 0x01) { // Escape
|
||||||
for (int i = 0; i < rs->ds->window_count; i++) {
|
for (int i = 0; i < rs->ds->window_count; i++) {
|
||||||
@@ -181,7 +181,7 @@ static void shutdown_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
ss->hover_cancel = cb.contains(lx, ly);
|
ss->hover_cancel = cb.contains(lx, ly);
|
||||||
|
|
||||||
if (ev.left_pressed()) {
|
if (ev.left_pressed()) {
|
||||||
if (ss->hover_shutdown) desktop_request_power(Montauk::POWER_REQ_SHUTDOWN);
|
if (ss->hover_shutdown) desktop_request_power(montauk::abi::POWER_REQ_SHUTDOWN);
|
||||||
if (ss->hover_cancel) {
|
if (ss->hover_cancel) {
|
||||||
for (int i = 0; i < ss->ds->window_count; i++) {
|
for (int i = 0; i < ss->ds->window_count; i++) {
|
||||||
if (ss->ds->windows[i].app_data == ss) {
|
if (ss->ds->windows[i].app_data == ss) {
|
||||||
@@ -193,12 +193,12 @@ static void shutdown_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shutdown_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void shutdown_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
ShutdownDialogState* ss = (ShutdownDialogState*)win->app_data;
|
ShutdownDialogState* ss = (ShutdownDialogState*)win->app_data;
|
||||||
if (!ss || !key.pressed) return;
|
if (!ss || !key.pressed) return;
|
||||||
|
|
||||||
if (key.ascii == '\n' || key.ascii == '\r') {
|
if (key.ascii == '\n' || key.ascii == '\r') {
|
||||||
desktop_request_power(Montauk::POWER_REQ_SHUTDOWN);
|
desktop_request_power(montauk::abi::POWER_REQ_SHUTDOWN);
|
||||||
}
|
}
|
||||||
if (key.scancode == 0x01) { // Escape
|
if (key.scancode == 0x01) { // Escape
|
||||||
for (int i = 0; i < ss->ds->window_count; i++) {
|
for (int i = 0; i < ss->ds->window_count; i++) {
|
||||||
@@ -314,7 +314,7 @@ static void sleep_dialog_on_mouse(Window* win, MouseEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sleep_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
|
static void sleep_dialog_on_key(Window* win, const montauk::abi::KeyEvent& key) {
|
||||||
SleepDialogState* ss = (SleepDialogState*)win->app_data;
|
SleepDialogState* ss = (SleepDialogState*)win->app_data;
|
||||||
if (!ss || !key.pressed) return;
|
if (!ss || !key.pressed) return;
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ static void handle_lock_mouse(DesktopState* ds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_lock_keyboard(DesktopState* ds, const Montauk::KeyEvent& key) {
|
static void handle_lock_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return;
|
if (!key.pressed) return;
|
||||||
|
|
||||||
// Enter submits
|
// Enter submits
|
||||||
@@ -101,7 +101,7 @@ static void forward_external_mouse(gui::Window* win,
|
|||||||
uint8_t buttons,
|
uint8_t buttons,
|
||||||
uint8_t prev) {
|
uint8_t prev) {
|
||||||
gui::Rect cr = desktop_content_rect(win);
|
gui::Rect cr = desktop_content_rect(win);
|
||||||
Montauk::WinEvent wev;
|
montauk::abi::WinEvent wev;
|
||||||
montauk::memset(&wev, 0, sizeof(wev));
|
montauk::memset(&wev, 0, sizeof(wev));
|
||||||
wev.type = 1; // mouse
|
wev.type = 1; // mouse
|
||||||
wev.mouse.x = mx - cr.x;
|
wev.mouse.x = mx - cr.x;
|
||||||
@@ -242,7 +242,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Rect cr = desktop_content_rect(win);
|
Rect cr = desktop_content_rect(win);
|
||||||
Montauk::WinEvent rev;
|
montauk::abi::WinEvent rev;
|
||||||
montauk::memset(&rev, 0, sizeof(rev));
|
montauk::memset(&rev, 0, sizeof(rev));
|
||||||
rev.type = 2;
|
rev.type = 2;
|
||||||
rev.resize.w = cr.w;
|
rev.resize.w = cr.w;
|
||||||
@@ -264,7 +264,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Rect cr = desktop_content_rect(win);
|
Rect cr = desktop_content_rect(win);
|
||||||
Montauk::WinEvent rev;
|
montauk::abi::WinEvent rev;
|
||||||
montauk::memset(&rev, 0, sizeof(rev));
|
montauk::memset(&rev, 0, sizeof(rev));
|
||||||
rev.type = 2;
|
rev.type = 2;
|
||||||
rev.resize.w = cr.w;
|
rev.resize.w = cr.w;
|
||||||
@@ -331,7 +331,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
win->dirty = true;
|
win->dirty = true;
|
||||||
} else {
|
} else {
|
||||||
Rect cr = desktop_content_rect(win);
|
Rect cr = desktop_content_rect(win);
|
||||||
Montauk::WinEvent rev;
|
montauk::abi::WinEvent rev;
|
||||||
montauk::memset(&rev, 0, sizeof(rev));
|
montauk::memset(&rev, 0, sizeof(rev));
|
||||||
rev.type = 2;
|
rev.type = 2;
|
||||||
rev.resize.w = cr.w;
|
rev.resize.w = cr.w;
|
||||||
@@ -615,7 +615,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Rect cr = desktop_content_rect(win);
|
Rect cr = desktop_content_rect(win);
|
||||||
Montauk::WinEvent rev;
|
montauk::abi::WinEvent rev;
|
||||||
montauk::memset(&rev, 0, sizeof(rev));
|
montauk::memset(&rev, 0, sizeof(rev));
|
||||||
rev.type = 2;
|
rev.type = 2;
|
||||||
rev.resize.w = cr.w;
|
rev.resize.w = cr.w;
|
||||||
@@ -661,7 +661,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
Window* raised = &ds->windows[new_idx];
|
Window* raised = &ds->windows[new_idx];
|
||||||
if (raised->external) {
|
if (raised->external) {
|
||||||
// Forward mouse event to external window
|
// Forward mouse event to external window
|
||||||
Montauk::WinEvent wev;
|
montauk::abi::WinEvent wev;
|
||||||
montauk::memset(&wev, 0, sizeof(wev));
|
montauk::memset(&wev, 0, sizeof(wev));
|
||||||
wev.type = 1; // mouse
|
wev.type = 1; // mouse
|
||||||
wev.mouse.x = mx - cr.x;
|
wev.mouse.x = mx - cr.x;
|
||||||
@@ -700,7 +700,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
// Forward if mouse is over content (hover/move) or button is held/released (drag continuity)
|
// Forward if mouse is over content (hover/move) or button is held/released (drag continuity)
|
||||||
if (cr.contains(mx, my) || left_held || left_released) {
|
if (cr.contains(mx, my) || left_held || left_released) {
|
||||||
if (win->external) {
|
if (win->external) {
|
||||||
Montauk::WinEvent wev;
|
montauk::abi::WinEvent wev;
|
||||||
montauk::memset(&wev, 0, sizeof(wev));
|
montauk::memset(&wev, 0, sizeof(wev));
|
||||||
wev.type = 1; // mouse
|
wev.type = 1; // mouse
|
||||||
wev.mouse.x = mx - cr.x;
|
wev.mouse.x = mx - cr.x;
|
||||||
@@ -726,7 +726,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
Rect cr = desktop_content_rect(win);
|
Rect cr = desktop_content_rect(win);
|
||||||
if (cr.contains(mx, my)) {
|
if (cr.contains(mx, my)) {
|
||||||
if (win->external) {
|
if (win->external) {
|
||||||
Montauk::WinEvent wev;
|
montauk::abi::WinEvent wev;
|
||||||
montauk::memset(&wev, 0, sizeof(wev));
|
montauk::memset(&wev, 0, sizeof(wev));
|
||||||
wev.type = 1; // mouse
|
wev.type = 1; // mouse
|
||||||
wev.mouse.x = mx - cr.x;
|
wev.mouse.x = mx - cr.x;
|
||||||
@@ -763,7 +763,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui::desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key) {
|
void gui::desktop_handle_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||||
if (ds->screen_locked) {
|
if (ds->screen_locked) {
|
||||||
handle_lock_keyboard(ds, key);
|
handle_lock_keyboard(ds, key);
|
||||||
return;
|
return;
|
||||||
@@ -776,7 +776,7 @@ void gui::desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key
|
|||||||
if (!desktop_window_fullscreen(win))
|
if (!desktop_window_fullscreen(win))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
montauk::memset(&ev, 0, sizeof(ev));
|
montauk::memset(&ev, 0, sizeof(ev));
|
||||||
ev.type = 0; // key
|
ev.type = 0; // key
|
||||||
ev.key = key;
|
ev.key = key;
|
||||||
@@ -828,7 +828,7 @@ void gui::desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key
|
|||||||
Window* win = &ds->windows[ds->focused_window];
|
Window* win = &ds->windows[ds->focused_window];
|
||||||
if (win->external) {
|
if (win->external) {
|
||||||
// Forward key event to external window via syscall
|
// Forward key event to external window via syscall
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
montauk::memset(&ev, 0, sizeof(ev));
|
montauk::memset(&ev, 0, sizeof(ev));
|
||||||
ev.type = 0; // key
|
ev.type = 0; // key
|
||||||
ev.key = key;
|
ev.key = key;
|
||||||
|
|||||||
@@ -339,11 +339,11 @@ static void launcher_activate_selected(DesktopState* ds) {
|
|||||||
break;
|
break;
|
||||||
case LAUNCHER_ITEM_COMMAND_REBOOT:
|
case LAUNCHER_ITEM_COMMAND_REBOOT:
|
||||||
desktop_close_launcher(ds);
|
desktop_close_launcher(ds);
|
||||||
desktop_request_power(Montauk::POWER_REQ_REBOOT);
|
desktop_request_power(montauk::abi::POWER_REQ_REBOOT);
|
||||||
return;
|
return;
|
||||||
case LAUNCHER_ITEM_COMMAND_SHUTDOWN:
|
case LAUNCHER_ITEM_COMMAND_SHUTDOWN:
|
||||||
desktop_close_launcher(ds);
|
desktop_close_launcher(ds);
|
||||||
desktop_request_power(Montauk::POWER_REQ_SHUTDOWN);
|
desktop_request_power(montauk::abi::POWER_REQ_SHUTDOWN);
|
||||||
return;
|
return;
|
||||||
case LAUNCHER_ITEM_SPECIAL_FOLDER:
|
case LAUNCHER_ITEM_SPECIAL_FOLDER:
|
||||||
if (item->path[0] != '\0') {
|
if (item->path[0] != '\0') {
|
||||||
@@ -355,7 +355,7 @@ static void launcher_activate_selected(DesktopState* ds) {
|
|||||||
desktop_close_launcher(ds);
|
desktop_close_launcher(ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void launcher_update_super_state(DesktopState* ds, const Montauk::KeyEvent& key) {
|
static void launcher_update_super_state(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||||
uint8_t sc = key.scancode & 0x7F;
|
uint8_t sc = key.scancode & 0x7F;
|
||||||
if (sc == 0x5B) {
|
if (sc == 0x5B) {
|
||||||
ds->super_left_down = key.pressed;
|
ds->super_left_down = key.pressed;
|
||||||
@@ -411,7 +411,7 @@ void desktop_close_launcher(DesktopState* ds) {
|
|||||||
ds->launcher_scroll = 0;
|
ds->launcher_scroll = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool desktop_handle_launcher_keyboard(DesktopState* ds, const Montauk::KeyEvent& key) {
|
bool desktop_handle_launcher_keyboard(DesktopState* ds, const montauk::abi::KeyEvent& key) {
|
||||||
launcher_update_super_state(ds, key);
|
launcher_update_super_state(ds, key);
|
||||||
uint8_t sc = key.scancode & 0x7F;
|
uint8_t sc = key.scancode & 0x7F;
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ void gui::desktop_init(DesktopState* ds) {
|
|||||||
ds->app_menu_open = false;
|
ds->app_menu_open = false;
|
||||||
desktop_init_launcher(ds);
|
desktop_init_launcher(ds);
|
||||||
|
|
||||||
montauk::memset(&ds->mouse, 0, sizeof(Montauk::MouseState));
|
montauk::memset(&ds->mouse, 0, sizeof(montauk::abi::MouseState));
|
||||||
montauk::set_mouse_bounds(ds->screen_w - 1, ds->screen_h - 1);
|
montauk::set_mouse_bounds(ds->screen_w - 1, ds->screen_h - 1);
|
||||||
gui::clipboard_clear();
|
gui::clipboard_clear();
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ void gui::desktop_init(DesktopState* ds) {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static uint64_t desktop_clock_token() {
|
static uint64_t desktop_clock_token() {
|
||||||
Montauk::DateTime dt;
|
montauk::abi::DateTime dt;
|
||||||
montauk::gettime(&dt);
|
montauk::gettime(&dt);
|
||||||
return ((uint64_t)dt.Year << 32)
|
return ((uint64_t)dt.Year << 32)
|
||||||
| ((uint64_t)dt.Month << 24)
|
| ((uint64_t)dt.Month << 24)
|
||||||
@@ -369,7 +369,7 @@ static void desktop_clear_window_dirty(DesktopState* ds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool desktop_netcfg_equal(const Montauk::NetCfg& a, const Montauk::NetCfg& b) {
|
static bool desktop_netcfg_equal(const montauk::abi::NetCfg& a, const montauk::abi::NetCfg& b) {
|
||||||
if (a.ipAddress != b.ipAddress || a.subnetMask != b.subnetMask ||
|
if (a.ipAddress != b.ipAddress || a.subnetMask != b.subnetMask ||
|
||||||
a.gateway != b.gateway || a.dnsServer != b.dnsServer) {
|
a.gateway != b.gateway || a.dnsServer != b.dnsServer) {
|
||||||
return false;
|
return false;
|
||||||
@@ -385,7 +385,7 @@ static bool desktop_refresh_panel_state(DesktopState* ds, uint64_t now) {
|
|||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (now - ds->net_cfg_last_poll > 5000) {
|
if (now - ds->net_cfg_last_poll > 5000) {
|
||||||
Montauk::NetCfg next;
|
montauk::abi::NetCfg next;
|
||||||
montauk::get_netcfg(&next);
|
montauk::get_netcfg(&next);
|
||||||
if (!desktop_netcfg_equal(next, ds->cached_net_cfg)) {
|
if (!desktop_netcfg_equal(next, ds->cached_net_cfg)) {
|
||||||
ds->cached_net_cfg = next;
|
ds->cached_net_cfg = next;
|
||||||
@@ -425,7 +425,7 @@ static bool desktop_refresh_panel_state(DesktopState* ds, uint64_t now) {
|
|||||||
|
|
||||||
bool desktop_poll_external_windows(DesktopState* ds) {
|
bool desktop_poll_external_windows(DesktopState* ds) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
Montauk::WinInfo extWins[8];
|
montauk::abi::WinInfo extWins[8];
|
||||||
int extCount = montauk::win_enumerate(extWins, 8);
|
int extCount = montauk::win_enumerate(extWins, 8);
|
||||||
|
|
||||||
// Check for new external windows and map them
|
// Check for new external windows and map them
|
||||||
@@ -649,7 +649,7 @@ void gui::desktop_run(DesktopState* ds) {
|
|||||||
|
|
||||||
// Poll keyboard events
|
// Poll keyboard events
|
||||||
while (montauk::is_key_available()) {
|
while (montauk::is_key_available()) {
|
||||||
Montauk::KeyEvent key;
|
montauk::abi::KeyEvent key;
|
||||||
montauk::getkey(&key);
|
montauk::getkey(&key);
|
||||||
desktop_handle_keyboard(ds, key);
|
desktop_handle_keyboard(ds, key);
|
||||||
keyboardChanged = true;
|
keyboardChanged = true;
|
||||||
@@ -730,7 +730,7 @@ static DesktopState* g_desktop;
|
|||||||
static constexpr const char kDesktopBinaryName[] = "desktop.elf";
|
static constexpr const char kDesktopBinaryName[] = "desktop.elf";
|
||||||
static constexpr int DESKTOP_PROC_SCAN_MAX = 256;
|
static constexpr int DESKTOP_PROC_SCAN_MAX = 256;
|
||||||
|
|
||||||
static bool desktop_proc_alive(const Montauk::ProcInfo& proc) {
|
static bool desktop_proc_alive(const montauk::abi::ProcInfo& proc) {
|
||||||
return proc.state == 1 || proc.state == 2 || proc.state == 3;
|
return proc.state == 1 || proc.state == 2 || proc.state == 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +745,7 @@ static bool proc_name_is_desktop(const char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool existing_desktop_running() {
|
static bool existing_desktop_running() {
|
||||||
static Montauk::ProcInfo procs[DESKTOP_PROC_SCAN_MAX];
|
static montauk::abi::ProcInfo procs[DESKTOP_PROC_SCAN_MAX];
|
||||||
int count = montauk::proclist(procs, DESKTOP_PROC_SCAN_MAX);
|
int count = montauk::proclist(procs, DESKTOP_PROC_SCAN_MAX);
|
||||||
if (count <= 0) return false;
|
if (count <= 0) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ void gui::desktop_draw_panel(DesktopState* ds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Date + Clock (right side)
|
// Date + Clock (right side)
|
||||||
Montauk::DateTime dt;
|
montauk::abi::DateTime dt;
|
||||||
montauk::gettime(&dt);
|
montauk::gettime(&dt);
|
||||||
|
|
||||||
char clock_str[12];
|
char clock_str[12];
|
||||||
@@ -256,7 +256,7 @@ void desktop_draw_app_menu(DesktopState* ds) {
|
|||||||
|
|
||||||
void desktop_draw_net_popup(DesktopState* ds) {
|
void desktop_draw_net_popup(DesktopState* ds) {
|
||||||
Framebuffer& fb = ds->fb;
|
Framebuffer& fb = ds->fb;
|
||||||
Montauk::NetCfg& nc = ds->cached_net_cfg;
|
montauk::abi::NetCfg& nc = ds->cached_net_cfg;
|
||||||
bool connected = nc.ipAddress != 0;
|
bool connected = nc.ipAddress != 0;
|
||||||
|
|
||||||
int popup_w = 220;
|
int popup_w = 220;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ void gui::desktop_close_window(DesktopState* ds, int idx) {
|
|||||||
if (ds->closing_ext_count < DesktopState::MAX_CLOSING) {
|
if (ds->closing_ext_count < DesktopState::MAX_CLOSING) {
|
||||||
ds->closing_ext_ids[ds->closing_ext_count++] = win->ext_win_id;
|
ds->closing_ext_ids[ds->closing_ext_count++] = win->ext_win_id;
|
||||||
}
|
}
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
montauk::memset(&ev, 0, sizeof(ev));
|
montauk::memset(&ev, 0, sizeof(ev));
|
||||||
ev.type = 3; // close
|
ev.type = 3; // close
|
||||||
montauk::win_sendevent(win->ext_win_id, &ev);
|
montauk::win_sendevent(win->ext_win_id, &ev);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ static constexpr int DD_INIT_H = 420;
|
|||||||
static constexpr int DD_TAB_BAR_H = 32;
|
static constexpr int DD_TAB_BAR_H = 32;
|
||||||
|
|
||||||
struct DiskDetailState {
|
struct DiskDetailState {
|
||||||
Montauk::DiskInfo info;
|
montauk::abi::DiskInfo info;
|
||||||
int active_tab;
|
int active_tab;
|
||||||
int win_id;
|
int win_id;
|
||||||
int win_w, win_h;
|
int win_w, win_h;
|
||||||
@@ -152,7 +152,7 @@ struct DiskDetailState {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
struct DevExplorerState {
|
struct DevExplorerState {
|
||||||
Montauk::DevInfo devs[MAX_TOTAL_DEVS];
|
montauk::abi::DevInfo devs[MAX_TOTAL_DEVS];
|
||||||
int dev_count;
|
int dev_count;
|
||||||
bool collapsed[NUM_CATEGORIES];
|
bool collapsed[NUM_CATEGORIES];
|
||||||
int selected_row;
|
int selected_row;
|
||||||
@@ -193,7 +193,7 @@ void render(uint32_t* pixels);
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
int build_display_rows(DevExplorerState* de, DisplayRow* rows);
|
int build_display_rows(DevExplorerState* de, DisplayRow* rows);
|
||||||
int append_printer_devices(Montauk::DevInfo* out, int max_count);
|
int append_printer_devices(montauk::abi::DevInfo* out, int max_count);
|
||||||
ScrollMetrics compute_scroll_metrics(DevExplorerState* de,
|
ScrollMetrics compute_scroll_metrics(DevExplorerState* de,
|
||||||
const DisplayRow* rows, int row_count);
|
const DisplayRow* rows, int row_count);
|
||||||
void set_scroll_from_px(DevExplorerState* de, const DisplayRow* rows,
|
void set_scroll_from_px(DevExplorerState* de, const DisplayRow* rows,
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ void open_disk_detail(int port, const char* model) {
|
|||||||
montauk::memset(&dd.info, 0, sizeof(dd.info));
|
montauk::memset(&dd.info, 0, sizeof(dd.info));
|
||||||
montauk::diskinfo(&dd.info, port);
|
montauk::diskinfo(&dd.info, port);
|
||||||
|
|
||||||
Montauk::WinCreateResult wres;
|
montauk::abi::WinCreateResult wres;
|
||||||
if (montauk::win_create(title, dd.win_w, dd.win_h, &wres) < 0 || wres.id < 0)
|
if (montauk::win_create(title, dd.win_w, dd.win_h, &wres) < 0 || wres.id < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ static bool handle_list_click(int mx, int my) {
|
|||||||
// Mouse handling (wheel, draggable scrollbar, clicks)
|
// Mouse handling (wheel, draggable scrollbar, clicks)
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static bool handle_main_mouse(const Montauk::WinEvent& ev) {
|
static bool handle_main_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
auto& de = g_state;
|
auto& de = g_state;
|
||||||
int mx = ev.mouse.x;
|
int mx = ev.mouse.x;
|
||||||
int my = ev.mouse.y;
|
int my = ev.mouse.y;
|
||||||
@@ -272,7 +272,7 @@ static bool handle_main_mouse(const Montauk::WinEvent& ev) {
|
|||||||
// Key handling
|
// Key handling
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static bool handle_key(const Montauk::KeyEvent& key) {
|
static bool handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return false;
|
if (!key.pressed) return false;
|
||||||
|
|
||||||
auto& de = g_state;
|
auto& de = g_state;
|
||||||
@@ -371,7 +371,7 @@ extern "C" void _start() {
|
|||||||
win.present();
|
win.present();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
bool redraw_main = false;
|
bool redraw_main = false;
|
||||||
bool redraw_detail = false;
|
bool redraw_detail = false;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ static void format_printer_detail(const ProbeState& probe,
|
|||||||
snprintf(out, (size_t)out_len, "Awaiting spooler probe");
|
snprintf(out, (size_t)out_len, "Awaiting spooler probe");
|
||||||
}
|
}
|
||||||
|
|
||||||
int append_printer_devices(Montauk::DevInfo* out, int max_count) {
|
int append_printer_devices(montauk::abi::DevInfo* out, int max_count) {
|
||||||
if (out == nullptr || max_count <= 0) return 0;
|
if (out == nullptr || max_count <= 0) return 0;
|
||||||
|
|
||||||
char current_uri[MAX_PATH_LEN] = {};
|
char current_uri[MAX_PATH_LEN] = {};
|
||||||
@@ -65,7 +65,7 @@ int append_printer_devices(Montauk::DevInfo* out, int max_count) {
|
|||||||
char uri_err[128] = {};
|
char uri_err[128] = {};
|
||||||
bool normalized_ok = normalize_ipp_uri(effective_uri, &normalized, uri_err, sizeof(uri_err));
|
bool normalized_ok = normalize_ipp_uri(effective_uri, &normalized, uri_err, sizeof(uri_err));
|
||||||
|
|
||||||
Montauk::DevInfo dev = {};
|
montauk::abi::DevInfo dev = {};
|
||||||
dev.category = CAT_PRINTER;
|
dev.category = CAT_PRINTER;
|
||||||
|
|
||||||
if (has_probe && probe.caps.printer_name[0]) {
|
if (has_probe && probe.caps.printer_name[0]) {
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ extern "C" void _start() {
|
|||||||
montauk::print("MontaukOS DHCP Client\n");
|
montauk::print("MontaukOS DHCP Client\n");
|
||||||
|
|
||||||
// 1. Get MAC address
|
// 1. Get MAC address
|
||||||
Montauk::NetCfg origCfg;
|
montauk::abi::NetCfg origCfg;
|
||||||
montauk::get_netcfg(&origCfg);
|
montauk::get_netcfg(&origCfg);
|
||||||
|
|
||||||
char macStr[32];
|
char macStr[32];
|
||||||
@@ -344,14 +344,14 @@ extern "C" void _start() {
|
|||||||
montauk::print(msg);
|
montauk::print(msg);
|
||||||
|
|
||||||
// 2. Set IP to 0.0.0.0 to allow broadcast send/receive
|
// 2. Set IP to 0.0.0.0 to allow broadcast send/receive
|
||||||
Montauk::NetCfg zeroCfg;
|
montauk::abi::NetCfg zeroCfg;
|
||||||
zeroCfg.ipAddress = 0;
|
zeroCfg.ipAddress = 0;
|
||||||
zeroCfg.subnetMask = 0;
|
zeroCfg.subnetMask = 0;
|
||||||
zeroCfg.gateway = 0;
|
zeroCfg.gateway = 0;
|
||||||
montauk::set_netcfg(&zeroCfg);
|
montauk::set_netcfg(&zeroCfg);
|
||||||
|
|
||||||
// 3. Create UDP socket and bind to port 68
|
// 3. Create UDP socket and bind to port 68
|
||||||
int fd = montauk::socket(Montauk::SOCK_UDP);
|
int fd = montauk::socket(montauk::abi::SOCK_UDP);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
montauk::print("Error: failed to create UDP socket\n");
|
montauk::print("Error: failed to create UDP socket\n");
|
||||||
montauk::set_netcfg(&origCfg);
|
montauk::set_netcfg(&origCfg);
|
||||||
@@ -399,7 +399,7 @@ extern "C" void _start() {
|
|||||||
}
|
}
|
||||||
uint64_t now = montauk::get_milliseconds();
|
uint64_t now = montauk::get_milliseconds();
|
||||||
if (now >= startMs + 10000) break;
|
if (now >= startMs + 10000) break;
|
||||||
montauk::wait_handle(fd, Montauk::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
montauk::wait_handle(fd, montauk::abi::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gotOffer) {
|
if (!gotOffer) {
|
||||||
@@ -451,7 +451,7 @@ extern "C" void _start() {
|
|||||||
}
|
}
|
||||||
uint64_t now = montauk::get_milliseconds();
|
uint64_t now = montauk::get_milliseconds();
|
||||||
if (now >= startMs + 10000) break;
|
if (now >= startMs + 10000) break;
|
||||||
montauk::wait_handle(fd, Montauk::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
montauk::wait_handle(fd, montauk::abi::IPC_SIGNAL_READABLE, startMs + 10000 - now);
|
||||||
}
|
}
|
||||||
|
|
||||||
montauk::closesocket(fd);
|
montauk::closesocket(fd);
|
||||||
@@ -463,7 +463,7 @@ extern "C" void _start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 8. Apply configuration
|
// 8. Apply configuration
|
||||||
Montauk::NetCfg newCfg;
|
montauk::abi::NetCfg newCfg;
|
||||||
newCfg.ipAddress = offer.offeredIp;
|
newCfg.ipAddress = offer.offeredIp;
|
||||||
newCfg.subnetMask = offer.subnetMask;
|
newCfg.subnetMask = offer.subnetMask;
|
||||||
newCfg.gateway = offer.router;
|
newCfg.gateway = offer.router;
|
||||||
|
|||||||
@@ -1047,7 +1047,7 @@ int file_field_mouse(mtk::TextInputState& input, const Rect& rect, char* buf, in
|
|||||||
focused, false, filter);
|
focused, false, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_file_mouse(const Montauk::WinEvent& ev) {
|
void handle_file_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
FileDialogState* st = &g_file;
|
FileDialogState* st = &g_file;
|
||||||
st->mouse_x = ev.mouse.x;
|
st->mouse_x = ev.mouse.x;
|
||||||
st->mouse_y = ev.mouse.y;
|
st->mouse_y = ev.mouse.y;
|
||||||
@@ -1159,7 +1159,7 @@ void handle_file_mouse(const Montauk::WinEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_file_key(const Montauk::KeyEvent& key) {
|
void handle_file_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return;
|
if (!key.pressed) return;
|
||||||
|
|
||||||
FileDialogState* st = &g_file;
|
FileDialogState* st = &g_file;
|
||||||
@@ -1234,11 +1234,11 @@ void draw() {
|
|||||||
draw_file_dialog();
|
draw_file_dialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_mouse(const Montauk::WinEvent& ev) {
|
void handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
handle_file_mouse(ev);
|
handle_file_mouse(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_key(const Montauk::KeyEvent& key) {
|
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
handle_file_key(key);
|
handle_file_key(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ constexpr int BUTTON_W = 88;
|
|||||||
|
|
||||||
void init(const gui::dialogs::Request& req);
|
void init(const gui::dialogs::Request& req);
|
||||||
void draw();
|
void draw();
|
||||||
void handle_mouse(const Montauk::WinEvent& ev);
|
void handle_mouse(const montauk::abi::WinEvent& ev);
|
||||||
void handle_key(const Montauk::KeyEvent& key);
|
void handle_key(const montauk::abi::KeyEvent& key);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
} // namespace filedialog
|
} // namespace filedialog
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ static constexpr uint8_t WIN_SCALE = 4;
|
|||||||
struct DialogCallbacks {
|
struct DialogCallbacks {
|
||||||
void (*draw)();
|
void (*draw)();
|
||||||
void (*on_close)();
|
void (*on_close)();
|
||||||
void (*handle_mouse)(const Montauk::WinEvent& ev);
|
void (*handle_mouse)(const montauk::abi::WinEvent& ev);
|
||||||
void (*handle_key)(const Montauk::KeyEvent& key);
|
void (*handle_key)(const montauk::abi::KeyEvent& key);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void run_dialog_loop(const DialogCallbacks& cb) {
|
static void run_dialog_loop(const DialogCallbacks& cb) {
|
||||||
@@ -44,7 +44,7 @@ static void run_dialog_loop(const DialogCallbacks& cb) {
|
|||||||
cb.draw();
|
cb.draw();
|
||||||
g_app.win.present();
|
g_app.win.present();
|
||||||
|
|
||||||
Montauk::WinEvent ev;
|
montauk::abi::WinEvent ev;
|
||||||
int rc = g_app.win.poll(&ev);
|
int rc = g_app.win.poll(&ev);
|
||||||
if (rc < 0) { cb.on_close(); break; }
|
if (rc < 0) { cb.on_close(); break; }
|
||||||
if (rc == 0) { montauk::sleep_ms(16); continue; }
|
if (rc == 0) { montauk::sleep_ms(16); continue; }
|
||||||
@@ -143,8 +143,8 @@ DIALOGS_EXPORT bool dialogs_run_request(const dlg::Request* request, dlg::Result
|
|||||||
}
|
}
|
||||||
|
|
||||||
void (*draw_fn)() = g_app.is_print ? printdialog::draw : filedialog::draw;
|
void (*draw_fn)() = g_app.is_print ? printdialog::draw : filedialog::draw;
|
||||||
void (*mouse_fn)(const Montauk::WinEvent&) = g_app.is_print ? printdialog::handle_mouse : filedialog::handle_mouse;
|
void (*mouse_fn)(const montauk::abi::WinEvent&) = g_app.is_print ? printdialog::handle_mouse : filedialog::handle_mouse;
|
||||||
void (*key_fn)(const Montauk::KeyEvent&) = g_app.is_print ? printdialog::handle_key : filedialog::handle_key;
|
void (*key_fn)(const montauk::abi::KeyEvent&) = g_app.is_print ? printdialog::handle_key : filedialog::handle_key;
|
||||||
|
|
||||||
draw_fn();
|
draw_fn();
|
||||||
g_app.win.present();
|
g_app.win.present();
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ void draw_message_box() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_message_mouse(const Montauk::WinEvent& ev) {
|
void handle_message_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
MessageBoxState* st = &g_message;
|
MessageBoxState* st = &g_message;
|
||||||
st->mouse_x = ev.mouse.x;
|
st->mouse_x = ev.mouse.x;
|
||||||
st->mouse_y = ev.mouse.y;
|
st->mouse_y = ev.mouse.y;
|
||||||
@@ -384,7 +384,7 @@ void handle_message_mouse(const Montauk::WinEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_message_key(const Montauk::KeyEvent& key) {
|
void handle_message_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return;
|
if (!key.pressed) return;
|
||||||
|
|
||||||
MessageBoxState* st = &g_message;
|
MessageBoxState* st = &g_message;
|
||||||
@@ -464,11 +464,11 @@ void draw() {
|
|||||||
draw_message_box();
|
draw_message_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_mouse(const Montauk::WinEvent& ev) {
|
void handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
handle_message_mouse(ev);
|
handle_message_mouse(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_key(const Montauk::KeyEvent& key) {
|
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
handle_message_key(key);
|
handle_message_key(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ constexpr int MAX_LINE_LEN = 128;
|
|||||||
void init(const char* message, uint8_t buttons, uint8_t default_choice = 0);
|
void init(const char* message, uint8_t buttons, uint8_t default_choice = 0);
|
||||||
void preferred_size(const char* title, int* out_w, int* out_h);
|
void preferred_size(const char* title, int* out_w, int* out_h);
|
||||||
void draw();
|
void draw();
|
||||||
void handle_mouse(const Montauk::WinEvent& ev);
|
void handle_mouse(const montauk::abi::WinEvent& ev);
|
||||||
void handle_key(const Montauk::KeyEvent& key);
|
void handle_key(const montauk::abi::KeyEvent& key);
|
||||||
void dismiss();
|
void dismiss();
|
||||||
uint8_t selected_choice();
|
uint8_t selected_choice();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ void print_submit(PrintDialogState* st) {
|
|||||||
dialog_finish("ok", "", job_id, msg, printer.uri, printer.name, st->copies);
|
dialog_finish("ok", "", job_id, msg, printer.uri, printer.name, st->copies);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_print_mouse(const Montauk::WinEvent& ev) {
|
void handle_print_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
PrintDialogState* st = &g_print;
|
PrintDialogState* st = &g_print;
|
||||||
st->mouse_x = ev.mouse.x;
|
st->mouse_x = ev.mouse.x;
|
||||||
st->mouse_y = ev.mouse.y;
|
st->mouse_y = ev.mouse.y;
|
||||||
@@ -456,7 +456,7 @@ void handle_print_mouse(const Montauk::WinEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_print_key(const Montauk::KeyEvent& key) {
|
void handle_print_key(const montauk::abi::KeyEvent& key) {
|
||||||
if (!key.pressed) return;
|
if (!key.pressed) return;
|
||||||
if (key.scancode == 0x01) {
|
if (key.scancode == 0x01) {
|
||||||
dialog_cancel();
|
dialog_cancel();
|
||||||
@@ -505,11 +505,11 @@ void draw() {
|
|||||||
draw_print_dialog();
|
draw_print_dialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_mouse(const Montauk::WinEvent& ev) {
|
void handle_mouse(const montauk::abi::WinEvent& ev) {
|
||||||
handle_print_mouse(ev);
|
handle_print_mouse(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_key(const Montauk::KeyEvent& key) {
|
void handle_key(const montauk::abi::KeyEvent& key) {
|
||||||
handle_print_key(key);
|
handle_print_key(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user