Repository navigation
4.3 System Call Interface
Relevant source files
- src/kernel/conductor.zig
- src/kernel/drivers/mouse.zig
- src/kernel/interrupts/irq_stubs.asm
- src/kernel/scheduler.zig
- src/kernel/security.zig
- src/kernel/syscall.zig
- src/kernel/system.zig
- src/kernel/vitals.zig
This section details the CadenzaOS system call interface, which establishes a controlled privilege boundary between ring-3 user tasks and ring-0 kernel services. The architecture relies on the x86 software interrupt gateway (int 0x80), low-level register preservation via assembly context stubs (isr80_stub), a Zig-based dispatch multiplexer (src/kernel/syscall.zig), behavioral telemetry integration with the Conductor (src/kernel/conductor.zig), and traffic validation via src/kernel/security.zig.
Sources: src/kernel/interrupts/irq_stubs.asm1-348, src/kernel/syscall.zig1-127, src/kernel/security.zig1-36
User tasks invoke system services by triggering software interrupt vector 0x80. The Interrupt Descriptor Table (IDT) routes this vector to the assembly stub isr80_stub defined in src/kernel/interrupts/irq_stubs.asm.
When isr80_stub executes, it preserves the general-purpose registers onto the task stack, matching the layout defined by TaskContextsrc/kernel/scheduler.zig56-62. It then passes a pointer to this register frame in rdi to the kernel dispatch handler (syscall_handler), switches stacks according to the returned execution context, and resumes execution via iretqsrc/kernel/interrupts/irq_stubs.asm161-204.

Sources: src/kernel/interrupts/irq_stubs.asm161-204, [src/kernel/scheduler.zig:56-62], src/kernel/syscall.zig25-127
The kernel dispatch logic is implemented within src/kernel/syscall.zig. The SyscallID enumeration defines the supported numeric service identifiers: WRITE_TEXT, GET_TEMPO, and RECORD_HABITsrc/kernel/syscall.zig18-23.
-
WRITE_TEXT(0): Interpretsarg1as a pointer to a UTF-8 character buffer andarg2as the length, writing strings viavga.writeStringsrc/kernel/syscall.zig42-49. -
GET_TEMPO(1): Queries and returns the active Conductor state enumeration fromconductor.current_statesrc/kernel/syscall.zig57-59. -
RECORD_HABIT(2): Receives previous and current command identifiers inarg1andarg2, evaluates transition scores against the Conductor transition matrix, updates learning weights, and returns anomaly detection indicators src/kernel/syscall.zig76-125.
Additionally, the kernel provisions a physical scratch page (SCRATCH_PAGE_PHYS at address 0x7000) to support binary loading and temporary staging operations during task initialization src/kernel/scheduler.zig21-23.

Sources: src/kernel/syscall.zig18-127, src/kernel/scheduler.zig21-23, src/kernel/conductor.zig24-33
Before processing sensitive input or inter-task communication payloads, CadenzaOS invokes lightweight pattern-matching routines via src/kernel/security.zig. The inspectTraffic function inspects byte buffers against a static array of MaliciousPatterns—such as NOP-sled signatures (\x90\x90\x90) and directory traversal sequences (../../) src/kernel/security.zig10-36.
If a signature matches, the inspection fails and the kernel rejects the operation, protecting system integrity against malformed inputs and injection attempts.
Sources: src/kernel/security.zig10-36
- Overview
- Getting Started and Build System
- Kernel Configuration and Global State
- Project Governance and Contributing
- Boot and Early Kernel Initialization
- Bootloader Stages and Linking
- kmain Boot Sequence
- Splash Screen and Branding
- Interrupts, Scheduling, and Syscalls
- IDT, PIC, APIC and IRQ Stubs
- Scheduler and Task Lifecycle
- System Call Interface
- Demonstration Tasks
- CodaFS Filesystem and Storage
- On-Disk Format and Operations
- Space Manager and Block Devices
- Binary Format and Program Loading
- Shell, Terminal, and Display
- Shell Command Pipeline
- Terminal, Input Devices and Prompts
- Display: VGA, Framebuffer, Console and Serial