/* 
 * Mach Operating System
 * Copyright (c) 1992 Carnegie Mellon University
 * All Rights Reserved.
 * 
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 * 
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 * 
 * Carnegie Mellon requests users of this software to return to
 * 
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 * 
 * any improvements or extensions that they make and grant Carnegie Mellon 
 * the rights to redistribute these changes.
 */
/*
 * HISTORY
 * $Log:	bsd_1.defs,v $
 * Revision 2.1  92/04/21  17:10:52  rwd
 * BSDSS
 * 
 *
 */

/*
 * IPC interface for selected UX server functions.
 */
subsystem bsd_1		101000;

#include <mach/mach_types.defs>
#include <uxkern/bsd_types.defs>

/*
 * Calls that need the current thread
 */
routine bsd_execve(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	out	cfname		: cfname_t;
	out	cfarg		: cfname_t;
	out	entry		: entry_array);

#if 0
routine bsd_exec_args_set(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	argp		: int;
	in	arg_size	: int;
	in	envp		: int;
	in	env_size	: int);
#endif 0

routine bsd_fork(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	new_state	: thread_state_t;
	out	child_pid	: int);

routine bsd_vfork(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	new_state	: thread_state_t;
	out	child_pid	: int);

routine bsd_take_signal(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	out	old_mask	: int;
	out	old_onstack	: int;
	out	sig		: int;
	out	code		: int;
	out	handler		: int;
	out	new_sp		: int);

routine bsd_sigreturn(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	old_on_stack	: int;
	in	old_sigmask	: int);

routine	bsd_getrusage(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	which		: int;
	out	rusage		: rusage_t);


/*
 * File name calls
 */
routine	bsd_chdir(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t);

routine	bsd_chroot(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t);

routine	bsd_open(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	mode		: int;
	in	crtmode		: int;
	out	fileno		: int);

#ifdef	COMPAT_43
routine	bsd_ocreat(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	fmode		: int;
	out	fileno		: int);
#else
skip;
#endif	/* COMPAT_43 */

routine	bsd_mknod(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	fmode		: int;
	in	dev		: int);

routine	bsd_link(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	target		: path_name_t;
	in	linkname	: path_name_t);

routine	bsd_symlink(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	target		: path_name_t;
	in	linkname	: path_name_t);

routine	bsd_unlink(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t);

routine	bsd_access(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	fmode		: int);

routine	bsd_stat(				/* stat/lstat */
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	follow		: boolean_t;
	in	name		: path_name_t;
	out	stat		: statb_t);

routine	bsd_readlink(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	name		: path_name_t;
	in	count		: int;
	out	buf		: small_char_array);

routine	bsd_chmod(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	fmode		: int);

routine	bsd_chown(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	uid		: int;
	in	gid		: int);

routine	bsd_utimes(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	times		: timeval_2_t);

routine	bsd_truncate(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	length		: int);

routine	bsd_rename(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	from_name	: path_name_t;
	in	to_name		: path_name_t);

routine	bsd_mkdir(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	name		: path_name_t;
	in	dmode		: int);

routine	bsd_rmdir(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	name		: path_name_t);

#if 0
routine	bsd_xutimes(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fname		: path_name_t;
	in	times		: timeval_3_t);

routine	bsd_mount(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fspec		: path_name_t;
	in	freg		: path_name_t;
	in	ronly		: int);

routine	bsd_umount(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fspec		: path_name_t);

#endif
routine	bsd_acct(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	acct_on		: boolean_t;
	in	fname		: path_name_t);

/*
 * Crucial IO
 */
routine	bsd_write_short(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;
	in	data		: small_char_array;
	out	amount_written	: int);

routine	bsd_write_long(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;
	in	data		: char_array;
	out	amount_written	: int);

#ifdef	COMPAT_43
routine	bsd_send_short(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;		/* socket */
	in	flags		: int;
	in	data		: small_char_array;
	out	amount_written	: int);

routine	bsd_send_long(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;		/* socket */
	in	flags		: int;
	in	data		: char_array;
	out	amount_written	: int);
#else
skip;
skip;
#endif	/* COMPAT_43 */

routine	bsd_sendto_short(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;
	in	flags		: int;
	in	to		: sockarg_t;
	in	data		: small_char_array;
	out	amount_written	: int);

routine	bsd_sendto_long(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;
	in	flags		: int;
	in	to		: sockarg_t;
	in	data		: char_array;
	out	amount_written	: int);

routine	bsd_select(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	nd		: int;
	inout	in_set		: fd_set;
	inout	ou_set		: fd_set;
	inout	ex_set		: fd_set;
	in	in_valid	: boolean_t;
	in	ou_valid	: boolean_t;
	in	ex_valid	: boolean_t;
	in	do_timeout	: boolean_t;
	in	tv		: timeval_t;
	out	rval		: int);

/*
 * Glue between MACH and U*X
 */
routine	bsd_task_by_pid(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	pid		: int;
	out	task		: task_t = MACH_MSG_TYPE_PORT_SEND);

