Blob Blame History Raw
#ifndef TOKSVC_DAEMON_IMPL_H
#define TOKSVC_DAEMON_IMPL_H

#include <psxtypes/psxtypes.h>
#include <ntapi/ntapi.h>

enum toks_daemon_opcodes {
	TOKS_DAEMON_OPCODE_BASE	= 0x20000,
	TOKS_DAEMON_CONNECT	= TOKS_DAEMON_OPCODE_BASE,
	TOKS_DAEMON_DISCONNECT,
	TOKS_DAEMON_TTYSIGNAL,
	TOKS_DAEMON_IPCSIGNAL,
	TOKS_DAEMON_SIGCHLD,
	TOKS_DAEMON_THREADEXIT,
	TOKS_DAEMON_ACQUIRE,
	TOKS_DAEMON_RELEASE,
	TOKS_DAEMON_OPCODE_CAP
};

struct toks_daemon_ctx;
struct toks_driver_ctx;

struct toks_client_ctx {
	void *  hprocess;
	void *  hinstance;
	void *  hport;
	void *  hswap;
	void *  halert;
	void *  hdaemon;
	nt_cid  cid;
};

struct toks_token {
	struct _nt_port_keys	keys;
	struct toks_client_ctx	client;
	struct toks_token *	self;
};

typedef int32_t __stdcall toks_daemon_routine(struct toks_daemon_ctx *);

struct toks_daemon_ctx {
	struct toks_driver_ctx *driver_ctx;

	nt_port_keys		daemon_keys;
	nt_port_attr		daemon_attr;
	nt_port_name		daemon_name;

	void *			hport_daemon;
	void *			hevent_daemon_ready;

	void *			hport_internal_client;
	void *			hevent_internal_client_ready;

	nt_tty_port_msg		request;
	nt_tty_port_msg		reply;
};

int32_t __stdcall toks_daemon_init(struct toks_daemon_ctx *, const nt_guid *);
int32_t __stdcall toks_daemon_loop(void *);

int32_t __stdcall toks_daemon_connect(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_signal(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_acquire(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_pidopen(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_release(struct toks_daemon_ctx *);

#endif