feat: fix ramdisk file copies being incorrectly marked as directories, update man pages

This commit is contained in:
2026-07-09 11:19:06 +02:00
parent 4f2bc72dc9
commit 51bab1e62e
9 changed files with 793 additions and 117 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
.SH TLS SUPPORT
HTTPS connections use BearSSL for TLS 1.2. Server certificates
are validated against the system CA bundle at
0:/etc/ca-certificates.crt.
0:/os/certs/ca-certificates.crt.
Entropy for the TLS handshake is provided by RDTSC-seeded
random data via the SYS_GETRANDOM syscall.
+32 -15
View File
@@ -10,9 +10,11 @@
.BI int montauk::readdir(const char* path, const char** names, int max);
.SH DESCRIPTION
MontaukOS provides a simple read-only Virtual File System (VFS)
backed by the boot ramdisk. Files are accessed via paths in the
format "<drive>:/<path>", where drive 0 is the ramdisk.
MontaukOS provides a Virtual File System (VFS) with read/write
support. Drive 0 is the boot ramdisk; additional drives may be
mounted from GPT partitions backed by FAT32 or ext2 (see
syscalls(2), STORAGE section). Files are accessed via paths in
the format "<drive>:/<path>".
.SS open
Opens a file and returns a non-negative handle on success, or a
@@ -40,14 +42,19 @@
montauk::close(h);
.SS readdir
Lists entries in a directory. Up to 'max' entry names (max 64)
are written to the 'names' array. The kernel allocates a user-
accessible page for the string data automatically. Directory
entries are returned with a trailing slash.
Lists entries in a directory. Up to 'max' entry names (VFS cap
256, driver-backed listings such as 0:/os/ cap 128) are written
to the 'names' array. The kernel allocates a user-accessible
page for the string data automatically. Directory entries are
returned with a trailing slash.
const char* entries[64];
int count = montauk::readdir("0:/", entries, 64);
// entries: "os/", "games/", "man/", "www/", "home/"
// entries: "os/", "apps/", "man/", "www/", "users/", ...
For directories that may contain more entries than fit in one
call, use montauk::readdir_at(path, names, max, startIndex) and
advance startIndex by the returned count until it returns 0.
.SH READING PATTERN
The standard pattern for reading a file:
@@ -67,19 +74,29 @@
}
montauk::close(h);
.SH WRITING FILES
Files can be created and written on the ramdisk:
.SH WRITING, DELETING, RENAMING
.BI int montauk::fcreate(const char* path);
.BI int montauk::fwrite(int handle, const uint8_t* buf, uint64_t offset, uint64_t size);
.BI int montauk::fdelete(const char* path);
.BI int montauk::fmkdir(const char* path);
.BI int montauk::frename(const char* oldPath, const char* newPath);
fcreate creates a new file and returns a handle. fwrite writes
bytes at the given offset. Changes persist only until reboot --
the ramdisk is reloaded from the USTAR archive on each boot.
bytes at the given offset. fdelete removes a file, fmkdir
creates a directory, and frename renames or moves a file or
directory (the basis for file manager move operations).
On drive 0 (the ramdisk), changes persist only until reboot --
the ramdisk is reloaded from the USTAR archive on each boot. On
disk-backed drives (FAT32/ext2 partitions mounted with
montauk::fs_mount), changes are written through to storage; use
montauk::fs_sync() to flush caches before power-off.
.SH NOTES
All files live on the ramdisk which is loaded at boot from a
USTAR tar archive.
Drive 0 is loaded at boot from a USTAR tar archive into RAM.
Other drives are mounted on demand from GPT partitions on
SATA/NVMe/USB block devices; see syscalls(2), STORAGE and
DEVICES sections.
.SH SEE ALSO
syscalls(2), spawn(2), malloc(3)
+40 -17
View File
@@ -3,49 +3,68 @@
intro - introduction to MontaukOS userspace
.SH DESCRIPTION
MontaukOS is a hobbyist 64-bit operating system written in C++20.
Userspace programs run in Ring 3, are loaded as static ELF64
binaries, and communicate with the kernel through the x86-64
SYSCALL/SYSRET mechanism.
MontaukOS is a hobbyist 64-bit operating system written in C++20,
currently at version 0.1.7 (API version 8). Userspace programs
run in Ring 3, are loaded as static ELF64 binaries, and
communicate with the kernel through the x86-64 SYSCALL/SYSRET
mechanism (150 syscalls -- see syscalls(2)).
Programs are compiled with a freestanding cross-compiler and
linked at virtual address 0x400000. There is no standard C
library for C++ programs -- all system interaction goes through
the montauk:: syscall wrappers.
the montauk:: syscall wrappers. A desktop environment with a
window server, GUI apps, and Bluetooth/audio/networking stacks
runs on top of the same syscall API.
.SH GETTING STARTED
To write a new program, create a directory under programs/src/
with a main.cpp file. The entry point is:
To write a new system/CLI program, create a directory under
programs/src/ with a main.cpp file. The entry point is:
extern "C" void _start() { ... }
There is no argc/argv. Use montauk::getargs() to retrieve any
arguments passed by the parent process. Include <montauk/syscall.h>
for the full typed syscall API.
for the full typed syscall API. GUI apps additionally use
win_create()/win_poll()/win_present() from montauk/Window.hpp
(see framebuffer(2)).
Build with:
cd programs && make
The resulting ELF binary appears in programs/bin/os/.
System/CLI binaries appear in programs/bin/os/; GUI app bundles
(ELF + manifest.toml + icon) appear under programs/bin/apps/<name>/.
.SH RAMDISK LAYOUT
The boot ramdisk is mounted as drive 0 with the following
directory structure:
0:/os/ System binaries (shell, init, man, etc.)
0:/games/ Games (doom)
0:/os/ System/CLI binaries (shell, init, man, etc.),
plus os-owned data: certs/, firmware/,
licenses/, wallpapers/
0:/apps/ GUI app bundles, one directory per app
(<app>.elf + manifest.toml + icon)
0:/config/ System-wide config TOMLs
0:/users/<name>/ Per-user home directories (created at
login), with Music/, Videos/, Pictures/,
config/ subdirectories
0:/fonts/ Shared fonts
0:/icons/ Shared icons
0:/man/ Manual pages
0:/www/ Web server content
0:/common/ Shared assets (wallpapers, etc.)
0:/users/ Per-user home directories
0:/lib/ Lua and TinyCC toolchain payloads
0:/boot/ Kernel, bootloader, ramdisk image
There is no 0:/games/, 0:/common/, 0:/home/, or 0:/etc/ --
these were used by earlier single-user releases and no longer
exist. Games and other GUI programs (including doom) ship as
bundles under 0:/apps/.
.SH SHELL
The interactive shell is the primary way to interact with
MontaukOS. Commands are resolved by searching the PATH
directories (0:/os/, 0:/games/) for matching .elf binaries.
Type 'help' at the shell prompt for a list of commands.
Use 'man shell' for detailed shell documentation.
MontaukOS. Commands are resolved against the current directory
first, then 0:/os/. Type 'help' at the shell prompt for a list
of commands. Use 'man shell' for detailed shell documentation.
.SH MAN PAGES
The following man pages are available:
@@ -60,7 +79,11 @@
fontscale(1) Terminal font scaling
edit(1) Text editor
man(1) The man command itself
printctl(1) Printer control
printd(1) Print spooler daemon
wiki(1) Wikipedia article viewer
legal(7) Copyright and legal information
tls-errors(5) TLS/BearSSL error reference
syscalls(2) Overview of all syscalls
spawn(2) Process spawning
file(2) File I/O syscalls
+129 -43
View File
@@ -5,7 +5,8 @@
.SH DESCRIPTION
The MontaukOS shell is a command interpreter launched by init
after system services have started. It provides command
execution, file navigation, and command history.
execution, file navigation, shell variables, command chaining,
tab completion, and command history.
Commands are either shell builtins or external programs. When
a command is not a builtin, the shell searches for a matching
@@ -15,10 +16,16 @@
When a non-builtin command is entered, the shell searches for
a matching binary in the following order:
1. 0:/os/<command>.elf
2. 0:/games/<command>.elf
3. 0:/<cwd>/<command>.elf (if cwd is set)
4. 0:/<command>.elf
1. <cwd>/<command> (exact name, e.g. "hello.elf")
2. <cwd>/<command>.elf
3. 0:/os/<command>.elf
4. 0:/os/<command> (no extension)
5. If on a non-zero drive, the drive root: <drive>:/<command>[.elf]
A command containing a "/" (or an explicit drive prefix, or a
leading "." or "/") is instead treated as a direct path and
resolved by the kernel against the process CWD, trying the
path as-is and then with ".elf" appended.
The first match is spawned and the shell waits for it to exit.
If no match is found, the shell prints:
@@ -26,8 +33,7 @@
<command>: command not found
Arguments after the command name are passed to the spawned
process. File path arguments are resolved against the current
working directory before being passed to external programs.
process.
.SH BUILTINS
@@ -36,60 +42,140 @@
.SS ls [dir]
List files in the current directory, or in the specified
directory. When a directory argument is given, the output
shows only the entries inside that directory with the
directory prefix stripped. Directory entries are shown
with a trailing slash.
directory. Directory entries are shown with a trailing slash.
Examples: ls, ls man, ls os
.SS cd [dir]
Change the working directory. With no argument or with /,
returns to the root (0:/). Use cd .. to go up one level.
Trailing slashes on directory names are stripped.
Change the working directory. With no argument, returns to the
logged-in user's home directory (0:/users/<user>); with /,
returns to the drive root. Use cd .. to go up one level.
The shell prompt reflects the current directory.
Examples: cd os, cd .., cd
.SS pwd
Print the current working directory as an absolute path
(e.g. "0:/os").
.SS echo [-n] ...
Print the arguments. -n suppresses the trailing newline.
.SS set [VAR=value]
With no argument, list all shell variables (built-in and
user-defined). With VAR=value, set a variable. With a bare
name, print that variable's value.
.SS unset VAR
Remove a user-defined shell variable.
.SS true / false
Return exit status 0 / 1 without doing anything. Useful with
&& and ||.
.SS N:
A bare "<number>:" (e.g. "1:") switches the current drive to
drive N and resets the working directory to that drive's root.
.SS exit
Terminate the shell process.
Terminate the shell process (with the last command's exit code).
.SH SYNTAX
.SS Variables
NAME=value Set a shell variable (no leading $)
$VAR or ${VAR} Expand a variable's value
$? Exit status of the last command
$USER, $HOME, $PWD Built-in dynamic variables (session user,
home directory, current directory)
\e$ Escape a literal '$'
.SS Tilde expansion
A leading ~ expands to the session home directory
(0:/users/<user>) when followed by end-of-string, '/', or a
space.
.SS Command chaining
cmd1 ; cmd2 Run cmd2 unconditionally after cmd1
cmd1 && cmd2 Run cmd2 only if cmd1 succeeded (exit 0)
cmd1 || cmd2 Run cmd2 only if cmd1 failed (nonzero exit)
Single and double quotes protect ;, &&, and || from being
treated as separators.
.SS Comments
A '#' outside of quotes starts a comment; the rest of the line
is ignored.
.SH EXTERNAL COMMANDS
All external commands live in 0:/os/ (see COMMAND RESOLUTION).
Where a dedicated man page exists it is noted below; run
'man <command>' for details.
.SS System commands (0:/os/)
man <topic> View manual pages
cat <file> Display file contents
info Show system information
date Show current date and time
uptime Show system uptime
clear Clear the screen and framebuffer
fontscale [n] Get or set terminal font scale
reset Reboot the system
shutdown Shut down the system
.SS File commands
cat <file> Display file contents
edit [file] Text editor -- see edit(1)
copy <src> <dst> Copy a file
move <src> <dst> Move/rename a file
rm <file> Remove a file
touch <file> Create an empty file
.SS Network commands (0:/os/)
ping <host> Send ICMP echo requests
nslookup <host> DNS lookup
ifconfig Show/set network configuration
.SS System commands
man <topic> View manual pages -- see man(1)
whoami Print the current username
info / mtkfetch Show system information
date Show current date and time
uptime Show system uptime
proclist List running processes
power CPU power/thermal status (power [watch [secs]])
clear Clear the screen and framebuffer
fontscale [n] Get or set terminal font scale -- see fontscale(1)
lua Lua interpreter
tcc TinyCC (in-system C compiler)
reset Reboot the system
shutdown Shut down the system
.SS Network commands
ping <host> Send ICMP echo requests -- see ping(1)
nslookup <host> DNS lookup -- see nslookup(1)
ifconfig Show/set network configuration
tcpconnect <host> <port> Interactive TCP client
irc IRC client
dhcp DHCP client
fetch HTTP/HTTPS client (TLS 1.2)
wiki Wikipedia article viewer
httpd HTTP server
irc IRC client
dhcp DHCP client -- see dhcp(1)
fetch <url> HTTP/HTTPS client (TLS 1.2) -- see fetch(1)
wiki <title> Wikipedia article viewer -- see wiki(1)
httpd HTTP server
Network commands accept both IP addresses and hostnames.
Hostnames are resolved via the configured DNS server.
.SS Games (0:/games/)
doom DOOM
.SS Bluetooth
btlist List connected Bluetooth devices
btbonds List bonded (paired) Bluetooth devices
.SS Software-defined radio
sdr [freqMHz [rateHz]] Receive and report basic signal
statistics from an attached RTL-SDR dongle
GUI applications (window server programs, not run from the
shell prompt as text commands) live under 0:/apps/, one bundle
per app -- e.g. doom, terminal, texteditor, spreadsheet,
wordprocessor, paint, calculator, network, bluetooth, audio,
disks, devexplorer, procmgr, powermgr, printers, timezone,
weather, wikipedia. There is no 0:/games/ directory.
.SH TAB COMPLETION
Pressing Tab completes the word under the cursor against, in
order: executable names in 0:/os/, shell builtins, and file/
directory entries in the current directory. A single match is
completed inline; multiple matches are listed below the prompt.
.SH INPUT
The shell uses non-blocking keyboard input via SYS_GETKEY to
support arrow key detection. Lines are limited to 255
characters.
The shell uses non-blocking keyboard input via SYS_GETKEY (with
SYS_INPUT_WAIT to sleep between events) to support arrow key
detection. Lines are limited to 255 characters.
.SS Editing
Backspace Delete character before cursor
Enter Execute command
Tab Tab-complete the current word
Enter Execute the command line
.SS History
The shell stores the last 32 unique commands. Duplicate
@@ -99,11 +185,11 @@
Down Arrow Recall next command (or clear line)
.SH PROMPT
The prompt displays the current working directory:
The prompt displays the current drive and working directory:
0:/> _ (at root)
0:/> _ (at root of drive 0)
0:/os> _ (in os/ directory)
0:/man> _ (in man/ directory)
1:/> _ (at root of drive 1)
.SH SEE ALSO
man(1), intro(1), syscalls(2)
+3 -3
View File
@@ -19,12 +19,12 @@
int pid = montauk::spawn("0:/os/man.elf", "intro");
The new process gets its own PML4 page table, a 16 KiB stack
(at 0x7FFFFEF000-0x7FFFFFF000), and begins executing at the
The new process gets its own PML4 page table, a 32 KiB stack
(at 0x7FFFFF7000-0x7FFFFFF000), and begins executing at the
ELF entry point (_start).
Returns the new process's PID on success, or -1 on failure.
Failure occurs when there are no free process slots (max 16),
Failure occurs when there are no free process slots (max 256),
the file cannot be found, or the ELF is invalid.
.SS waitpid
+578 -36
View File
@@ -3,9 +3,10 @@
syscalls - overview of MontaukOS system calls
.SH DESCRIPTION
MontaukOS provides 46 system calls (numbers 0-45) for userspace
programs. Syscalls use the x86-64 SYSCALL instruction with the
following register convention:
MontaukOS provides 150 system calls (numbers 0-149, sparsely
assigned -- not every number in the range is in use) for
userspace programs. Syscalls use the x86-64 SYSCALL instruction
with the following register convention:
RAX Syscall number (in) / return value (out)
RDI Argument 1
@@ -15,13 +16,15 @@
R8 Argument 5
R9 Argument 6
Include <montauk/syscall.h> for typed wrappers in the montauk::
namespace.
Include <Api/Syscall.hpp> for the numeric SYS_* constants and
ABI structs, and <montauk/syscall.h> for typed wrappers in the
montauk:: namespace. This page groups syscalls the same way the
kernel source does (one subsystem header per group).
.SH PROCESS MANAGEMENT
.B SYS_EXIT (0)
Terminate the calling process.
void montauk::exit(int code = 0);
[[noreturn]] void montauk::exit(int code = 0);
.B SYS_YIELD (1)
Yield the remainder of the time slice.
@@ -43,6 +46,61 @@
Block until the given process has exited.
void montauk::waitpid(int pid);
.B SYS_GETARGS (25)
Get the argument string passed to this process at spawn time.
int montauk::getargs(char* buf, uint64_t maxLen);
.B SYS_PROCLIST (61)
List running processes (pid, parent, state, name, heap usage,
accumulated CPU time).
int montauk::proclist(montauk::abi::ProcInfo* buf, int max);
.B SYS_KILL (62)
Terminate another process by PID.
int montauk::kill(int pid);
.B SYS_CHDIR (96)
Change the calling process's current working directory.
int montauk::chdir(const char* path);
.B SYS_GETCWD (95)
Get the calling process's current working directory.
int montauk::getcwd(char* buf, uint64_t maxLen);
.B SYS_SETUSER (92)
Associate a process with a logged-in user name (used by login/session
management).
int montauk::setuser(int pid, const char* name);
.B SYS_GETUSER (93)
Get the user name associated with the calling process.
int montauk::getuser(char* buf, uint64_t maxLen);
.SH THREADING
Threads share the spawning process's address space and heap
(see montauk/heap.h for the heap lock). Declared in
montauk/thread.h.
.B SYS_THREAD_SPAWN (130)
Spawn a new thread in the calling process. Returns a positive
TID on success, -1 on failure.
int montauk::thread_spawn(ThreadEntry entry, void* arg,
uint64_t stack_bytes = 0);
.B SYS_THREAD_EXIT (131)
Terminate only the calling thread. If it is the main thread,
the whole process exits.
[[noreturn]] void montauk::thread_exit(int code = 0);
.B SYS_THREAD_JOIN (132)
Block until the given TID exits, then reclaim its kernel state.
int montauk::thread_join(int tid, int* out_code = nullptr);
.B SYS_THREAD_SELF (133)
Return the calling thread's TID (equals getpid() for the main
thread).
int montauk::thread_self();
.SH CONSOLE I/O
.B SYS_PRINT (4)
Write a null-terminated string to the terminal.
@@ -70,9 +128,55 @@
void montauk::close(int handle);
.B SYS_READDIR (10)
List directory entries (max 64 per call).
List directory entries (max 256 per call for VFS directories,
128 for driver-backed listings such as 0:/os/). For larger
directories use SYS_READDIR_AT.
int montauk::readdir(const char* path, const char** names, int max);
.B SYS_READDIR_AT (136)
Paginated directory read. Returns entries starting at
startIndex; call repeatedly with startIndex advanced by the
returned count until it returns 0 to enumerate directories of
any size.
int montauk::readdir_at(const char* path, const char** names,
int max, int startIndex);
.B SYS_FWRITE (41)
Write bytes to a file at a given offset.
int montauk::fwrite(int handle, const uint8_t* buf,
uint64_t offset, uint64_t size);
.B SYS_FCREATE (42)
Create a new file on the target volume. Returns a handle or
negative on error.
int montauk::fcreate(const char* path);
.B SYS_FDELETE (77)
Delete a file.
int montauk::fdelete(const char* path);
.B SYS_FMKDIR (78)
Create a directory.
int montauk::fmkdir(const char* path);
.B SYS_FRENAME (94)
Rename or move a file/directory (used as the basis for file
manager move operations).
int montauk::frename(const char* oldPath, const char* newPath);
.B SYS_DRIVELIST (79)
List mounted drive numbers.
int montauk::drivelist(int* outDrives, int max);
.B SYS_DRIVELABEL (124)
Get the volume label of a drive.
int montauk::drivelabel(int drive, char* outLabel, int maxLen);
.B SYS_DRIVEKIND (127)
Get the block device kind backing a drive: 0=unknown/ramdisk,
1=SATA, 2=SATAPI, 3=NVMe, 4=USB mass storage.
int montauk::drivekind(int drive);
.SH MEMORY
.B SYS_ALLOC (11)
Map zeroed pages into the process address space.
@@ -82,6 +186,11 @@
Reserved (currently a no-op).
void montauk::free(void* ptr);
.B SYS_MEMSTATS (67)
Get kernel-wide physical memory usage (total/free/used bytes,
page size).
void montauk::memstats(montauk::abi::MemStats* out);
.SH TIMEKEEPING
.B SYS_GETTICKS (13)
Get APIC timer ticks since boot.
@@ -97,9 +206,18 @@
Hour, Minute, and Second fields.
void montauk::gettime(montauk::abi::DateTime* out);
.B SYS_SETTZ (90)
Set the process/system timezone offset, in minutes from UTC.
void montauk::settz(int offset_minutes);
.B SYS_GETTZ (91)
Get the current timezone offset, in minutes from UTC.
int montauk::gettz();
.SH SYSTEM
.B SYS_GETINFO (15)
Get OS name, version, and configuration.
Get OS name, version string, API version, max process count,
and the monotonic kernel build number.
void montauk::get_info(montauk::abi::SysInfo* info);
.SH KEYBOARD
@@ -115,10 +233,34 @@
Block until a printable character is typed.
char montauk::getchar();
.B SYS_INPUT_WAIT (123)
Block until the input serial number differs from
observedSerial or the timeout elapses; used to sleep
efficiently between input-driven redraws.
uint64_t montauk::input_wait(uint64_t observedSerial, uint64_t timeoutMs);
.SH MOUSE
.B SYS_MOUSESTATE (47)
Get the current mouse position, scroll delta, and button mask.
void montauk::mouse_state(montauk::abi::MouseState* out);
.B SYS_SETMOUSEBOUNDS (48)
Set the maximum X/Y the mouse cursor may reach (e.g. framebuffer
dimensions).
void montauk::set_mouse_bounds(int32_t maxX, int32_t maxY);
.SH NETWORKING
.B SYS_PING (19)
Send an ICMP echo request and wait for reply.
int32_t montauk::ping(uint32_t ip, uint32_t timeoutMs);
int32_t montauk::ping(uint32_t ip, uint32_t timeoutMs = 3000);
.B SYS_RESOLVE (44)
Resolve a hostname to an IPv4 address via DNS. Sends a UDP
query to the configured DNS server and waits up to 5 seconds
for a reply. Returns the IP in network byte order, or 0 on
failure. IP address strings (e.g. "10.0.0.1") are detected
and returned directly without a DNS query.
uint32_t montauk::resolve(const char* hostname);
.B SYS_GETNETCFG (37)
Get the current network configuration (IP, mask, gateway, MAC,
@@ -134,14 +276,6 @@
and RX/TX packet counters.
int montauk::net_status(montauk::abi::NetStatus* out);
.B SYS_RESOLVE (44)
Resolve a hostname to an IPv4 address via DNS. Sends a UDP
query to the configured DNS server and waits up to 5 seconds
for a reply. Returns the IP in network byte order, or 0 on
failure. IP address strings (e.g. "10.0.0.1") are detected
and returned directly without a DNS query.
uint32_t montauk::resolve(const char* hostname);
.SH SOCKETS
.B SYS_SOCKET (29)
Create a socket. type=SOCK_TCP (1) or SOCK_UDP (2).
@@ -188,24 +322,13 @@
int montauk::recvfrom(int fd, void* buf, uint32_t maxLen,
uint32_t* srcIp, uint16_t* srcPort);
.SH FILE WRITE
.B SYS_FWRITE (41)
Write bytes to a file at a given offset.
int montauk::fwrite(int handle, const uint8_t* buf,
uint64_t offset, uint64_t size);
.B SYS_FCREATE (42)
Create a new file on the ramdisk. Returns a handle or negative
on error.
int montauk::fcreate(const char* path);
.SH FRAMEBUFFER
.B SYS_FBINFO (21)
Get framebuffer dimensions and format.
void montauk::fb_info(montauk::abi::FbInfo* info);
.B SYS_FBMAP (22)
Map the framebuffer into process memory at 0x50000000.
Map the framebuffer into process memory.
void* montauk::fb_map();
.SH TERMINAL
@@ -221,11 +344,6 @@
void montauk::termscale(int scale_x, int scale_y);
void montauk::get_termscale(int* scale_x, int* scale_y);
.SH ARGUMENTS
.B SYS_GETARGS (25)
Get the argument string passed to this process at spawn time.
int montauk::getargs(char* buf, uint64_t maxLen);
.SH RANDOM
.B SYS_GETRANDOM (45)
Fill a buffer with random bytes using RDTSC-seeded entropy.
@@ -238,8 +356,432 @@
[[noreturn]] void montauk::reset();
.B SYS_SHUTDOWN (27)
Shut down the system (currently unimplemented).
Shut down the system.
[[noreturn]] void montauk::shutdown();
.B SYS_SUSPEND (89)
Enter ACPI S3 sleep. Returns after wake, 0 on success.
int montauk::suspend();
.B SYS_POWER_REQUEST (135)
Cross-process graceful power-off request channel. The desktop
posts a pending action (POWER_REQ_SHUTDOWN / POWER_REQ_REBOOT)
then exits; login.elf reads it with POWER_REQ_QUERY
(read-and-clear), runs the shutdown stages, and finally calls
shutdown()/reset(). See montauk::abi::PowerRequestAction.
int montauk::power_request(int action);
.B SYS_POWERINFO (149)
Get the CPU power/thermal snapshot (HWP state, throttling,
package temperature, base/max/effective frequency). Returns 0
on success, -1 if unsupported by the running hardware.
int montauk::syscall1(SYS_POWERINFO, (uint64_t)&out);
// out: montauk::abi::PowerInfo*
.SH KERNEL LOG
.B SYS_KLOG (46)
Read from the kernel ring log buffer.
int64_t montauk::read_klog(char* buf, uint64_t size);
.SH I/O REDIRECTION
Used by the terminal app and similar programs to run a child
process with its console I/O captured instead of going directly
to the framebuffer console.
.B SYS_SPAWN_REDIR (49)
Spawn a process with its console I/O redirected to the caller.
int montauk::spawn_redir(const char* path, const char* args = nullptr);
.B SYS_CHILDIO_READ (50)
Read buffered output produced by a redirected child.
int montauk::childio_read(int childPid, char* buf, int maxLen);
.B SYS_CHILDIO_WRITE (51)
Write text input to a redirected child's stdin.
int montauk::childio_write(int childPid, const char* data, int len);
.B SYS_CHILDIO_WRITEKEY (52)
Forward a raw key event to a redirected child.
int montauk::childio_writekey(int childPid, const montauk::abi::KeyEvent* key);
.B SYS_CHILDIO_SETTERMSZ (53)
Tell a redirected child its terminal dimensions changed.
int montauk::childio_settermsz(int childPid, int cols, int rows);
.SH WINDOW SERVER
Window server syscalls are used by GUI programs to create and
drive an on-screen window (see montauk/Window.hpp for the
higher-level win_create/win_poll/win_present wrappers built on
top of these).
.B SYS_WINCREATE (54)
Create a window and get its pixel buffer.
int montauk::win_create(const char* title, int w, int h,
montauk::abi::WinCreateResult* result);
.B SYS_WINDESTROY (55)
Destroy a window.
int montauk::win_destroy(int id);
.B SYS_WINPRESENT (56)
Flush the pixel buffer to the screen.
uint64_t montauk::win_present(int id);
.B SYS_WINPOLL (57)
Poll the next event (key, mouse, resize, close, scale) for a
window.
int montauk::win_poll(int id, montauk::abi::WinEvent* event);
.B SYS_WINENUM (58)
Enumerate all windows currently managed by the window server.
int montauk::win_enumerate(montauk::abi::WinInfo* info, int max);
.B SYS_WINMAP (59)
Map (or re-map) a window's pixel buffer into the caller's
address space.
uint64_t montauk::win_map(int id);
.B SYS_WINUNMAP (97)
Unmap a window's pixel buffer from the caller's address space.
int montauk::win_unmap(int id);
.B SYS_WINSENDEVENT (60)
Inject an event into a window's event queue.
int montauk::win_sendevent(int id, const montauk::abi::WinEvent* event);
.B SYS_WINRESIZE (64)
Resize a window and its pixel buffer.
uint64_t montauk::win_resize(int id, int w, int h);
.B SYS_WINSETSCALE (65)
Set the desktop-wide UI scale factor.
int montauk::win_setscale(int scale);
.B SYS_WINGETSCALE (66)
Get the desktop-wide UI scale factor.
int montauk::win_getscale();
.B SYS_WINSETCURSOR (68)
Set the mouse cursor shown while over a window (0=arrow,
1=resize_h, 2=resize_v).
int montauk::win_setcursor(int id, int cursor);
.B SYS_WINSETFLAGS (126)
Set window flags (e.g. WIN_FLAG_FULLSCREEN).
int montauk::win_setflags(int id, uint32_t flags);
.SH DEVICES
.B SYS_DEVLIST (63)
Enumerate detected devices (CPU, interrupts, timers, input,
USB, network, display, storage, PCI, audio, ACPI) for the
device explorer app.
int montauk::devlist(montauk::abi::DevInfo* buf, int max);
.B SYS_DISKINFO (69)
Get detailed info for one block device (model, serial, sector
size, NCQ/TRIM/SMART support, etc.).
int montauk::diskinfo(montauk::abi::DiskInfo* buf, int port);
.SH STORAGE
.B SYS_PARTLIST (70)
Enumerate GPT partitions across all block devices.
int montauk::partlist(montauk::abi::PartInfo* buf, int max);
.B SYS_DISKREAD (71)
Raw, driver-agnostic sector read from a block device.
int64_t montauk::disk_read(int blockDev, uint64_t lba,
uint32_t sectorCount, void* buf);
.B SYS_DISKWRITE (72)
Raw, driver-agnostic sector write to a block device.
int64_t montauk::disk_write(int blockDev, uint64_t lba,
uint32_t sectorCount, const void* buf);
.B SYS_GPTINIT (73)
Initialize a fresh GPT partition table on a block device.
int montauk::gpt_init(int blockDev);
.B SYS_GPTADD (74)
Add a partition to an existing GPT table.
int montauk::gpt_add(const montauk::abi::GptAddParams* params);
.B SYS_FSMOUNT (75)
Mount a partition's filesystem onto a drive number.
int montauk::fs_mount(int partIndex, int driveNum);
.B SYS_FSFORMAT (76)
Format a partition with a filesystem (FS_TYPE_FAT32 or
FS_TYPE_EXT2).
int montauk::fs_format(const montauk::abi::FsFormatParams* params);
.B SYS_FS_SYNC (134)
Flush all block-device write caches and cleanly unmount
disk-backed volumes ahead of power-off. Returns the number of
volumes unmounted. Part of the graceful shutdown sequence
(see SYS_POWER_REQUEST).
int montauk::fs_sync();
.SH AUDIO
.B SYS_AUDIOOPEN (80)
Open a mixer output stream at the given sample rate, channel
count, and bit depth. Returns a stream handle.
int montauk::audio_open(uint32_t sampleRate, uint8_t channels,
uint8_t bitsPerSample);
.B SYS_AUDIOCLOSE (81)
Close an audio stream.
void montauk::audio_close(int handle);
.B SYS_AUDIOWRITE (82)
Write PCM samples to an audio stream.
int montauk::audio_write(int handle, const void* data, uint32_t size);
.B SYS_AUDIOCTL (83)
Control an audio stream or the global mixer. Commands 0-3 act
on the stream named by the handle argument; commands 4-12 act
on that stream's routing/mute state or the global master and
ignore or reuse the handle as documented below.
int montauk::audio_ctl(int handle, int cmd, int value);
Convenience wrappers (all thin calls onto audio_ctl):
audio_set_volume, audio_get_volume AUDIO_CTL_{SET,GET}_VOLUME (0/1)
audio_get_pos AUDIO_CTL_GET_POS (2)
audio_pause, audio_resume AUDIO_CTL_PAUSE (3)
audio_get_output AUDIO_CTL_GET_OUTPUT (4): 0=HDA, 1=Bluetooth
(SET_OUTPUT, 5) switch a stream's output route
audio_bt_status AUDIO_CTL_BT_STATUS (6)
audio_set_master_volume, _get_ AUDIO_CTL_{SET,GET}_MASTER_VOLUME (7/8), 0-100
audio_set_mute, audio_get_mute AUDIO_CTL_{SET,GET}_MUTE (9/10), per-stream
audio_set_master_mute, _get_ AUDIO_CTL_{SET,GET}_MASTER_MUTE (11/12)
.B SYS_AUDIOLIST (128)
Enumerate active mixer streams (owner PID, name, format,
volume, mute/pause state).
int montauk::audio_list(montauk::abi::AudioStreamInfo* buf, int maxCount);
.B SYS_AUDIOWAIT (129)
Return the current mixer state serial. With timeoutMs > 0,
blocks until the serial differs from prevSerial or the timeout
elapses; with timeoutMs == 0 it returns immediately.
uint64_t montauk::audio_wait(uint64_t prevSerial, uint64_t timeoutMs);
.SH BLUETOOTH
.B SYS_BTSCAN (84)
Scan for discoverable Bluetooth devices for up to timeoutMs.
int montauk::bt_scan(montauk::abi::BtScanResult* buf, int maxCount,
uint32_t timeoutMs);
.B SYS_BTCONNECT (85)
Connect (and pair/bond if needed) to a device by BD_ADDR.
int montauk::bt_connect(const uint8_t* bdAddr);
.B SYS_BTDISCONNECT (86)
Disconnect from a device by BD_ADDR.
int montauk::bt_disconnect(const uint8_t* bdAddr);
.B SYS_BTLIST (87)
List currently connected devices.
int montauk::bt_list(montauk::abi::BtDevInfo* buf, int maxCount);
.B SYS_BTINFO (88)
Get local adapter info (BD_ADDR, name, init/scanning state).
int montauk::bt_info(montauk::abi::BtAdapterInfo* buf);
.B SYS_BTSETADDR (137)
Change the adapter's BD_ADDR (6-byte buffer, byte 0 is the
least-significant octet). Volatile -- apply after the last
controller reset and persist separately to bluetooth.toml.
int montauk::bt_set_addr(const uint8_t* bdAddr);
.B SYS_BTBONDS (138)
List bonded (paired) devices.
int montauk::bt_bonds(montauk::abi::BtBondInfo* buf, int maxCount);
.B SYS_BTFORGET (139)
Forget a paired device; it must re-pair next time.
int montauk::bt_forget(const uint8_t* bdAddr);
.SH SOFTWARE-DEFINED RADIO
Receive-only SDR API. Receivers are enumerated by index in
[0, SYS_SDR_COUNT); SYS_SDR_OPEN returns a handle used by the
rest of the calls. Samples are delivered as interleaved 8-bit
unsigned I/Q (CU8, SDR_FORMAT_CU8) from the device's ring
buffer. Backed by an RTL-SDR (RTL2832U + R820T2) driver.
.B SYS_SDR_COUNT (140)
Number of available SDR receivers.
int montauk::sdr_count();
.B SYS_SDR_INFO (141)
Get static/dynamic info for one receiver by index (name, tuner,
frequency/sample-rate ranges, gain steps, present/streaming
flags).
int montauk::sdr_info(int index, montauk::abi::SdrDeviceInfo* out);
.B SYS_SDR_OPEN (142)
Open a receiver by index. Returns a handle.
int montauk::sdr_open(int index);
.B SYS_SDR_CLOSE (143)
Close a receiver handle.
int montauk::sdr_close(int handle);
.B SYS_SDR_START (144)
Begin streaming samples.
int montauk::sdr_start(int handle);
.B SYS_SDR_STOP (145)
Stop streaming samples.
int montauk::sdr_stop(int handle);
.B SYS_SDR_READ (146)
Non-blocking read of queued I/Q samples. Returns bytes copied.
int montauk::sdr_read(int handle, void* buf, uint32_t len);
.B SYS_SDR_SETPARAM (147)
Set a tunable parameter (see SDR_PARAM_* below).
int montauk::sdr_set_param(int handle, int param, uint64_t value);
.B SYS_SDR_GETPARAM (148)
Get a tunable parameter's current value.
int64_t montauk::sdr_get_param(int handle, int param);
Parameters (montauk::abi::SDR_PARAM_*): FREQ (center frequency,
Hz), SAMPLE_RATE (Hz), GAIN_MODE (0=auto/AGC, 1=manual), GAIN
(tenths of dB), FREQ_CORR (ppm), AGC (demod digital AGC, 0/1),
DIRECT_SAMP (0=off, 1=I, 2=Q). Convenience wrappers exist for
each: sdr_set_freq/sdr_get_freq, sdr_set_sample_rate/
sdr_get_sample_rate, sdr_set_gain_mode, sdr_set_gain,
sdr_set_freq_correction, sdr_set_agc.
.SH CLIPBOARD
.B SYS_CLIPBOARD_SET_TEXT (119)
Set the system clipboard's text contents (max
CLIPBOARD_MAX_TEXT_BYTES, 256 KiB).
int montauk::clipboard_set_text(const char* data, uint32_t len);
.B SYS_CLIPBOARD_GET_INFO (120)
Get the clipboard's current size and serial number (for
change detection).
int montauk::clipboard_get_info(montauk::abi::ClipboardInfo* out);
.B SYS_CLIPBOARD_GET_TEXT (121)
Read the clipboard's text contents.
int montauk::clipboard_get_text(char* buf, uint32_t bufLen,
uint32_t* outLen, uint64_t* outSerial = nullptr);
.B SYS_CLIPBOARD_CLEAR (122)
Clear the clipboard.
int montauk::clipboard_clear();
.SH GENERIC IPC
Handle-based IPC primitives underlying streams, mailboxes,
waitsets, and shared-memory surfaces (see kernel/src/Ipc/Ipc.hpp).
All are accessed via numeric handles with rights-based security
and can be waited on with SYS_WAIT_HANDLE or a waitset.
.B SYS_DUPHANDLE (98)
Duplicate a handle (e.g. to hand a copy to a child process).
int montauk::dup_handle(int handle);
.B SYS_WAIT_HANDLE (99)
Block until a handle's signals intersect wantedSignals, or
timeoutMs elapses. See IPC_SIGNAL_* (READABLE, WRITABLE,
PEER_CLOSED, EXITED, READY).
uint32_t montauk::wait_handle(int handle, uint32_t wantedSignals,
uint64_t timeoutMs = ~0ULL);
.B SYS_STREAM_CREATE (100)
Create a byte-pipe stream, returning a read handle and a write
handle.
int montauk::stream_create(int* outReadHandle, int* outWriteHandle,
uint32_t capacity = 0);
.B SYS_STREAM_READ (101)
Read bytes from a stream handle.
int montauk::stream_read(int handle, void* buf, int maxLen);
.B SYS_STREAM_WRITE (102)
Write bytes to a stream handle.
int montauk::stream_write(int handle, const void* data, int len);
.B SYS_MAILBOX_CREATE (103)
Create a message-queue mailbox, returning a send handle and a
receive handle.
int montauk::mailbox_create(int* outSendHandle, int* outRecvHandle);
.B SYS_MAILBOX_SEND (104)
Send a typed message, optionally attaching a handle to
transfer to the receiver.
int montauk::mailbox_send(int handle, uint32_t msgType, const void* data,
uint16_t len, int attachHandle = -1);
.B SYS_MAILBOX_RECV (105)
Receive a message.
int montauk::mailbox_recv(int handle, uint32_t* outMsgType, void* data,
uint16_t* inOutLen, int* outAttachHandle = nullptr);
.B SYS_WAITSET_CREATE (106)
Create a waitset for multiplexing waits across many handles.
int montauk::waitset_create();
.B SYS_WAITSET_ADD (107)
Add a handle and its signal mask to a waitset.
int montauk::waitset_add(int waitsetHandle, int targetHandle,
uint32_t signals);
.B SYS_WAITSET_REMOVE (108)
Remove an entry from a waitset by index.
int montauk::waitset_remove(int waitsetHandle, int index);
.B SYS_WAITSET_WAIT (109)
Block until any member handle's watched signals fire, or
timeoutMs elapses.
int montauk::waitset_wait(int waitsetHandle, montauk::abi::IpcWaitResult* outReady,
uint64_t timeoutMs = ~0ULL);
.B SYS_PROC_OPEN (110)
Open a handle to another process by PID (for waiting on its
exit via IPC_SIGNAL_EXITED, etc.).
int montauk::proc_open(int pid);
.B SYS_SURFACE_CREATE (111)
Create a shared pixel-buffer surface of byteSize bytes.
int montauk::surface_create(uint64_t byteSize);
.B SYS_SURFACE_MAP (112)
Map a surface into the caller's address space.
void* montauk::surface_map(int handle);
.B SYS_SURFACE_RESIZE (113)
Resize a surface.
int montauk::surface_resize(int handle, uint64_t newSize);
.SH SHARED LIBRARIES
.B SYS_LOAD_LIB (114)
Load a shared library ELF (.lib) into the caller's address
space.
int montauk::load_lib(const char* path);
.B SYS_UNLOAD_LIB (115)
Unload a previously loaded library.
int montauk::unload_lib(int handle);
.B SYS_DLSYM (116)
Resolve a symbol offset within a loaded library to a callable
address.
void* montauk::dlsym(int handle, uint64_t symbolOffset);
.B SYS_GETLIBBASE (117)
Get the base virtual address a loaded library was mapped at.
uint64_t montauk::get_libbase(int handle);
.SH CRASH REPORTING
.B SYS_CRASH_REPORT (118)
Retrieve the kernel-filled crash report for the last faulting
process (exception vector/name, faulting address, register
state, page-fault error bits). Used by the crashpad app.
int montauk::crash_report(montauk::abi::CrashReportInfo* out);
.SH SEE ALSO
spawn(2), file(2), framebuffer(2), malloc(3)
spawn(2), file(2), framebuffer(2), malloc(3), intro(1)
+1 -1
View File
@@ -40,7 +40,7 @@
.SH TLS SUPPORT
Connections use BearSSL for TLS 1.2. Server certificates
are validated against the system CA bundle at
0:/etc/ca-certificates.crt.
0:/os/certs/ca-certificates.crt.
.SH KEYBOARD