xref: /titanic_51/usr/src/uts/common/sys/ddi_implfuncs.h (revision cd21e7c548ae2a3b5e522244bf798f2a6b4ba02d)
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
500d0963fSdilpreet  * Common Development and Distribution License (the "License").
600d0963fSdilpreet  * 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  */
217b93957cSeota 
227c478bd9Sstevel@tonic-gate /*
23fc256490SJason Beloro  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
26*cd21e7c5SGarrett D'Amore /*
27*cd21e7c5SGarrett D'Amore  * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
28*cd21e7c5SGarrett D'Amore  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef _SYS_DDI_IMPLFUNCS_H
317c478bd9Sstevel@tonic-gate #define	_SYS_DDI_IMPLFUNCS_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h>
387c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
397c478bd9Sstevel@tonic-gate #include <sys/types.h>
407c478bd9Sstevel@tonic-gate #include <sys/task.h>
417c478bd9Sstevel@tonic-gate #include <sys/project.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Declare implementation functions that sunddi functions can
477c478bd9Sstevel@tonic-gate  * call in order to perform their required task. Each kernel
487c478bd9Sstevel@tonic-gate  * architecture must provide them.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate int
527c478bd9Sstevel@tonic-gate i_ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
537c478bd9Sstevel@tonic-gate 	off_t offset, off_t len, caddr_t *vaddrp);
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate int
567c478bd9Sstevel@tonic-gate i_ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate struct regspec *
597c478bd9Sstevel@tonic-gate i_ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate int
637c478bd9Sstevel@tonic-gate i_ddi_map_fault(dev_info_t *dip, dev_info_t *rdip,
647c478bd9Sstevel@tonic-gate 	struct hat *hat, struct seg *seg, caddr_t addr,
657c478bd9Sstevel@tonic-gate 	struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate ddi_regspec_t
687c478bd9Sstevel@tonic-gate i_ddi_get_regspec(dev_info_t *dip, dev_info_t *rdip, uint_t rnumber,
697c478bd9Sstevel@tonic-gate 	off_t offset, off_t len);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * Implementation specific memory allocation and de-allocation routines.
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate int
757c478bd9Sstevel@tonic-gate i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attributes,
767c478bd9Sstevel@tonic-gate 	size_t length, int cansleep, int streaming,
777c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
787c478bd9Sstevel@tonic-gate 	size_t *real_length, ddi_acc_hdl_t *handlep);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate void
817b93957cSeota i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap);
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate int
847c478bd9Sstevel@tonic-gate i_ddi_devi_get_ppa(dev_info_t *dip);
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate void
877c478bd9Sstevel@tonic-gate i_ddi_devi_set_ppa(dev_info_t *dip, int ppa);
887c478bd9Sstevel@tonic-gate 
897b93957cSeota void
907b93957cSeota i_ddi_devacc_to_hatacc(ddi_device_acc_attr_t *devaccp, uint_t *hataccp);
917b93957cSeota 
927b93957cSeota void
937b93957cSeota i_ddi_cacheattr_to_hatacc(uint_t flags, uint_t *hataccp);
947b93957cSeota 
957b93957cSeota boolean_t
967b93957cSeota i_ddi_check_cache_attr(uint_t flags);
977b93957cSeota 
987c478bd9Sstevel@tonic-gate /*
997c478bd9Sstevel@tonic-gate  * Access and DMA handle fault set/clear routines
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate void
1027c478bd9Sstevel@tonic-gate i_ddi_acc_set_fault(ddi_acc_handle_t handle);
1037c478bd9Sstevel@tonic-gate void
1047c478bd9Sstevel@tonic-gate i_ddi_acc_clr_fault(ddi_acc_handle_t handle);
1057c478bd9Sstevel@tonic-gate void
1067c478bd9Sstevel@tonic-gate i_ddi_dma_set_fault(ddi_dma_handle_t handle);
1077c478bd9Sstevel@tonic-gate void
1087c478bd9Sstevel@tonic-gate i_ddi_dma_clr_fault(ddi_dma_handle_t handle);
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  *      Event-handling functions for rootnex
1127c478bd9Sstevel@tonic-gate  *      These provide the standard implementation of fault handling
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate void
1157c478bd9Sstevel@tonic-gate i_ddi_rootnex_init_events(dev_info_t *dip);
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate int
1187c478bd9Sstevel@tonic-gate i_ddi_rootnex_get_eventcookie(dev_info_t *dip, dev_info_t *rdip,
1197c478bd9Sstevel@tonic-gate 	char *eventname, ddi_eventcookie_t *cookiep);
1207c478bd9Sstevel@tonic-gate int
1217c478bd9Sstevel@tonic-gate i_ddi_rootnex_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
1227c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t eventid, void (*handler)(dev_info_t *dip,
1237c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t event, void *arg, void *impl_data), void *arg,
1247c478bd9Sstevel@tonic-gate 	ddi_callback_id_t *cb_id);
1257c478bd9Sstevel@tonic-gate int
1267c478bd9Sstevel@tonic-gate i_ddi_rootnex_remove_eventcall(dev_info_t *devi, ddi_callback_id_t cb_id);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate int
1297c478bd9Sstevel@tonic-gate i_ddi_rootnex_post_event(dev_info_t *dip, dev_info_t *rdip,
1307c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t eventid, void *impl_data);
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  * Clustering: Return the global devices path base, or
1347c478bd9Sstevel@tonic-gate  * the entire global devices path prefix.
1357c478bd9Sstevel@tonic-gate  */
1367c478bd9Sstevel@tonic-gate const char *
1377c478bd9Sstevel@tonic-gate i_ddi_get_dpath_base();
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate const char *
1407c478bd9Sstevel@tonic-gate i_ddi_get_dpath_prefix();
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate /*
1437c478bd9Sstevel@tonic-gate  * Search and return properties from the PROM
1447c478bd9Sstevel@tonic-gate  */
1457c478bd9Sstevel@tonic-gate int
1467c478bd9Sstevel@tonic-gate impl_ddi_bus_prop_op(dev_t dev, dev_info_t *dip,
1477c478bd9Sstevel@tonic-gate 	dev_info_t *ch_dip, ddi_prop_op_t prop_op, int mod_flags,
1487c478bd9Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate /*
1517c478bd9Sstevel@tonic-gate  * Copy an integer from PROM to native machine representation
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate int
1547c478bd9Sstevel@tonic-gate impl_ddi_prop_int_from_prom(uchar_t *intp, int n);
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate extern int impl_ddi_sunbus_initchild(dev_info_t *);
1587c478bd9Sstevel@tonic-gate extern void impl_ddi_sunbus_removechild(dev_info_t *);
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate /*
1617c478bd9Sstevel@tonic-gate  * Implementation specific access handle allocator and init. routines
1627c478bd9Sstevel@tonic-gate  */
1637c478bd9Sstevel@tonic-gate extern ddi_acc_handle_t impl_acc_hdl_alloc(int (*waitfp)(caddr_t),
1647c478bd9Sstevel@tonic-gate 	caddr_t arg);
1657c478bd9Sstevel@tonic-gate extern void impl_acc_hdl_free(ddi_acc_handle_t handle);
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate extern ddi_acc_hdl_t *impl_acc_hdl_get(ddi_acc_handle_t handle);
1687c478bd9Sstevel@tonic-gate extern void impl_acc_hdl_init(ddi_acc_hdl_t *hp);
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate /* access error handling support */
1717c478bd9Sstevel@tonic-gate extern void impl_acc_err_init(ddi_acc_hdl_t *);
17200d0963fSdilpreet extern int impl_dma_check(dev_info_t *, const void *, const void *,
17300d0963fSdilpreet     const void *);
1747c478bd9Sstevel@tonic-gate extern int i_ddi_ontrap(ddi_acc_handle_t);
1757c478bd9Sstevel@tonic-gate extern void i_ddi_notrap(ddi_acc_handle_t);
1767c478bd9Sstevel@tonic-gate extern int i_ddi_prot_trampoline();
1777c478bd9Sstevel@tonic-gate extern int i_ddi_caut_trampoline();
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate /*
1807c478bd9Sstevel@tonic-gate  * misc/bootdev entry points - these are private routines and subject
1817c478bd9Sstevel@tonic-gate  * to change.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate extern int
1847c478bd9Sstevel@tonic-gate i_devname_to_promname(char *dev_name, char *ret_buf, size_t);
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate extern int
1877c478bd9Sstevel@tonic-gate i_promname_to_devname(char *prom_name, char *ret_buf);
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate extern char *
1907c478bd9Sstevel@tonic-gate i_convert_boot_device_name(char *, char *, size_t *);
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate /*
1937c478bd9Sstevel@tonic-gate  * Nodeid management ...
1947c478bd9Sstevel@tonic-gate  */
1957c478bd9Sstevel@tonic-gate void impl_ddi_init_nodeid(void);
1967c478bd9Sstevel@tonic-gate int impl_ddi_alloc_nodeid(int *nodeid);
1977c478bd9Sstevel@tonic-gate int impl_ddi_take_nodeid(int nodeid, int kmflag);
1987c478bd9Sstevel@tonic-gate void impl_ddi_free_nodeid(int nodeid);
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * minorname/devtspectype conversions
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate extern char *
2047c478bd9Sstevel@tonic-gate i_ddi_devtspectype_to_minorname(dev_info_t *dip, dev_t dev, int spec_type);
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate extern int
2077c478bd9Sstevel@tonic-gate i_ddi_minorname_to_devtspectype(dev_info_t *dip, char *minor_name,
2087c478bd9Sstevel@tonic-gate 	dev_t *devp, int *spectypep);
2097c478bd9Sstevel@tonic-gate 
210737d277aScth /*
211737d277aScth  * Routines in ddi_v9_asm.s
212737d277aScth  */
213737d277aScth extern int do_peek(size_t, void *, void *);
214737d277aScth extern int do_poke(size_t, void *, void *);
215737d277aScth extern void peek_fault(void);
216737d277aScth extern void poke_fault(void);
217737d277aScth extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *);
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate /*
2207c478bd9Sstevel@tonic-gate  * Helper functions
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate char *i_ddi_strdup(char *, uint_t);
2237c478bd9Sstevel@tonic-gate void i_ddi_prop_list_delete(ddi_prop_t *);
2247c478bd9Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t);
2257c478bd9Sstevel@tonic-gate int i_ddi_load_drvconf(major_t);
2267c478bd9Sstevel@tonic-gate int i_ddi_unload_drvconf(major_t);
2277c478bd9Sstevel@tonic-gate ddi_node_state_t i_ddi_node_state(dev_info_t *);
228737d277aScth int i_ddi_devi_attached(dev_info_t *);
2297c478bd9Sstevel@tonic-gate void i_ddi_parse_name(char *, char **, char **, char **);
2307c478bd9Sstevel@tonic-gate void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t);
2317c478bd9Sstevel@tonic-gate int i_ddi_detach_installed_driver(major_t, int);
2327c478bd9Sstevel@tonic-gate void i_ddi_set_binding_name(dev_info_t *, char *);
2337c478bd9Sstevel@tonic-gate void i_ddi_bind_devs();
2346532b960SJerry Gilliam int i_ddi_unbind_devs_by_alias(major_t, char *);
2357c478bd9Sstevel@tonic-gate void i_ddi_unbind_devs(major_t);
2367c478bd9Sstevel@tonic-gate ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *);
2377c478bd9Sstevel@tonic-gate struct devnames;
2387c478bd9Sstevel@tonic-gate void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *);
2397c478bd9Sstevel@tonic-gate void i_ddi_prop_list_rele(ddi_prop_list_t *, struct devnames *);
2407c478bd9Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_search(dev_t, char *, uint_t, ddi_prop_t **);
2417c478bd9Sstevel@tonic-gate int resolve_pathname(char *, dev_info_t **, dev_t *, int *);
2427c478bd9Sstevel@tonic-gate int i_ddi_prompath_to_devfspath(char *, char *);
2437c478bd9Sstevel@tonic-gate int i_ddi_attach_node_hierarchy(dev_info_t *);
2447c478bd9Sstevel@tonic-gate dev_info_t *i_ddi_attach_pseudo_node(char *);
2457c478bd9Sstevel@tonic-gate int i_ddi_attach_hw_nodes(char *);
2467c478bd9Sstevel@tonic-gate int i_ddi_devs_attached(major_t);
247d62bc4baSyz147064 int i_ddi_minor_node_count(dev_info_t *, const char *);
24820906b23SVikram Hegde int ddi_is_pci_dip(dev_info_t *dip);
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate /* non-DDI functions: wrapper around mod_hold/rele_dev_by_major() */
2517c478bd9Sstevel@tonic-gate struct dev_ops *ddi_hold_driver(major_t);
2527c478bd9Sstevel@tonic-gate void ddi_rele_driver(major_t);
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate /*
25583c4dfe9Sjg  * /etc/devices cache files management
2567c478bd9Sstevel@tonic-gate  */
2577c478bd9Sstevel@tonic-gate void i_ddi_devices_init(void);
2587c478bd9Sstevel@tonic-gate void i_ddi_read_devices_files(void);
2593c34adc5Sramat void i_ddi_clean_devices_files(void);
2607c478bd9Sstevel@tonic-gate 
26183c4dfe9Sjg /*
26283c4dfe9Sjg  * devid cache
26383c4dfe9Sjg  */
26483c4dfe9Sjg void devid_cache_init(void);
26583c4dfe9Sjg void devid_cache_read(void);
26683c4dfe9Sjg void devid_cache_cleanup(void);
2677c478bd9Sstevel@tonic-gate int i_ddi_devi_get_devid(dev_t, dev_info_t *, ddi_devid_t *);
2687c478bd9Sstevel@tonic-gate int e_ddi_devid_discovery(ddi_devid_t);
2697c478bd9Sstevel@tonic-gate int e_devid_cache_register(dev_info_t *, ddi_devid_t);
2707c478bd9Sstevel@tonic-gate void e_devid_cache_unregister(dev_info_t *);
2717c478bd9Sstevel@tonic-gate int e_devid_cache_to_devt_list(ddi_devid_t, char *, int *, dev_t **);
2727c478bd9Sstevel@tonic-gate void e_devid_cache_free_devt_list(int, dev_t *);
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate /*
27525e8c5aaSvikram  * I/O retire persistent store
27625e8c5aaSvikram  */
27725e8c5aaSvikram void retire_store_init(void);
27825e8c5aaSvikram void retire_store_read(void);
27925e8c5aaSvikram int e_ddi_retire_persist(char *devpath);
28025e8c5aaSvikram int e_ddi_retire_unpersist(char *devpath);
28125e8c5aaSvikram int e_ddi_device_retired(char *devpath);
28225e8c5aaSvikram 
28325e8c5aaSvikram /*
2847c478bd9Sstevel@tonic-gate  * Resource control functions to lock down device memory.
2857c478bd9Sstevel@tonic-gate  */
286c6939658Ssl108498 extern int i_ddi_incr_locked_memory(proc_t *, rctl_qty_t);
287c6939658Ssl108498 extern void i_ddi_decr_locked_memory(proc_t *, rctl_qty_t);
2887c478bd9Sstevel@tonic-gate 
289fc256490SJason Beloro /*
290fc256490SJason Beloro  * Direct I/O support functions
291fc256490SJason Beloro  */
292fc256490SJason Beloro extern void translate_devid(dev_info_t *dip);
293fc256490SJason Beloro 
2947c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2977c478bd9Sstevel@tonic-gate }
2987c478bd9Sstevel@tonic-gate #endif
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate #endif	/* _SYS_DDI_IMPLFUNCS_H */
301