/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_CTFS_H
#define	_SYS_CTFS_H

#pragma ident	"@(#)ctfs.h	1.1	04/07/15 SMI"

#include <sys/contract.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Location of the contract filesystem.
 */
#define	CTFS_ROOT	"/system/contract"

/*
 * CTFS ioctl constants
 */
#define	CTFS_PREFIX	('c' << 24 | 't' << 16)
#define	CTFS_IOC(x, y)	(CTFS_PREFIX | (x) << 8 | (y))

/*
 * Control codes for messages written to template files.
 */
#define	CTFS_TMPL(x)	CTFS_IOC('t', x)
#define	CT_TACTIVATE	CTFS_TMPL(0)	/* Activate template */
#define	CT_TCLEAR	CTFS_TMPL(1)	/* Clear active template */
#define	CT_TCREATE	CTFS_TMPL(2)	/* Create contract from template */
#define	CT_TSET		CTFS_TMPL(3)	/* Set parameter */
#define	CT_TGET		CTFS_TMPL(4)	/* Get parameter */

/*
 * Control codes for messages written to ctl files.
 */
#define	CTFS_CTL(x)	CTFS_IOC('c', x)
#define	CT_CABANDON	CTFS_CTL(0)	/* Abandon contract */
#define	CT_CACK		CTFS_CTL(1)	/* Ack a message */
#define	CT_CQREQ	CTFS_CTL(2)	/* Request an additional quantum */
#define	CT_CADOPT	CTFS_CTL(3)	/* Adopt a contract */
#define	CT_CNEWCT	CTFS_CTL(4)	/* Define new contract */

/*
 * Control codes for messages written to status files.
 */
#define	CTFS_STAT(x)	CTFS_IOC('s', x)
#define	CT_SSTATUS	CTFS_STAT(0)	/* Obtain contract status */

/*
 * Control codes for messages written to event endpoints.
 */
#define	CTFS_EVT(x)	CTFS_IOC('e', x)
#define	CT_ERESET	CTFS_EVT(0)	/* Reset event queue pointer */
#define	CT_ERECV	CTFS_EVT(1)	/* Read next event */
#define	CT_ECRECV	CTFS_EVT(2)	/* Read next critical event */
#define	CT_ENEXT	CTFS_EVT(3)	/* Skip current event */
#define	CT_ERELIABLE	CTFS_EVT(4)	/* Request reliable event receipt */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_CTFS_H */
