/*
 *  Function prototypes used by the iBCS2 emulator
 *
 * $Id: ibcs.h,v 1.1.1.2 1994/02/23 17:22:54 mike Exp $
 * $Source: /var/CVS/ibcs/ibcs.h,v $
 */
#include <linux/sys.h>		/* for fn_ptr */
#include <linux/ptrace.h>	/* for pt_regs */
#include <linux/signal.h>

/*
 * the function prefix sys_... are used by linux in native mode.
 * ibcs_... are emulation interfaces for routine that differ from iBCS2 
 * and linux.  The xnx_... are xenix routines.  Note, just because
 * xnx routines are listed doesn't mean we support native xenix binaries.
 * (yet :-)
 */
typedef struct IBCS_function {
	void *	kfunc;	/* function to call (sys_..., ibcs_... or xnx_...)
			 * or pointer to a sub class.
			 */
	short	nargs;	/* number of args to kfunc or Ukn, Spl or Fast */
#ifdef IBCS_TRACE
	short	trace;	/* trace function we can turn tracing on or off */
	char *	name;	/* name of function (for tracing) */
	char *	args;	/* how to print the arg list (see plist) */
#endif
} IBCS_func;

struct ibcs_statfs {
	short f_type;
	long f_bsize;
	long f_frsize;
	long f_blocks;
	long f_bfree;
	long f_files;
	long f_ffree;
	char f_fname[6];
	char f_fpack[6];
};

struct ibcs_stat {
        unsigned short st_dev;
        unsigned short st_ino;
        unsigned short st_mode;
        unsigned short st_nlink;
        unsigned short st_uid;
        unsigned short st_gid;
        unsigned short st_rdev;
        unsigned long  st_size;
        unsigned long  st_atime;
        unsigned long  st_mtime;
        unsigned long  st_ctime;
};

/* coff.c */
extern int ibcs_fork(struct pt_regs * regs);
extern int ibcs_pipe(struct pt_regs * regs);
extern int ibcs_getpid(struct pt_regs * regs);
extern int ibcs_getuid(struct pt_regs * regs);
extern int ibcs_getgid(struct pt_regs * regs);
extern int ibcs_wait(struct pt_regs * regs);
extern int ibcs_execv(struct pt_regs * regs);
extern int ibcs_exec(struct pt_regs * regs);
extern int ibcs_trace_set(int);
extern int ibcs_trace_func(int, int, int);
extern int ibcs_utsname(int);
extern int ibcs_read(int fd, char *buf, int nbytes);
extern int ibcs_procids(struct pt_regs * regs);
extern int ibcs_select(struct pt_regs *regs);

/* emulate.c */
extern void iABI_emulate(struct pt_regs *regs);
extern void ibcs_exit(int n);
extern int iABI_errors(int errno);
extern int ibcs_syscall(struct pt_regs *regs);

/* fcntl.c */
extern int ibcs_fcntl(struct pt_regs *regs);

/* ioctl.c */
extern int ibcs_ioctl(int fd, unsigned int ioctl_num, void *arg);

/* ipc.c */
extern int ibcs_semsys (struct pt_regs *regs);
extern int ibcs_shmsys (struct pt_regs *regs);

/* mmap.c */
extern int ibcs_mmap(unsigned int vaddr, unsigned int vsize, int prot,
 		     int flags, int fd, unsigned int file_offset);

/* open.c */
extern int ibcs_statfs(const char * path, struct ibcs_statfs * buf);
extern int ibcs_fstatfs(unsigned int fd, struct ibcs_statfs * buf);
extern int ibcs_open(const char * fname, int flag, int mode);
extern int ibcs_getdents(int fd, char *buf, int nybtes);

/* poll.c */
extern int ibcs_poll(struct poll * fds, size_t nfds, int timeout);

/* signal.c */
void ibcs_sig_handler (struct pt_regs * regs, int sig, __sighandler_t handler);
extern int ibcs_signal(struct pt_regs * regs);
extern int ibcs_sigset(struct pt_regs * regs);
void ibcs_sighold (struct pt_regs * regs);
void ibcs_sigrelse (struct pt_regs * regs);
void ibcs_sigignore (struct pt_regs * regs);
void ibcs_sigpause (struct pt_regs * regs);
extern int ibcs_sigfunc(struct pt_regs * regs);
extern int ibcs_kill(int pid, int sig);

/* socket.c */
extern int ibcs_getsockopt(unsigned long *sp);
extern int ibcs_setsockopt(unsigned long *sp);

/* stat.c */
extern int ibcs_stat(char * filename, struct ibcs_stat * statbuf);
extern int ibcs_lstat(char * filename, struct ibcs_stat * statbuf);
extern int ibcs_fstat(unsigned int fd, struct ibcs_stat * statbuf);

/* sysconf.c */
extern int sys_sysconf(int name);

/* sysfs.c */
extern int ibcs_sysfs(struct pt_regs * regs);

/* sysi86.c */
extern int ibcs_sysi86(struct pt_regs * regs);

/* ulimit.c */
extern int ibcs_ulimit(int cmd, int val);

/* wysev386.c */
extern int wv386_gethostname(char *name, int len);
extern int wv386_getdomainname(char *name, int len);
extern int wv386_wait3(int *loc);
extern int wv386_socket(struct pt_regs *regs);
extern int wv386_connect(struct pt_regs *regs);
extern int wv386_accept(struct pt_regs *regs);
extern int wv386_send(struct pt_regs *regs);
extern int wv386_recv(struct pt_regs *regs);
extern int wv386_bind(struct pt_regs *regs);
extern int wv386_setsockopt(struct pt_regs *regs);
extern int wv386_listen(struct pt_regs *regs);
extern int wv386_getsockopt(struct pt_regs *regs);
extern int wv386_recvfrom(struct pt_regs *regs);
extern int wv386_sendto(struct pt_regs *regs);
extern int wv386_shutdown(struct pt_regs *regs);
extern int wv386_socketpair(struct pt_regs *regs);
extern int wv386_getpeername(struct pt_regs *regs);
extern int wv386_getsockname(struct pt_regs *regs);

/* From wysev386i.c */
extern int wv386_ioctl(int fd, unsigned int ioctl_num, void *arg);

/* From socksys.c */
extern void init_socksys(void);
extern void cleanup_socksys(void);