/*
 * More IO
 */
#ifdef	COMPAT_43
routine	bsd_recvfrom_short(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;
	in	flags		: int;
	in	len		: int;
	out	from_addr	: sockarg_t;
	out	data		: small_char_array);

routine	bsd_recvfrom_long(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	fileno		: int;
	in	flags		: int;
	in	len		: int;
	out	from_addr	: sockarg_t;
	out	data		: char_array);
#else
skip;
skip;
#endif	/* COMPAT_43 */

routine	bsd_setgroups(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  gidsetsize		: int;
	in  gidset		: gidset_t);

routine	bsd_setrlimit(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  which		: int;
	in  lim			: rlimit_t);

#ifdef	COMPAT_43
routine	bsd_osigvec(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  signo		: int;
	in  have_nsv		: boolean_t;
	in  nsv			: sigvec_t;
	out osv			: sigvec_t;
	in  tramp		: int);
#else
skip;
#endif	/* COMPAT_43 */

#if 0
routine bsd_signal(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  signo		: int;
	in  handler		: int;
	out ohandler		: int;
	in  tramp		: int);

#endif 0
routine	bsd_sigstack(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  have_nss		: boolean_t;
	in  nss			: sigstack_t;
	out oss			: sigstack_t);

routine	bsd_settimeofday(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  have_tv		: boolean_t;
	in  tv			: timeval_t;
	in  have_tz		: boolean_t;
	in  tz			: timezone_t);

routine	bsd_adjtime(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  delta		: timeval_t;
	out olddelta		: timeval_t);

routine	bsd_setitimer(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  which		: int;
	in  have_itv		: boolean_t;
	in  itv			: itimerval_t;
	out oitv		: itimerval_t);

routine	bsd_sethostname(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  hostname		: hostname_t;
	in  len			: int);

routine	bsd_bind(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  s			: int;
	in  name		: sockarg_t);

#ifdef	COMPAT_43
routine	bsd_oaccept(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  s			: int;
	out name		: sockarg_t;
	out new_s		: int);
#else
skip;
#endif	/* COMPAT_43 */

routine	bsd_connect(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  s			: int;
	in  name		: sockarg_t);

routine	bsd_setsockopt(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  s			: int;
	in  level		: int;
	in  name		: int;
	in  val			: sockarg_t);

routine	bsd_getsockopt(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  s			: int;
	in  level		: int;
	in  name		: int;
	out val			: sockarg_t);

#ifdef	COMPAT_43
routine	bsd_ogetsockname(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  s			: int;
	out name		: sockarg_t);

routine	bsd_ogetpeername(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t;
	in  s			: int;
	out name		: sockarg_t);
#else
skip;
skip;
#endif	/* COMPAT_43 */

routine bsd_init_process(
	    proc_port		: mach_port_t;
	out	interrupt	: boolean_t);

#ifdef CMUCS
routine	bsd_table_set(
	    proc_port		: mach_port_t;
	out interrupt		: boolean_t;
	in  id			: int;
	in  index		: int;
	in  lel			: int;
	in  nel			: int;
	in  addr		: small_char_array;
	out nel_done		: int);

routine	bsd_table_get(
	    proc_port		: mach_port_t;
	out interrupt		: boolean_t;
	in  id			: int;
	in  index		: int;
	in  lel			: int;
	in  nel			: int;
	out addr		: char_array, dealloc;
	out nel_done		: int);
#else
skip;
skip;
#endif

#if vice
routine	bsd_pioctl(
	    proc_port		: mach_port_t;
	out interrupt		: boolean_t;
	in  path		: path_name_t;
	in  com			: int;
	in  follow		: boolean_t;
	in  in_data		: small_char_array;
	in  out_data_wanted	: int;
	out out_data		: small_char_array);
#endif vice

routine bsd_emulator_error(
	    proc_port		: mach_port_t;
	in  err_message		: small_char_array);

routine bsd_readwrite(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	which		: boolean_t;
	in	fileno		: int;
	in	size		: int;
	out	amount		: int);

routine bsd_share_wakeup(
		proc_port	: mach_port_t;
	in	lock_offset	: int);

skip;	/* was bsd_signals_wakeup */

routine bsd_maprw_request_it(
		proc_port	: mach_port_t;
	out interrupt		: boolean_t;
	in	fileno		: int);

routine bsd_maprw_release_it(
		proc_port	: mach_port_t;
	out interrupt		: boolean_t;
	in	fileno		: int);

routine bsd_maprw_remap(
		proc_port	: mach_port_t;
	out interrupt		: boolean_t;
	in	fileno		: int;
	in	offset		: int;
	in	size		: int);

/*
 * More glue between MACH and U*X
 */
routine	bsd_pid_by_task(
		proc_port	: mach_port_t;
	out	interrupt	: boolean_t;
	in	task		: task_t;
	out	pid		: int;
	out	command		: path_name_t;
	out	rval		: int);
