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*a3114836SGerry Liu * Common Development and Distribution License (the "License"). 6*a3114836SGerry Liu * 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 /* 22fa9e4066Sahrens * Copyright 2005 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 _SYS_ESUNDDI_H 277c478bd9Sstevel@tonic-gate #define _SYS_ESUNDDI_H 287c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 297c478bd9Sstevel@tonic-gate #include <sys/proc.h> 307c478bd9Sstevel@tonic-gate #include <sys/autoconf.h> 317c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 327c478bd9Sstevel@tonic-gate #include <sys/epm.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef _KERNEL 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * esunddi.h: Function prototypes for kernel ddi functions. 427c478bd9Sstevel@tonic-gate * Note that drivers calling these functions are not 437c478bd9Sstevel@tonic-gate * portable. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate int 477c478bd9Sstevel@tonic-gate e_ddi_prop_create(dev_t dev, dev_info_t *dip, int flag, 487c478bd9Sstevel@tonic-gate char *name, caddr_t value, int length); 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate int 517c478bd9Sstevel@tonic-gate e_ddi_prop_modify(dev_t dev, dev_info_t *dip, int flag, 527c478bd9Sstevel@tonic-gate char *name, caddr_t value, int length); 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate int 557c478bd9Sstevel@tonic-gate e_ddi_prop_update_int(dev_t match_dev, dev_info_t *dip, 567c478bd9Sstevel@tonic-gate char *name, int data); 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate int 597c478bd9Sstevel@tonic-gate e_ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip, 607c478bd9Sstevel@tonic-gate char *name, int64_t data); 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate int 637c478bd9Sstevel@tonic-gate e_ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, 647c478bd9Sstevel@tonic-gate char *name, int *data, uint_t nelements); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate int 677c478bd9Sstevel@tonic-gate e_ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, 687c478bd9Sstevel@tonic-gate char *name, int64_t *data, uint_t nelements); 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate int 717c478bd9Sstevel@tonic-gate e_ddi_prop_update_string(dev_t match_dev, dev_info_t *dip, 727c478bd9Sstevel@tonic-gate char *name, char *data); 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate int 757c478bd9Sstevel@tonic-gate e_ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip, 767c478bd9Sstevel@tonic-gate char *name, char **data, uint_t nelements); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate int 797c478bd9Sstevel@tonic-gate e_ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip, 807c478bd9Sstevel@tonic-gate char *name, uchar_t *data, uint_t nelements); 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate int 837c478bd9Sstevel@tonic-gate e_ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate void 867c478bd9Sstevel@tonic-gate e_ddi_prop_remove_all(dev_info_t *dip); 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate int 897c478bd9Sstevel@tonic-gate e_ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate int 927c478bd9Sstevel@tonic-gate e_ddi_getprop(dev_t dev, vtype_t type, char *name, int flags, int defaultval); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate int64_t 957c478bd9Sstevel@tonic-gate e_ddi_getprop_int64(dev_t dev, vtype_t type, char *name, 967c478bd9Sstevel@tonic-gate int flags, int64_t defvalue); 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate int 997c478bd9Sstevel@tonic-gate e_ddi_getproplen(dev_t dev, vtype_t type, char *name, int flags, int *lengthp); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate int 1027c478bd9Sstevel@tonic-gate e_ddi_getlongprop(dev_t dev, vtype_t type, char *name, int flags, 1037c478bd9Sstevel@tonic-gate caddr_t valuep, int *lengthp); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate int 1067c478bd9Sstevel@tonic-gate e_ddi_getlongprop_buf(dev_t dev, vtype_t type, char *name, int flags, 1077c478bd9Sstevel@tonic-gate caddr_t valuep, int *lengthp); 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate int 1107c478bd9Sstevel@tonic-gate e_ddi_parental_suspend_resume(dev_info_t *dip); 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate int 1137c478bd9Sstevel@tonic-gate e_ddi_resume(dev_info_t *dip, ddi_attach_cmd_t); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate int 1167c478bd9Sstevel@tonic-gate e_ddi_suspend(dev_info_t *dip, ddi_detach_cmd_t cmd); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate void 1197c478bd9Sstevel@tonic-gate pm_init(void); 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate void 1227c478bd9Sstevel@tonic-gate e_ddi_prop_list_delete(ddi_prop_t *proplist); 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate int 1257c478bd9Sstevel@tonic-gate e_ddi_copyfromdev(dev_info_t *, off_t, const void *, void *, size_t); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate int 1287c478bd9Sstevel@tonic-gate e_ddi_copytodev(dev_info_t *, off_t, const void *, void *, size_t); 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate /* 1317c478bd9Sstevel@tonic-gate * return codes for devi_stillreferenced() 1327c478bd9Sstevel@tonic-gate * 1337c478bd9Sstevel@tonic-gate * DEVI_REFERENCED - specfs has open minor device(s) for the devinfo 1347c478bd9Sstevel@tonic-gate * DEVI_NOT_REFERENCED - specfs has no open minor device for the devinfo 1357c478bd9Sstevel@tonic-gate */ 1367c478bd9Sstevel@tonic-gate #define DEVI_REFERENCED 1 1377c478bd9Sstevel@tonic-gate #define DEVI_NOT_REFERENCED 0 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate int 1407c478bd9Sstevel@tonic-gate devi_stillreferenced(dev_info_t *dip); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate extern int (*pm_platform_power)(power_req_t *); 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * A consolidation private function which is essentially equivalent to 1467c478bd9Sstevel@tonic-gate * ddi_umem_lock but with the addition of arguments ops_vector and procp. 1477c478bd9Sstevel@tonic-gate * The procp argument can be eliminated eventually as part of proper 1487c478bd9Sstevel@tonic-gate * dynamic reconfiguration callback implementation. 1497c478bd9Sstevel@tonic-gate * 1507c478bd9Sstevel@tonic-gate * The valid flag values are those used for ddi_umem_lock plus an 1517c478bd9Sstevel@tonic-gate * additional flag (DDI_UMEMLOCK_LONGTERM) which must be set when the 1527c478bd9Sstevel@tonic-gate * locking will be maintained for an indefinitely long period (essentially 1537c478bd9Sstevel@tonic-gate * permanent), rather than for what would be required for a typical I/O 1547c478bd9Sstevel@tonic-gate * completion. When DDI_UMEMLOCK_LONGTERM is set, umem_lockmemory will 1557c478bd9Sstevel@tonic-gate * return EFAULT if the memory pertains to a regular file which is 1567c478bd9Sstevel@tonic-gate * mapped MAP_SHARED. This is to prevent a deadlock in the pvn routines 1577c478bd9Sstevel@tonic-gate * if a file truncation is attempted after the locking is done. 1587c478bd9Sstevel@tonic-gate */ 1597c478bd9Sstevel@tonic-gate int 1607c478bd9Sstevel@tonic-gate umem_lockmemory(caddr_t addr, size_t size, int flags, 1617c478bd9Sstevel@tonic-gate ddi_umem_cookie_t *cookie, 1627c478bd9Sstevel@tonic-gate struct umem_callback_ops *ops_vector, 1637c478bd9Sstevel@tonic-gate proc_t *procp); 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate #define DDI_UMEMLOCK_LONGTERM 0x04 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * These are evolving forms of the ddi function ddi_hold_devi_by_instance. 1697c478bd9Sstevel@tonic-gate * Like ddi_hold_devi_by_instance, the hold should be released with 1707c478bd9Sstevel@tonic-gate * ddi_release_devi. 1717c478bd9Sstevel@tonic-gate */ 1727c478bd9Sstevel@tonic-gate dev_info_t * 1737c478bd9Sstevel@tonic-gate e_ddi_hold_devi_by_dev(dev_t dev, int flags); 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate dev_info_t * 1767c478bd9Sstevel@tonic-gate e_ddi_hold_devi_by_path(char *path, int flags); 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* {e_}ddi_hold_devi{_by{instance|dev|path}} flags */ 1797c478bd9Sstevel@tonic-gate #define E_DDI_HOLD_DEVI_NOATTACH 0x01 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate void 1827c478bd9Sstevel@tonic-gate e_ddi_hold_devi(dev_info_t *); 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate /* 1857c478bd9Sstevel@tonic-gate * Return the reference count on a devinfo node. The caller can determine, 1867c478bd9Sstevel@tonic-gate * with knowledge of his own holds, if the devinfo node is still in use. 1877c478bd9Sstevel@tonic-gate */ 1887c478bd9Sstevel@tonic-gate int 1897c478bd9Sstevel@tonic-gate e_ddi_devi_holdcnt(dev_info_t *dip); 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * Perform path reconstruction given a major and instance. Does not 1937c478bd9Sstevel@tonic-gate * drive attach of the path. 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate int 1967c478bd9Sstevel@tonic-gate e_ddi_majorinstance_to_path(major_t major, int instance, char *name); 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * walk all devinfo nodes linked on the driver list 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate void 2027c478bd9Sstevel@tonic-gate e_ddi_walk_driver(char *, int (*f)(dev_info_t *, void *), void *); 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate /* 2057c478bd9Sstevel@tonic-gate * Given the nodeid for a persistent node, find the corresponding 2067c478bd9Sstevel@tonic-gate * devinfo node. 2077c478bd9Sstevel@tonic-gate * NOTE: .conf nodeids are not valid arguments to this function. 2087c478bd9Sstevel@tonic-gate */ 2097c478bd9Sstevel@tonic-gate dev_info_t * 210fa9e4066Sahrens e_ddi_nodeid_to_dip(pnode_t nodeid); 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /* 213*a3114836SGerry Liu * Defines for DR interfaces 214*a3114836SGerry Liu */ 215*a3114836SGerry Liu #define DEVI_BRANCH_CHILD 0x01 /* Walk immediate children of root */ 216*a3114836SGerry Liu #define DEVI_BRANCH_CONFIGURE 0x02 /* Configure branch after create */ 217*a3114836SGerry Liu #define DEVI_BRANCH_DESTROY 0x04 /* Destroy branch after unconfigure */ 218*a3114836SGerry Liu #define DEVI_BRANCH_EVENT 0x08 /* Post NDI event */ 219*a3114836SGerry Liu #define DEVI_BRANCH_PROM 0x10 /* Branches derived from PROM nodes */ 220*a3114836SGerry Liu #define DEVI_BRANCH_SID 0x20 /* SID node branches */ 221*a3114836SGerry Liu #define DEVI_BRANCH_ROOT 0x40 /* Node is the root of a branch */ 222*a3114836SGerry Liu 223*a3114836SGerry Liu typedef struct devi_branch { 224*a3114836SGerry Liu void *arg; 225*a3114836SGerry Liu void (*devi_branch_callback)(dev_info_t *, void *, uint_t); 226*a3114836SGerry Liu int type; 227*a3114836SGerry Liu union { 228*a3114836SGerry Liu int (*prom_branch_select)(pnode_t, void *, uint_t); 229*a3114836SGerry Liu int (*sid_branch_create)(dev_info_t *, void *, uint_t); 230*a3114836SGerry Liu } create; 231*a3114836SGerry Liu } devi_branch_t; 232*a3114836SGerry Liu 233*a3114836SGerry Liu extern int e_ddi_branch_create(dev_info_t *pdip, devi_branch_t *bp, 234*a3114836SGerry Liu dev_info_t **dipp, uint_t flags); 235*a3114836SGerry Liu extern int e_ddi_branch_configure(dev_info_t *rdip, dev_info_t **dipp, 236*a3114836SGerry Liu uint_t flags); 237*a3114836SGerry Liu extern int e_ddi_branch_unconfigure(dev_info_t *rdip, dev_info_t **dipp, 238*a3114836SGerry Liu uint_t flags); 239*a3114836SGerry Liu extern int e_ddi_branch_destroy(dev_info_t *rdip, dev_info_t **dipp, 240*a3114836SGerry Liu uint_t flags); 241*a3114836SGerry Liu extern void e_ddi_branch_hold(dev_info_t *rdip); 242*a3114836SGerry Liu extern void e_ddi_branch_rele(dev_info_t *rdip); 243*a3114836SGerry Liu extern int e_ddi_branch_held(dev_info_t *rdip); 244*a3114836SGerry Liu extern int e_ddi_branch_referenced(dev_info_t *rdip, 245*a3114836SGerry Liu int (*cb)(dev_info_t *dip, void *, uint_t), void *arg); 246*a3114836SGerry Liu 247*a3114836SGerry Liu /* 2487c478bd9Sstevel@tonic-gate * Obsolete interfaces, no longer used, to be removed. 2497c478bd9Sstevel@tonic-gate * Retained only for driver compatibility. 2507c478bd9Sstevel@tonic-gate */ 2517c478bd9Sstevel@tonic-gate void 2527c478bd9Sstevel@tonic-gate e_ddi_enter_driver_list(struct devnames *, int *); /* obsolete */ 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate int 2557c478bd9Sstevel@tonic-gate e_ddi_tryenter_driver_list(struct devnames *, int *); /* obsolete */ 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate void 2587c478bd9Sstevel@tonic-gate e_ddi_exit_driver_list(struct devnames *, int); /* obsolete */ 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2647c478bd9Sstevel@tonic-gate } 2657c478bd9Sstevel@tonic-gate #endif 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate #endif /* _SYS_ESUNDDI_H */ 268