xref: /titanic_41/usr/src/uts/common/sys/sysevent_impl.h (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SYSEVENT_IMPL_H
28 #define	_SYS_SYSEVENT_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/nvpair.h>
33 #include <sys/id_space.h>
34 #include <sys/door.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 typedef uint64_t se_data_t;
41 
42 /*
43  * The following data structure assist in loading and extracting event
44  * header and attribute data into contiguous memory.  Access to all typed
45  * data done so on 64-bit boundaries.  *Do Not* alter any of the structures
46  * defined below without thorough thought and testing.
47  */
48 
49 /* Attribute name */
50 typedef struct se_name {
51 	int32_t		name_sz;
52 	int32_t		name_pad;
53 	se_data_t	name;	/* 64-bit aligned offset */
54 } se_name_t;
55 
56 /* Attribute value */
57 typedef struct se_value {
58 	int32_t		value_type;	/* data type */
59 	int32_t		value_sz;
60 	se_data_t	value;		/* data value - 64-bit aligned offset */
61 } se_value_t;
62 
63 /* sysevent internal attribute name-value pair stored in contiguous memory */
64 typedef struct sysevent_attr_impl {
65 	int32_t		se_attr_sz;	/* Size of attribute data */
66 	int32_t		se_attr_pad;	/* pad */
67 	se_data_t	se_attr_name;	/* name of data attribute */
68 	se_data_t	se_attr_val;	/* value and type of data */
69 } sysevent_attr_impl_t;
70 
71 /* Attribute list states */
72 #define	ATTR_DETACHED	0
73 #define	ATTR_ATTACHED	1
74 
75 /*
76  * The following type definitions describe a sysevent object that is
77  * generated by a call to sysevent_alloc and sent to userland.
78  */
79 
80 /*
81  * sysevent event header information -
82  * 	contained in every event generated.  The header and the event
83  *	must remain 64-bit aligned.  The header, up to the attribute
84  *	offset, can be contained in a single cache line.
85  */
86 typedef struct sysevent_hdr {
87 	sysevent_id_t	se_id;		/* unique identifier */
88 	uint32_t	se_version;	/* version of this data structure */
89 	uint32_t	se_flag;
90 	uint32_t	se_class;	/* event class id - reserved */
91 	uint32_t	se_subclass;	/* event subclass id - reserved */
92 	int32_t		se_payload_sz;	/* size of attr data + strings */
93 	uint16_t	se_subclass_off; /* offset to subclass string */
94 	uint16_t	se_pub_off;	/* offset to publisher string */
95 	uint64_t	se_attr_off;	/* pointer or offset to attr data */
96 } sysevent_hdr_t;
97 
98 /* sysevent event buffer - 64-bit aligned offsets */
99 typedef struct sys_event_impl {
100 	sysevent_hdr_t	se_header;
101 	se_data_t	se_class_name;	/* class string in contig memory */
102 	se_data_t	se_subclass_name; /* subclass string in contig memory */
103 	se_data_t	se_pub;		/* publisher string in contig mem */
104 	se_data_t 	se_attr_buf;	/* contiguous attribute memory	*/
105 } sysevent_impl_t;
106 
107 /* Helpful defines */
108 #define	seh_version	se_header.se_version
109 #define	seh_class	se_header.se_class
110 #define	seh_subclass	se_header.se_subclass
111 #define	seh_seq		se_header.se_id.eid_seq
112 #define	seh_time	se_header.se_id.eid_ts
113 #define	seh_subclass_off se_header.se_subclass_off
114 #define	seh_pub_off	se_header.se_pub_off
115 #define	seh_attr_off	se_header.se_attr_off
116 #define	seh_payload_sz	se_header.se_payload_sz
117 #define	seh_flag	se_header.se_flag
118 
119 /* Event buffer version */
120 #define	SYS_EVENT_VERSION	0
121 
122 /* Event buffer flags */
123 #define	SE_PACKED_BUF	1
124 
125 #define	SYSEVENT_IMPL(ev)	((sysevent_impl_t *)(void *)(ev))
126 #define	SE_VERSION(ev)		(SYSEVENT_IMPL(ev)->seh_version)
127 #define	SE_CLASS(ev)		(SYSEVENT_IMPL(ev)->seh_class)
128 #define	SE_SUBCLASS(ev)		(SYSEVENT_IMPL(ev)->seh_subclass)
129 #define	SE_SEQ(ev)		(SYSEVENT_IMPL(ev)->seh_seq)
130 #define	SE_TIME(ev)		(SYSEVENT_IMPL(ev)->seh_time)
131 #define	SE_SUBCLASS_OFF(ev)	(SYSEVENT_IMPL(ev)->seh_subclass_off)
132 #define	SE_PUB_OFF(ev)		(SYSEVENT_IMPL(ev)->seh_pub_off)
133 #define	SE_PAYLOAD_SZ(ev)	(SYSEVENT_IMPL(ev)->seh_payload_sz)
134 #define	SE_FLAG(ev)		(SYSEVENT_IMPL(ev)->seh_flag)
135 #define	SE_SIZE(ev)		(sizeof (sysevent_impl_t) + SE_PAYLOAD_SZ(ev))
136 #define	SE_CLASS_NAME(ev)	((char *)&(SYSEVENT_IMPL(ev)->se_class_name))
137 #define	SE_SUBCLASS_NAME(ev)	((char *)((caddr_t)(ev) + SE_SUBCLASS_OFF(ev)))
138 #define	SE_PUB_NAME(ev)		((char *)((caddr_t)(ev) + SE_PUB_OFF(ev)))
139 
140 /*
141  * Attribute data can be stored in contiguous memory or
142  * as a list of attribute data elements.  The storage format is determined
143  * by the SE_PACKED_BUF flag in the event buffer flags.
144  *
145  */
146 
147 /* 64-bit boundary alignment function */
148 #define	SE_ALIGN(x)	((((ulong_t)x) + 7ul) & ~7ul)
149 
150 /* Access to unpacked attribute list */
151 #define	SE_ATTR_PTR(ev)		(SYSEVENT_IMPL(ev)->seh_attr_off)
152 
153 /* Offset to packed attribute data */
154 #define	SE_ATTR_OFF(ev)	SE_PUB_OFF(ev) + SE_ALIGN(strlen(SE_PUB_NAME(ev)) + 1)
155 
156 /* syseventd door */
157 #define	LOGEVENT_DOOR_UPCALL	"/etc/sysevent/sysevent_door"
158 
159 /*
160  * door upcall data structures
161  */
162 typedef struct log_event_upcall_arg {
163 	int32_t retcode;
164 	int32_t	pad;
165 	sysevent_impl_t buf;
166 } log_event_upcall_arg_t;
167 
168 typedef struct log_eventq {
169 	struct log_eventq	*next;
170 	log_event_upcall_arg_t	arg;
171 } log_eventq_t;
172 
173 /* Syseventd Channel structures */
174 
175 #define	MAX_CHAN	256	/* Maximum channels per system */
176 #define	MAX_SUBSCRIBERS	100	/* Maximum subscribers per channel */
177 #define	MAX_PUBLISHERS	1	/* Maximum publishers per channel */
178 
179 /*
180  * Channel-based subscription structures
181  */
182 
183 /* Class hashing defines */
184 #define	CLASS_HASH_SZ	63
185 #define	CLASS_HASH(class_name)	((hash_func(class_name) \
186 				% CLASS_HASH_SZ) + 1)
187 #define	CHAN_HASH_SZ	32
188 
189 typedef struct subclass_lst {
190 	struct subclass_lst	*sl_next;
191 	char			*sl_name;
192 	uchar_t			sl_num[MAX_SUBSCRIBERS + 1];
193 } subclass_lst_t;
194 
195 typedef struct class_lst {
196 	struct class_lst	*cl_next;
197 	char			*cl_name;
198 	struct subclass_lst	*cl_subclass_list;
199 } class_lst_t;
200 
201 /* User/Kernel Structure to pass event registration modctl data */
202 typedef struct se_pubsub {
203 	uint32_t	ps_buflen;
204 	uint32_t	ps_channel_name_len;
205 	uint32_t	ps_id;
206 	uint32_t	ps_op;
207 	uint32_t	ps_type;
208 } se_pubsub_t;
209 
210 /* op defines */
211 #define	SE_REGISTER		0
212 #define	SE_UNREGISTER		1
213 #define	SE_CLEANUP		2
214 #define	SE_OPEN_REGISTRATION	3
215 #define	SE_CLOSE_REGISTRATION	4
216 #define	SE_BIND_REGISTRATION	5
217 #define	SE_UNBIND_REGISTRATION	6
218 #define	SE_GET_REGISTRATION	7
219 
220 /* type defines */
221 #define	SUBSCRIBER	0
222 #define	PUBLISHER	1
223 
224 /* nvpair names */
225 #define	CLASS_NAME	"class"
226 
227 #ifdef	_KERNEL
228 
229 typedef struct sysevent_channel_descriptor {
230 	char   *scd_channel_name;	/* Name of channel */
231 	struct sysevent_channel_descriptor *scd_next;
232 	int    scd_ref_cnt;		/* Reference count of channel opens */
233 	id_space_t *scd_subscriber_cache;	/* cache of subscriber ids */
234 	id_space_t *scd_publisher_cache;	/* cache of publisher ids */
235 	uchar_t scd_subscriber_ids[MAX_SUBSCRIBERS + 1]; /* used sub ids */
236 	uchar_t scd_publisher_ids[MAX_PUBLISHERS + 1];	/* used  pub ids */
237 	class_lst_t *scd_class_list_tbl[CLASS_HASH_SZ + 1];
238 } sysevent_channel_descriptor_t;
239 
240 /*
241  * log_sysevent private interfaces
242  */
243 void log_event_init(void);
244 void log_sysevent_flushq(int cmd, uint_t flag);
245 int log_sysevent_filename(char *file);
246 int log_usr_sysevent(sysevent_t *ev, int ev_size, sysevent_id_t *eid);
247 int log_sysevent_copyout_data(sysevent_id_t *eid, size_t ubuflen, caddr_t ubuf);
248 int log_sysevent_free_data(sysevent_id_t *eid);
249 int log_sysevent_register(char *channel_name, char *data, se_pubsub_t *udata);
250 uint64_t log_sysevent_new_id();
251 
252 /*
253  * Structures and definitions for general purpose event channels
254  */
255 
256 /* Limits */
257 #define	EVCH_MAX_CHANNELS		1024
258 #define	EVCH_MAX_BINDS_PER_CHANNEL	512
259 #define	EVCH_MAX_SUBSCRIPTIONS		32
260 #define	EVCH_SUBPOOLFACT		8
261 #define	EVCH_DEFAULT_EVENTS		2000
262 #define	EVCH_MAX_TRY_DELIVERY		3
263 
264 /* Linkage element for evch_dlist_t lists */
265 typedef struct evch_dlelem {
266 	struct evch_dlelem	*dl_next;
267 	struct evch_dlelem	*dl_prev;
268 } evch_dlelem_t;
269 
270 /* List head */
271 typedef struct {
272 	evch_dlelem_t	dh_head;
273 	int		dh_count;
274 } evch_dlist_t;
275 
276 /* Placeholder for elements in a evch_squeue_t queue */
277 typedef struct evch_qelem {
278 	struct evch_qelem	*q_next;
279 	void			*q_objref;
280 	size_t			q_objsize;
281 } evch_qelem_t;
282 
283 /* Queue head data */
284 typedef struct {
285 	evch_qelem_t	*sq_head;
286 	evch_qelem_t	*sq_tail;
287 	uint32_t 	sq_count;
288 	uint32_t 	sq_highwm;
289 } evch_squeue_t;
290 
291 /*
292  * Defines for event queue routines
293  */
294 #define	EVQ_IGNORE	1
295 #define	EVQ_DELIVER	2
296 
297 #define	EVQ_CONT	0
298 #define	EVQ_AGAIN	1
299 #define	EVQ_SLEEP	2
300 
301 /* Call back routine typedefs */
302 typedef int (*filter_f)(void *, void *);
303 typedef int (*deliver_f)(void *, void *);
304 typedef int (*kerndlv_f)(void *, void *);
305 typedef void (*destr_f)(void *, void *);
306 typedef int (*compare_f)(evch_dlelem_t *, char *);
307 
308 /*
309  * Event structure handled by evch_evq_* functions. Sysevent type events are
310  * stored as the payload.
311  */
312 typedef struct {
313 	uint32_t	ge_size;	/* Total size of event structure */
314 	uint32_t	ge_refcount;	/* No of queues event is linked to */
315 	destr_f		ge_destruct;	/* Destructor for event structure */
316 	uint32_t	*ge_dstcookie;	/* Cookie for destructor function */
317 	uchar_t		ge_payload[1];	/* Placeholder for event data */
318 } evch_gevent_t;
319 
320 /*
321  * Event queue descriptor
322  */
323 typedef struct {
324 	evch_squeue_t	eq_eventq;	/* Protected by eq_dtmutex */
325 	kt_did_t	eq_thrid;	/* Id delivery thread */
326 	kmutex_t	eq_queuemx;	/* Protect. of this struct and ev q */
327 	kcondvar_t	eq_thrsleepcv;	/* Delivery thread sleeps on empty q */
328 	int		eq_dactive;	/* Event delivery is in progress */
329 	kcondvar_t	eq_dactivecv;	/* Unsubscr. has to wait on this */
330 	evch_dlist_t	eq_subscr;	/* Chain of all evch_evqsub_t */
331 	uint32_t	eq_nsleep;	/* Statistic: Publisher set to sleep */
332 	int		eq_holdmode;	/* Hold event delivery */
333 	evch_gevent_t	*eq_curevent;	/* Event currently beeing delivered */
334 	evch_qelem_t	*eq_nextev;	/* For iterating over events in a q */
335 	kcondvar_t	eq_onholdcv;	/* To signal hold mode of deliv. thr. */
336 	uchar_t		eq_tabortflag;	/* Request to abort delivery thread */
337 } evch_eventq_t;
338 
339 /*
340  * Event queue per subscriber structure
341  */
342 typedef struct {
343 	evch_dlelem_t	su_link;
344 	filter_f	su_filter;	/* Event filter function pointer */
345 	void		*su_fcookie;	/* cookie for event filter */
346 	deliver_f	su_callb;	/* Event delivery callback */
347 	void		*su_cbcookie;	/* callback cookie */
348 } evch_evqsub_t;
349 
350 /* Eveny delivery type */
351 #define	EVCH_DELKERN		1	/* Kernel event delivery */
352 #define	EVCH_DELDOOR		2	/* User event delivery via doors */
353 
354 /*
355  * Per channel subscriber data structure. Chained in a linked list to an
356  * event channel and to a binding.
357  */
358 typedef struct chsubd {
359 	evch_dlelem_t	sd_link;	/* Links all subscribers of this ch. */
360 	struct chsubd	*sd_subnxt;	/* Links all subscr. for a binding */
361 	char		*sd_ident;	/* Subscriber identifier */
362 	evch_eventq_t	*sd_queue;	/* Event queue for this subscriber */
363 	evch_evqsub_t	*sd_msub;	/* Main event queue subscr. */
364 	char		*sd_classname;	/* Filter criteria */
365 	size_t		sd_clnsize;	/* Size of sd_classname buffer */
366 	evch_evqsub_t	*sd_ssub;	/* Subscriber queue subscr. */
367 	int		sd_type;	/* Type of event delivery */
368 	kerndlv_f	sd_callback;	/* Callback for kernel delivery */
369 	void		*sd_cbcookie;	/* Cookie for kernel delivery */
370 	door_handle_t	sd_door;	/* Door handle for user delivery */
371 	int		sd_active;	/* Subscription is in use indicator */
372 	pid_t		sd_pid;		/* PID of subscribing process */
373 	uint8_t		sd_persist;	/* Persistent user land subscription */
374 	uint8_t		sd_dump;	/* Dump with sysevent_evc_walk_* */
375 } evch_subd_t;
376 
377 /*
378  * General purpose event channel descriptor structure. This is the main
379  * structure for event subscribing, publishing, delivery to/from an event
380  * channel.
381  */
382 typedef struct {
383 	evch_dlelem_t	ch_link;	/* Must be first elem. of structure */
384 	char		*ch_name;	/* Channel name */
385 	size_t		ch_namelen;	/* Length of channel name buffer */
386 	kmutex_t	ch_mutex;	/* To protect this structure */
387 	evch_eventq_t	*ch_queue;	/* Publisher event queue */
388 	evch_dlist_t	ch_subscr;	/* List of subscr. data (evch_subd_t) */
389 	uint32_t	ch_bindings;	/* No of bindings to this channel */
390 	int		ch_maxbinds;	/* Maximum number of binds */
391 	uid_t		ch_uid;		/* Creators effective user id */
392 	gid_t		ch_gid;		/* Creators effective group id */
393 	kmutex_t	ch_pubmx;	/* Mutex for ch_pubcv and ch_nevents */
394 	kcondvar_t	ch_pubcv;	/* To set publisher to sleep */
395 	uint32_t	ch_nevents;	/* Current number of events */
396 	uint32_t	ch_maxev;	/* Maximum number of events */
397 	int		ch_maxsubscr;	/* Maximum number of subscriptions */
398 	int		ch_holdpend;	/* Hold pending events mode if != 0 */
399 	time_t		ch_ctime;	/* Channel creation time */
400 } evch_chan_t;
401 
402 /*
403  * Channel binding structure. Allocated per binding to a channel. Protected
404  * by locking the channel structure
405  */
406 typedef struct {
407 	evch_chan_t	*bd_channel;
408 	evch_subd_t	*bd_sublst;	/* chain of all subscriptions */
409 } evch_bind_t;
410 
411 /*
412  * Structure to keep a snapshot of all events of a channel
413  */
414 typedef struct {
415 	evch_eventq_t	*sn_queue;	/* Event queue with snapshot of ev's */
416 	sysevent_impl_t	*sn_nxtev;	/* Pointer to find next event */
417 } evchanq_t;
418 
419 /* Project privat interfaces */
420 evchan_t *evch_usrchanopen(const char *name, uint32_t flags, int *err);
421 void evch_usrchanclose(evchan_t *cbp);
422 sysevent_impl_t *evch_usrallocev(size_t evsize, uint32_t flags);
423 void evch_usrfreeev(sysevent_impl_t *ev);
424 int evch_usrpostevent(evchan_t *bp, sysevent_impl_t *ev, uint32_t flags);
425 int evch_usrsubscribe(evchan_t *bp, const char *sid, const char *class,
426     int d, uint32_t flags);
427 int evch_usrcontrol_set(evchan_t *bp, int cmd, uint32_t value);
428 int evch_usrcontrol_get(evchan_t *bp, int cmd, uint32_t *value);
429 void evch_usrunsubscribe(evchan_t *bp, const char *subid, uint32_t flag);
430 int evch_usrgetchnames(char *buf, size_t size);
431 int evch_usrgetchdata(char *chname, void *buf, size_t size);
432 
433 void sysevent_evc_init();
434 void sysevent_evc_thrinit();
435 evchanq_t *sysevent_evc_walk_init(evchan_t *, char *);
436 sysevent_t *sysevent_evc_walk_step(evchanq_t *);
437 void sysevent_evc_walk_fini(evchanq_t *);
438 char *sysevent_evc_event_attr(sysevent_t *, size_t *);
439 
440 #endif /* _KERNEL */
441 
442 /*
443  * Structures and limits to deliver channel data to syseventadm
444  */
445 #define	EVCH_MAX_DATA_SIZE	(1024 * 1024)
446 
447 typedef struct {
448 	uint32_t	sb_nextoff;	/* Offset to next subscr info struct */
449 	uint32_t	sb_stroff;	/* Offset to strings */
450 	uint32_t	sb_clnamoff;	/* Offset of class in sb_strings */
451 	uint32_t	sb_pid;		/* Subscriber process id */
452 	uint32_t	sb_nevents;	/* Current no of event in sub q */
453 	uint32_t	sb_evhwm;	/* High watermark of sub q */
454 	uint32_t	sb_persist;	/* != 0 if subscription persists */
455 	uint32_t	sb_status;	/* != 0 if subscription is inactive */
456 	uint32_t	sb_active;	/* > 0 if subscription is in use */
457 	uint32_t	sb_dump;	/* != 0 if sub will be dumped */
458 	char		sb_strings[1];	/* String space for subid and class */
459 } sev_subinfo_t;
460 
461 typedef struct {
462 	uint32_t	cd_version;	/* Version of this structure */
463 	uint32_t	cd_suboffs;	/* Offset of subscriber info struct */
464 	uint64_t	cd_ctime;	/* Creation time */
465 	uint32_t	cd_uid;		/* User id */
466 	uint32_t	cd_gid;		/* Owner group id */
467 	uint32_t	cd_perms;	/* Permission bits */
468 	uint32_t	cd_maxev;	/* Max number of events */
469 	uint32_t	cd_evhwm;	/* High watermark of main event queue */
470 	uint32_t	cd_nevents;	/* current no of events in main ev q */
471 	uint32_t	cd_maxsub;	/* Max number of subscriptions */
472 	uint32_t	cd_nsub;	/* Current number of subscriptions */
473 	uint32_t	cd_maxbinds;	/* Max number of binds */
474 	uint32_t	cd_nbinds;	/* Current number of binds */
475 	uint32_t	cd_holdpend;	/* != 0 when HOLDPEND mode is set */
476 	uint32_t	cd_limev;	/* Limit of events per channel */
477 	sev_subinfo_t	cd_subinfo[1];	/* Per subscriber data */
478 } sev_chinfo_t;
479 
480 /*
481  * Project private flags for sysevent_evc_subscribe. Bits 0 to 7 are reserved
482  * for the consolidation private interface.
483  */
484 #define	EVCH_SUB_DUMP		0x0100
485 
486 /*
487  * Permission flags
488  */
489 #define	EVCH_PUB		0x0004	/* wants to publish events */
490 #define	EVCH_SUB		0x0008	/* wants to subscribe to channel */
491 
492 #define	EVCH_SUBU		0x0001	/* Subscribing allowed for uid */
493 #define	EVCH_PUBU		0x0002	/* Publishing allowed for uid */
494 #define	EVCH_PSUSR		0x0003	/* EVCH_SUBU + EVCH_PUBU */
495 #define	EVCH_SUBG		0x0004	/* Subscribing allowed for gid */
496 #define	EVCH_PUBG		0x0008	/* Publishing allowed for gid */
497 #define	EVCH_PSGRP		0x000C	/* EVCH_SUBG + EVCH_PUBG */
498 #define	EVCH_SUBO		0x0010	/* Subscribing allowed to all users */
499 #define	EVCH_PUBO		0x0020	/* Publishing allowed to all users */
500 #define	EVCH_PSOTH		0x0030	/* EVCH_SUBO + EVCH_PUBO */
501 #define	EVCH_PSALL		0x003f	/* Mask of all permission bits */
502 
503 /*
504  * Sysevent driver ioctls
505  */
506 #define	SEV_BASE		0x53455600
507 #define	SEV_PUBLISH		SEV_BASE | 0x01
508 #define	SEV_CHAN_OPEN		SEV_BASE | 0x02
509 #define	SEV_CHAN_CONTROL	SEV_BASE | 0x03
510 #define	SEV_SUBSCRIBE		SEV_BASE | 0x04
511 #define	SEV_UNSUBSCRIBE		SEV_BASE | 0x05
512 #define	SEV_CHANNAMES		SEV_BASE | 0x06
513 #define	SEV_CHANDATA		SEV_BASE | 0x07
514 
515 #define	DEVSYSEVENT	"/dev/sysevent"
516 #define	DEVICESYSEVENT	"/devices/pseudo/sysevent@0:sysevent"
517 
518 /*
519  * Maximum allowed binding handles
520  * It's a limit required by bitmap algorithm design (see sys/bitmap.h).
521  * Use pack(4) to make sizeof structs be the same on x86 and amd64.
522  */
523 #define	SYSEVENT_MINOR_MAX	SHRT_MAX
524 
525 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
526 #pragma pack(4)
527 #endif
528 
529 /* copyin/copyout data */
530 typedef struct box {
531 	uint64_t name;		/* pointer to something */
532 	uint32_t len;
533 } sev_box_t;
534 
535 typedef struct bind_args {
536 	sev_box_t chan_name;
537 	uint32_t flags;
538 } sev_bind_args_t;
539 
540 typedef struct control_args {
541 	uint32_t cmd;
542 	uint32_t value;
543 } sev_control_args_t;
544 
545 typedef struct publish_args {
546 	sev_box_t ev;
547 	uint32_t flags;
548 } sev_publish_args_t;
549 
550 typedef struct subscribe_args {
551 	sev_box_t sid;
552 	sev_box_t class_info;
553 	int door_desc;
554 	uint32_t flags;
555 } sev_subscribe_args_t;
556 
557 typedef struct unsubscribe_args {
558 	sev_box_t sid;
559 } sev_unsubscribe_args_t;
560 
561 typedef struct chandata {
562 	sev_box_t in_data;
563 	sev_box_t out_data;
564 } sev_chandata_args_t;
565 
566 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
567 #pragma pack()
568 #endif
569 
570 #ifdef	__cplusplus
571 }
572 #endif
573 
574 #endif	/* _SYS_SYSEVENT_IMPL_H */
575