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*737d277aScth  * Copyright 2006 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_DDI_IMPLFUNCS_H
287c478bd9Sstevel@tonic-gate #define	_SYS_DDI_IMPLFUNCS_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h>
377c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <sys/task.h>
407c478bd9Sstevel@tonic-gate #include <sys/project.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * Declare implementation functions that sunddi functions can
467c478bd9Sstevel@tonic-gate  * call in order to perform their required task. Each kernel
477c478bd9Sstevel@tonic-gate  * architecture must provide them.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate int
517c478bd9Sstevel@tonic-gate i_ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
527c478bd9Sstevel@tonic-gate 	off_t offset, off_t len, caddr_t *vaddrp);
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate int
557c478bd9Sstevel@tonic-gate i_ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate struct regspec *
587c478bd9Sstevel@tonic-gate i_ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate int
627c478bd9Sstevel@tonic-gate i_ddi_map_fault(dev_info_t *dip, dev_info_t *rdip,
637c478bd9Sstevel@tonic-gate 	struct hat *hat, struct seg *seg, caddr_t addr,
647c478bd9Sstevel@tonic-gate 	struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate ddi_regspec_t
677c478bd9Sstevel@tonic-gate i_ddi_get_regspec(dev_info_t *dip, dev_info_t *rdip, uint_t rnumber,
687c478bd9Sstevel@tonic-gate 	off_t offset, off_t len);
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Implementation specific memory allocation and de-allocation routines.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate int
747c478bd9Sstevel@tonic-gate i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attributes,
757c478bd9Sstevel@tonic-gate 	size_t length, int cansleep, int streaming,
767c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
777c478bd9Sstevel@tonic-gate 	size_t *real_length, ddi_acc_hdl_t *handlep);
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate int
807c478bd9Sstevel@tonic-gate i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits,
817c478bd9Sstevel@tonic-gate 	size_t length, int cansleep, int streaming,
827c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
837c478bd9Sstevel@tonic-gate 	uint_t *real_length, ddi_acc_hdl_t *handlep);
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate void
867c478bd9Sstevel@tonic-gate i_ddi_mem_free(caddr_t kaddr, int streaming);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate int
897c478bd9Sstevel@tonic-gate i_ddi_devi_get_ppa(dev_info_t *dip);
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate void
927c478bd9Sstevel@tonic-gate i_ddi_devi_set_ppa(dev_info_t *dip, int ppa);
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Access and DMA handle fault set/clear routines
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate void
987c478bd9Sstevel@tonic-gate i_ddi_acc_set_fault(ddi_acc_handle_t handle);
997c478bd9Sstevel@tonic-gate void
1007c478bd9Sstevel@tonic-gate i_ddi_acc_clr_fault(ddi_acc_handle_t handle);
1017c478bd9Sstevel@tonic-gate void
1027c478bd9Sstevel@tonic-gate i_ddi_dma_set_fault(ddi_dma_handle_t handle);
1037c478bd9Sstevel@tonic-gate void
1047c478bd9Sstevel@tonic-gate i_ddi_dma_clr_fault(ddi_dma_handle_t handle);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  *      Event-handling functions for rootnex
1087c478bd9Sstevel@tonic-gate  *      These provide the standard implementation of fault handling
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate void
1117c478bd9Sstevel@tonic-gate i_ddi_rootnex_init_events(dev_info_t *dip);
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate int
1147c478bd9Sstevel@tonic-gate i_ddi_rootnex_get_eventcookie(dev_info_t *dip, dev_info_t *rdip,
1157c478bd9Sstevel@tonic-gate 	char *eventname, ddi_eventcookie_t *cookiep);
1167c478bd9Sstevel@tonic-gate int
1177c478bd9Sstevel@tonic-gate i_ddi_rootnex_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
1187c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t eventid, void (*handler)(dev_info_t *dip,
1197c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t event, void *arg, void *impl_data), void *arg,
1207c478bd9Sstevel@tonic-gate 	ddi_callback_id_t *cb_id);
1217c478bd9Sstevel@tonic-gate int
1227c478bd9Sstevel@tonic-gate i_ddi_rootnex_remove_eventcall(dev_info_t *devi, ddi_callback_id_t cb_id);
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate int
1257c478bd9Sstevel@tonic-gate i_ddi_rootnex_post_event(dev_info_t *dip, dev_info_t *rdip,
1267c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t eventid, void *impl_data);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*
1297c478bd9Sstevel@tonic-gate  * Clustering: Return the global devices path base, or
1307c478bd9Sstevel@tonic-gate  * the entire global devices path prefix.
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate const char *
1337c478bd9Sstevel@tonic-gate i_ddi_get_dpath_base();
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate const char *
1367c478bd9Sstevel@tonic-gate i_ddi_get_dpath_prefix();
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  * Search and return properties from the PROM
1407c478bd9Sstevel@tonic-gate  */
1417c478bd9Sstevel@tonic-gate int
1427c478bd9Sstevel@tonic-gate impl_ddi_bus_prop_op(dev_t dev, dev_info_t *dip,
1437c478bd9Sstevel@tonic-gate 	dev_info_t *ch_dip, ddi_prop_op_t prop_op, int mod_flags,
1447c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * Copy an integer from PROM to native machine representation
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate int
1507c478bd9Sstevel@tonic-gate impl_ddi_prop_int_from_prom(uchar_t *intp, int n);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate extern int impl_ddi_sunbus_initchild(dev_info_t *);
1547c478bd9Sstevel@tonic-gate extern void impl_ddi_sunbus_removechild(dev_info_t *);
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate /*
1577c478bd9Sstevel@tonic-gate  * Implementation specific access handle allocator and init. routines
1587c478bd9Sstevel@tonic-gate  */
1597c478bd9Sstevel@tonic-gate extern ddi_acc_handle_t impl_acc_hdl_alloc(int (*waitfp)(caddr_t),
1607c478bd9Sstevel@tonic-gate 	caddr_t arg);
1617c478bd9Sstevel@tonic-gate extern void impl_acc_hdl_free(ddi_acc_handle_t handle);
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate extern ddi_acc_hdl_t *impl_acc_hdl_get(ddi_acc_handle_t handle);
1647c478bd9Sstevel@tonic-gate extern void impl_acc_hdl_init(ddi_acc_hdl_t *hp);
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /* access error handling support */
1677c478bd9Sstevel@tonic-gate extern void impl_acc_err_init(ddi_acc_hdl_t *);
1687c478bd9Sstevel@tonic-gate extern int i_ddi_ontrap(ddi_acc_handle_t);
1697c478bd9Sstevel@tonic-gate extern void i_ddi_notrap(ddi_acc_handle_t);
1707c478bd9Sstevel@tonic-gate extern int i_ddi_prot_trampoline();
1717c478bd9Sstevel@tonic-gate extern int i_ddi_caut_trampoline();
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate /*
1747c478bd9Sstevel@tonic-gate  * misc/bootdev entry points - these are private routines and subject
1757c478bd9Sstevel@tonic-gate  * to change.
1767c478bd9Sstevel@tonic-gate  */
1777c478bd9Sstevel@tonic-gate extern int
1787c478bd9Sstevel@tonic-gate i_devname_to_promname(char *dev_name, char *ret_buf, size_t);
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate extern int
1817c478bd9Sstevel@tonic-gate i_promname_to_devname(char *prom_name, char *ret_buf);
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate extern char *
1847c478bd9Sstevel@tonic-gate i_convert_boot_device_name(char *, char *, size_t *);
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate /*
1877c478bd9Sstevel@tonic-gate  * Nodeid management ...
1887c478bd9Sstevel@tonic-gate  */
1897c478bd9Sstevel@tonic-gate void impl_ddi_init_nodeid(void);
1907c478bd9Sstevel@tonic-gate int impl_ddi_alloc_nodeid(int *nodeid);
1917c478bd9Sstevel@tonic-gate int impl_ddi_take_nodeid(int nodeid, int kmflag);
1927c478bd9Sstevel@tonic-gate void impl_ddi_free_nodeid(int nodeid);
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  * minorname/devtspectype conversions
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate extern char *
1987c478bd9Sstevel@tonic-gate i_ddi_devtspectype_to_minorname(dev_info_t *dip, dev_t dev, int spec_type);
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate extern int
2017c478bd9Sstevel@tonic-gate i_ddi_minorname_to_devtspectype(dev_info_t *dip, char *minor_name,
2027c478bd9Sstevel@tonic-gate 	dev_t *devp, int *spectypep);
2037c478bd9Sstevel@tonic-gate 
204*737d277aScth /*
205*737d277aScth  * Routines in ddi_v9_asm.s
206*737d277aScth  */
207*737d277aScth extern int do_peek(size_t, void *, void *);
208*737d277aScth extern int do_poke(size_t, void *, void *);
209*737d277aScth extern void peek_fault(void);
210*737d277aScth extern void poke_fault(void);
211*737d277aScth extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *);
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate /*
2147c478bd9Sstevel@tonic-gate  * Helper functions
2157c478bd9Sstevel@tonic-gate  */
2167c478bd9Sstevel@tonic-gate char *i_ddi_strdup(char *, uint_t);
2177c478bd9Sstevel@tonic-gate void i_ddi_prop_list_delete(ddi_prop_t *);
2187c478bd9Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t);
2197c478bd9Sstevel@tonic-gate int i_ddi_load_drvconf(major_t);
2207c478bd9Sstevel@tonic-gate int i_ddi_unload_drvconf(major_t);
2217c478bd9Sstevel@tonic-gate ddi_node_state_t i_ddi_node_state(dev_info_t *);
222*737d277aScth int i_ddi_devi_attached(dev_info_t *);
2237c478bd9Sstevel@tonic-gate void i_ddi_parse_name(char *, char **, char **, char **);
2247c478bd9Sstevel@tonic-gate void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t);
2257c478bd9Sstevel@tonic-gate int i_ddi_detach_installed_driver(major_t, int);
2267c478bd9Sstevel@tonic-gate void i_ddi_set_binding_name(dev_info_t *, char *);
2277c478bd9Sstevel@tonic-gate void i_ddi_bind_devs();
2287c478bd9Sstevel@tonic-gate void i_ddi_unbind_devs(major_t);
2297c478bd9Sstevel@tonic-gate ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *);
2307c478bd9Sstevel@tonic-gate struct devnames;
2317c478bd9Sstevel@tonic-gate void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *);
2327c478bd9Sstevel@tonic-gate void i_ddi_prop_list_rele(ddi_prop_list_t *, struct devnames *);
2337c478bd9Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_search(dev_t, char *, uint_t, ddi_prop_t **);
2347c478bd9Sstevel@tonic-gate int resolve_pathname(char *, dev_info_t **, dev_t *, int *);
2357c478bd9Sstevel@tonic-gate int i_ddi_prompath_to_devfspath(char *, char *);
2367c478bd9Sstevel@tonic-gate int i_ddi_attach_node_hierarchy(dev_info_t *);
2377c478bd9Sstevel@tonic-gate dev_info_t *i_ddi_attach_pseudo_node(char *);
2387c478bd9Sstevel@tonic-gate int i_ddi_attach_hw_nodes(char *);
2397c478bd9Sstevel@tonic-gate int i_ddi_devs_attached(major_t);
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate /* non-DDI functions: wrapper around mod_hold/rele_dev_by_major() */
2427c478bd9Sstevel@tonic-gate struct dev_ops *ddi_hold_driver(major_t);
2437c478bd9Sstevel@tonic-gate void ddi_rele_driver(major_t);
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate /*
2467c478bd9Sstevel@tonic-gate  * devid cache
2477c478bd9Sstevel@tonic-gate  */
2487c478bd9Sstevel@tonic-gate void i_ddi_devices_init(void);
2497c478bd9Sstevel@tonic-gate void i_ddi_read_devices_files(void);
2503c34adc5Sramat void i_ddi_clean_devices_files(void);
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate int i_ddi_devi_get_devid(dev_t, dev_info_t *, ddi_devid_t *);
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate int e_ddi_devid_discovery(ddi_devid_t);
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate int e_devid_cache_register(dev_info_t *, ddi_devid_t);
2577c478bd9Sstevel@tonic-gate void e_devid_cache_unregister(dev_info_t *);
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate int e_devid_cache_to_devt_list(ddi_devid_t, char *, int *, dev_t **);
2607c478bd9Sstevel@tonic-gate void e_devid_cache_free_devt_list(int, dev_t *);
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate /*
2637c478bd9Sstevel@tonic-gate  * Resource control functions to lock down device memory.
2647c478bd9Sstevel@tonic-gate  */
2657c478bd9Sstevel@tonic-gate extern int i_ddi_incr_locked_memory(proc_t *, task_t *, kproject_t *,
2667c478bd9Sstevel@tonic-gate 	zone_t *, rctl_qty_t);
2677c478bd9Sstevel@tonic-gate extern void i_ddi_decr_locked_memory(proc_t *, task_t *, kproject_t *,
2687c478bd9Sstevel@tonic-gate 	zone_t *, rctl_qty_t);
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate #endif
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate #endif	/* _SYS_DDI_IMPLFUNCS_H */
277