xref: /titanic_51/usr/src/uts/common/sys/esunddi.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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 /*
23*fa9e4066Sahrens  * Copyright 2005 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	_SYS_ESUNDDI_H
287c478bd9Sstevel@tonic-gate #define	_SYS_ESUNDDI_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
337c478bd9Sstevel@tonic-gate #include <sys/proc.h>
347c478bd9Sstevel@tonic-gate #include <sys/autoconf.h>
357c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
367c478bd9Sstevel@tonic-gate #include <sys/epm.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * esunddi.h:		Function prototypes for kernel ddi functions.
467c478bd9Sstevel@tonic-gate  *	Note that drivers calling these functions are not
477c478bd9Sstevel@tonic-gate  *	portable.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate int
517c478bd9Sstevel@tonic-gate e_ddi_prop_create(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_modify(dev_t dev, dev_info_t *dip, int flag,
567c478bd9Sstevel@tonic-gate 	char *name, caddr_t value, int length);
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate int
597c478bd9Sstevel@tonic-gate e_ddi_prop_update_int(dev_t match_dev, dev_info_t *dip,
607c478bd9Sstevel@tonic-gate 	char *name, int data);
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate int
637c478bd9Sstevel@tonic-gate e_ddi_prop_update_int64(dev_t match_dev, dev_info_t *dip,
647c478bd9Sstevel@tonic-gate     char *name, int64_t data);
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate int
677c478bd9Sstevel@tonic-gate e_ddi_prop_update_int_array(dev_t match_dev, dev_info_t *dip,
687c478bd9Sstevel@tonic-gate     char *name, int *data, uint_t nelements);
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate int
717c478bd9Sstevel@tonic-gate e_ddi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip,
727c478bd9Sstevel@tonic-gate     char *name, int64_t *data, uint_t nelements);
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate int
757c478bd9Sstevel@tonic-gate e_ddi_prop_update_string(dev_t match_dev, dev_info_t *dip,
767c478bd9Sstevel@tonic-gate 	char *name, char *data);
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate int
797c478bd9Sstevel@tonic-gate e_ddi_prop_update_string_array(dev_t match_dev, dev_info_t *dip,
807c478bd9Sstevel@tonic-gate     char *name, char **data, uint_t nelements);
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate int
837c478bd9Sstevel@tonic-gate e_ddi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip,
847c478bd9Sstevel@tonic-gate     char *name, uchar_t *data, uint_t nelements);
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate int
877c478bd9Sstevel@tonic-gate e_ddi_prop_remove(dev_t dev, dev_info_t *dip, char *name);
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate void
907c478bd9Sstevel@tonic-gate e_ddi_prop_remove_all(dev_info_t *dip);
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate int
937c478bd9Sstevel@tonic-gate e_ddi_prop_undefine(dev_t dev, dev_info_t *dip, int flag, char *name);
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate int
967c478bd9Sstevel@tonic-gate e_ddi_getprop(dev_t dev, vtype_t type, char *name, int flags, int defaultval);
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate int64_t
997c478bd9Sstevel@tonic-gate e_ddi_getprop_int64(dev_t dev, vtype_t type, char *name,
1007c478bd9Sstevel@tonic-gate 	int flags, int64_t defvalue);
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate int
1037c478bd9Sstevel@tonic-gate e_ddi_getproplen(dev_t dev, vtype_t type, char *name, int flags, int *lengthp);
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate int
1067c478bd9Sstevel@tonic-gate e_ddi_getlongprop(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_getlongprop_buf(dev_t dev, vtype_t type, char *name, int flags,
1117c478bd9Sstevel@tonic-gate 	caddr_t valuep, int *lengthp);
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate int
1147c478bd9Sstevel@tonic-gate e_ddi_parental_suspend_resume(dev_info_t *dip);
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate int
1177c478bd9Sstevel@tonic-gate e_ddi_resume(dev_info_t *dip, ddi_attach_cmd_t);
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate int
1207c478bd9Sstevel@tonic-gate e_ddi_suspend(dev_info_t *dip, ddi_detach_cmd_t cmd);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate void
1237c478bd9Sstevel@tonic-gate pm_init(void);
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate void
1267c478bd9Sstevel@tonic-gate e_ddi_prop_list_delete(ddi_prop_t *proplist);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate int
1297c478bd9Sstevel@tonic-gate e_ddi_copyfromdev(dev_info_t *, off_t, const void *, void *, size_t);
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate int
1327c478bd9Sstevel@tonic-gate e_ddi_copytodev(dev_info_t *, off_t, const void *, void *, size_t);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /*
1357c478bd9Sstevel@tonic-gate  * return codes for devi_stillreferenced()
1367c478bd9Sstevel@tonic-gate  *
1377c478bd9Sstevel@tonic-gate  * DEVI_REFERENCED	- specfs has open minor device(s) for the devinfo
1387c478bd9Sstevel@tonic-gate  * DEVI_NOT_REFERENCED	- specfs has no open minor device for the devinfo
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate #define	DEVI_REFERENCED		1
1417c478bd9Sstevel@tonic-gate #define	DEVI_NOT_REFERENCED	0
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate int
1447c478bd9Sstevel@tonic-gate devi_stillreferenced(dev_info_t *dip);
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate extern int (*pm_platform_power)(power_req_t *);
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * A consolidation private function which is essentially equivalent to
1507c478bd9Sstevel@tonic-gate  * ddi_umem_lock but with the addition of arguments ops_vector and procp.
1517c478bd9Sstevel@tonic-gate  * The procp argument can be eliminated eventually as part of proper
1527c478bd9Sstevel@tonic-gate  * dynamic reconfiguration callback implementation.
1537c478bd9Sstevel@tonic-gate  *
1547c478bd9Sstevel@tonic-gate  * The valid flag values are those used for ddi_umem_lock plus an
1557c478bd9Sstevel@tonic-gate  * additional flag (DDI_UMEMLOCK_LONGTERM) which must be set when the
1567c478bd9Sstevel@tonic-gate  * locking will be maintained for an indefinitely long period (essentially
1577c478bd9Sstevel@tonic-gate  * permanent), rather than for what would be required for a typical I/O
1587c478bd9Sstevel@tonic-gate  * completion.  When DDI_UMEMLOCK_LONGTERM is set, umem_lockmemory will
1597c478bd9Sstevel@tonic-gate  * return EFAULT if the memory pertains to a regular file which is
1607c478bd9Sstevel@tonic-gate  * mapped MAP_SHARED.  This is to prevent a deadlock in the pvn routines
1617c478bd9Sstevel@tonic-gate  * if a file truncation is attempted after the locking is done.
1627c478bd9Sstevel@tonic-gate  */
1637c478bd9Sstevel@tonic-gate int
1647c478bd9Sstevel@tonic-gate umem_lockmemory(caddr_t addr, size_t size, int flags,
1657c478bd9Sstevel@tonic-gate 		ddi_umem_cookie_t *cookie,
1667c478bd9Sstevel@tonic-gate 		struct umem_callback_ops *ops_vector,
1677c478bd9Sstevel@tonic-gate 		proc_t *procp);
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate #define	DDI_UMEMLOCK_LONGTERM	0x04
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * These are evolving forms of the ddi function ddi_hold_devi_by_instance.
1737c478bd9Sstevel@tonic-gate  * Like ddi_hold_devi_by_instance, the hold should be released with
1747c478bd9Sstevel@tonic-gate  * ddi_release_devi.
1757c478bd9Sstevel@tonic-gate  */
1767c478bd9Sstevel@tonic-gate dev_info_t	*
1777c478bd9Sstevel@tonic-gate e_ddi_hold_devi_by_dev(dev_t dev, int flags);
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate dev_info_t	*
1807c478bd9Sstevel@tonic-gate e_ddi_hold_devi_by_path(char *path, int flags);
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate /* {e_}ddi_hold_devi{_by{instance|dev|path}} flags */
1837c478bd9Sstevel@tonic-gate #define	E_DDI_HOLD_DEVI_NOATTACH	0x01
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate void
1867c478bd9Sstevel@tonic-gate e_ddi_hold_devi(dev_info_t *);
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate  * Return the reference count on a devinfo node. The caller can determine,
1907c478bd9Sstevel@tonic-gate  * with knowledge of his own holds, if the devinfo node is still in use.
1917c478bd9Sstevel@tonic-gate  */
1927c478bd9Sstevel@tonic-gate int
1937c478bd9Sstevel@tonic-gate e_ddi_devi_holdcnt(dev_info_t *dip);
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate /*
1967c478bd9Sstevel@tonic-gate  * Perform path reconstruction given a major and instance. Does not
1977c478bd9Sstevel@tonic-gate  * drive attach of the path.
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate int
2007c478bd9Sstevel@tonic-gate e_ddi_majorinstance_to_path(major_t major, int instance, char *name);
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * walk all devinfo nodes linked on the driver list
2047c478bd9Sstevel@tonic-gate  */
2057c478bd9Sstevel@tonic-gate void
2067c478bd9Sstevel@tonic-gate e_ddi_walk_driver(char *, int (*f)(dev_info_t *, void *), void *);
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * Given the nodeid for a persistent node, find the corresponding
2107c478bd9Sstevel@tonic-gate  * devinfo node.
2117c478bd9Sstevel@tonic-gate  * NOTE: .conf nodeids are not valid arguments to this function.
2127c478bd9Sstevel@tonic-gate  */
2137c478bd9Sstevel@tonic-gate dev_info_t *
214*fa9e4066Sahrens e_ddi_nodeid_to_dip(pnode_t nodeid);
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate /*
2177c478bd9Sstevel@tonic-gate  * Obsolete interfaces, no longer used, to be removed.
2187c478bd9Sstevel@tonic-gate  * Retained only for driver compatibility.
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate void
2217c478bd9Sstevel@tonic-gate e_ddi_enter_driver_list(struct devnames *, int *);	/* obsolete */
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate int
2247c478bd9Sstevel@tonic-gate e_ddi_tryenter_driver_list(struct devnames *, int *);	/* obsolete */
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate void
2277c478bd9Sstevel@tonic-gate e_ddi_exit_driver_list(struct devnames *, int);		/* obsolete */
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2337c478bd9Sstevel@tonic-gate }
2347c478bd9Sstevel@tonic-gate #endif
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate #endif /* _SYS_ESUNDDI_H */
237