contract_impl.h revision 7b209c2cc5ea45251aba06dcc6181d3f23da807a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_CONTRACT_IMPL_H
#define _SYS_CONTRACT_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/contract.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int ct_debug;
#ifdef _SYSCALL32
/*
* 32-bit versions of the event, status and parameter structures, for use
* (only) by the 64-bit kernel. See sys/contract.h for the normal versions.
* Use pack(4) to get offsets and structure size correct on amd64.
*/
#pragma pack(4)
#endif
typedef struct ct_event32 {
} ct_event32_t;
typedef struct ct_status32 {
int ctst_nevents;
int ctst_ntime;
int ctst_qtime;
typedef struct ct_param32 {
} ct_param32_t;
#pragma pack()
#endif
#endif /* _SYSCALL32 */
struct proc;
/*
* Contract template ops vector
*/
typedef struct ctmplops {
void (*ctop_free)(struct ct_template *);
const cred_t *);
} ctmplops_t;
/*
* Contract template
*/
typedef struct ct_template {
struct ct_type *ctmpl_type;
void *ctmpl_data;
typedef enum ct_listnum {
CTEL_CONTRACT, /* ../contracts/type/<id>/events */
CTEL_BUNDLE, /* ../contracts/type/bundle */
CTEL_PBUNDLE, /* ../contracts/type/pbundle */
} ct_listnum_t;
typedef enum ctqflags {
} ctqflags_t;
typedef enum ct_ack {
CT_NACK, /* disallow break */
CT_NONE /* no matching contracts */
} ct_ack_t;
/*
* Contract event queue
*/
typedef struct ct_equeue {
int ctq_nlisteners; /* number of listeners */
int ctq_nreliable; /* number of reliable listeners */
int ctq_ninf; /* number of informative events */
int ctq_max; /* max informative events */
} ct_equeue_t;
typedef struct ct_member {
int ctm_refs; /* number of references per list */
int ctm_trimmed; /* membership has been trimmed */
int ctm_nreliable; /* reliable listeners */
} ct_member_t;
typedef struct ct_kevent {
int cte_refs;
int cte_flags; /* see above */
} ct_kevent_t;
/*
* Contract vnode linkage.
* Avoid having too much knowledge about the FS.
*/
typedef struct contract_vnode {
/*
* Contract ops vector
* free - when reference count drops to zero
* abandon - when holding process dies or relinquishes interest
* destroy - when contract is to be completely destroyed
* status - when contractfs needs to return detailed status information
*/
typedef struct contops {
void (*contop_free)(struct contract *);
void (*contop_abandon)(struct contract *);
void (*contop_destroy)(struct contract *);
void *, model_t);
int (*contop_newct)(struct contract *);
} contops_t;
typedef ct_template_t *(ct_f_default_t)(void);
/*
* Contract type information.
*/
typedef struct ct_type {
const char *ct_type_name; /* type as a string */
} ct_type_t;
typedef enum ctflags {
CTF_INHERIT = 0x1
} ctflags_t;
typedef struct ct_time {
long ctm_total; /* Total time allowed for event */
} ct_time_t;
/*
* Contract
*/
typedef struct contract {
/* Static data */
void *ct_data; /* contract type data */
/* Protected by other locks */
int ct_evcnt; /* number of critical events */
} contract_t;
typedef struct ct_listener {
int ctl_flags; /* state flags */
/*
* Contract template interfaces
*/
void ctmpl_free(ct_template_t *);
void ctmpl_activate(ct_template_t *);
void ctmpl_clear(ct_template_t *);
/*
* Contract functions
*/
void contract_init(void);
void contract_destroy(contract_t *);
void contract_exit(struct proc *);
/*
* Event interfaces
*/
void cte_remove_listener(ct_listener_t *);
void cte_reset_listener(ct_listener_t *);
/*
* Contract implementation interfaces
*/
int contract_compar(const void *, const void *);
struct proc *, int);
void contract_hold(contract_t *);
void contract_rele(contract_t *);
void contract_rele_unlocked(contract_t *);
void contract_orphan(contract_t *);
ctid_t contract_max(void);
/*
* Type interfaces
*/
extern int ct_ntypes;
ct_f_default_t *);
int contract_type_count(ct_type_t *);
/*
* FS interfaces
*/
/*
* Negotiation stubs
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_CONTRACT_IMPL_H */