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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _DACF_IMPL_H 287c478bd9Sstevel@tonic-gate #define _DACF_IMPL_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * Implementation-Private definitions for Device autoconfiguration (dacf) 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #include <sys/types.h> 397c478bd9Sstevel@tonic-gate #include <sys/dacf.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate typedef struct dacf_module { 427c478bd9Sstevel@tonic-gate char *dm_name; /* module name */ 437c478bd9Sstevel@tonic-gate krwlock_t dm_lock; /* module lock */ 447c478bd9Sstevel@tonic-gate int dm_loaded; /* whether dm_opsets is valid */ 457c478bd9Sstevel@tonic-gate dacf_opset_t *dm_opsets; /* null-terminated array of op-sets */ 467c478bd9Sstevel@tonic-gate } dacf_module_t; 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define DACF_RULE_HASHSIZE 8 507c478bd9Sstevel@tonic-gate #define DACF_MODULE_HASHSIZE 8 517c478bd9Sstevel@tonic-gate #define DACF_INFO_HASHSIZE 16 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Flags to dacf_process_rsrvs 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate #define DACF_PROC_INVOKE 0x0001 577c478bd9Sstevel@tonic-gate #define DACF_PROC_RELE 0x0002 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate typedef enum dacf_devspec { 607c478bd9Sstevel@tonic-gate DACF_DS_ERROR = -1, /* error state */ 617c478bd9Sstevel@tonic-gate DACF_DS_MIN_NT = 1, /* match minor node-type */ 627c478bd9Sstevel@tonic-gate DACF_DS_DRV_MNAME = 2, /* match driver minor name */ 637c478bd9Sstevel@tonic-gate DACF_DS_DEV_PATH = 3 /* match device path */ 647c478bd9Sstevel@tonic-gate } dacf_devspec_t; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #define DACF_NUM_DEVSPECS 3 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate typedef struct dacf_arg { 697c478bd9Sstevel@tonic-gate char *arg_name; /* operation argument name */ 707c478bd9Sstevel@tonic-gate char *arg_val; /* operation argument value */ 717c478bd9Sstevel@tonic-gate struct dacf_arg *arg_next; /* next arg in chain */ 727c478bd9Sstevel@tonic-gate } dacf_arg_t; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate typedef struct dacf_rule { 757c478bd9Sstevel@tonic-gate char *r_devspec_data; /* the dev-spec data to match against */ 767c478bd9Sstevel@tonic-gate char *r_module; /* module implementing the operation */ 777c478bd9Sstevel@tonic-gate char *r_opset; /* opset in module that impls. op */ 787c478bd9Sstevel@tonic-gate dacf_opid_t r_opid; /* operation id for this rule */ 797c478bd9Sstevel@tonic-gate uint_t r_opts; /* reserved for options */ 807c478bd9Sstevel@tonic-gate uint_t r_refs; /* reference count */ 817c478bd9Sstevel@tonic-gate dacf_arg_t *r_args; /* linked list of operation arguments */ 827c478bd9Sstevel@tonic-gate } dacf_rule_t; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate typedef struct dacf_rsrvlist { 857c478bd9Sstevel@tonic-gate dacf_rule_t *rsrv_rule; /* the rule being reserved for later */ 867c478bd9Sstevel@tonic-gate dacf_infohdl_t rsrv_ihdl; 877c478bd9Sstevel@tonic-gate int rsrv_result; /* retval of the last invoke */ 887c478bd9Sstevel@tonic-gate struct dacf_rsrvlist *rsrv_next; 897c478bd9Sstevel@tonic-gate } dacf_rsrvlist_t; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #ifdef _KERNEL 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate extern kmutex_t dacf_lock; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate int dacf_module_register(char *, struct dacfsw *); 967c478bd9Sstevel@tonic-gate int dacf_module_unregister(char *); 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate int dacf_arg_insert(dacf_arg_t **, char *, char *); 997c478bd9Sstevel@tonic-gate void dacf_arglist_delete(dacf_arg_t **); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate void dacf_init(void); 1027c478bd9Sstevel@tonic-gate int read_dacf_binding_file(char *); 1037c478bd9Sstevel@tonic-gate void dacf_clear_rules(void); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate dacf_devspec_t dacf_get_devspec(char *); 1067c478bd9Sstevel@tonic-gate const char *dacf_devspec_to_str(dacf_devspec_t); 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate dacf_opid_t dacf_get_op(char *); 1097c478bd9Sstevel@tonic-gate const char *dacf_opid_to_str(dacf_opid_t); 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate int dacf_getopt(char *, uint_t *); 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate int dacf_rule_insert(dacf_devspec_t, char *, char *, char *, 1147c478bd9Sstevel@tonic-gate dacf_opid_t, uint_t, dacf_arg_t *); 1157c478bd9Sstevel@tonic-gate void dacf_rule_hold(dacf_rule_t *); 1167c478bd9Sstevel@tonic-gate void dacf_rule_rele(dacf_rule_t *); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate struct ddi_minor_data; 1197c478bd9Sstevel@tonic-gate void dacf_rsrv_make(dacf_rsrvlist_t *, dacf_rule_t *, void *, 1207c478bd9Sstevel@tonic-gate dacf_rsrvlist_t **); 1217c478bd9Sstevel@tonic-gate void dacf_process_rsrvs(dacf_rsrvlist_t **, dacf_opid_t, int); 1227c478bd9Sstevel@tonic-gate void dacf_clr_rsrvs(dev_info_t *, dacf_opid_t); 1237c478bd9Sstevel@tonic-gate 124*7bcaeddbSRobert Mustacchi dacf_rule_t *dacf_match(dacf_opid_t, dacf_devspec_t, const void *); 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * Failure codes from dacf_op_invoke, assigned to dacf_rsrvlist_t.rsrv_result 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate #define DACF_ERR_MOD_NOTFOUND -1 1307c478bd9Sstevel@tonic-gate #define DACF_ERR_OPSET_NOTFOUND -2 1317c478bd9Sstevel@tonic-gate #define DACF_ERR_OP_NOTFOUND -3 1327c478bd9Sstevel@tonic-gate #define DACF_ERR_OP_FAILED -4 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate int dacf_op_invoke(dacf_rule_t *, dacf_infohdl_t, int); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * Debugging support 1387c478bd9Sstevel@tonic-gate */ 1397c478bd9Sstevel@tonic-gate #define DACF_DBG_MSGS 0x00000001 1407c478bd9Sstevel@tonic-gate #define DACF_DBG_DEVI 0x00000002 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate extern int dacfdebug; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * dacf client support: definitions pertaining to the various kernel hooks 1477c478bd9Sstevel@tonic-gate * that utilize the dacf framework 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate 150*7bcaeddbSRobert Mustacchi void dacfc_match_create_minor(const char *, const char *, dev_info_t *, 1517c478bd9Sstevel@tonic-gate struct ddi_minor_data *, int); 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate int dacfc_postattach(dev_info_t *); 1547c478bd9Sstevel@tonic-gate int dacfc_predetach(dev_info_t *); 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate #endif 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #endif /* _DACF_IMPL_H */ 163