You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PromptOS uses the SYSCALL/SYSRET mechanism for User → Kernel transitions.
The ABI follows the System V AMD64 convention with adaptations.
🧠 Design Philosophy (ASSUMPTION: E1 = Hybrid)
Internal: Handle-based system (not file descriptor numbers)
External: POSIX compatibility shim in libc
No fork(): Instead spawn() for new processes
Signals present: POSIX-like; event-based IPC can be added optionally
📞 2. Calling Convention
Register Allocation
Register
Usage
RAX
Syscall number (Input) / Return Value (Output)
RDI
Argument 1
RSI
Argument 2
RDX
Argument 3
R10
Argument 4 (not RCX, as SYSCALL overwrites RCX)
R8
Argument 5
R9
Argument 6
Caller-Saved Registers
The following registers may be modified by the kernel:
RAX, RCX, R11 (always modified by SYSCALL)
RDI, RSI, RDX, R10, R8, R9 (Arguments)
Callee-Saved Registers
The following registers are preserved by the kernel:
RBX, RBP, R12, R13, R14, R15, RSP
Return Values
RAX Value
Meaning
>= 0
Success (Return value is syscall-specific)
< 0
Error (negative errno value)
3. Error Codes
#defineEOK 0 // No error
#defineEPERM 1 // Operation not permitted
#defineENOENT 2 // No such file or directory
#defineESRCH 3 // No such process
#defineEINTR 4 // Interrupted system call
#defineEIO 5 // I/O error
#defineENXIO 6 // No such device or address
#defineE2BIG 7 // Argument list too long
#defineENOEXEC 8 // Exec format error
#defineEBADF 9 // Bad file number
#defineECHILD 10 // No child processes
#defineEAGAIN 11 // Try again (EWOULDBLOCK)
#defineENOMEM 12 // Out of memory
#defineEACCES 13 // Permission denied
#defineEFAULT 14 // Bad address
#defineEBUSY 16 // Device or resource busy
#defineEEXIST 17 // File exists
#defineEXDEV 18 // Cross-device link
#defineENODEV 19 // No such device
#defineENOTDIR 20 // Not a directory
#defineEISDIR 21 // Is a directory
#defineEINVAL 22 // Invalid argument
#defineENFILE 23 // File table overflow
#defineEMFILE 24 // Too many open files
#defineENOTTY 25 // Not a typewriter
#defineEFBIG 27 // File too large
#defineENOSPC 28 // No space left on device
#defineESPIPE 29 // Illegal seek
#defineEROFS 30 // Read-only file system
#defineEMLINK 31 // Too many links
#defineEPIPE 32 // Broken pipe
#defineEDOM 33 // Math argument out of domain
#defineERANGE 34 // Math result not representable
#defineENOSYS 38 // Function not implemented
#defineENOTEMPTY 39 // Directory not empty
#defineELOOP 40 // Too many symbolic links
#defineENOMSG 42 // No message of desired type
#defineENODATA 61 // No data available
#defineETIME 62 // Timer expired
#defineEOVERFLOW 75 // Value too large
#defineEILSEQ 84 // Illegal byte sequence
#defineENOTSOCK 88 // Socket operation on non-socket
#defineEMSGSIZE 90 // Message too long
#defineEPROTOTYPE 91 // Protocol wrong type
#defineENOPROTOOPT 92 // Protocol not available
#defineEPROTONOSUPPORT 93 // Protocol not supported
#defineEOPNOTSUPP 95 // Operation not supported
#defineEAFNOSUPPORT 97 // Address family not supported
#defineEADDRINUSE 98 // Address already in use
#defineEADDRNOTAVAIL 99 // Cannot assign requested address
#defineENETDOWN 100 // Network is down
#defineENETUNREACH 101 // Network is unreachable
#defineECONNABORTED 103 // Software caused connection abort
#defineECONNRESET 104 // Connection reset by peer
#defineENOBUFS 105 // No buffer space available
#defineEISCONN 106 // Transport endpoint connected
#defineENOTCONN 107 // Transport endpoint not connected
#defineETIMEDOUT 110 // Connection timed out
#defineECONNREFUSED 111 // Connection refused
#defineEHOSTUNREACH 113 // No route to host
#defineEALREADY 114 // Operation already in progress
#defineEINPROGRESS 115 // Operation now in progress
#defineECANCELED 125 // Operation Canceled
typedefint64_thandle_t; // Universal handletypedefint32_tpid_t; // Process IDtypedefint32_ttid_t; // Thread IDtypedefint64_toff_t; // File offsettypedefuint32_tmode_t; // File modetypedefuint32_tuid_t; // User IDtypedefuint32_tgid_t; // Group ID
struct stat
structstat {
dev_tst_dev; // Device IDino_tst_ino; // Inode numbermode_tst_mode; // File modeuint32_tst_nlink; // Number of hard linksuid_tst_uid; // User IDgid_tst_gid; // Group IDdev_tst_rdev; // Device ID (if special file)off_tst_size; // Total size in bytesint64_tst_atime; // Last access timeint64_tst_mtime; // Last modification timeint64_tst_ctime; // Last status change timeuint64_tst_blksize; // Block size for I/Ouint64_tst_blocks; // Number of 512B blocks
};
struct dirent
structdirent {
ino_td_ino; // Inode numberoff_td_off; // Offset to next entryuint16_td_reclen; // Record lengthuint8_td_type; // File typechard_name[256]; // File name
};
struct pollfd
structpollfd {
handle_tfd; // Handleint16_tevents; // Requested eventsint16_trevents; // Returned events
};
#definePOLLIN 0x0001 // Data available
#definePOLLOUT 0x0004 // Writing possible
#definePOLLERR 0x0008 // Error condition
#definePOLLHUP 0x0010 // Hung up
SpawnFlags
typedefenum {
SPAWN_NONE=0,
SPAWN_DETACHED= (1 << 0), // Don't wait for childSPAWN_NEW_SESSION= (1 << 1), // Create new sessionSPAWN_SHARE_CWD= (1 << 2), // Share working directory
} SpawnFlags;