home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
emxtutor.zip
/
emxsrcd1.zip
/
emx
/
doc
/
system.doc
Wrap
Text File
|
1998-09-03
|
52KB
|
1,308 lines
===============================================================================
system.doc emx 0.9d SYSTEM DEVELOPER'S GUIDE 03-Sep-1998
===============================================================================
Copyright (c) 1990-1998 by Eberhard Mattes
DOS calls
---------
DOS calls marked [*] are not available yet under OS/2. A DOS call is
performed by loading the function number into AH, the arguments into
the relevant registers and
- issuing INT 21H under DOS
- calling emx_syscall (ordinal 2) exported by emx.dll.
doscall AH=01H Read keyboard and echo
In: --
Out: AL character
Notes: Ctrl-C generates SIGINT
doscall AH=02H Display character
In: DL character
Out: --
Notes: Checks for Ctrl-C under DOS
doscall AH=03H Auxiliary input [*]
In: --
Out: AL character
Notes: Not tested. You should open a file called COM1 (or
similar) to get input from a serial interface
doscall AH=04H Auxiliary output [*]
In: DL character
Out: --
Notes: Not tested. You should open a file called COM1 (or
similar) to send output to a serial interface
doscall AH=05H Print character [*]
In: DL character
Out: --
Notes: Not tested. You should open a file called PRN to print
doscall AH=06H Direct console I/O
In: DL character/function:
00H-FEH: display character
FFH: read keyboard
Out: for DL=FFH:
NZ character available (has been read)
ZR no character available
AL character
for DL=00H-FEH:
--
Notes: Does not check for Ctrl-C under DOS
doscall AH=07H Direct console input
In: --
Out: AL character
Notes: Without echo, does not check for Ctrl-C under DOS
doscall AH=08H Read keyboard
In: --
Out: AL character
Notes: Without echo, Ctrl-C generates SIGINT
doscall AH=09H Display string [*]
In: EDX pointer to $ terminated string
Out: --
Notes: The $ is not displayed. The string length must not
exceed 65531
doscall AH=0AH __cgets() Buffered keyboard input
In: EDX pointer to buffer
Out: --
Notes: BYTE PTR EDX[0] must be set to the maximum number of
characters (including terminating CR)
BYTE PTR EDX[1] is set to the number of characters
(excluding terminating CR)
EDX+2 start of buffer
Checks for Ctrl-C. Editing possible. Not reentrant
(don't use in signal handler before unwinding the
exception handlers)
doscall AH=0BH Check keyboard status
In: --
Out: AL=FFH character(s) available
AL=00H no characters available
Notes: Checks for Ctrl-C. Not tested
doscall AH=0DH Reset disk
Note: Ignored under OS/2
doscall AH=0EH __chdrive() Select disk
In: DL drive number (0=A, 1=B, ...)
doscall AH=19H __getdrive() Get current disk
In: --
Out: AL current selected drive (0=A, 1=B, ...)
doscall AH=2AH Get date
In: --
Out: CX year (1980-2099)
DH month (1-12)
DL day (1-31)
AL day of week (0=Su, 1=Mo, 2=Tu, 3=We, 4=Th, 5=Fr, 6=Sa)
doscall AH=2BH Set date [*]
In: CX year (1980-2099)
DH month (1-12)
DL day (1-31)
Out: AL=00H ok
AL=FFH date invalid
Notes: Not tested
doscall AH=2CH Get time
In: --
Out: CH hour (0-23)
CL minutes (0-59)
DH seconds (0-59)
DL hundredths (0-99) (may be always 00H)
doscall AH=2DH Set time [*]
In: CH hour (0-23)
CL minutes (0-59)
DH seconds (0-59)
DL hundredths (0-99)
Out: AL=00H ok
AL=FFH time invalid
Notes: Not tested
doscall AH=2EH Set/reset verify flag [*]
In: AL=00H turn off verify
AL=01H turn on verify
Out: --
Notes: Not tested
doscall AH=30H __os_version() Get DOS or OS/2 version number
In: --
Out: AL major version number
AH minor version number
BH OEM serial number
BL:CX user serial number
EAX Bits 16..31: 6D65H ("em")
doscall AH=33H Ctrl-C check [*]
In: AL=00H get Ctrl-C checking state
AL=01H set Ctrl-C checking state
for AL=01H:
DL=00H turn Ctrl-C checking off
DL=01H turn Ctrl-C checking off
Out: AL=00H-01H ok
AL=FFH error
for AL=00H:
DL=00H Ctrl-C checking off
DL=01H Ctrl-C checking on
Notes: Not tested. Use signal handling instead
doscall AH=36H Get disk free space [*]
In: DL drive number (0=default, 1=A:, 2=B:, ...)
Out: AX=FFFFH: invalid drive number
otherwise:
AX sectors per cluster
BX available clusters
CX bytes per sector
DX clusters per drive
Notes: Not tested
doscall AH=37H __swchar() Get/set switch character
In: AL=00H get switch character
AL=01H set switch character [*]
For AL=01H:
DL new switch character
Out: AL=00H Success
DL Switch character (for AL=00H)
Note: Under OS/2, this function returns AL=0FFH (failure)
doscall AH=38H Get/set country data [*]
In: AL=00H current country
AL=FFH BX contains country code
AL=xx country code (00H < xx < 0FFH)
EBX country code (for AL=FFH)
EDX pointer to 34-byte memory area, or -1 for "set"
Out: CY error, EAX=error number
EBX country code
doscall AH=39H __mkdir() Create directory
In: EDX path name
Out: CY error, EAX=error number
Notes: Path name must not be longer than 65531 bytes. Not
tested
doscall AH=3AH __rmdir() Remove directory
In: EDX path name
Out: CY error, EAX=error number
Notes: Path name must not be longer than 65531 bytes. Not
tested
doscall AH=3BH __chdir() Change current directory
In: EDX path name
Out: CY error, EAX=error number
Notes: Path name must not be longer than 65531 bytes. Not
tested
Bugs: All processes share the same current directory
doscall AH=3CH Create handle
In: EDX path name
CX attributes
Out: CY error, EAX=error number
EAX handle
Notes: Path name must not be longer than 65531 bytes
doscall AH=3DH Open handle
In: EDX path name
AL access code
Out: CY error, EAX=error number
EAX handle
Notes: Path name must not be longer than 65531 bytes.
Access code:
bits 0-3 access mode:
0000 read
0001 write
0010 read and write
bits 4-6 sharing mode:
000 compatibility (same as 100 for OS/2)
001 deny read and write
010 deny write
011 deny read
100 deny none
bit 7 file inherited by (DOS) child processes
Bugs: files are always inherited by protected mode child processes
doscall AH=3EH __close() Close handle
In: EBX handle
Out: CY error, EAX=error number
doscall AH=3FH __read() Read handle
In: EBX handle
ECX number of bytes
EDX buffer
Out: CY error, EAX=error number
EAX number of bytes read
doscall AH=40H __write() Write handle
In: EBX handle
ECX number of bytes
EDX buffer
Out: CY error, EAX=error number
EAX number of bytes written
Note: The behaviour of this DOS call is undefined for ECX=0: the file
may or may not get truncated
doscall AH=41H __remove() Delete directory entry
In: EDX path name
Out: CY error, EAX=error number
Notes: Path name must not be longer than 65531 bytes
doscall AH=42H _lseek() Move file pointer
In: AL origin (0=beginning of file, 1=current position, 2=end)
EBX handle
EDX distance
Out: CY error, EAX=error number
EAX new position
Notes: Seeking before beginning of file isn't an error
doscall AH=43H __chmod() Get/set file attributes
In: AL=00H get attributes
AL=01H set attributes
CX attributes (for AL=01H)
EDX path name
Out: CY error, EAX=error number
CX attributes (for AL=00H)
Notes: Path name must not be longer than 65531 bytes
doscall AX=4400H __ioctl1() Get IOCTL data
In: EBX handle
Out: CY error, EAX=error number
EDX device data (bit 7 = 0: file)
Bits 0-5: drive number (0=A, 1=B, ..., always 0 for OS/2)
EDX device data (bit 7 = 1: device or pipe (OS/2))
Bit 0: standard input
Bit 1: standard output
Bit 2: null device
Bit 3: clock device
Notes: Other bits are reserved and currently not used by the C library
doscall AX=4401H __ioctl1() Set IOCTL data [*]
In: EBX handle
EDX device data
Out: CY error, EAX=error number
Notes: Not tested
doscall AX=4402H Send control data to character device [*]
doscall AX=4403H Receive control data from character device [*]
In: EBX handle
ECX number of bytes
EDX buffer
Out: CY error, EAX=error number
EAX number of bytes transferred
Notes: Not tested
doscall AX=4404H Send control data to block device [*]
doscall AX=4405H Receive control data from block device [*]
In: BL drive number (0=default, 1=A:, 2=B:, ...)
ECX number of bytes
EDX buffer
Out: CY error, EAX=error number
EAX number of bytes transferred
Notes: Not tested
doscall AX=4406H Check input status [*]
doscall AX=4407H Check output status [*]
In: EBX handle
Out: CY error, EAX=error number
AL=00H not ready
AL=FFH ready
Notes: Not tested
doscall AX=4408H Is changable [*]
In: BL drive number (0=default, 1=A:, 2=B:, ...)
Out: CY error, EAX=error number
AX=00H changable
AX=01H not changable
Notes: Not tested
doscall AX=4409H Is redirected block device [*]
In: BL drive number (0=default, 1=A:, 2=B:, ...)
Out: CY error, EAX=error number
DX device attributes
Notes: Not tested
doscall AX=440AH Is redirected handle [*]
In: EBX handle
Out: CY error, EAX=error number
DX IOCTL bits
Notes: Not tested
doscall AX=440BH Retry [*]
In: BX number of retries
CX wait time
Out: CY error, EAX=error number
Notes: Not tested
doscall AH=45H __dup() Duplicate file handle
In: EBX file handle
Out: CY error, EAX=error number
EAX new handle
doscall AH=46H __dup2() Force duplicate file handle
In: EBX file handle (source)
ECX file handle (destination)
Out: CY error, EAX=error number
Notes: doesn't work under DOS
doscall AH=47H __getcwd() Get current directory
In: ESI pointer to buffer (64 bytes for DOS, more for OS/2)
DL drive number (0=default, 1=A:, 2=B:, ...)
Out: CY error, EAX=error number
doscall AH=4CH __exit() End process
In: AL return code
Out: --
Notes: Never returns
doscall AH=4EH __findfirst() Find first file
In: EDX path name
ESI pointer to buffer (should be long for OS/2)
CX attributes
Out: CY error, EAX=error number
Notes: Automatically sets DTA to ESI
Nested searches are not supported by emx.dll to avoid
a potential handle leak
doscall AH=4FH __findnext() Find next file
In: ESI pointer to buffer (filled in by function 4EH)
Out: CY error, EAX=error number
Notes: Automatically sets DTA to ESI
doscall AH=54H Get verify state [*]
In: --
Out: AL=00H no verify after write
AL=01H verify after write
Notes: Not tested
doscall AH=56H __rename() Change directory entry
In: EDX pointer to first path name
EDI pointer to second path name
Out: CY error, EAX=error number
Notes: Path names must not be longer than 32763 bytes
doscall AH=57H Get/set date/time of file
In: AL=00H get date and time
AL=01H set date and time [*]
EBX handle
CX time (for AL=01H)
DX date (for AL=01H)
Out: CY error, EAX=error number
CX time (for AL=00H)
DX date (for AL=00H)
Notes: CX, bits 0..4: seconds / 2
CX, bits 5..10: minutes
CX, bits 11..15: hours
DX, bits 0..4: day
DX, bits 5..9: month
DX, bits 10..15: year - 1980
doscall AH=58H Get/set allocation strategy [*]
Note: See DOS manual
doscall AH=59H Get extended error [*]
Note: See DOS manual
doscall AH=5AH Create temporary file [*]
In: CX attributes
EDX pointer to path name (followed by a byte of 0 and
13 bytes of memory)
Out: CY error, EAX=error number
EAX handle
Notes: Path name must not be longer than 65531 bytes
doscall AH=5BH Create new file [*]
In: CX attributes
EDX pointer to path name
Out: CY error, EAX=error number
EAX handle
Notes: Path name must not be longer than 65531 bytes. Not
tested
doscall AH=5CH Lock/unlock [*]
In: AL=00H lock
AL=01H unlock
EBX handle
EDX offset
EDI length
Out: CY error, EAX=error number
doscall AH=60H Canonicalize filename or path [*]
In: ESI input path name
EDI output buffer
Out: CY error, EAX=error number
doscall AH=66H Get/set global codepage table [*]
In: AL=01H get global codepage table
AL=02H set global codepage table
EBX active code page (for AL=02H)
EDX system code page (for AL=02H)
Out: CY error, EAX=error number
EBX active code page (for AL=01H)
EDX system code page (for AL=01H)
doscall AH=67H Set handle count [*]
In: EBX number of handles
Out: CY error, EAX=error number
doscall AH=68H Commit file [*]
In: EBX handle
Out: CY error, EAX=error number
doscall AH=6AH Commit file [*]
In: EBX handle
Out: CY error, EAX=error number
doscall AH=6CH Extended open/create [*]
In: AL=00H
BL open mode
BH flags
CX attribute
DL action
DH=00H
ESI path name
Out: CY error, EAX=error number
EAX handle
ECX status
System calls
------------
A system call is performed by loading 7FH into AH, the function number
into AL, the arguments into the relevant registers and
- issuing INT 21H under DOS
- calling emx_syscall (ordinal 2) exported by emx.dll.
syscall AL=00H __sbrk()
In: EDX value added to current break value
Out: EAX previous break value, -1 if error
syscall AL=01H __brk()
In: EDX new break value
Out: EAX=0 ok
EAX=-1 error
syscall AL=02H __ulimit()
In: ECX=3 UL_GMEMLIM Get greatest possible break value
ECX=81 UL_OBJREST Get remaining bytes in current heap object
EDX new limit (currently ignored)
Out: EAX return value
ECX errno, if non-zero
syscall AL=03H __vmstat()
In: EBX pointer to buffer (2 DWORDs)
ECX size of buffer (bytes)
Out: --
Notes: Not tested. At most ECX/4 DWORDs will be filled in
Buffer layout:
DWORD number of page faults caused by this process
DWORD total number of page faults
syscall AL=04H __umask1()
In: EDX file permission mask
Out: EAX previous file permission mask
Note: This file permission mask is not used -- obsolete
syscall AL=05H __getpid()
In: --
Out: EAX process id
syscall AL=06H __spawnve()
In: EDX pointer to parameter block
Out: CY error
EAX error number (CY)
EAX process id (NC, asynchronous process)
EAX return code (NC, synchronous process)
NC ok, EAX=process id
Parameter block:
DWORD pointer to arguments (offset)
DWORD pointer to environment (offset)
DWORD pointer to file name (offset)
WORD pointer to arguments (selector)
WORD pointer to environment (selector)
WORD pointer to file name (selector)
WORD number of arguments
WORD size of arguments
WORD number of environment strings
WORD size of environment
WORD mode (lower 8 bits):
0 P_WAIT spawn child, wait til terminated
1 P_NOWAIT not implemented yet
2 P_OVERLAY exec child, kill current process
3 P_DEBUG debug child, use with ptrace()
4 P_SESSION run in separate session
5 P_DETACH detached
6 P_PM run as PM program
flags (upper 8 bits):
Bit 8-10: 0000=P_DEFAULT 0011=P_FULLSCREEN
0001=P_MINIMIZE 0100=P_WINDOWED
0010=P_MAXIMIZE
Bit 12: P_BACKGROUND
Bit 13: P_NOCLOSE
Bit 14: P_NOSESSION
Bit 15: there's another WORD of flag bits
WORD optional, more flag bits (continued from previous word),
only present if bit 15 of the previous WORD is set:
Bit 16: P_QUOTE
Bit 17: P_TILDE
Bit 18: P_DEBUGDESC
Error codes:
EAGAIN too many processes
ENOENT file not found
ENOEXEC invalid program file
ENOMEM out of memory
EINVAL invalid argument (invalid mode)
E2BIG arguments or environment too big
Notes: `arguments' contains all the program arguments, delimited
by zeros and preceded by a flags byte (usually 80H), e.g.,
DB 80H, "name", 0, 80H, "arg1", 0, 80H, "arg2", 0
`environment' contains the environment strings, delimited
by zeros, an additional byte of zeros at the end, e.g.,
DB "PATH=C:\", 0, "EMXPATH=C:\EMX\BIN", 0, 0
The `size' variables must include all the bytes of zeros.
This function ignores the EMXPATH and PATH environment
variables. Currently, DOS programs don't get the
environment given in the parameter block -- they inherit the
environment of emx
syscall AL=07H
Note: Used by RSX
syscall AL=08H __ptrace()
In: EBX request code
EDI process id of child (or lower word=PID, upper word=TID)
EDX address
ECX data
Out: EAX result. -1 if error (or if PEEKed -1)
ECX errno. Zero if no error
Request codes (cf. /emx/include/sys/ptrace.h):
0 PTRACE_TRACEME not used by emx
1 PTRACE_PEEKTEXT return the word at text address EDX
2 PTRACE_PEEKDATA return the word at data address EDX
3 PTRACE_PEEKUSER return the word at user block address EDX
4 PTRACE_POKETEXT write ECX to text address EDX
5 PTRACE_POKEDATA write ECX to data address EDX
6 PTRACE_POKEUSER write ECX to user block address EDX
7 PTRACE_RESUME resume process (with signal ECX)
8 PTRACE_EXIT terminate process
9 PTRACE_STEP execute one instruction (with signal ECX)
10 PTRACE_SESSION session switching
11 PTRACE_NOTIFICATION obtain a notification (ECX bytes at EDX)
12 PTRACE_CONT continue after notification
13 PTRACE_THAW thaw (enable) a thread
14 PTRACE_FREEZE freeze (disable) a thread
15 PTRACE_ATTACH attach to a descendant
16 PTRACE_DETACH detach from a descendant
Addresses in the user block (cf. /emx/include/sys/user.h):
48 u_ar0: this variable points to the registers after subtracting
0E0000000H
52 u_fpvalid: the first byte is non-zero if the floating-point
state is valid
56 u_fpstate: floating point state, 108 bytes
164 u_fpstatus: currently always 0 (used for exceptions?)
Addresses of registers relative to u_ar0 - 0E0000000H
(cf. /emx/include/sys/reg.h):
0 GS 20 ESI 40 ECX 60 CS
4 FS 24 EBP 44 EAX 64 EFLAGS
8 ES 28 n/a 48 n/a 68 ESP
12 DS 32 EBX 52 ERRCD 72 SS
16 EDI 36 EDX 56 EIP
Notes: There is no difference between text and data addresses.
If there is no process with ID EDI or if the process
exists but isn't tracable, 3 (ESRCH) will be returned
ECX. All other errors (address out of range, invalid
request code) return 5 (EIO) in ECX. PTRACE_TRACEME is
not implemented, cf. spawnve(). Only the registers
EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP and some
bits of EFLAGS can be changed. PTRACE_POKEUSER is
ignored for other addresses. The floating point state
consists of 27 32-bit integers, see 387 reference
manual.
syscall AL=09H __wait()
In: --
Out: EAX process ID (-1 if no children)
ECX errno (0 if no error)
EDX termination status:
DL=7FH, DH=signal number process stopped
DL=00H, DH=return code process terminated: exit()
DL=signal number, DH=00H process terminated: signal
(not implemented)
Notes: wait() is currently implemented for processes started
with P_DEBUG and running under control of ptrace().
Under OS/2, wait() is also implemented for all other
types of processes started under control of emx by the
process. See AX=7F0CH for signal numbers
syscall AL=0AH Get emx version
In: --
Out: EAX version number
Bits 0..7: version letter ("a".."z")
Bits 8..15: minor version number ("0".."9")
Bits 16..23: 2EH (".")
Bits 24..31: major version number ("0".."9")
Example: 2.3e -> EAX = "2.3e" = 322E3365H
EBX environment:
Bit 0: VCPI
Bit 1: XMS
Bit 2: VDISK.SYS 3.3
Bit 3: DESQview
Bit 4: 287
Bit 5: 387
Bit 6: 486 (not implemented)
Bit 7: DPMI 0.9 (not implemented)
Bit 8: DPMI 1.0 (not implemented)
Bit 9: OS/2
Bit 10: -t option given
Bit 11: Data executable (-ac option)
Bit 12: RSX
ECX revision index
EDX 0 (reserved for future expansion)
Note: The version number returned in EAX is suitable for
comparing, but not for printing without swapping bytes.
The 387 bit is always set under OS/2.
syscall AL=0BH Available memory
In: --
Out: EAX number of available 4K pages of memory
Note: This function returns the amount of memory available
without resorting to swapping
syscall AL=0CH __signal() set signal handler
In: ECX signal number
EDX address of signal handler or SIG_IGN, SIG_DFL, SIG_ACK
Out: EAX=-1 error
EAX address of previous signal handler
Signal numbers:
1 SIGHUP hangup (not implemented)
2 SIGINT interrupt (Ctrl-C)
3 SIGQUIT quit (only for raise())
4 SIGILL illegal instruction (only for ptrace())
5 SIGTRAP single step (debugging) (only for ptrace())
6 SIGABRT abort()
7 SIGEMT EMT instruction (not implemented)
8 SIGFPE floating point (only for ptrace())
9 SIGKILL kill (not implemented)
11 SIGSEGV segmentation fault (only for ptrace())
12 SIGSYS invalid argument to syscall (not implemented)
13 SIGPIPE broken pipe
14 SIGALRM alarm
15 SIGTERM termination, process killed
16 SIGUSR1 user-defined signal #1
17 SIGUSR2 user-defined signal #2
18 SIGCLD status for child process available
21 SIGBREAK break (Ctrl-Break) (see notes)
Special signal handler values:
0 SIG_DFL default signal handler (see notes)
1 SIG_IGN ignore signal
4 SIG_ACK unblock the signal (for SA_ACK)
Notes: Both Ctrl-C and Ctrl-Break generate SIGINT. An
application program can raise SIGBREAK. The default
handler for SIGINT and SIGBREAK displays `Program
stopped' and exits to DOS with return code 3. The
default handler for SIGTERM exits to DOS with return
code 3. SIGTERM is not implemented for OS/2. The
default handler for SIGQUIT creates a core dump file
and exits to DOS
syscall AL=0DH __kill() send signal to a process
In: ECX signal number, see __signal()
EDX process ID
Out: EAX=0 ok
EAX=-1 error
ECX errno [0.8d]
Notes: Under DOS, this function currently does not switch
processes. Only SIGINT and SIGBREAK can be sent to any
process. A process can send SIGQUIT only to itself.
Almost not tested under DOS
syscall AL=0EH __raise() raise a signal
In: ECX signal number, see __signal()
Out: EAX=0 ok
EAX=-1 error
ECX errno [0.8d]
syscall AL=0FH __uflags() set flags
In: ECX mask (only bits set to 1 in ECX will be changed)
EDX new values of the bits selected by ECX
Out: EAX old flags
Bits:
0-1 signal() semantics
00 emx (SIG_ACK)
01 System V
10 BSD
2-3 __sbrk() behavior
00 always returns contiguous memory (limits size)
01 may return non-contiguous memory, monotonous
10 may return non-contiguous memory, arbitrary
NOTE: All bits are zero initially
syscall AL=10H __unwind() unwind signal handlers
In: --
Out: --
Note: This must be used if a signal handler decides not to
return and to use longjmp() instead. This is required
if the signal handler restores the stack frame of
another function.
syscall AL=11H __core() write a core image file
In: EBX file handle
Out: CY failed
EAX errno (0 if successful)
syscall AL=12H __portaccess() Enable access to I/O ports
In: ECX first port number (0..3FFH)
EDX last port number (0..3FFH)
Out: CY failed
EAX errno (0 if successful)
Notes: The -ai option must be used to enable _portaccess. The
ports are enabled for *all* processes run by the
current instance of emx. You cannot disable access to
ports after enabling access
syscall AL=13H __memaccess() Enable access to memory
In: EBX first address (0..0FF000H)
ECX last address (0FFFH..0FFFFFH)
EDX 0: read access, 1:write access
Out: CY failed
EAX errno if failed (CY)
EAX pointer to start of mapped memory area (NC)
Notes: The -am option must be used to enable _memaccess. The
first address must be page aligned, the last address +
1 must be page aligned. For write access, the -aw
option must be used. If the address range is entirely
in the range 0A0000H..0BFFFFH, read and write access is
also granted without -aw. Otherwise, only read access
is granted. The address given are physical addresses,
that is, if a memory manager remaps low memory, you
lose
syscall AL=14H __ioctl2() Unix-like ioctl()
In: EBX handle
ECX request code
EDX argument
Out: EAX return value
ECX errno, if non-zero
syscall AL=15H __alarm() Set alarm clock
In: EDX seconds
Out: EAX time remaining before setting new value
Note: While in DOS, SIGALRM is blocked. SIGALRM will be delivered
after return from DOS
syscall AL=16H Used internally for polling the keyboard
Note: Cannot be called by user program
syscall AL=17H __sleep() Suspend process
In: EDX seconds
Out: EAX number of remaining seconds if interrupted by signal
syscall AL=18H __chsize() Change size of file
In: EBX file handle
EDX file size (bytes)
Out: CY failed
EAX errno (0 if successful)
Note: The position of the file pointer is undefined after
calling this function. Bytes appended are undefined
syscall AL=19H __fcntl() Unix-like fcntl()
In: EBX handle
ECX request code
EDX argument
Out: EAX return value
ECX errno, if non-zero
Notes: O_NDELAY is only implemented for handle 0, if refers to
the keyboard and is not in ICANON mode. O_GETFD and
O_SETFD are implemented partially under DOS. O_SETFL
is implemented for termio on handle 0 only. No other
request codes are implemented. Parts of fcntl() are
implemented in the C library
syscall AL=1AH __pipe() Create unnamed pipe
In: ECX pipe size (bytes)
EDX pointer to storage for two handles (two DWORDs)
Out: EAX 0 (success) or -1 (failure)
ECX errno (0 if successful)
Note: Not implemented under DOS
syscall AL=1BH __fsync() Upate file system
In: EBX file handle
Out: EAX 0 (success) or -1 (failure)
ECX errno (0 if successful)
Note: Not implemented under DOS
syscall AL=1CH __fork() Duplicate process
In: --
Out: EAX process ID or 0 (in new process) or -1 (failure)
ECX errno (0 if successful)
Note: Not implemented
syscall AL=1DH __scrsize() Get number of rows and columns
In: EDX pointer to structure
Out: -- (first word set to number of columns (width), second
word set to number of rows (height))
syscall AL=1EH __select() Synchronous I/O multiplexing
In: EDX pointer to structure
Out: EAX 0 (timeout), > 0 (ready) or -1 (failure)
ECX errno (0 if successful)
syscall AL=1FH __syserrno() Get last error code
In: --
Out: EAX OS/2 or DOS error code for last syscall of this thread
Notes: Not implemented under DOS
syscall AL=20H __stat() Get information about a path name
In: EDX path name
EDI pointer to structure
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
Note: Not implemented under DOS
syscall AL=21H __fstat() Get information about an open file
In: EBX file handle
EDI pointer to structure
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
Note: Not implemented under DOS
syscall AL=23H __filesys() Get name of file-system driver
In: EDX pointer to drive name
EDI pointer to output buffer
ECX size of output buffer
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
Note: File-system driver names include FAT, HPFS, LAN, CDFS, NFS
syscall AL=24H __utimes() Set access and modification time of a file
In: EDX pointer to path name
ESI pointer to array of structures
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
Notes: The first element of the array is the access time, the
second element is the modification time. The
structures contain two fields:
- the number of seconds elapsed since 00:00 01-Jan-1970
(local time)
- milliseconds.
The milliseconds field is ignored.
syscall AL=25H __ftruncate() Truncate a file
In: EBX file handle
EDX file size (bytes)
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
Notes: The position of the file pointer is undefined after
calling this function. __ftruncate() doesn't increase
the size of a file
syscall AL=26H __clock() Processor time
In: ---
Out: EAX timer ticks of processor time used, low-order 32 bits
EDX high-order 32 bits
Note: Returns time elapsed, not CPU time. There are 100 timer
ticks per second.
syscall AL=27H __ftime() Get current time
In: EDX pointer to structure
syscall AL=28H __umask() Set file permission mask
In: EDX file permission mask
Out: EAX previous file permission mask
syscall AL=29H __getppid() Get parent process ID
In: --
Out: EAX parent process id
syscall AL=2AH __nls_memupr() Convert buffer to upper case
In: EDX pointer to buffer
ECX size of buffer
syscall AL=2BH __open() Open a file
In: EDX pointer to path name
ECX flags (attributes, sharing mode, create)
EBX initial size (ignored unless _SO_SIZE is set)
Out: EAX handle (success), -1 (failure)
ECX errno (0 if successful)
Notes: Path name must not be longer than 65531 bytes. Bits
0..7 of ECX contain the sharing mode, bits 8..15
contain the attributes, the remaining bits contain
additional flags:
bit 16 _SO_CREAT Create file if it doesn't exist
bit 17 _SO_EXCL Fail if file exists and _SO_CREAT is set
bit 18 _SO_TRUNC Truncate file
bit 19 _SO_NOINHERIT Children don't inherit this handle
bit 20 _SO_SYNC Write through
bit 21 _SO_SIZE Set inital size (EBX)
syscall AL=2CH __newthread() Notify emx of new thread
In: EDX thread ID
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if successful)
syscall AL=2DH __endthread() Notify emx of end of thread
In: EDX thread ID
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if successful)
syscall AL=2EH __waitpid()
In: EDX pid
ECX options (WNOHANG)
Out: EAX process ID (-1 if no children, 0 if it would block)
ECX errno (0 if no error)
EDX termination status, see wait()
Note: __waitpid() is not implemented under DOS
syscall AL=2FH __read_kbd()
In: EDX flags (bit 0: echo, bit 1: wait, bit 2:sig)
Out: EAX character (or -1)
syscall AL=30H __sleep2() Suspend process
In: EDX milliseconds
Out: EAX 0
syscall AL=31H __unwind2() Unwind signal handlers
In: EDX exception handler chain
Out: --
Note: This must be used if a signal handler decides not to
return and to use longjmp() instead. This is required
if the signal handler restores the stack frame of
another function.
syscall AL=32H __pause() Wait for signal
In: --
Out: --
Note: __pause() is not implemented under DOS
syscall AL=33H __execname() Get the name of the executable file
In: EDX pointer to buffer
ECX size of buffer
Out: EAX 0 (success), -1 (failure)
syscall AL=34H __initthread() Install exception handler in new thread
In: EDX pointer to EXCEPTIONREGISTRATIONRECORD
Out: EAX 0 (success), -1 (failure)
syscall AL=35H __sigaction() Examine or specify action for a signal
In: ECX signal number
EDX pointer to sigaction structure (input)
EBX pointer to sigaction structure (output)
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
Note: POSIX.1
syscall AL=36H __sigpending() Query set of pending signals
In: EDX pointer to sigset_t (output)
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
Note: POSIX.1
syscall AL=37H __sigprocmask() Examine or change the signal mask
In: ECX manner in which to set the mask
EDX pointer to sigset_t (input)
EBX pointer to sigset_t (output)
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
Note: POSIX.1
syscall AL=38H __sigsuspend() Replace signal mask and wait for signal
In: EDX pointer to sigset_t (input)
Out: EAX -1 (failure)
ECX errno (EINTR)
Notes: POSIX.1. Not yet implemented under DOS
syscall AL=39H __imphandle() Import an OS/2 file handle
In: EDX OS/2 file handle
Out: EAX relocated file handle (success), -1 (failure)
ECX errno (0 if no error)
Note: Not implemented under DOS (ENOSYS)
syscall AL=3AH __fpuemu() Interface for floating point unit emulator
In: ECX Command code
EDX Pointer to communication area
Out: EAX 0 (success), -1 (failure)
Communication area:
DWORD Notification code
DWORD Process number (zero-based, not the PID!)
DWORD Signal number
WORD GS
WORD FS
WORD ES
WORD DS
DWORD EDI
DWORD ESI
DWORD EBP
DWORD ESP (kernel)
DWORD EBX
DWORD EDX
DWORD ECX
DWORD EAX
DWORD ERRCD
DWORD EIP
DWORD CS
DWORD EFLAGS
DWORD ESP
DWORD SS
Commmand codes:
0 Initialization (register as floating point emulator)
1 Get next notification
2 Raise signal
Notification codes:
0 New application process started
1 Application process terminated (not yet fully implemented)
2 Emulate a floating-point instruction
Note: The client process' memory space is addressed with the
FS register
syscall AL=3BH __getsockhandle() Return the TCP/IP handle of a socket
In: EBX File handle
Out: EAX handle (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=3CH __socket() Create a socket
In: ECX Domain
EDX Type
EBX Protocol
Out: EAX handle (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=3DH __bind() Bind a name to a socket
In: EBX File handle
EDX Pointer to address
ECX Size of address
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=3EH __listen() Listen for connections on a socket
In: EBX File handle
EDX backlog
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=3FH __recv() Receive a message from a socket
In: EBX File handle
EDX Pointer to buffer
ECX Size of buffer
ESI Flags
Out: EAX number of bytes (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=40H __send() Send a message to a socket
In: EBX File handle
EDX Pointer to buffer
ECX Size of buffer
ESI Flags
Out: EAX number of bytes (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=41H __accept() Accept a connection on a socket
In: EBX File handle
EDX Pointer to address
ECX Pointer to size of address
Out: EAX handle (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=42H __connect() Initiate a connection on a socket
In: EBX File handle
EDX Pointer to address
ECX Size of address
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=43H __getsockopt() Get options on a socket
In: EBX File handle
EDX Level
ECX Option name
ESI Pointer to option value
EDI Pointer to option length
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=44H __setsockopt() Set options on a socket
In: EBX File handle
EDX Level
ECX Option name
ESI Pointer to option value
EDI Option length
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=45H __getsockname() Get socket name
In: EBX File handle
EDX Pointer to name
ECX Pointer to length
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=46H __getpeername() Get name of connected peer
In: EBX File handle
EDX Pointer to name
ECX Pointer to length
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=47H __gethostbyname() Get network host entry by name
In: EDX Pointer to name
EBX Pointer to result
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
Note: h_errno is passed in errno
syscall AL=48H __gethostbyaddr() Get network host entry by address
In: EDX Pointer to address
ECX Length
ESI Type
EBX Pointer to result
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
Note: h_errno is passed in errno
syscall AL=49H __getservbyname() Get service entry by name
In: EDX Pointer to name
ECX Pointer to protocol
EBX Pointer to result
Out: EAX 0 (success), -1 (failure)
ECX always zero
syscall AL=4AH __getservbyport() Get service entry by port
In: EDX Port number
ECX Pointer to protocol
EBX Pointer to result
Out: EAX 0 (success), -1 (failure)
ECX always zero
syscall AL=4BH __getprotobyname() Get protocol entry by name
In: EDX Pointer to name
EBX Pointer to result
Out: EAX 0 (success), -1 (failure)
ECX always zero
syscall AL=4CH __getprotobynumber() Get protocol entry by number
In: EDX Number
EBX Pointer to result
Out: EAX 0 (success), -1 (failure)
ECX always zero
syscall AL=4DH __getnetbyname() Get network entry by name
In: EDX Pointer to name
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=4EH __getnetbyaddr() Get network entry by address
In: EDX Address
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=4FH __gethostname() Get host name
In: EDX Pointer to name
ECX Length of buffer
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=50H __gethostid() Get host indentifier
In: EBX Pointer to result
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=51H __shutdown() Shut down part of a full-duplex connection
In: EBX Handle
EDX What to shut down
Out: EAX 0 (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=52H __recvfrom() Receive a message from a socket
In: EDX Pointer to structure (struct _recvfrom)
Out: EAX number of bytes (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=53H __sendto() Send a message to a socket
In: EDX Pointer to structure (struct _sendto)
Out: EAX number of bytes (success), -1 (failure)
ECX errno (0 if no error)
syscall AL=54H __impsockhandle() Import a socket handle of IBM TCP/IP
In: EDX socket handle
ECX flags (reserved, must be 0)
Out: EAX relocated file handle (success), -1 (failure)
ECX errno (0 if no error)
Note: Not implemented under DOS (ENOSYS)
syscall AL=55H __recvmsg() -- NOT YET IMPLEMENTED
syscall AL=56H __sendmsg() -- NOT YET IMPLEMENTED
syscall AL=57H __ttyname()
In: EDX file handle
EDI pointer to output buffer
ECX size of output buffer
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
Note: Not yet implemented under DOS (ENOSYS)
syscall AL=58H __settime() Set system time
In: EDX pointer to struct timeval
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
syscall AL=59H __profil() Sampling profiler
In: EDX pointer to struct _profil
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
syscall AL=5AH __nls_ctype() Initialize character table (DBCS lead bytes)
In: EDX pointer to array of 256 bytes
Out: EAX 0 (ok), -1 (error)
ECX errno (0 if successful)
syscall AL=5BH __syserrno() Set last error code
In: EDX new error code
Out: EAX Old OS/2 or DOS error code for last syscall of this thread
Notes: Not implemented under DOS; returns -1 if not implemented
(does not set errno)
Selectors (DOS)
---------------
0000H null selector
000FH code segment (read only)
0017H data segment (size changable with brk/sbrk)
001FH video memory (text mode)
0027H symbol table (only if symbols available and -S option set; read only)
Do not rely on the selectors given above, they may change in a future
version of emx. Moreover, they are different when the program is run
under OS/2. Use only the values found in the segment registers on
program entry.
Argument Passing
----------------
The arguments and the environment are passed on the stack:
(high end of stack)
environment and argument strings; use envp[] and argv[] for accessing
argv[], NULL terminated
ESP-> envp[], NULL terminated
Note: Under OS/2, the environment strings are not in the stack.
--------------------------- END OF SYSTEM.DOC -------------------------------