1*25e8c5aaSvikram /* 2*25e8c5aaSvikram * CDDL HEADER START 3*25e8c5aaSvikram * 4*25e8c5aaSvikram * 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. 7*25e8c5aaSvikram * 8*25e8c5aaSvikram * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*25e8c5aaSvikram * or http://www.opensolaris.org/os/licensing. 10*25e8c5aaSvikram * See the License for the specific language governing permissions 11*25e8c5aaSvikram * and limitations under the License. 12*25e8c5aaSvikram * 13*25e8c5aaSvikram * When distributing Covered Code, include this CDDL HEADER in each 14*25e8c5aaSvikram * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*25e8c5aaSvikram * If applicable, add the following below this CDDL HEADER, with the 16*25e8c5aaSvikram * fields enclosed by brackets "[]" replaced with your own identifying 17*25e8c5aaSvikram * information: Portions Copyright [yyyy] [name of copyright owner] 18*25e8c5aaSvikram * 19*25e8c5aaSvikram * CDDL HEADER END 20*25e8c5aaSvikram */ 21*25e8c5aaSvikram /* 22*25e8c5aaSvikram * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*25e8c5aaSvikram * Use is subject to license terms. 24*25e8c5aaSvikram */ 25*25e8c5aaSvikram 26*25e8c5aaSvikram #ifndef _SYS_CONTRACT_DEVICE_IMPL_H 27*25e8c5aaSvikram #define _SYS_CONTRACT_DEVICE_IMPL_H 28*25e8c5aaSvikram 29*25e8c5aaSvikram #pragma ident "%Z%%M% %I% %E% SMI" 30*25e8c5aaSvikram 31*25e8c5aaSvikram #include <sys/contract_impl.h> 32*25e8c5aaSvikram #include <sys/dditypes.h> 33*25e8c5aaSvikram #include <sys/contract/device.h> 34*25e8c5aaSvikram #include <sys/fs/snode.h> 35*25e8c5aaSvikram 36*25e8c5aaSvikram #ifdef __cplusplus 37*25e8c5aaSvikram extern "C" { 38*25e8c5aaSvikram #endif 39*25e8c5aaSvikram 40*25e8c5aaSvikram /* 41*25e8c5aaSvikram * Result of negotiation end: event successfully occurred or not 42*25e8c5aaSvikram */ 43*25e8c5aaSvikram #define CT_EV_SUCCESS 150 44*25e8c5aaSvikram #define CT_EV_FAILURE 151 45*25e8c5aaSvikram 46*25e8c5aaSvikram struct ctmpl_device { 47*25e8c5aaSvikram ct_template_t ctd_ctmpl; 48*25e8c5aaSvikram uint_t ctd_aset; 49*25e8c5aaSvikram uint_t ctd_noneg; 50*25e8c5aaSvikram char *ctd_minor; 51*25e8c5aaSvikram }; 52*25e8c5aaSvikram 53*25e8c5aaSvikram struct cont_device { 54*25e8c5aaSvikram contract_t cond_contract; /* common contract data */ 55*25e8c5aaSvikram char *cond_minor; /* minor node resource in contract */ 56*25e8c5aaSvikram dev_info_t *cond_dip; /* dip for minor node */ 57*25e8c5aaSvikram dev_t cond_devt; /* dev_t of minor node */ 58*25e8c5aaSvikram uint_t cond_spec; /* spec type of minor node */ 59*25e8c5aaSvikram uint_t cond_aset; /* acceptable state set */ 60*25e8c5aaSvikram uint_t cond_noneg; /* no negotiation if set */ 61*25e8c5aaSvikram uint_t cond_state; /* current state of device */ 62*25e8c5aaSvikram uint_t cond_neg; /* contract undergoing negotiation */ 63*25e8c5aaSvikram uint64_t cond_currev_id; /* id of event being negotiated */ 64*25e8c5aaSvikram uint_t cond_currev_type; /* type of event being negotiated */ 65*25e8c5aaSvikram uint_t cond_currev_ack; /* ack/nack status of ev negotiation */ 66*25e8c5aaSvikram list_node_t cond_next; /* linkage - devinfo's contracts */ 67*25e8c5aaSvikram }; 68*25e8c5aaSvikram 69*25e8c5aaSvikram /* 70*25e8c5aaSvikram * Kernel APIs 71*25e8c5aaSvikram */ 72*25e8c5aaSvikram extern ct_type_t *device_type; 73*25e8c5aaSvikram /* 74*25e8c5aaSvikram * struct proc; 75*25e8c5aaSvikram */ 76*25e8c5aaSvikram void contract_device_init(void); 77*25e8c5aaSvikram ct_ack_t contract_device_offline(dev_info_t *dip, dev_t dev, int spec_type); 78*25e8c5aaSvikram void contract_device_degrade(dev_info_t *dip, dev_t dev, int spec_type); 79*25e8c5aaSvikram void contract_device_undegrade(dev_info_t *dip, dev_t dev, int spec_type); 80*25e8c5aaSvikram int contract_device_open(dev_t dev, int spec_type, contract_t **ctpp); 81*25e8c5aaSvikram void contract_device_remove_dip(dev_info_t *dip); 82*25e8c5aaSvikram ct_ack_t contract_device_negotiate(dev_info_t *dip, dev_t dev, int spec_type, 83*25e8c5aaSvikram uint_t evtype); 84*25e8c5aaSvikram void contract_device_finalize(dev_info_t *dip, dev_t dev, int spec_type, 85*25e8c5aaSvikram uint_t evtype, int ct_result); 86*25e8c5aaSvikram void contract_device_negend(dev_info_t *dip, dev_t dev, int spec_type, 87*25e8c5aaSvikram int result); 88*25e8c5aaSvikram 89*25e8c5aaSvikram #ifdef __cplusplus 90*25e8c5aaSvikram } 91*25e8c5aaSvikram #endif 92*25e8c5aaSvikram 93*25e8c5aaSvikram #endif /* _SYS_CONTRACT_DEVICE_IMPL_H */ 94