Blame include/ntapi/nt_daemon.h

dd89bb
#ifndef _NT_DAEMON_H_
dd89bb
#define _NT_DAEMON_H_
dd89bb
dd89bb
/**
dd89bb
 *  daemon start-up routines
dd89bb
 *  -----------------------
dd89bb
 *  upon successful return from dsr_init(),
dd89bb
 *  an LPC-based daemon will have entered its
dd89bb
 *  main service loop in a dedicated thread,
dd89bb
 *  having already established an internal
dd89bb
 *  connection.
dd89bb
 *
dd89bb
 *  remarks
dd89bb
 *  -------
dd89bb
 *  1) in the larger-scale midipix project, three
dd89bb
 *     different daemons are initialized using the
dd89bb
 *     below api, namely the optional tty server,
dd89bb
 *     the optional virtual mount server, and the
dd89bb
 *     posix system call layer internal daemon.
dd89bb
 *
dd89bb
 *  2) the initialization routines make use of two
dd89bb
 *     events: a 'damon-is-ready' event, and an
dd89bb
 *     'internal-client-is-ready' event.  if these
dd89bb
 *     events are not provided by the application
dd89bb
 *     then they will be created by this library,
dd89bb
 *     in which case each of the two handles may
dd89bb
 *     optionally be saved to a caller-provided
dd89bb
 *     address.
dd89bb
 *
dd89bb
 *  3) the dedicated thread of a well-designed
dd89bb
 *     daemon should be able to use a stack that
dd89bb
 *     is relatively very small; to fine-tune
dd89bb
 *     the stack size of the daemon's dedicated
dd89bb
 *     thread, use the appropriate members of
dd89bb
 *     the nt_daemon_params structure.
dd89bb
**/
dd89bb
dd89bb
#include <psxtypes/psxtypes.h>
dd89bb
#include "nt_thread.h"
dd89bb
#include "nt_port.h"
dd89bb
dd89bb
/* NT_DSR_INIT_FLAGS */
dd89bb
#define	NT_DSR_INIT_DEFAULT		0x0000
dd89bb
#define	NT_DSR_INIT_GENERATE_KEYS	0x0001
dd89bb
#define	NT_DSR_INIT_FORMAT_KEYS		0x0002
dd89bb
#define NT_DSR_INIT_CLOSE_EVENTS	0x0004
dd89bb
dd89bb
/* daemon start: max wait: 156 seconds (twelve bonobo couples) */
dd89bb
#define NT_DSR_INIT_MAX_WAIT		156 * (-1) * 10 * 1000 * 1000
dd89bb
dd89bb
typedef int32_t __stdcall nt_daemon_routine(void * context);
dd89bb
dd89bb
typedef struct _nt_daemon_params {
dd89bb
	wchar16_t *		port_name;
dd89bb
	nt_port_keys *		port_keys;
dd89bb
	nt_port_name_keys *	port_name_keys;
dd89bb
	uintptr_t		port_msg_size;
dd89bb
	nt_daemon_routine *	daemon_once_routine;
dd89bb
	nt_daemon_routine *	daemon_loop_routine;
dd89bb
	void *			daemon_loop_context;
dd89bb
	void *			hport_daemon;
dd89bb
	void **			pport_daemon;
dd89bb
	void *			hport_internal_client;
dd89bb
	void **			pport_internal_client;
dd89bb
	void *			hevent_daemon_ready;
dd89bb
	void **			pevent_daemon_ready;
dd89bb
	void *			hevent_internal_client_ready;
dd89bb
	void **			pevent_internal_client_ready;
dd89bb
	void *			hthread_daemon_start;
dd89bb
	void *			hthread_daemon_loop;
dd89bb
	void *			hthread_internal_client;
dd89bb
	int32_t			exit_code_daemon_start;
dd89bb
	int32_t			exit_code_daemon_loop;
dd89bb
	int32_t			exit_code_internal_client;
dd89bb
	uint32_t		flags;
dd89bb
	size_t			stack_size_commit;
dd89bb
	size_t			stack_size_reserve;
dd89bb
	nt_user_stack *		stack_info;
dd89bb
} nt_daemon_params, nt_dsr_params;
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_dsr_init(nt_daemon_params *);
dd89bb
typedef int32_t __stdcall ntapi_dsr_start(nt_daemon_params *);
dd89bb
typedef int32_t __stdcall ntapi_dsr_create_port(nt_daemon_params *);
dd89bb
typedef int32_t __stdcall ntapi_dsr_connect_internal_client(nt_daemon_params *);
dd89bb
typedef int32_t __stdcall ntapi_dsr_internal_client_connect(nt_daemon_params *);
dd89bb
typedef int32_t __stdcall ntapi_dsr_loop(void *);
dd89bb
dd89bb
#endif