Overview
TermuOS is a custom x86_64 operating system written primarily in C with low-level assembly components. The system uses the Limine bootloader protocol and contains a growing set of subsystems including:
Custom Kernel
Monolithic-style kernel architecture with modular subsystems.
Memory Management
Bitmap physical memory allocator, virtual memory manager, and heap system.
Filesystem Layer
Virtual filesystem abstraction with RAMFS and FAT32 support.
Desktop & Graphics
Framebuffer graphics engine with desktop and window management support.
Boot Process
TermuOS boots using the Limine boot protocol. The kernel requests services such as framebuffer access, memory maps, and higher-half direct mapping during startup.
LIMINE_BASE_REVISION(3);
static volatile struct limine_framebuffer_request fb_request = {
.id = LIMINE_FRAMEBUFFER_REQUEST,
.revision = 0
};
Kernel Architecture
The kernel initializes architecture-specific systems, memory management, graphics, networking, scheduling, shell services, and filesystem support.
| Subsystem | Description |
|---|---|
| IDT/GDT | x86_64 interrupt and descriptor table setup. |
| PIT | Programmable interval timer for scheduling. |
| Framebuffer | Graphics output system. |
| Input Drivers | Keyboard and mouse support. |
| Scheduler | Kernel task scheduling and context switching. |
Memory Management
TermuOS includes a bitmap-based physical memory manager. Each bit represents a 4KB page where:
- 0 = free page
- 1 = allocated page
#define PAGE_TO_BIT(p) ((p) / PAGE_SIZE)
#define BIT_IDX(bit) ((bit) / BITS_PER_ENTRY)
#define BIT_OFF(bit) ((bit) % BITS_PER_ENTRY)
The kernel also contains:
PMM
Physical page frame allocator.
VMM
Virtual memory paging system.
Heap
Kernel heap allocation system.
Scheduler
The scheduler subsystem manages multitasking and context switching. Assembly routines are used for low-level register switching between tasks.
Filesystem Layer
The filesystem subsystem uses a virtual filesystem abstraction layer. This allows multiple filesystem implementations to operate under a common API.
VFS
Path handling, node management, and abstraction layer.
RAMFS
In-memory filesystem implementation.
FAT32
FAT32 filesystem support and drivers.
static void vfs_strcpy(char *dst, const char *src, int max)
{
int i = 0;
while (src[i] && i < max - 1)
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
}
Shell
The TermuOS shell provides a command-line environment for interacting with kernel services. It supports command parsing, formatted output, filesystem interaction, and desktop integration.
| Feature | Description |
|---|---|
| Command Parsing | Tokenization and argument handling. |
| Filesystem Access | Commands for navigating the VFS. |
| Networking | Network utility integration. |
| Desktop Hooks | Ability to launch graphical interfaces. |
#define INPUT_MAX 256
#define MAX_ARGS 16
#define HOSTNAME "TermuOS"
#define USERNAME "root"
Graphics Engine
The graphics subsystem operates directly on the framebuffer. A software backbuffer is used for rendering before presenting frames to the display.
Framebuffer
Low-level pixel rendering.
Bitmap Support
Bitmap image rendering and loading.
Font Rendering
Embedded 8x8 bitmap font system.
#define MAX_W 1920
#define MAX_H 1080
static uint32_t backbuffer[MAX_W * MAX_H];
Desktop & Window Manager
TermuOS contains a desktop environment and a basic window manager subsystem. Applications can be managed through the wm/ and desktop/ modules.
Networking
The networking subsystem includes low-level packet handling, checksum generation, ARP management, and network interface abstractions.
uint16_t net_htons(uint16_t x)
{
return (x >> 8) | (x << 8);
}
Current networking modules:
- Network interface abstraction
- Packet buffer management
- ARP support
- Checksum generation
- Byte order conversion utilities
Userspace & Syscalls
The user subsystem contains syscall interfaces and userspace interaction layers. Assembly syscall stubs bridge low-level execution between kernel and userspace.
syscall.c
Kernel-side syscall handling.
syscall_asm.asm
Assembly syscall entry routines.
userspace.c
Userspace runtime integration.
Repository Layout
TermuOS/
├── kernel/
│ ├── arch/
│ ├── desktop/
│ ├── drivers/
│ ├── fs/
│ ├── gfx/
│ ├── lib/
│ ├── mm/
│ ├── net/
│ ├── sched/
│ ├── shell/
│ ├── user/
│ └── wm/
├── assets/
├── limine/
├── Makefile
└── limine.conf
Build Instructions
TermuOS is built using Clang, NASM, and the Limine bootloader.
make
Running in QEMU:
qemu-system-x86_64 -cdrom termuos.iso