10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*4845Svikram * Common Development and Distribution License (the "License"). 6*4845Svikram * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*4845Svikram * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _LIBRCM_IMPL_H 270Sstevel@tonic-gate #define _LIBRCM_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <assert.h> 360Sstevel@tonic-gate #include <stdio.h> 370Sstevel@tonic-gate #include <stdarg.h> 380Sstevel@tonic-gate #include <dlfcn.h> 390Sstevel@tonic-gate #include <errno.h> 400Sstevel@tonic-gate #include <fcntl.h> 410Sstevel@tonic-gate #include <poll.h> 420Sstevel@tonic-gate #include <stdlib.h> 430Sstevel@tonic-gate #include <string.h> 440Sstevel@tonic-gate #include <strings.h> 450Sstevel@tonic-gate #include <syslog.h> 460Sstevel@tonic-gate #include <unistd.h> 470Sstevel@tonic-gate #include <sys/mman.h> 480Sstevel@tonic-gate #include <sys/wait.h> 490Sstevel@tonic-gate #include <sys/types.h> 500Sstevel@tonic-gate #include <sys/stat.h> 510Sstevel@tonic-gate #include <sys/param.h> 520Sstevel@tonic-gate #include <sys/systeminfo.h> 530Sstevel@tonic-gate #include <librcm.h> 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * This file contains information private to librcm rcm_daemon. 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate #define RCM_DAEMON_START "/usr/lib/rcm/rcm_daemon" 590Sstevel@tonic-gate #define RCM_SERVICE_DOOR "/var/run/rcm_daemon_door" 600Sstevel@tonic-gate #define RCM_MODULE_SUFFIX "_rcm.so" 610Sstevel@tonic-gate 620Sstevel@tonic-gate /* 630Sstevel@tonic-gate * flag fields supported by individual librcm interfaces 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate #define RCM_ALLOC_HDL_MASK (RCM_NOPID) 660Sstevel@tonic-gate #define RCM_GET_INFO_MASK (RCM_INCLUDE_SUBTREE|RCM_INCLUDE_DEPENDENT|\ 670Sstevel@tonic-gate RCM_DR_OPERATION|RCM_MOD_INFO|RCM_FILESYS) 680Sstevel@tonic-gate #define RCM_REGISTER_MASK (RCM_FILESYS|RCM_REGISTER_DR|\ 690Sstevel@tonic-gate RCM_REGISTER_EVENT|RCM_REGISTER_CAPACITY) 700Sstevel@tonic-gate #define RCM_REQUEST_MASK (RCM_QUERY|RCM_SCOPE|RCM_FORCE|RCM_FILESYS|\ 71*4845Svikram RCM_QUERY_CANCEL|RCM_RETIRE_REQUEST) 72*4845Svikram #define RCM_NOTIFY_MASK (RCM_FILESYS|RCM_RETIRE_NOTIFY) 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* event data names */ 750Sstevel@tonic-gate #define RCM_CMD "rcm.cmd" 760Sstevel@tonic-gate #define RCM_RESULT "rcm.result" 770Sstevel@tonic-gate #define RCM_RESULT_INFO "rcm.result_info" 780Sstevel@tonic-gate #define RCM_RSRCNAMES "rcm.rsrcnames" 790Sstevel@tonic-gate #define RCM_RSRCSTATE "rcm.rsrcstate" 800Sstevel@tonic-gate #define RCM_CLIENT_ID "rcm.client_id" 810Sstevel@tonic-gate #define RCM_CLIENT_INFO "rcm.client_info" 820Sstevel@tonic-gate #define RCM_CLIENT_ERROR "rcm.client_error" 830Sstevel@tonic-gate #define RCM_CLIENT_MODNAME "rcm.client_modname" 840Sstevel@tonic-gate #define RCM_CLIENT_PROPERTIES "rcm.client_properties" 850Sstevel@tonic-gate #define RCM_SEQ_NUM "rcm.seq_num" 860Sstevel@tonic-gate #define RCM_REQUEST_FLAG "rcm.request_flag" 870Sstevel@tonic-gate #define RCM_SUSPEND_INTERVAL "rcm.suspend_interval" 880Sstevel@tonic-gate #define RCM_CHANGE_DATA "rcm.change_data" 890Sstevel@tonic-gate #define RCM_EVENT_DATA "rcm.event_data" 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* 920Sstevel@tonic-gate * action commands shared by librcm and rcm_daemon 930Sstevel@tonic-gate */ 940Sstevel@tonic-gate #define CMD_KNOCK 0 950Sstevel@tonic-gate #define CMD_REGISTER 1 960Sstevel@tonic-gate #define CMD_UNREGISTER 2 970Sstevel@tonic-gate #define CMD_GETINFO 3 980Sstevel@tonic-gate #define CMD_SUSPEND 4 990Sstevel@tonic-gate #define CMD_RESUME 5 1000Sstevel@tonic-gate #define CMD_OFFLINE 6 1010Sstevel@tonic-gate #define CMD_ONLINE 7 1020Sstevel@tonic-gate #define CMD_REMOVE 8 1030Sstevel@tonic-gate #define CMD_EVENT 9 1040Sstevel@tonic-gate #define CMD_REQUEST_CHANGE 10 1050Sstevel@tonic-gate #define CMD_NOTIFY_CHANGE 11 1060Sstevel@tonic-gate #define CMD_GETSTATE 12 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* 1090Sstevel@tonic-gate * Ops vector for calling directly into daemon from RCM modules 1100Sstevel@tonic-gate */ 1110Sstevel@tonic-gate typedef struct { 1120Sstevel@tonic-gate int (*librcm_regis)(); 1130Sstevel@tonic-gate int (*librcm_unregis)(); 1140Sstevel@tonic-gate int (*librcm_getinfo)(); 1150Sstevel@tonic-gate int (*librcm_suspend)(); 1160Sstevel@tonic-gate int (*librcm_resume)(); 1170Sstevel@tonic-gate int (*librcm_offline)(); 1180Sstevel@tonic-gate int (*librcm_online)(); 1190Sstevel@tonic-gate int (*librcm_remove)(); 1200Sstevel@tonic-gate int (*librcm_request_change)(); 1210Sstevel@tonic-gate int (*librcm_notify_change)(); 1220Sstevel@tonic-gate int (*librcm_notify_event)(); 1230Sstevel@tonic-gate int (*librcm_getstate)(); 1240Sstevel@tonic-gate } librcm_ops_t; 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate /* 1270Sstevel@tonic-gate * rcm handle struture 1280Sstevel@tonic-gate */ 1290Sstevel@tonic-gate struct rcm_handle { 1300Sstevel@tonic-gate char *modname; 1310Sstevel@tonic-gate pid_t pid; 1320Sstevel@tonic-gate int seq_num; 1330Sstevel@tonic-gate librcm_ops_t *lrcm_ops; 1340Sstevel@tonic-gate struct module *module; 1350Sstevel@tonic-gate }; 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate struct rcm_info { 1380Sstevel@tonic-gate nvlist_t *info; 1390Sstevel@tonic-gate struct rcm_info *next; 1400Sstevel@tonic-gate }; 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate /* 1430Sstevel@tonic-gate * module utility routines 1440Sstevel@tonic-gate */ 1450Sstevel@tonic-gate char *rcm_module_dir(uint_t); 1460Sstevel@tonic-gate void *rcm_module_open(char *); 1470Sstevel@tonic-gate void rcm_module_close(void *); 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* 1500Sstevel@tonic-gate * rcm scripting utility routines 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate char *rcm_script_dir(uint_t dirnum); 1530Sstevel@tonic-gate char *rcm_dir(uint_t dirnum, int *rcm_script); 1540Sstevel@tonic-gate char *rcm_get_script_dir(char *script_name); 1550Sstevel@tonic-gate int rcm_is_script(char *filename); 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate #ifdef __cplusplus 1590Sstevel@tonic-gate } 1600Sstevel@tonic-gate #endif 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate #endif /* _LIBRCM_IMPL_H */ 163