source: vendor/emx/current/src/dos/process.inc

Last change on this file was 18, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 13.8 KB
Line 
1;
2; PROCESS.INC -- Manage processes
3;
4; Copyright (c) 1991-1996 by Eberhard Mattes
5;
6; This file is part of emx.
7;
8; emx is free software; you can redistribute it and/or modify it
9; under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2, or (at your option)
11; any later version.
12;
13; emx is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17;
18; You should have received a copy of the GNU General Public License
19; along with emx; see the file COPYING. If not, write to
20; the Free Software Foundation, 59 Temple Place - Suite 330,
21; Boston, MA 02111-1307, USA.
22;
23; See emx.asm for a special exception.
24;
25
26;
27; Requires: SIGNAL.INC (for SIGNALS)
28;
29
30;
31; Capacity
32;
33MAX_FILES = 40 ; Max number of open files per process
34MAX_PROCESSES = 6 ; Max number of processes
35MAX_TIMERS = 2 * MAX_PROCESSES ; Max number of timers
36
37;
38; Special process pointers
39;
40NO_PROCESS = 0 ; Used for PROCESS_PTR, PROCESS_SIG,
41 ; FIND_PROCESS, etc.
42NO_WPROCESS = 1 ; Used for WAIT_PROCESS
43
44;
45; P_FLAGS bits
46;
47PF_DEBUG = 0001H ; Process is being debugged
48PF_WAIT_WAIT = 0002H ; Process waits for being waited for
49PF_387_USED = 0004H ; 387 used, don't FNINIT
50PF_PRELOADING = 0008H ; Preloading in progress (for swapper)
51PF_TERMIO_TIME = 0010H ; VTIME expired
52PF_SLEEP_FLAG = 0020H ; sleep interval expired
53PF_PSEUDO_ASYNC = 0040H ; wait() can be done for pseudo async
54PF_REDIR_STDERR = 0200H ; Redirect stderr to stdout
55PF_QUOTE = 0400H ; Quote arguments for children
56PF_COMMIT = 0800H ; Commit memory
57PF_DONT_ZERO = 1000H ; Don't zero unitialized data
58PF_PRELOAD = 4000H ; Disable preloading (-L)
59PF_NO_CORE = 8000H ; Disable core dumps (-c)
60PF_FPUEMU_INIT = 10000H ; FPU emu initialized for this process
61
62;
63; P_UFLAGS bits
64;
65UF_SIG_MODEL = 00003H ; Mask for signal() semantics
66UF_SIG_EMX = 00000H ; signal() semantics: emx (SIG_ACK)
67UF_SIG_SYSV = 00001H ; signal() semantics: System V
68UF_SIG_BSD = 00002H ; signal() semantics: BSD
69
70;
71; P_STATUS values
72;
73PS_NONE = 0 ; empty slot
74PS_DEFUNCT = 1 ; terminated, zombie (til wait)
75PS_INIT = 2 ; initialized but not started
76PS_RUN = 3 ; running
77PS_STOP = 4 ; stopped (debugging)
78PS_WAIT_SPAWN = 5 ; executes synchronous spawn
79PS_WAIT_CHILD = 6 ; executes wait()
80PS_WAIT_PTRACE = 7 ; executes ptrace()
81PS_FPUEMU_CLIENT = 8 ; application being serviced by FPU emu
82PS_FPUEMU_NEXT = 9 ; FPU emulator waiting for notification
83
84;
85; Bits in the P_HW_ACCESS byte
86;
87HW_ACCESS_MEM = 01H ; Memory read access allowed
88HW_ACCESS_IO = 02H ; Port access allowed
89HW_ACCESS_WRITE = 04H ; Memory write access allowed
90HW_ACCESS_CODE = 08H ; Data segment and stack executable
91
92;
93; Bits in the P_HFLAGS array, cf. <sys/fcntl.h>
94;
95HF_APPEND = 0008H ; O_APPEND
96HF_NDELAY = 0004H ; O_NONBLOCK and O_NDELAY
97HF_NOINHERIT = 1000H ; O_NOINHERIT and FD_CLOEXEC
98
99;
100; Process table entry
101;
102; Note: P_PID must come first to simplify initialization
103;
104PROCESS STRUC
105P_PID DD ? ; Process ID (NO_PID: slot not used)
106P_LINEAR DD ? ; Linear address
107P_DSEG_SIZE DD ? ; Size of data segment
108P_LIN_SIZE DD ? ; Allocated linear addresses
109P_BRK DD ? ; Current break value
110P_INIT_BRK DD ? ; Initial break value
111P_STACK_ADDR DD ? ; Top of stack
112P_STACK_SIZE DD ? ; Stack size
113P_TEXT_OFF DD ? ; Start of code area
114P_TEXT_SIZE DD ? ; Size of code area
115P_DATA_OFF DD ? ; Start of data area
116P_DATA_SIZE DD ? ; Size of data area
117P_BSS_OFF DD ? ; Start of bss area
118P_BSS_SIZE DD ? ; Size of bss area
119P_ENTRY_POINT DD ? ; Entry point
120P_NUMBER DD ? ; Process number for __fpuemu()
121P_SYMBOLS DD ? ; Number of symbols
122P_STATUS DW ? ; Process status (PS_*)
123P_EXEC_HANDLE DW ? ; Handle of executable file
124P_LDT DW ? ; Selector of local descriptor table
125P_LDT_PTR DW ? ; Pointer to LDT
126P_UMASK DW ? ; umask
127P_UMASK1 DW ? ; umask (old semantics)
128P_LAST_BYTES DW ? ; Number of bytes in last page
129P_PIDX DB ? ; Process index for paging
130P_RC DB ? ; Return code (P_STATUS = PS_DEFUNCT)
131P_SIG_NO DB ? ; Signal number (P_STATUS = PS_STOP)
132P_HW_ACCESS DB ? ; -a option bits
133P_DRIVE DB ? ; -r option
134P_INTERFACE DB ? ; Interface version, from layout table
135P_PAD DB 0 DUP (?) ; Padding
136P_COMMIT_SIZE DD ? ; Additional pages
137P_SPAWN_RC DD ? ; Return code of child process (note 1)
138P_PAGE_FAULTS DD ? ; Number of page faults
139P_PPID DD ? ; Parent process id
140P_STR_OFF DD ? ; Offset of strings in symbol segment
141P_EXEC_OFFSET DD ? ; Offset of first page in exec file
142P_LAST_PAGE DD ? ; Last page of exec file (0=ignore)
143P_SYM_PAGE DD ? ; Page number for symbols
144P_RELOC_SIZE DD ? ; Size of relocation information
145P_FLAGS DD ? ; Flags (PF_*)
146P_TRUNC DD ? ; Bits set by -t option
147P_SIG_HANDLERS DD SIGNALS DUP (?) ; Signal handlers
148P_SA_MASK DD SIGNALS DUP (?) ; sa_mask of struct sigaction
149P_SA_FLAGS DD SIGNALS DUP (?) ; sa_flags of struct sigaction
150P_SIG_PENDING DD ? ; Pending signals (bitwise)
151P_SIG_BLOCKED DD ? ; Blocked signals (bitwise)
152P_UFLAGS DD ? ; These flags can be changed by process
153P_VESAINFO_PTR DD ? ; Pointer to VESA info data area
154P_PRF_BUFF DD ? ; profil(): Pointer to counters
155P_PRF_BUFSIZ DD ? ; profil(): Size of buffer
156P_PRF_OFFSET DD ? ; profil(): First address
157P_PRF_SCALE DD ? ; profil(): Scaling factor
158P_HANDLES DW MAX_FILES DUP (?) ; DOS file handles
159P_HFLAGS DW MAX_FILES DUP (?) ; Handle flags (note 2)
160;
161; Cf. PMINT.INC!!! (sequence, padding!)
162;
163P_GS DW ?
164P_FS DW ?
165P_ES DW ?
166P_DS DW ?
167P_EDI DD ?
168P_ESI DD ?
169P_EBP DD ?
170P_ESP_1 DD ?
171P_EBX DD ?
172P_EDX DD ?
173P_ECX DD ?
174P_EAX DD ?
175P_ERRCD DD ?
176P_EIP DD ?
177P_CS DW ?, 0
178P_EFLAGS DD ?
179P_ESP DD ?
180P_SS DW ?, 0
181;
182; Floating point status
183;
184 IF FLOATING_POINT
185P_CW DW ?, 0 ; Control-word register
186P_SW DW ?, 0 ; Status-word register
187P_TW DW ?, 0 ; Tag-word register
188P_FIP DD ? ; Last instruction (EIP)
189P_FCS DW ? ; Last instruction (CS)
190P_FOP DW ? ; Last instruction (opcode)
191P_FOO DD ? ; Memory operand offset
192P_FOS DW ?, 0 ; Memory operand segment
193P_FST DT 8 DUP (?) ; Stack
194 ENDIF
195PROCESS ENDS
196;
197; Note 1: The P_SPAWN_RC field contains the process ID of the child,
198; if a child has been spawned for debugging (NP_DEBUG)
199; or if an asynchronous child process has ended.
200;
201; Note 2: P_HFLAGS is 16 bits wide to simplify things -- everytime we
202; access P_HFLAGS, we also access P_HANDLES, therefore we already
203; have computed the offset (2 * handle)
204;
205
206;
207; Cf. <sys/process.h>
208;
209NP_SPAWN_SYNC = 0 ; P_WAIT
210NP_SPAWN_ASYNC = 1 ; P_NOWAIT
211NP_EXEC = 2 ; P_OVERLAY
212NP_DEBUG = 3 ; P_DEBUG
213
214NP2_QUOTE = 0001H ; P_QUOTE >> 16
215
216;
217; Cf. struct _new_proc in <sys/emx.h>
218;
219; Note: Fields sorted by size to avoid problems with alignment (gcc!)
220;
221NEW_PROC STRUC
222NP_ARG_OFF DD ? ; Pointer to arguments (offset)
223NP_ENV_OFF DD ? ; Pointer to environment (offset)
224NP_FNAME_OFF DD ? ; Pointer to file name (offset)
225NP_ARG_SEL DW ? ; Pointer to arguments (selector)
226NP_ENV_SEL DW ? ; Pointer to environment (selector)
227NP_FNAME_SEL DW ? ; Pointer to file name (selector)
228NP_ARG_COUNT DW ? ; Number of arguments
229NP_ARG_SIZE DW ? ; Size of arguments
230NP_ENV_COUNT DW ? ; Number of environment strings
231NP_ENV_SIZE DW ? ; Size of environment
232NP_MODE1 DW ? ; Lower 16 bits of mode (see above)
233NP_MODE2 DW ? ; Upper 16 bits of mode (note 2)
234; The fields below are in addition to the structure passed to function 7F06H
235NP_PARENT DW ? ; Pointer to parent process (note 3)
236NP_FPROC DW ? ; Pointer to files process (note 4)
237NEW_PROC ENDS
238
239NP_USER_SIZE = NEW_PROC.NP_MODE2 ; Size of structure passed to
240 ; function 7F06H
241;
242; Note 2: The NP_MODE2 field of the NEW_PROC structure is ignored unless
243; Bit 15 of NP_MODE1 is set.
244;
245; Note 3: The NP_PARENT field of the NEW_PROC structure points to the
246; process table entry of the process starting the new process.
247; If the new process is exec'ed (not spawned), this is *not*
248; the parent process.
249;
250; Note 4: The NP_FPROC field of the NEW_PROC structure points to the
251; process table entry of the process from which the file handles
252; and signal settings are to be inherited.
253;
254
255;
256; Timers
257;
258TT_NONE = 0
259TT_EXPIRED = 1
260TT_ALARM = 2
261TT_SLEEP = 3
262TT_TERMIO_TIME = 4
263
264TT_RUNNING = TT_ALARM ; T_TYPE >= TT_RUNNING -> running
265
266TIMER STRUC
267T_TYPE DW ? ; Type of timer
268T_PROCESS DW ? ; Pointer to process table entry
269T_TICKS DD ? ; Remaining timer ticks
270TIMER ENDS
271
272;
273; Status of floating point unit emulator. Some of the status information
274; should be kept in P_STATUS of the PTE for the client process instead.
275;
276FES_OFF = 0 ; FPU emu not loaded
277FES_NONE = 1 ; Failed to load the FPU emu
278FES_LOADING = 2 ; Loading the FPU emu
279FES_INIT1 = 3 ; Initialization, sending FPUN_NEWPROC
280FES_ON = 4 ; Normal state of the FPU emu
281FES_NEWPROC = 5 ; New process started
282FES_ENDPROC = 6 ; Process ended
283
284SV_DATA SEGMENT
285 EXTERNDEF CLOCK_LO:DWORD
286 EXTERNDEF CLOCK_HI:DWORD
287SV_DATA ENDS
288
289 IFNDEF __PROCESS
290
291SV_DATA SEGMENT
292
293 EXTRN PROCESS_TABLE:DWORD
294 EXTRN PROC0:PROCESS
295 EXTRN PROCESS_PTR:WORD
296 EXTRN PROCESS_SIG:WORD
297 EXTRN PROCESS_FP:WORD
298 EXTRN PROCESS_FPUEMU:WORD
299 EXTRN PROCESS_FPUCLIENT:WORD
300 EXTRN VIDEO_LIN:DWORD
301 EXTRN TIMER_TABLE:DWORD
302 EXTRN TIMER_MIN:DWORD
303 EXTRN TIMER_TICKS:DWORD
304 EXTRN FPUEMU_STATE:BYTE
305 EXTRN NP1:NEW_PROC
306 EXTRN EMX_DIR:BYTE
307
308SV_DATA ENDS
309
310
311SV_CODE SEGMENT
312
313 EXTRN NEW_PROCESS:NEAR
314 EXTRN FIND_PROCESS:NEAR
315 EXTRN REMOVE_PROCESS:NEAR
316 EXTRN ZOMBIE_PROCESS:NEAR
317 EXTRN KILL_PROCESS:NEAR
318 EXTRN SAVE_PROCESS:NEAR
319 EXTRN REST_PROCESS:NEAR
320 EXTRN WAIT_PROCESS:NEAR
321 EXTRN SET_TIMER:NEAR
322 EXTRN SLEEP:NEAR
323 EXTRN SET_COMMIT:NEAR
324 EXTRN CREATE_PID:NEAR
325 EXTRN FIND_EXEC:NEAR
326 EXTRN FPUEMU_LOAD:NEAR
327 EXTRN FPUEMU_CALL:NEAR
328 EXTRN FPUEMU_ENDPROC:NEAR
329 EXTRN FPUEMU_NEWPROC:NEAR
330
331SV_CODE ENDS
332
333
334INIT_CODE SEGMENT
335
336 EXTRN PROCESS_INIT:NEAR
337
338INIT_CODE ENDS
339
340 ENDIF
Note: See TracBrowser for help on using the repository browser.