Tweak: Improved Documentation and README.MD

This commit is contained in:
boreddevnl
2026-03-17 17:40:00 +01:00
parent 1404a6ae4f
commit 5b10127e02
10 changed files with 177 additions and 122 deletions

View File

@@ -1,8 +1,13 @@
# Userland SDK Reference
<div align="center">
<h1>Userland SDK Reference</h1>
<p><em>Custom libc implementations and system calls in BoredOS.</em></p>
</div>
---
BoredOS provides a custom `libc` implementation necessary for writing userland applications (`.elf` binaries). By avoiding a full-blown standard library like `glibc`, the OS ensures a minimal executable footprint tailored strictly to the existing kernel features.
## The Custom libc Structure (`src/userland/libc/`)
## 🛠️ The Custom libc Structure (`src/userland/libc/`)
The SDK comprises a few key files containing wrappers around kernel system calls:
@@ -11,13 +16,14 @@ The SDK comprises a few key files containing wrappers around kernel system calls
- `syscall.h` / `syscall.c`: The raw interface to issue `syscall` assembly instructions, routing requests to the kernel.
- `libui.h` / `libui.c`: Graphical interface commands (creating windows, drawing pixels, events).
## System Calls Overview
## 🖧 System Calls Overview
When a userland application wants to interact with the hardware (print to screen, read a file, create a window), it must ask the kernel via a **System Call**.
In BoredOS (`x86_64`), system calls are issued using the `syscall` instruction. The kernel intercepts this instruction and inspects the processor's RAX register to figure out *what* the application wants to do.
The custom `libc` provides `syscallX` wrapper functions that abstract the assembly details:
```c
// Example: Performing a minimal system call from userland
int sys_write(int fd, const char *buf, int len) {
@@ -25,7 +31,7 @@ int sys_write(int fd, const char *buf, int len) {
}
```
### Notable System Calls
### 📌 Notable System Calls
- **`SYS_WRITE` (1)**: Currently acts as a generic output mechanism for `printf`, typically routing text to the kernel's serial output for debugging, or to an active text-mode console.
- **`SYS_GUI` (3)**: The primary multiplexer for all window manager operations. The arguments define subcommands (like `UI_CREATE_WINDOW`, `UI_FILL_RECT`).
@@ -33,4 +39,7 @@ int sys_write(int fd, const char *buf, int len) {
- **`SYS_EXIT` (60)**: Terminates the current process and returns control to the kernel.
- **`SYSTEM_CMD_YIELD` (43)**: Instructs the process scheduler to pause the current process and let another process run.
If you are developing a new application, **do not invoke syscalls manually**. Instead, include `stdlib.h` and use the C functions provided.
> [!IMPORTANT]
> If you are developing a new application, **do not invoke syscalls manually**. Instead, include `stdlib.h` and use the C functions provided.
---