Skip to content

Syscall Table ​

Syscalls are the interface between user-space programs and the JSOS kernel. They are invoked from Yog code with the syscall() intrinsic, which yogc compiles to a SVC #0 instruction.

Phase 2+ — not yet implemented. The table below documents the planned interface. Phase 1 has no kernel/user boundary; all code runs in EL1.

How syscalls work ​

js
// User code
const n = syscall(0, 1, buf, len);   // write(fd=1, buf, len) → bytes written

yogc emits:

asm
; Arguments already in x0–x2 (placed by caller)
movz x8, #0          ; syscall number
svc  #0              ; trap to EL1 kernel SVC handler
; return value in x0

The kernel SVC handler (Phase 2) reads x8 for the syscall number and dispatches to the appropriate handler. Return values are placed in x0 before eret.

Phase 2 — Core I/O ​

NumberNameSignatureDescription
0write(fd, buf, len) → nWrite len bytes from buf to file descriptor fd
1read(fd, buf, len) → nRead up to len bytes from fd into buf
2open(path) → fdOpen a file; returns file descriptor or negative error
3fwrite(fd, buf, len) → nBuffered write
4fread(fd, buf, len) → nBuffered read
5spawn(bin, len) → pidLoad binary image of len bytes from bin and start a new process
6exit(code)Terminate the calling process with exit code code
7wait(pid) → codeBlock until process pid exits; return its exit code

Well-known file descriptors:

fdTarget
0stdin (UART RX)
1stdout (UART TX)
2stderr (UART TX)

Phase 5 — Memory management ​

NumberNameSignatureDescription
8mmap(addr, len, prot) → ptrMap len bytes at hint address addr; returns actual address
9munmap(addr, len) → 0Unmap a previously mapped region
10brk(addr) → addrSet program break (end of heap segment)

prot flags (OR together):

ValueMeaning
0x1PROT_READ
0x2PROT_WRITE
0x4PROT_EXEC

Phase 7 — IPC and signals ​

NumberNameSignatureDescription
11pipe(fds)Create a pipe; write fd and read fd placed in fds[0] and fds[1]
12signal(sig, handler)Register handler as the signal handler for signal number sig
13kill(pid, sig) → 0Send signal sig to process pid
14sigreturn()Return from a signal handler; restores saved register state

Calling convention ​

JSOS follows the AArch64 procedure call standard (AAPCS64) for syscalls:

  • Arguments in x0–x5 (up to 6)
  • Syscall number in x8
  • Return value in x0
  • Negative return values indicate errors (errno-style)
  • Registers x0–x17 are caller-saved across SVC

The syscall() intrinsic in Yog handles argument placement and number loading. Direct SVC instructions are not part of the Yog dialect.

Yog — union of JS syntax and silicon.