source: vendor/emx/current/src/os2/emxdll.h

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: 17.1 KB
Line 
1/* emxdll.h -- Global header file for emx.dll
2 Copyright (c) 1992-2000 by Eberhard Mattes
3
4This file is part of emx.
5
6emx is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11emx is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with emx; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA.
20
21As special exception, emx.dll can be distributed without source code
22unless it has been changed. If you modify emx.dll, this exception
23no longer applies and you must remove this paragraph from all source
24files for emx.dll. */
25
26
27#define STR(X) #X
28#define XSTR(X) STR(X)
29
30/* Round up to the next integral multiple of the page size. */
31
32#define ROUND_PAGE(x) ((((x) - 1) & ~0xfff) + 0x1000)
33
34/* IBM TCP/IP's socket handles are < 2048. See also emxdll.asm. */
35
36#define MAX_SOCKETS 2048
37
38/* Maximum number of file handles created by sock_init(). As of
39 TCP/IP 2.0, sock_init() creates two handles. */
40
41#define MAXFH_SOCK_INIT 2
42
43/* Maximum number of heap objects (16 = 512 / 32). */
44
45#define MAX_HEAP_OBJS 16
46
47/* This is the default heap object size. */
48
49#define HEAP_OBJ_SIZE (32 * 1024 * 1024)
50
51#define ENTRY_POINT 0x10000
52#define U_OFFSET 0x0400
53#define KERNEL_U_ADDR 0x0e0000000
54
55/* Bits in `handle_flags[]' and `files[].flags' */
56
57#define HF_FILE 0x0001
58#define HF_DEV 0x0002
59#define HF_UPIPE 0x0004
60#define HF_NPIPE 0x0008
61#define HF_CON 0x0010
62#define HF_NUL 0x0040
63#define HF_CLK 0x0080
64#define HF_ASYNC 0x0100
65#define HF_SOCKET 0x0200
66#define HF_XF86SUP 0x0400
67#define HF_OPEN 0x1000
68#define HF_APPEND 0x2000
69#define HF_NDELAY 0x4000
70#define HF_NOINHERIT 0x80000000 /* Temporarily used while forking */
71
72#define L_FLAG_DLL 0x0001
73#define L_FLAG_LINK386 0x0002
74
75#define FORK_REQ_DONE 0
76#define FORK_REQ_INIT 1
77#define FORK_REQ_DLL 2
78#define FORK_REQ_MEM 3
79
80#define FORK_OBJ_SIZE 0x20000 /* 128KB */
81
82#define DEBUG_STDERR 0x0001 /* Open CON device, don't use handle 2 */
83#define DEBUG_STACK 0x0002 /* Unused */
84#define DEBUG_SETMEM 0x0004 /* Show setmem() arguments */
85#define DEBUG_SYSCALL 0x0008 /* Show syscalls */
86#define DEBUG_TERMIO 0x0010 /* Unused */
87#define DEBUG_FIND1 0x0020 /* Fetch only 1 entry with DosFindFirst/Next */
88#define DEBUG_QPINFO2 0x0040 /* Call DosQueryPathInfo twice */
89#define DEBUG_NOXF86SUP 0x0080 /* Don't check for xf86sup devices */
90#define DEBUG_NOINHSIG 0x0100 /* Don't inherit signal actions */
91#define DEBUG_NOFDZERO 0x0200 /* Don't fix select()'s missing FD_ZERO bug */
92#define DEBUG_NOFORKDLL 0x0400 /* Don't load DLLs in forked process */
93#define DEBUG_SOCLOSE 0x0800 /* Don't mind socket closed behind our back */
94
95#define NSIG 29
96
97#define FIND_COUNT 4
98
99#define FLAG_C 0x0001
100#define FLAG_Z 0x0040
101
102/* TRUNC_DRV() is defined for 'A' through 'Z', 'a' through 'z', and 1
103 through 26. */
104
105#define TRUNC_UNC (1 << 0)
106#define TRUNC_DRV(c) (1 << ((c) & 0x1f))
107#define TRUNC_ALL (~0)
108
109typedef void (sigfun)(int signo);
110
111struct select_data;
112struct stat;
113struct termio;
114struct termios;
115struct timeb;
116struct timeval;
117struct _find;
118struct _new_proc;
119struct _profil;
120struct _select;
121
122struct signal_entry
123{
124 sigfun *handler; /* Signal handler, SIG_DFL, or SIG_IGN */
125 ULONG sa_mask; /* Signals to be blocked */
126 ULONG sa_flags; /* Flags */
127};
128
129typedef struct
130{
131 ULONG text_base;
132 ULONG text_end;
133 ULONG data_base;
134 ULONG data_end;
135 ULONG bss_base;
136 ULONG bss_end;
137 ULONG heap_base;
138 ULONG heap_end;
139 ULONG heap_brk;
140 ULONG heap_off;
141 ULONG os2_dll;
142 ULONG stack_base;
143 ULONG stack_end;
144 ULONG flags;
145 ULONG reserved[2];
146 char options[64];
147} layout_table;
148
149typedef struct
150{
151 ULONG last_sys_errno; /* Error code for last syscall */
152 ULONG prev_sys_errno; /* Previous value of the above */
153 ULONG find_handle;
154 ULONG find_count;
155 ULONG sig_blocked; /* Blocked signals */
156 ULONG sig_pending; /* Pending signals */
157 ULONG sig_prev_blocked; /* Previous signal mask */
158 FILEFINDBUF3 find_buf[FIND_COUNT];
159 const FILEFINDBUF3 *find_next;
160 struct signal_entry sig_table[NSIG];
161} thread_data;
162
163typedef union
164{
165 struct
166 {
167 ULONG edi;
168 ULONG esi;
169 ULONG ebp;
170 ULONG esp;
171 ULONG ebx;
172 ULONG edx;
173 ULONG ecx;
174 ULONG eax;
175 ULONG eflags;
176 ULONG eip;
177 } e;
178 struct
179 {
180 USHORT di;
181 USHORT edi_hi;
182 USHORT si;
183 USHORT esi_hi;
184 USHORT bp;
185 USHORT ebp_hi;
186 USHORT sp;
187 USHORT esp_hi;
188 USHORT bx;
189 USHORT ebx_hi;
190 USHORT dx;
191 USHORT edx_hi;
192 USHORT cx;
193 USHORT ecx_hi;
194 USHORT ax;
195 USHORT eax_hi;
196 USHORT flags;
197 USHORT eflags_hi;
198 USHORT ip;
199 USHORT eip_hi;
200 } x;
201 struct
202 {
203 ULONG edi;
204 ULONG esi;
205 ULONG ebp;
206 ULONG esp;
207 UCHAR bl;
208 UCHAR bh;
209 USHORT ebx_hi;
210 UCHAR dl;
211 UCHAR dh;
212 USHORT edx_hi;
213 UCHAR cl;
214 UCHAR ch;
215 USHORT ecx_hi;
216 UCHAR al;
217 UCHAR ah;
218 USHORT eax_hi;
219 ULONG eflags;
220 ULONG eip;
221 } b;
222} syscall_frame;
223
224struct fork_data_dll
225{
226 ULONG req_code; /* Request code */
227 HMODULE hmod; /* Module handle */
228 char path[CCHMAXPATH+1]; /* File name */
229};
230
231struct fork_data_mem
232{
233 ULONG req_code; /* Request code */
234 ULONG address;
235 ULONG count;
236 HMODULE hmod;
237 void *shared;
238 char buf[1];
239};
240
241struct fork_data_init
242{
243 ULONG req_code; /* Request code */
244 ULONG msize; /* Size of shared memory object */
245 ULONG brk;
246 ULONG stack_base;
247 ULONG stack_page;
248 ULONG reg_ebp;
249 ULONG umask;
250 ULONG umask1;
251 ULONG uflags; /* User flags */
252 HEV req_sem;
253 HEV ack_sem;
254};
255
256struct fork_sock
257{
258 int f; /* File handle */
259 int s; /* Socket handle */
260};
261
262struct fork_data_done
263{
264 ULONG req_code; /* Request code */
265 ULONG size; /* Number of bytes used for this structure */
266 struct signal_entry sig_actions[NSIG];
267 ULONG handle_count; /* Number of file handles */
268 ULONG *fd_flags_array; /* FD_CLOEXEC */
269 ULONG sock_init_count; /* Number of handles created by sock_init() */
270 ULONG sock_init_array[MAXFH_SOCK_INIT];
271 ULONG sock_count; /* Number of sockets */
272 struct fork_sock *sock_array; /* File and socket handles */
273};
274
275typedef union
276{
277 ULONG req_code;
278 struct fork_data_dll dll;
279 struct fork_data_mem mem;
280 struct fork_data_init init;
281 struct fork_data_done done;
282} fork_data;
283
284
285struct my_datetime
286{
287 ULONG seconds;
288 ULONG minutes;
289 ULONG hours;
290 ULONG day;
291 ULONG month;
292 ULONG year;
293};
294
295/* This structure describes one heap object. */
296
297struct heap_obj
298{
299 ULONG base; /* Base address */
300 ULONG end; /* End address */
301 ULONG brk; /* Address of first unused byte */
302};
303
304extern BYTE opt_drive;
305extern ULONG opt_trunc;
306extern BYTE opt_expand;
307extern BYTE opt_quote;
308extern ULONG debug_flags;
309extern HMTX common_mutex;
310extern BYTE debug_same_sess;
311extern HFILE errout_handle;
312extern HEV signal_sem;
313extern HEV kbd_sem_new;
314extern ULONG stack_base;
315extern ULONG stack_end;
316extern BYTE exe_name[];
317extern HFILE exe_fhandle;
318extern BYTE exe_heap;
319extern BYTE nocore_flag;
320extern BYTE no_popup;
321extern thread_data *threads[];
322extern ULONG layout_flags;
323extern BYTE interface;
324extern ULONG umask_bits;
325extern ULONG umask_bits1;
326extern char *startup_env;
327extern layout_table *layout;
328extern char kbd_started;
329extern ULONG my_pid;
330extern BYTE fork_flag;
331extern ULONG fork_exec_pid;
332extern char const signal_valid[NSIG];
333extern ULONG uflags;
334extern int zombie_count;
335extern char sig_flag;
336extern BYTE dont_doskillthread;
337extern ULONG version_major;
338extern ULONG version_minor;
339extern ULONG heap_obj_size;
340extern unsigned heap_obj_count;
341extern char first_heap_obj_fixed;
342extern ULONG heap_off;
343extern struct heap_obj *top_heap_obj;
344extern struct heap_obj heap_objs[MAX_HEAP_OBJS];
345extern BYTE ptrace_forking;
346extern ULONG ptrace_fork_addr;
347
348#if defined (INCL_DOSPROCESS)
349extern PIB *init_pib_ptr;
350#endif
351
352#if defined (INCL_DOSEXCEPTIONS)
353extern EXCEPTIONREGISTRATIONRECORD *exc_reg_ptr;
354#endif
355
356/* The following variables reside in a shared data object and are
357 defined in emxdll.asm. */
358
359/* Counter for creating unique names for named pipes. */
360
361extern ULONG pipe_number;
362
363/* Counter for creating unique names for queues. */
364
365extern ULONG queue_number;
366
367/* This array holds reference counts for socket handles:
368 sock_proc_count[S] is the number of processes referencing socket
369 handle S. The per-process reference count is maintained in *files,
370 see files.h. Fortunately, the range of socket handles of IBM
371 TCP/IP is bound: all socket handles are less than 2048; see
372 FD_SETSIZE in IBM's <sys/socket.h>. */
373
374extern ULONG sock_proc_count[MAX_SOCKETS];
375
376
377/* Access to shared data should be enclosed in LOCK_COMMON and
378 UNLOCK_COMMON. */
379
380#define LOCK_COMMON do_lock_common ()
381#define UNLOCK_COMMON DosReleaseMutexSem (common_mutex)
382
383
384/* Prototypes. */
385
386void truncate_name (char *dst, const char *src);
387ULONG set_error (ULONG rc);
388int xlate_errno (int e);
389void child_started (void);
390void start_cwait_thread (void);
391ULONG kbd_avail (void);
392int termio_read (ULONG handle, char *dst, unsigned count, int *errnop);
393void otext (const char *msg);
394void odword (ULONG x);
395void core_dump (void);
396ULONG core_main (ULONG handle);
397void core_regs_i (syscall_frame *frame);
398void generate_signal (thread_data *td, int signo);
399thread_data *get_thread (void);
400int get_tid (void);
401int proc_check (int pid);
402ULONG querysysinfo (ULONG index);
403unsigned long long get_clock (int init_flag);
404void init_signal16 (void);
405void touch (void *base, ULONG count);
406void conout (UCHAR chr);
407ULONG load_module (const char *mod_name, HMODULE *phmod);
408int verify_memory (ULONG start, ULONG size);
409
410#if defined (INCL_DOSEXCEPTIONS)
411void core_regs_e (CONTEXTRECORD *context);
412int initthread (EXCEPTIONREGISTRATIONRECORD *registration);
413void unwind (EXCEPTIONREGISTRATIONRECORD *registration,
414 EXCEPTIONREPORTRECORD *report);
415int deliver_pending_signals (thread_data *td, syscall_frame *frame,
416 CONTEXTRECORD *context_record);
417#endif
418
419void init_fileio (void);
420void init_process (void);
421void init_fork (const char *s);
422void init_exceptions (void);
423void initialize1 (void);
424void initialize2 (void);
425void init2_signal (void);
426void term_process (void);
427void term_memory (void);
428void term_semaphores (void);
429void term_tcpip (void);
430void term_signal (void);
431ULONG setmem (ULONG base, ULONG size, ULONG flags, ULONG error);
432ULONG setmem_error (ULONG rc);
433void *checked_private_alloc (ULONG size);
434ULONG private_alloc (void **mem, ULONG size);
435ULONG private_free (void *mem);
436void error (ULONG rc, const char *msg);
437int conv_hex8 (const char *s, ULONG *dst);
438void receive_signals (void);
439ULONG reset_event_sem (HEV sem);
440sigfun *do_signal (ULONG signo, sigfun *handler, syscall_frame *frame);
441void do_raise (int signo, syscall_frame *frame);
442int do_kill (int signo, int pid, syscall_frame *frame, int *errnop);
443void sig_block_start (void);
444void sig_block_end (void);
445ULONG set_alarm (ULONG value);
446void stop_alarm (void);
447ULONG do_wait (ULONG *ptermstatus, ULONG *errnop);
448ULONG do_waitpid (ULONG pid, ULONG opt, ULONG *ptermstatus,
449 ULONG *errnop);
450void init_heap (void);
451long do_sbrk (long incr);
452long do_brk (ULONG brkp);
453int do_fcntl (ULONG handle, ULONG request, ULONG arg, int *errnop);
454int do_ioctl1 (ULONG handle, int *errnop);
455int do_ioctl2 (ULONG handle, ULONG request, ULONG arg, int *errnop);
456int do_dup (ULONG handle, ULONG target, int *errnop);
457int do_close (ULONG handle);
458ULONG do_read (ULONG handle, void *dst, ULONG count, int *errnop);
459ULONG do_write (ULONG handle, void *src, ULONG count, int *errnop);
460ULONG do_seek (ULONG handle, ULONG origin, LONG distance, int *errnop);
461int do_pipe (int *dst, ULONG pipesize);
462int do_ftruncate (ULONG handle, ULONG fsize);
463int do_chsize (ULONG handle, ULONG fsize);
464int do_fsync (ULONG handle, int *errnop);
465int do_filesys (char *dst, ULONG dst_size, const char *drv_name, int *errnop);
466int do_mkdir (const char *path);
467int do_rmdir (const char *path);
468int do_chdir (const char *path);
469int do_delete (const char *path);
470int do_rename (const char *old_path, const char *new_path);
471UCHAR do_getdrive (void);
472ULONG do_selectdisk (ULONG drv);
473int old_creat (const char *path, ULONG attr, int *errnop);
474int old_open (const char *path, ULONG mode, int *errnop);
475int sys_open (const char *path, unsigned flags, unsigned long size,
476 int *errnop);
477int do_stat (const char *path, struct stat *dst, int *errnop);
478int do_fstat (ULONG handle, struct stat *dst, int *errnop);
479int do_utimes (const char *path, const struct timeval *tv, int *errnop);
480int do_ttyname (char *dst, ULONG dst_size, ULONG handle, int *errnop);
481void do_lock_common (void);
482ULONG create_event_sem (HEV *psem, ULONG attr);
483void close_event_sem (HEV sem);
484ULONG create_mutex_sem (HMTX *psem);
485void request_mutex (HMTX sem);
486ULONG create_muxwait_sem (HMUX *psem, ULONG count, SEMRECORD *array,
487 ULONG attr);
488void close_muxwait_sem (HMUX sem);
489ULONG get_attr (const char *path, int *errnop);
490ULONG set_attr (const char *path, ULONG attr);
491ULONG do_getcwd (char *dst, int drive);
492ULONG do_find_first (const char *path, ULONG attr, struct _find *dst);
493ULONG do_find_next (struct _find *dst);
494ULONG do_get_timestamp (ULONG handle, ULONG *time, ULONG *date);
495ULONG do_set_timestamp (ULONG handle, ULONG time, ULONG date);
496ULONG do_imphandle (ULONG handle, int *errnop);
497int check_npipe (const char *s);
498int set_ttyname (char *dst, ULONG dst_size, const char *name, int *errnop);
499void fork_register_mem (ULONG start, ULONG end, HMODULE hmod);
500void fork_register_dll (HMODULE hmod);
501int fork_dll_registered (HMODULE hmod);
502void copy_fork (void);
503void fileio_fork_parent_init (void);
504void fileio_fork_parent_fillin (struct fork_data_done *p);
505void fileio_fork_parent_restore (void);
506void fileio_fork_child (struct fork_data_done *p);
507ULONG new_thread (ULONG tid, int *errnop);
508ULONG end_thread (ULONG tid, int *errnop);
509void kbd_stop (void);
510void kbd_init (void);
511void kbd_restart (void);
512void quit (ULONG rc) __attribute__ ((noreturn));
513void do_ftime (struct timeb *dst);
514int do_settime (const struct timeval *tp, int *errnop);
515ULONG do_spawn (struct _new_proc *np, ULONG *result);
516void do_pause (void);
517int do_ptrace (ULONG request, ULONG pid, ULONG addr, ULONG data,
518 ULONG *errnop);
519ULONG spawn_debug (ULONG pid, ULONG sid);
520int do_fork (syscall_frame *frame, ULONG *errnop);
521int do_select (struct _select *args, int *errnop);
522int execname (char *buf, ULONG bufsize);
523void debug_set_wait (ULONG pid, ULONG tid, ULONG wait_ret, ULONG end);
524ULONG proc_add_attach (ULONG pid);
525void proc_remove_attach (ULONG pid);
526void unix2time (struct my_datetime *dst, ULONG src);
527ULONG packed2unix (FDATE date, FTIME time);
528int kbd_input (UCHAR *dst, int binary_p, int echo_p, int wait_p,
529 int check_avail_p);
530void conin_string (UCHAR *buf);
531int sprintf (char *dst, const char *fmt, ...);
532void oprintf (const char *fmt, ...);
533ULONG get_dbcs_lead (void);
534ULONG query_async (ULONG handle);
535ULONG translate_async (ULONG handle);
536void init_termio (ULONG handle);
537void termio_set (ULONG handle, const struct termio *tio);
538void termio_get (ULONG handle, struct termio *tio);
539void termios_set (ULONG handle, const struct termios *tio);
540void termios_get (ULONG handle, struct termios *tio);
541void termio_flush (ULONG handle);
542ULONG termio_avail (ULONG handle);
543ULONG async_avail (ULONG handle);
544ULONG async_writable (ULONG handle);
545int do_profil (const struct _profil *p, int *errnop);
546
547void exit_tcpip (void);
548int tcpip_init_fork (const struct fork_data_done *p);
549void copy_fork_sock (const struct fork_data_done *p);
550void tcpip_fork_sock (struct fork_data_done *p);
551void tcpip_undo_fork_sock (const struct fork_data_done *p);
552
553int pm_init (void);
554void pm_term (void);
555void pm_message_box (PCSZ text);
556
557#if defined (_SIGSET_T)
558int do_sigaction (int sig, const struct sigaction *iact,
559 struct sigaction *oact);
560int do_sigpending (sigset_t *set);
561int do_sigprocmask (int how, const sigset_t *iset, sigset_t *oset,
562 syscall_frame *frame);
563int do_sigsuspend (const sigset_t *mask);
564#endif
565
566ULONG xf86sup_query (ULONG handle, ULONG *pflags);
567int xf86sup_avail (ULONG handle, int *errnop);
568int xf86sup_ioctl (ULONG handle, ULONG request, ULONG arg, int *errnop);
569int xf86sup_fcntl (ULONG handle, ULONG request, ULONG arg, int *errnop);
570int xf86sup_select_add_read (struct select_data *d, int fd);
571int xf86sup_ttyname (char *dst, ULONG dst_size, ULONG handle, int *errnop);
572ULONG xf86sup_uncond_enadup (ULONG handle, ULONG on);
573ULONG xf86sup_maybe_enadup (ULONG handle, ULONG on);
574void xf86sup_all_enadup (ULONG on);
Note: See TracBrowser for help on using the repository browser.