17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*25e8c5aaSvikram * Common Development and Distribution License (the "License"). 6*25e8c5aaSvikram * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*25e8c5aaSvikram * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _LIBRCM_IMPL_H 277c478bd9Sstevel@tonic-gate #define _LIBRCM_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <assert.h> 367c478bd9Sstevel@tonic-gate #include <stdio.h> 377c478bd9Sstevel@tonic-gate #include <stdarg.h> 387c478bd9Sstevel@tonic-gate #include <dlfcn.h> 397c478bd9Sstevel@tonic-gate #include <errno.h> 407c478bd9Sstevel@tonic-gate #include <fcntl.h> 417c478bd9Sstevel@tonic-gate #include <poll.h> 427c478bd9Sstevel@tonic-gate #include <stdlib.h> 437c478bd9Sstevel@tonic-gate #include <string.h> 447c478bd9Sstevel@tonic-gate #include <strings.h> 457c478bd9Sstevel@tonic-gate #include <syslog.h> 467c478bd9Sstevel@tonic-gate #include <unistd.h> 477c478bd9Sstevel@tonic-gate #include <sys/mman.h> 487c478bd9Sstevel@tonic-gate #include <sys/wait.h> 497c478bd9Sstevel@tonic-gate #include <sys/types.h> 507c478bd9Sstevel@tonic-gate #include <sys/stat.h> 517c478bd9Sstevel@tonic-gate #include <sys/param.h> 527c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h> 537c478bd9Sstevel@tonic-gate #include <librcm.h> 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * This file contains information private to librcm rcm_daemon. 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate #define RCM_DAEMON_START "/usr/lib/rcm/rcm_daemon" 597c478bd9Sstevel@tonic-gate #define RCM_SERVICE_DOOR "/var/run/rcm_daemon_door" 607c478bd9Sstevel@tonic-gate #define RCM_MODULE_SUFFIX "_rcm.so" 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * flag fields supported by individual librcm interfaces 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate #define RCM_ALLOC_HDL_MASK (RCM_NOPID) 667c478bd9Sstevel@tonic-gate #define RCM_GET_INFO_MASK (RCM_INCLUDE_SUBTREE|RCM_INCLUDE_DEPENDENT|\ 677c478bd9Sstevel@tonic-gate RCM_DR_OPERATION|RCM_MOD_INFO|RCM_FILESYS) 687c478bd9Sstevel@tonic-gate #define RCM_REGISTER_MASK (RCM_FILESYS|RCM_REGISTER_DR|\ 697c478bd9Sstevel@tonic-gate RCM_REGISTER_EVENT|RCM_REGISTER_CAPACITY) 707c478bd9Sstevel@tonic-gate #define RCM_REQUEST_MASK (RCM_QUERY|RCM_SCOPE|RCM_FORCE|RCM_FILESYS|\ 71*25e8c5aaSvikram RCM_QUERY_CANCEL|RCM_RETIRE_REQUEST) 72*25e8c5aaSvikram #define RCM_NOTIFY_MASK (RCM_FILESYS|RCM_RETIRE_NOTIFY) 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* event data names */ 757c478bd9Sstevel@tonic-gate #define RCM_CMD "rcm.cmd" 767c478bd9Sstevel@tonic-gate #define RCM_RESULT "rcm.result" 777c478bd9Sstevel@tonic-gate #define RCM_RESULT_INFO "rcm.result_info" 787c478bd9Sstevel@tonic-gate #define RCM_RSRCNAMES "rcm.rsrcnames" 797c478bd9Sstevel@tonic-gate #define RCM_RSRCSTATE "rcm.rsrcstate" 807c478bd9Sstevel@tonic-gate #define RCM_CLIENT_ID "rcm.client_id" 817c478bd9Sstevel@tonic-gate #define RCM_CLIENT_INFO "rcm.client_info" 827c478bd9Sstevel@tonic-gate #define RCM_CLIENT_ERROR "rcm.client_error" 837c478bd9Sstevel@tonic-gate #define RCM_CLIENT_MODNAME "rcm.client_modname" 847c478bd9Sstevel@tonic-gate #define RCM_CLIENT_PROPERTIES "rcm.client_properties" 857c478bd9Sstevel@tonic-gate #define RCM_SEQ_NUM "rcm.seq_num" 867c478bd9Sstevel@tonic-gate #define RCM_REQUEST_FLAG "rcm.request_flag" 877c478bd9Sstevel@tonic-gate #define RCM_SUSPEND_INTERVAL "rcm.suspend_interval" 887c478bd9Sstevel@tonic-gate #define RCM_CHANGE_DATA "rcm.change_data" 897c478bd9Sstevel@tonic-gate #define RCM_EVENT_DATA "rcm.event_data" 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * action commands shared by librcm and rcm_daemon 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate #define CMD_KNOCK 0 957c478bd9Sstevel@tonic-gate #define CMD_REGISTER 1 967c478bd9Sstevel@tonic-gate #define CMD_UNREGISTER 2 977c478bd9Sstevel@tonic-gate #define CMD_GETINFO 3 987c478bd9Sstevel@tonic-gate #define CMD_SUSPEND 4 997c478bd9Sstevel@tonic-gate #define CMD_RESUME 5 1007c478bd9Sstevel@tonic-gate #define CMD_OFFLINE 6 1017c478bd9Sstevel@tonic-gate #define CMD_ONLINE 7 1027c478bd9Sstevel@tonic-gate #define CMD_REMOVE 8 1037c478bd9Sstevel@tonic-gate #define CMD_EVENT 9 1047c478bd9Sstevel@tonic-gate #define CMD_REQUEST_CHANGE 10 1057c478bd9Sstevel@tonic-gate #define CMD_NOTIFY_CHANGE 11 1067c478bd9Sstevel@tonic-gate #define CMD_GETSTATE 12 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * Ops vector for calling directly into daemon from RCM modules 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate typedef struct { 1127c478bd9Sstevel@tonic-gate int (*librcm_regis)(); 1137c478bd9Sstevel@tonic-gate int (*librcm_unregis)(); 1147c478bd9Sstevel@tonic-gate int (*librcm_getinfo)(); 1157c478bd9Sstevel@tonic-gate int (*librcm_suspend)(); 1167c478bd9Sstevel@tonic-gate int (*librcm_resume)(); 1177c478bd9Sstevel@tonic-gate int (*librcm_offline)(); 1187c478bd9Sstevel@tonic-gate int (*librcm_online)(); 1197c478bd9Sstevel@tonic-gate int (*librcm_remove)(); 1207c478bd9Sstevel@tonic-gate int (*librcm_request_change)(); 1217c478bd9Sstevel@tonic-gate int (*librcm_notify_change)(); 1227c478bd9Sstevel@tonic-gate int (*librcm_notify_event)(); 1237c478bd9Sstevel@tonic-gate int (*librcm_getstate)(); 1247c478bd9Sstevel@tonic-gate } librcm_ops_t; 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * rcm handle struture 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate struct rcm_handle { 1307c478bd9Sstevel@tonic-gate char *modname; 1317c478bd9Sstevel@tonic-gate pid_t pid; 1327c478bd9Sstevel@tonic-gate int seq_num; 1337c478bd9Sstevel@tonic-gate librcm_ops_t *lrcm_ops; 1347c478bd9Sstevel@tonic-gate struct module *module; 1357c478bd9Sstevel@tonic-gate }; 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate struct rcm_info { 1387c478bd9Sstevel@tonic-gate nvlist_t *info; 1397c478bd9Sstevel@tonic-gate struct rcm_info *next; 1407c478bd9Sstevel@tonic-gate }; 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * module utility routines 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate char *rcm_module_dir(uint_t); 1467c478bd9Sstevel@tonic-gate void *rcm_module_open(char *); 1477c478bd9Sstevel@tonic-gate void rcm_module_close(void *); 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate /* 1507c478bd9Sstevel@tonic-gate * rcm scripting utility routines 1517c478bd9Sstevel@tonic-gate */ 1527c478bd9Sstevel@tonic-gate char *rcm_script_dir(uint_t dirnum); 1537c478bd9Sstevel@tonic-gate char *rcm_dir(uint_t dirnum, int *rcm_script); 1547c478bd9Sstevel@tonic-gate char *rcm_get_script_dir(char *script_name); 1557c478bd9Sstevel@tonic-gate int rcm_is_script(char *filename); 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate #endif 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #endif /* _LIBRCM_IMPL_H */ 163