sysevent_impl.h revision c6fc6ddd482fa5c17788a38bd238258f2c22597c
/*
* 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_SYSEVENT_IMPL_H
#define _SYS_SYSEVENT_IMPL_H
#include <sys/id_space.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The following data structure assist in loading and extracting event
* header and attribute data into contiguous memory. Access to all typed
* data done so on 64-bit boundaries. *Do Not* alter any of the structures
* defined below without thorough thought and testing.
*/
/* Attribute name */
typedef struct se_name {
} se_name_t;
/* Attribute value */
typedef struct se_value {
} se_value_t;
/* sysevent internal attribute name-value pair stored in contiguous memory */
typedef struct sysevent_attr_impl {
/* Attribute list states */
#define ATTR_DETACHED 0
#define ATTR_ATTACHED 1
/*
* The following type definitions describe a sysevent object that is
* generated by a call to sysevent_alloc and sent to userland.
*/
/*
* sysevent event header information -
* contained in every event generated. The header and the event
* must remain 64-bit aligned. The header, up to the attribute
* offset, can be contained in a single cache line.
*/
typedef struct sysevent_hdr {
/* sysevent event buffer - 64-bit aligned offsets */
typedef struct sys_event_impl {
/* Helpful defines */
/* Event buffer version */
#define SYS_EVENT_VERSION 0
/* Event buffer flags */
#define SE_PACKED_BUF 1
/*
* Attribute data can be stored in contiguous memory or
* as a list of attribute data elements. The storage format is determined
* by the SE_PACKED_BUF flag in the event buffer flags.
*
*/
/* 64-bit boundary alignment function */
/* Access to unpacked attribute list */
/* Offset to packed attribute data */
/* syseventd door */
#define LOGEVENT_DOOR_UPCALL "/var/run/sysevent_door"
/*
* door upcall data structures
*/
typedef struct log_event_upcall_arg {
typedef struct log_eventq {
struct log_eventq *next;
} log_eventq_t;
/* Syseventd Channel structures */
/*
* Channel-based subscription structures
*/
/* Class hashing defines */
#define CLASS_HASH_SZ 63
% CLASS_HASH_SZ) + 1)
#define CHAN_HASH_SZ 32
typedef struct subclass_lst {
struct subclass_lst *sl_next;
char *sl_name;
typedef struct class_lst {
char *cl_name;
struct subclass_lst *cl_subclass_list;
} class_lst_t;
typedef struct se_pubsub {
} se_pubsub_t;
/* op defines */
#define SE_REGISTER 0
#define SE_UNREGISTER 1
#define SE_CLEANUP 2
#define SE_OPEN_REGISTRATION 3
#define SE_CLOSE_REGISTRATION 4
#define SE_BIND_REGISTRATION 5
#define SE_UNBIND_REGISTRATION 6
#define SE_GET_REGISTRATION 7
/* type defines */
#define SUBSCRIBER 0
#define PUBLISHER 1
/* nvpair names */
#define CLASS_NAME "class"
#ifdef _KERNEL
typedef struct sysevent_channel_descriptor {
char *scd_channel_name; /* Name of channel */
struct sysevent_channel_descriptor *scd_next;
int scd_ref_cnt; /* Reference count of channel opens */
/*
* log_sysevent private interfaces
*/
void log_event_init(void);
int log_sysevent_filename(char *file);
/*
* Structures and definitions for general purpose event channels
*/
/* Limits */
#define EVCH_MAX_CHANNELS 1024
#define EVCH_MAX_BINDS_PER_CHANNEL 512
#define EVCH_MAX_SUBSCRIPTIONS 32
#define EVCH_SUBPOOLFACT 8
#define EVCH_DEFAULT_EVENTS 2000
#define EVCH_MAX_TRY_DELIVERY 3
/* Linkage element for evch_dlist_t lists */
typedef struct evch_dlelem {
struct evch_dlelem *dl_next;
struct evch_dlelem *dl_prev;
/* List head */
typedef struct {
int dh_count;
} evch_dlist_t;
/* Placeholder for elements in a evch_squeue_t queue */
typedef struct evch_qelem {
struct evch_qelem *q_next;
void *q_objref;
} evch_qelem_t;
/* Queue head data */
typedef struct {
/*
* Defines for event queue routines
*/
#define EVQ_IGNORE 1
#define EVQ_DELIVER 2
#define EVQ_CONT 0
#define EVQ_AGAIN 1
#define EVQ_SLEEP 2
/* Call back routine typedefs */
typedef int (*filter_f)(void *, void *);
typedef int (*deliver_f)(void *, void *);
typedef int (*kerndlv_f)(void *, void *);
typedef void (*destr_f)(void *, void *);
typedef int (*compare_f)(evch_dlelem_t *, char *);
/*
* Event structure handled by evch_evq_* functions. Sysevent type events are
* stored as the payload.
*/
typedef struct {
/*
* Event queue descriptor
*/
typedef struct {
int eq_dactive; /* Event delivery is in progress */
int eq_holdmode; /* Hold event delivery */
/*
* Event queue per subscriber structure
*/
typedef struct {
void *su_fcookie; /* cookie for event filter */
void *su_cbcookie; /* callback cookie */
/* Eveny delivery type */
/*
* Per channel subscriber data structure. Chained in a linked list to an
* event channel and to a binding.
*/
typedef struct chsubd {
char *sd_ident; /* Subscriber identifier */
char *sd_classname; /* Filter criteria */
int sd_type; /* Type of event delivery */
void *sd_cbcookie; /* Cookie for kernel delivery */
int sd_active; /* Subscription is in use indicator */
} evch_subd_t;
/*
* General purpose event channel descriptor structure. This is the main
* channel.
*/
typedef struct {
char *ch_name; /* Channel name */
int ch_maxbinds; /* Maximum number of binds */
int ch_maxsubscr; /* Maximum number of subscriptions */
int ch_holdpend; /* Hold pending events mode if != 0 */
} evch_chan_t;
/*
* Channel binding structure. Allocated per binding to a channel. Protected
* by locking the channel structure
*/
typedef struct {
} evch_bind_t;
/*
* Structure to keep a snapshot of all events of a channel
*/
typedef struct {
} evchanq_t;
/* Project privat interfaces */
void sysevent_evc_init();
void sysevent_evc_thrinit();
void sysevent_evc_walk_fini(evchanq_t *);
#endif /* _KERNEL */
/*
* Structures and limits to deliver channel data to syseventadm
*/
typedef struct {
typedef struct {
} sev_chinfo_t;
/*
* Project private flags for sysevent_evc_subscribe. Bits 0 to 7 are reserved
* for the consolidation private interface.
*/
#define EVCH_SUB_DUMP 0x0100
/*
* Permission flags
*/
/*
* Sysevent driver ioctls
*/
#define SEV_BASE 0x53455600
#define DEVSYSEVENT "/dev/sysevent"
#define DEVICESYSEVENT "/devices/pseudo/sysevent@0:sysevent"
/*
* Maximum allowed binding handles
* Use pack(4) to make sizeof structs be the same on x86 and amd64.
*/
#define SYSEVENT_MINOR_MAX SHRT_MAX
#pragma pack(4)
#endif
typedef struct box {
} sev_box_t;
typedef struct bind_args {
typedef struct control_args {
typedef struct publish_args {
typedef struct subscribe_args {
int door_desc;
typedef struct unsubscribe_args {
typedef struct chandata {
#pragma pack()
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SYSEVENT_IMPL_H */