home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 036 / emxfix02.zip / emx / src / os2 / emxdll.h < prev    next >
C/C++ Source or Header  |  1994-12-21  |  13KB  |  432 lines

  1. /* emxdll.h -- Global header file for emx.dll
  2.    Copyright (c) 1992-1994 by Eberhard Mattes
  3.  
  4. This file is part of emx.
  5.  
  6. emx is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. emx is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with emx; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. As special exception, emx.dll can be distributed without source code
  21. unless it has been changed.  If you modify emx.dll, this exception
  22. no longer applies and you must remove this paragraph from all source
  23. files for emx.dll.  */
  24.  
  25.  
  26. #define STR(X)  #X
  27. #define XSTR(X) STR(X)
  28.  
  29. #define ENTRY_POINT     0x10000
  30. #define U_OFFSET        0x0400
  31. #define KERNEL_U_ADDR   0x0e0000000
  32.  
  33. /* Bits in `handle_flags[]' and `files[].flags' */
  34.  
  35. #define HF_FILE         0x0001
  36. #define HF_DEV          0x0002
  37. #define HF_UPIPE        0x0004
  38. #define HF_NPIPE        0x0008
  39. #define HF_CON          0x0010
  40. #define HF_NUL          0x0040
  41. #define HF_CLK          0x0080
  42. #define HF_ASYNC        0x0100
  43. #define HF_SOCKET       0x0200
  44. #define HF_OPEN         0x1000
  45. #define HF_APPEND       0x2000
  46. #define HF_NDELAY       0x4000
  47.  
  48. #define L_FLAG_DLL              0x0001
  49. #define L_FLAG_LINK386          0x0002
  50.  
  51. #define FORK_REQ_DONE           0
  52. #define FORK_REQ_INIT           1
  53. #define FORK_REQ_MEM            2
  54.  
  55. #define FORK_OBJ_SIZE           0x20000 /* 128KB */
  56.  
  57. #define DEBUG_STDERR    1
  58. #define DEBUG_STACK     2
  59. #define DEBUG_SETMEM    4
  60. #define DEBUG_SYSCALL   8
  61. #define DEBUG_TERMIO    16
  62.  
  63. #define NSIG 22
  64.  
  65. #define FLAG_C          0x0001
  66. #define FLAG_Z          0x0040
  67.  
  68. typedef void (sigfun)(int signo);
  69.  
  70. struct _find;
  71. struct timeb;
  72. struct timeval;
  73. struct stat;
  74. struct _select;
  75. struct _new_proc;
  76.  
  77. struct signal_entry
  78. {
  79.   sigfun *handler;              /* Signal handler, SIG_DFL, or SIG_IGN */
  80.   ULONG sa_mask;                /* Signals to be blocked */
  81.   ULONG sa_flags;               /* Flags */
  82. };
  83.  
  84. typedef struct
  85. {
  86.   ULONG text_base;
  87.   ULONG text_end;
  88.   ULONG data_base;
  89.   ULONG data_end;
  90.   ULONG bss_base;
  91.   ULONG bss_end;
  92.   ULONG heap_base;
  93.   ULONG heap_end;
  94.   ULONG heap_brk;
  95.   ULONG heap_off;
  96.   ULONG os2_dll;
  97.   ULONG stack_base;
  98.   ULONG stack_end;
  99.   ULONG flags;
  100.   ULONG reserved[2];
  101.   char options[64];
  102. } layout_table;
  103.  
  104. typedef struct
  105. {
  106.   ULONG last_sys_errno;         /* Error code for last syscall */
  107.   ULONG prev_sys_errno;         /* Previous value of the above */
  108.   ULONG find_handle;
  109.   ULONG find_count;
  110.   ULONG sig_blocked;            /* Blocked signals */
  111.   ULONG sig_pending;            /* Pending signals */
  112.   ULONG sig_prev_blocked;       /* Previous signal mask */
  113.   FILEFINDBUF3 find_buf;
  114.   struct signal_entry sig_table[NSIG];
  115. } thread_data;
  116.  
  117. typedef union
  118. {
  119.   struct
  120.     {
  121.       ULONG edi;
  122.       ULONG esi;
  123.       ULONG ebp;
  124.       ULONG esp;
  125.       ULONG ebx;
  126.       ULONG edx;
  127.       ULONG ecx;
  128.       ULONG eax;
  129.       ULONG eflags;
  130.       ULONG eip;
  131.     } e;
  132.   struct
  133.     {
  134.       USHORT di;
  135.       USHORT edi_hi;
  136.       USHORT si;
  137.       USHORT esi_hi;
  138.       USHORT bp;
  139.       USHORT ebp_hi;
  140.       USHORT sp;
  141.       USHORT esp_hi;
  142.       USHORT bx;
  143.       USHORT ebx_hi;
  144.       USHORT dx;
  145.       USHORT edx_hi;
  146.       USHORT cx;
  147.       USHORT ecx_hi;
  148.       USHORT ax;
  149.       USHORT eax_hi;
  150.       USHORT flags;
  151.       USHORT eflags_hi;
  152.       USHORT ip;
  153.       USHORT eip_hi;
  154.     } x;
  155.   struct
  156.     {
  157.       ULONG edi;
  158.       ULONG esi;
  159.       ULONG ebp;
  160.       ULONG esp;
  161.       UCHAR bl;
  162.       UCHAR bh;
  163.       USHORT ebx_hi;
  164.       UCHAR dl;
  165.       UCHAR dh;
  166.       USHORT edx_hi;
  167.       UCHAR cl;
  168.       UCHAR ch;
  169.       USHORT ecx_hi;
  170.       UCHAR al;
  171.       UCHAR ah;
  172.       USHORT eax_hi;
  173.       ULONG eflags;
  174.       ULONG eip;
  175.     } b;
  176. } syscall_frame;
  177.  
  178. struct fork_data_mem
  179. {
  180.   ULONG req_code;
  181.   ULONG address;
  182.   ULONG count;
  183.   void *shared;
  184.   char buf[1];
  185. };
  186.  
  187. struct fork_data_init
  188. {
  189.   ULONG req_code;               /* Request code */
  190.   ULONG msize;                  /* Size of shared memory object */
  191.   ULONG brk;
  192.   ULONG stack_base;
  193.   ULONG stack_page;
  194.   ULONG reg_ebp;
  195.   struct signal_entry sig_actions[NSIG];
  196.   ULONG umask;
  197.   ULONG umask1;
  198.   ULONG uflags;                 /* User flags */
  199.   HEV req_sem;
  200.   HEV ack_sem;
  201. };
  202.  
  203. typedef union
  204. {
  205.   ULONG req_code;
  206.   struct fork_data_mem mem;
  207.   struct fork_data_init init;
  208. } fork_data;
  209.  
  210.  
  211. struct my_datetime
  212. {
  213.   ULONG seconds;
  214.   ULONG minutes;
  215.   ULONG hours;
  216.   ULONG day;
  217.   ULONG month;
  218.   ULONG year;
  219. };
  220.  
  221.  
  222. struct termio;
  223. struct termios;
  224.  
  225.  
  226. extern BYTE opt_drive;
  227. extern BYTE opt_trunc;
  228. extern BYTE opt_expand;
  229. extern BYTE opt_quote;
  230. extern ULONG debug_flags;
  231. extern HMTX common_mutex;
  232. extern BYTE debug_same_sess;
  233. extern ULONG pipe_number;
  234. extern ULONG queue_number;
  235. extern HFILE errout_handle;
  236. extern HEV signal_sem;
  237. extern HEV kbd_sem_new;
  238. extern ULONG stack_base;
  239. extern ULONG stack_end;
  240. extern ULONG heap_base;
  241. extern ULONG heap_off;
  242. extern ULONG brk_ptr;
  243. extern BYTE exe_name[];
  244. extern HFILE exe_fhandle;
  245. extern BYTE exe_heap;
  246. extern BYTE nocore_flag;
  247. extern BYTE no_popup;
  248. extern thread_data *threads[];
  249. extern ULONG layout_flags;
  250. extern BYTE interface;
  251. extern ULONG umask_bits;
  252. extern ULONG umask_bits1;
  253. extern char *startup_env;
  254. extern layout_table *layout;
  255. extern ULONG heap_size;
  256. extern ULONG heap_end;
  257. extern char kbd_started;
  258. extern ULONG my_pid;
  259. extern BYTE fork_flag;
  260. extern ULONG fork_exec_pid;
  261. extern char const signal_valid[NSIG];
  262. extern ULONG uflags;
  263. extern int zombie_count;
  264. extern char sig_flag;
  265. extern BYTE dont_doskillthread;
  266. extern ULONG version_major;
  267. extern ULONG version_minor;
  268.  
  269. #if defined (INCL_DOSPROCESS)
  270. extern PIB *init_pib_ptr;
  271. #endif
  272.  
  273. #if defined (INCL_DOSEXCEPTIONS)
  274. extern EXCEPTIONREGISTRATIONRECORD *exc_reg_ptr;
  275. #endif
  276.  
  277.  
  278. #define LOCK_COMMON    do_lock_common ()
  279. #define UNLOCK_COMMON  DosReleaseMutexSem (common_mutex)
  280.  
  281.  
  282. void truncate_name (char *dst, const char *src);
  283. ULONG set_error (ULONG rc);
  284. int xlate_errno (int e);
  285. void child_started (void);
  286. void start_cwait_thread (void);
  287. ULONG debug (void);
  288. ULONG debug_read_byte (ULONG addr, BYTE *dst);
  289. ULONG debug_read_word (ULONG addr, ULONG *dst);
  290. ULONG kbd_avail (void);
  291. int termio_read (ULONG handle, char *dst, unsigned count, int *errnop);
  292. void otext (const char *msg);
  293. void odword (ULONG x);
  294. void core_dump (void);
  295. ULONG core_main (ULONG handle);
  296. void core_regs_i (syscall_frame *frame);
  297. void generate_signal (thread_data *td, int signo);
  298. thread_data *get_thread (void);
  299. int get_tid (void);
  300. int proc_check (int pid);
  301. ULONG querysysinfo (ULONG index);
  302. unsigned long long get_clock (int init_flag);
  303. void init_signal16 (void);
  304. void touch (void *base, ULONG count);
  305. void conout (UCHAR chr);
  306.  
  307. #if defined (INCL_DOSEXCEPTIONS)
  308. void core_regs_e (CONTEXTRECORD *context);
  309. int initthread (EXCEPTIONREGISTRATIONRECORD *registration);
  310. void unwind (EXCEPTIONREGISTRATIONRECORD *registration,
  311.     EXCEPTIONREPORTRECORD *report);
  312. int deliver_pending_signals (thread_data *td, syscall_frame *frame,
  313.     CONTEXTRECORD *context_record);
  314. #endif
  315.  
  316. void init_fileio (void);
  317. void init_processes (void);
  318. void init_memory (void);
  319. void init_fork (const char *s);
  320. void init_exceptions (void);
  321. void use_layout (void);
  322. void initialize1 (void);
  323. void initialize2 (void);
  324. void *allocate_obj (ULONG size, ULONG flags);
  325. ULONG free_obj (void *mem);
  326. ULONG setmem (ULONG base, ULONG size, ULONG flags, ULONG error);
  327. ULONG setmem_error (ULONG rc);
  328. void *allocate_sub (ULONG size);
  329. ULONG sub_alloc (void **mem, ULONG size);
  330. ULONG sub_free (void *mem, ULONG size);
  331. void error (ULONG rc, const char *msg);
  332. void receive_signals (void);
  333. ULONG reset_event_sem (HEV sem);
  334. sigfun *do_signal (ULONG signo, sigfun *handler, syscall_frame *frame);
  335. void do_raise (int signo, syscall_frame *frame);
  336. int do_kill (int signo, int pid, syscall_frame *frame, int *errnop);
  337. void sig_block_start (void);
  338. void sig_block_end (void);
  339. ULONG set_alarm (ULONG value);
  340. void stop_alarm (void);
  341. ULONG do_wait (ULONG *ptermstatus, ULONG *errnop);
  342. ULONG do_waitpid (ULONG pid, ULONG opt, ULONG *ptermstatus,
  343.     ULONG *errnop);
  344. void init_heap (void);
  345. long do_sbrk (long incr);
  346. long do_brk (ULONG brkp);
  347. int do_fcntl (ULONG handle, ULONG request, ULONG arg, int *errnop);
  348. int do_ioctl1 (ULONG handle, int *errnop);
  349. int do_ioctl2 (ULONG handle, ULONG request, ULONG arg, int *errnop);
  350. int do_dup (ULONG handle, ULONG target, int *errnop);
  351. int do_close (ULONG handle);
  352. ULONG do_read (ULONG handle, void *dst, ULONG count, int *errnop);
  353. ULONG do_write (ULONG handle, void *src, ULONG count, int *errnop);
  354. ULONG do_seek (ULONG handle, ULONG origin, LONG distance, int *errnop);
  355. int do_pipe (int *dst, ULONG pipesize);
  356. int do_ftruncate (ULONG handle, ULONG fsize);
  357. int do_chsize (ULONG handle, ULONG fsize);
  358. int do_fsync (ULONG handle, int *errnop);
  359. int do_filesys (char *dst, ULONG dst_size, const char *drv_name, int *errnop);
  360. int do_mkdir (const char *path);
  361. int do_rmdir (const char *path);
  362. int do_chdir (const char *path);
  363. int do_delete (const char *path);
  364. int do_rename (const char *old_path, const char *new_path);
  365. UCHAR do_getdrive (void);
  366. ULONG do_selectdisk (ULONG drv);
  367. int old_creat (const char *path, ULONG attr, int *errnop);
  368. int old_open (const char *path, ULONG mode, int *errnop);
  369. int sys_open (const char *path, unsigned flags, int *errnop);
  370. int do_stat (const char *path, struct stat *dst, int *errnop);
  371. int do_fstat (ULONG handle, struct stat *dst, int *errnop);
  372. int do_utimes (const char *path, const struct timeval *tv, int *errnop);
  373. void do_lock_common (void);
  374. ULONG create_event_sem (HEV *psem, ULONG attr);
  375. ULONG create_mutex_sem (HMTX *psem);
  376. void request_mutex (HMTX sem);
  377. ULONG get_attr (const char *path, int *errnop);
  378. ULONG set_attr (const char *path, ULONG attr);
  379. ULONG do_getcwd (char *dst, int drive);
  380. ULONG do_find_first (const char *path, ULONG attr, struct _find *dst);
  381. ULONG do_find_next (struct _find *dst);
  382. ULONG do_get_timestamp (ULONG handle, ULONG *time, ULONG *date);
  383. ULONG do_set_timestamp (ULONG handle, ULONG time, ULONG date);
  384. ULONG do_imphandle (ULONG handle, int *errnop);
  385. int check_npipe (const char *s);
  386. void copy_fork (void);
  387. ULONG new_thread (ULONG tid, int *errnop);
  388. ULONG end_thread (ULONG tid, int *errnop);
  389. void kbd_stop (void);
  390. void kbd_init (void);
  391. void kbd_restart (void);
  392. void quit (ULONG rc) __attribute__ ((noreturn));
  393. void do_ftime (struct timeb *dst);
  394. ULONG do_spawn (struct _new_proc *np, ULONG *result);
  395. void do_pause (void);
  396. int do_ptrace (ULONG request, ULONG pid, ULONG addr, ULONG data,
  397.     ULONG *errnop);
  398. ULONG spawn_debug (ULONG pid, ULONG sid);
  399. int do_fork (syscall_frame *frame, ULONG *errnop);
  400. int do_select (struct _select *args, int *errnop);
  401. int execname (char *buf, ULONG bufsize);
  402. void debug_set_wait (ULONG pid, ULONG wait_ret, ULONG end);
  403. void unix2time (struct my_datetime *dst, ULONG src);
  404. ULONG packed2unix (FDATE date, FTIME time);
  405. int kbd_input (UCHAR *dst, int binary_p, int echo_p, int wait_p,
  406.     int check_avail_p);
  407. void conin_string (UCHAR *buf);
  408. int sprintf (char *dst, const char *fmt, ...);
  409. void oprintf (const char *fmt, ...);
  410. ULONG query_async (ULONG handle);
  411. ULONG translate_async (ULONG handle);
  412. void init_termio (ULONG handle);
  413. void termio_set (ULONG handle, const struct termio *tio);
  414. void termio_get (ULONG handle, struct termio *tio);
  415. void termios_set (ULONG handle, const struct termios *tio);
  416. void termios_get (ULONG handle, struct termios *tio);
  417. void termio_flush (ULONG handle);
  418. ULONG termio_avail (ULONG handle);
  419. ULONG async_avail (ULONG handle);
  420.  
  421. int pm_init (void);
  422. void pm_message_box (PCSZ text);
  423.  
  424. #if defined (_SIGSET_T)
  425. int do_sigaction (int sig, const struct sigaction *iact,
  426.     struct sigaction *oact);
  427. int do_sigpending (sigset_t *set);
  428. int do_sigprocmask (int how, const sigset_t *iset, sigset_t *oset,
  429.     syscall_frame *frame);
  430. int do_sigsuspend (const sigset_t *mask);
  431. #endif
  432.