1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 2000-2001 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYSEVENTD_H 28*7c478bd9Sstevel@tonic-gate #define _SYSEVENTD_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 31*7c478bd9Sstevel@tonic-gate extern "C" { 32*7c478bd9Sstevel@tonic-gate #endif 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #define MAX_SLM 20 /* Max sysevent loadable modules */ 35*7c478bd9Sstevel@tonic-gate #define MAX_MODCTL_RETRY 3 /* Maximum number of modctl retries */ 36*7c478bd9Sstevel@tonic-gate /* for free and get data */ 37*7c478bd9Sstevel@tonic-gate #define LOGEVENT_BUFSIZE 1024 /* message size greater than this */ 38*7c478bd9Sstevel@tonic-gate /* requires another kernel trip */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate /* Debug and errlogging stuff */ 41*7c478bd9Sstevel@tonic-gate extern void syseventd_print(int level, char *message, ...); 42*7c478bd9Sstevel@tonic-gate extern void syseventd_err_print(char *message, ...); 43*7c478bd9Sstevel@tonic-gate extern void syseventd_exit(int status); 44*7c478bd9Sstevel@tonic-gate extern int debug_level; 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * struct event_dispatch_pkg - per-client event dispatch package 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate struct event_dispatch_pkg { 50*7c478bd9Sstevel@tonic-gate hrtime_t start_time; /* start time ev delivery */ 51*7c478bd9Sstevel@tonic-gate struct sysevent_client *scp; /* Client data */ 52*7c478bd9Sstevel@tonic-gate sysevent_t *ev; /* event buf to deliver */ 53*7c478bd9Sstevel@tonic-gate sema_t *completion_sema; 54*7c478bd9Sstevel@tonic-gate int completion_state; 55*7c478bd9Sstevel@tonic-gate int completion_status; 56*7c478bd9Sstevel@tonic-gate int retry_count; /* running retry counter */ 57*7c478bd9Sstevel@tonic-gate }; 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* completion states */ 60*7c478bd9Sstevel@tonic-gate #define SE_NOT_DISPATCHED 0 /* Not yet dispatched to client */ 61*7c478bd9Sstevel@tonic-gate #define SE_OUTSTANDING 1 /* Dispatched and outstanding */ 62*7c478bd9Sstevel@tonic-gate #define SE_COMPLETE 2 /* Delivery complete */ 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * struct event_dispatchq - queue of dispatched event dispatch pacakges 66*7c478bd9Sstevel@tonic-gate */ 67*7c478bd9Sstevel@tonic-gate struct event_dispatchq { 68*7c478bd9Sstevel@tonic-gate struct event_dispatchq *next; 69*7c478bd9Sstevel@tonic-gate struct event_dispatch_pkg *d_pkg; 70*7c478bd9Sstevel@tonic-gate }; 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate /* 73*7c478bd9Sstevel@tonic-gate * struct ev_completion - event completion data 74*7c478bd9Sstevel@tonic-gate * This structure contains information regarding the 75*7c478bd9Sstevel@tonic-gate * event delivery status for each client dispatched. 76*7c478bd9Sstevel@tonic-gate */ 77*7c478bd9Sstevel@tonic-gate struct ev_completion { 78*7c478bd9Sstevel@tonic-gate sysevent_t *ev; /* event */ 79*7c478bd9Sstevel@tonic-gate struct ev_completion *next; 80*7c478bd9Sstevel@tonic-gate struct event_dispatchq *dispatch_list; /* per_client dspatch packages */ 81*7c478bd9Sstevel@tonic-gate int client_count; /* Number of clients */ 82*7c478bd9Sstevel@tonic-gate /* event was dispatched to. */ 83*7c478bd9Sstevel@tonic-gate sema_t client_sema; /* Client completion */ 84*7c478bd9Sstevel@tonic-gate /* synchronization */ 85*7c478bd9Sstevel@tonic-gate }; 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate /* 88*7c478bd9Sstevel@tonic-gate * module_t - SLM client module data 89*7c478bd9Sstevel@tonic-gate */ 90*7c478bd9Sstevel@tonic-gate typedef struct module { 91*7c478bd9Sstevel@tonic-gate struct module *next; 92*7c478bd9Sstevel@tonic-gate char *name; 93*7c478bd9Sstevel@tonic-gate void *dlhandle; 94*7c478bd9Sstevel@tonic-gate int (*deliver_event)(); 95*7c478bd9Sstevel@tonic-gate struct slm_mod_ops *(*event_mod_init)(); 96*7c478bd9Sstevel@tonic-gate void (*event_mod_fini)(); 97*7c478bd9Sstevel@tonic-gate } module_t; 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate /* 100*7c478bd9Sstevel@tonic-gate * struct sysevent_client - per-client data 101*7c478bd9Sstevel@tonic-gate */ 102*7c478bd9Sstevel@tonic-gate struct sysevent_client { 103*7c478bd9Sstevel@tonic-gate mutex_t client_lock; /* Lock for struct data */ 104*7c478bd9Sstevel@tonic-gate cond_t client_cv; /* Deliver cond variable */ 105*7c478bd9Sstevel@tonic-gate thread_t tid; /* Client deliver thread id */ 106*7c478bd9Sstevel@tonic-gate int client_type; /* SLM only */ 107*7c478bd9Sstevel@tonic-gate int client_num; /* Assigned at load time */ 108*7c478bd9Sstevel@tonic-gate int client_flags; /* Client flags */ 109*7c478bd9Sstevel@tonic-gate int retry_limit; /* Defined by slm_mod_ops */ 110*7c478bd9Sstevel@tonic-gate void *client_data; /* Client-type specific data */ 111*7c478bd9Sstevel@tonic-gate struct event_dispatchq *eventq; /* Client event queue */ 112*7c478bd9Sstevel@tonic-gate }; 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* Client types */ 115*7c478bd9Sstevel@tonic-gate #define SLM_CLIENT 0 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate /* Client flags */ 118*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_UNLOADED 0 119*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_LOADED 0X00000001 120*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_SUSPENDED 0X00000002 121*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_THR_RUNNING 0X00000004 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_IS_UNLOADED(scp) \ 124*7c478bd9Sstevel@tonic-gate ((scp)->client_flags == SE_CLIENT_UNLOADED) 125*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_IS_LOADED(scp) \ 126*7c478bd9Sstevel@tonic-gate ((scp)->client_flags & SE_CLIENT_LOADED) 127*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_IS_SUSPENDED(scp) \ 128*7c478bd9Sstevel@tonic-gate ((scp)->client_flags & SE_CLIENT_SUSPENDED) 129*7c478bd9Sstevel@tonic-gate #define SE_CLIENT_IS_THR_RUNNING(scp) \ 130*7c478bd9Sstevel@tonic-gate ((scp)->client_flags & SE_CLIENT_THR_RUNNING) 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 134*7c478bd9Sstevel@tonic-gate } 135*7c478bd9Sstevel@tonic-gate #endif 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate #endif /* _SYSEVENTD_H */ 138