/** * @file syscall.h * @brief System call interface. * * Defines system call numbers and the kernel-side handler. User-mode * processes invoke system calls via INT 0x80 with the call number in EAX * and arguments in EBX, ECX, EDX, ESI, EDI. */ #ifndef SYSCALL_H #define SYSCALL_H #include #include "isr.h" /** System call numbers. */ #define SYS_EXIT 0 /**< Exit the process. Arg: exit code in EBX. */ #define SYS_WRITE 1 /**< Write to a file descriptor. fd=EBX, buf=ECX, len=EDX. */ #define SYS_READ 2 /**< Read from a file descriptor. fd=EBX, buf=ECX, len=EDX. */ #define SYS_FORK 3 /**< Fork the current process. */ #define SYS_GETPID 4 /**< Get current process ID. */ #define SYS_YIELD 5 /**< Yield the CPU. */ #define SYS_WAITPID 6 /**< Wait for a child process. pid=EBX. */ #define SYS_EXEC 7 /**< Execute a program. path=EBX, argv=ECX. */ #define SYS_GETENV 8 /**< Get environment variable. key=EBX, buf=ECX, bufsize=EDX. */ #define SYS_SETENV 9 /**< Set environment variable. key=EBX, value=ECX. */ #define SYS_READDIR 10 /**< Read directory entry. path=EBX, idx=ECX, buf=EDX. Returns type or -1. */ /** Total number of system calls. */ #define NUM_SYSCALLS 11 /** * Initialize the system call handler. * Installs INT 0x80 in the IDT. */ void init_syscalls(void); /** * System call dispatcher (called from the INT 0x80 handler). * * @param regs Register state at the time of the interrupt. */ void syscall_handler(registers_t *regs); #endif /* SYSCALL_H */