xref: /onnv-gate/usr/src/uts/common/sys/ddi_implfuncs.h (revision 1900:7657500f392a)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51865Sdilpreet  * Common Development and Distribution License (the "License").
61865Sdilpreet  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*1900Seota 
220Sstevel@tonic-gate /*
231333Scth  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _SYS_DDI_IMPLFUNCS_H
280Sstevel@tonic-gate #define	_SYS_DDI_IMPLFUNCS_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <sys/obpdefs.h>
370Sstevel@tonic-gate #include <sys/vnode.h>
380Sstevel@tonic-gate #include <sys/types.h>
390Sstevel@tonic-gate #include <sys/task.h>
400Sstevel@tonic-gate #include <sys/project.h>
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifdef	_KERNEL
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * Declare implementation functions that sunddi functions can
460Sstevel@tonic-gate  * call in order to perform their required task. Each kernel
470Sstevel@tonic-gate  * architecture must provide them.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate 
500Sstevel@tonic-gate int
510Sstevel@tonic-gate i_ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
520Sstevel@tonic-gate 	off_t offset, off_t len, caddr_t *vaddrp);
530Sstevel@tonic-gate 
540Sstevel@tonic-gate int
550Sstevel@tonic-gate i_ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp);
560Sstevel@tonic-gate 
570Sstevel@tonic-gate struct regspec *
580Sstevel@tonic-gate i_ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber);
590Sstevel@tonic-gate 
600Sstevel@tonic-gate 
610Sstevel@tonic-gate int
620Sstevel@tonic-gate i_ddi_map_fault(dev_info_t *dip, dev_info_t *rdip,
630Sstevel@tonic-gate 	struct hat *hat, struct seg *seg, caddr_t addr,
640Sstevel@tonic-gate 	struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
650Sstevel@tonic-gate 
660Sstevel@tonic-gate ddi_regspec_t
670Sstevel@tonic-gate i_ddi_get_regspec(dev_info_t *dip, dev_info_t *rdip, uint_t rnumber,
680Sstevel@tonic-gate 	off_t offset, off_t len);
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  * Implementation specific memory allocation and de-allocation routines.
720Sstevel@tonic-gate  */
730Sstevel@tonic-gate int
740Sstevel@tonic-gate i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attributes,
750Sstevel@tonic-gate 	size_t length, int cansleep, int streaming,
760Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
770Sstevel@tonic-gate 	size_t *real_length, ddi_acc_hdl_t *handlep);
780Sstevel@tonic-gate 
790Sstevel@tonic-gate int
800Sstevel@tonic-gate i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits,
810Sstevel@tonic-gate 	size_t length, int cansleep, int streaming,
820Sstevel@tonic-gate 	ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
830Sstevel@tonic-gate 	uint_t *real_length, ddi_acc_hdl_t *handlep);
840Sstevel@tonic-gate 
850Sstevel@tonic-gate void
86*1900Seota i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap);
870Sstevel@tonic-gate 
880Sstevel@tonic-gate int
890Sstevel@tonic-gate i_ddi_devi_get_ppa(dev_info_t *dip);
900Sstevel@tonic-gate 
910Sstevel@tonic-gate void
920Sstevel@tonic-gate i_ddi_devi_set_ppa(dev_info_t *dip, int ppa);
930Sstevel@tonic-gate 
94*1900Seota boolean_t
95*1900Seota i_ddi_check_endian_attr(ddi_device_acc_attr_t *devaccp);
96*1900Seota 
97*1900Seota void
98*1900Seota i_ddi_devacc_to_hatacc(ddi_device_acc_attr_t *devaccp, uint_t *hataccp);
99*1900Seota 
100*1900Seota void
101*1900Seota i_ddi_cacheattr_to_hatacc(uint_t flags, uint_t *hataccp);
102*1900Seota 
103*1900Seota boolean_t
104*1900Seota i_ddi_check_cache_attr(uint_t flags);
105*1900Seota 
1060Sstevel@tonic-gate /*
1070Sstevel@tonic-gate  * Access and DMA handle fault set/clear routines
1080Sstevel@tonic-gate  */
1090Sstevel@tonic-gate void
1100Sstevel@tonic-gate i_ddi_acc_set_fault(ddi_acc_handle_t handle);
1110Sstevel@tonic-gate void
1120Sstevel@tonic-gate i_ddi_acc_clr_fault(ddi_acc_handle_t handle);
1130Sstevel@tonic-gate void
1140Sstevel@tonic-gate i_ddi_dma_set_fault(ddi_dma_handle_t handle);
1150Sstevel@tonic-gate void
1160Sstevel@tonic-gate i_ddi_dma_clr_fault(ddi_dma_handle_t handle);
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate /*
1190Sstevel@tonic-gate  *      Event-handling functions for rootnex
1200Sstevel@tonic-gate  *      These provide the standard implementation of fault handling
1210Sstevel@tonic-gate  */
1220Sstevel@tonic-gate void
1230Sstevel@tonic-gate i_ddi_rootnex_init_events(dev_info_t *dip);
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate int
1260Sstevel@tonic-gate i_ddi_rootnex_get_eventcookie(dev_info_t *dip, dev_info_t *rdip,
1270Sstevel@tonic-gate 	char *eventname, ddi_eventcookie_t *cookiep);
1280Sstevel@tonic-gate int
1290Sstevel@tonic-gate i_ddi_rootnex_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
1300Sstevel@tonic-gate 	ddi_eventcookie_t eventid, void (*handler)(dev_info_t *dip,
1310Sstevel@tonic-gate 	ddi_eventcookie_t event, void *arg, void *impl_data), void *arg,
1320Sstevel@tonic-gate 	ddi_callback_id_t *cb_id);
1330Sstevel@tonic-gate int
1340Sstevel@tonic-gate i_ddi_rootnex_remove_eventcall(dev_info_t *devi, ddi_callback_id_t cb_id);
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate int
1370Sstevel@tonic-gate i_ddi_rootnex_post_event(dev_info_t *dip, dev_info_t *rdip,
1380Sstevel@tonic-gate 	ddi_eventcookie_t eventid, void *impl_data);
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate /*
1410Sstevel@tonic-gate  * Clustering: Return the global devices path base, or
1420Sstevel@tonic-gate  * the entire global devices path prefix.
1430Sstevel@tonic-gate  */
1440Sstevel@tonic-gate const char *
1450Sstevel@tonic-gate i_ddi_get_dpath_base();
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate const char *
1480Sstevel@tonic-gate i_ddi_get_dpath_prefix();
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate /*
1510Sstevel@tonic-gate  * Search and return properties from the PROM
1520Sstevel@tonic-gate  */
1530Sstevel@tonic-gate int
1540Sstevel@tonic-gate impl_ddi_bus_prop_op(dev_t dev, dev_info_t *dip,
1550Sstevel@tonic-gate 	dev_info_t *ch_dip, ddi_prop_op_t prop_op, int mod_flags,
1560Sstevel@tonic-gate 	char *name, caddr_t valuep, int *lengthp);
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate /*
1590Sstevel@tonic-gate  * Copy an integer from PROM to native machine representation
1600Sstevel@tonic-gate  */
1610Sstevel@tonic-gate int
1620Sstevel@tonic-gate impl_ddi_prop_int_from_prom(uchar_t *intp, int n);
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate extern int impl_ddi_sunbus_initchild(dev_info_t *);
1660Sstevel@tonic-gate extern void impl_ddi_sunbus_removechild(dev_info_t *);
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate /*
1690Sstevel@tonic-gate  * Implementation specific access handle allocator and init. routines
1700Sstevel@tonic-gate  */
1710Sstevel@tonic-gate extern ddi_acc_handle_t impl_acc_hdl_alloc(int (*waitfp)(caddr_t),
1720Sstevel@tonic-gate 	caddr_t arg);
1730Sstevel@tonic-gate extern void impl_acc_hdl_free(ddi_acc_handle_t handle);
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate extern ddi_acc_hdl_t *impl_acc_hdl_get(ddi_acc_handle_t handle);
1760Sstevel@tonic-gate extern void impl_acc_hdl_init(ddi_acc_hdl_t *hp);
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /* access error handling support */
1790Sstevel@tonic-gate extern void impl_acc_err_init(ddi_acc_hdl_t *);
1801865Sdilpreet extern int impl_dma_check(dev_info_t *, const void *, const void *,
1811865Sdilpreet     const void *);
1820Sstevel@tonic-gate extern int i_ddi_ontrap(ddi_acc_handle_t);
1830Sstevel@tonic-gate extern void i_ddi_notrap(ddi_acc_handle_t);
1840Sstevel@tonic-gate extern int i_ddi_prot_trampoline();
1850Sstevel@tonic-gate extern int i_ddi_caut_trampoline();
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate /*
1880Sstevel@tonic-gate  * misc/bootdev entry points - these are private routines and subject
1890Sstevel@tonic-gate  * to change.
1900Sstevel@tonic-gate  */
1910Sstevel@tonic-gate extern int
1920Sstevel@tonic-gate i_devname_to_promname(char *dev_name, char *ret_buf, size_t);
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate extern int
1950Sstevel@tonic-gate i_promname_to_devname(char *prom_name, char *ret_buf);
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate extern char *
1980Sstevel@tonic-gate i_convert_boot_device_name(char *, char *, size_t *);
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate /*
2010Sstevel@tonic-gate  * Nodeid management ...
2020Sstevel@tonic-gate  */
2030Sstevel@tonic-gate void impl_ddi_init_nodeid(void);
2040Sstevel@tonic-gate int impl_ddi_alloc_nodeid(int *nodeid);
2050Sstevel@tonic-gate int impl_ddi_take_nodeid(int nodeid, int kmflag);
2060Sstevel@tonic-gate void impl_ddi_free_nodeid(int nodeid);
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate /*
2090Sstevel@tonic-gate  * minorname/devtspectype conversions
2100Sstevel@tonic-gate  */
2110Sstevel@tonic-gate extern char *
2120Sstevel@tonic-gate i_ddi_devtspectype_to_minorname(dev_info_t *dip, dev_t dev, int spec_type);
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate extern int
2150Sstevel@tonic-gate i_ddi_minorname_to_devtspectype(dev_info_t *dip, char *minor_name,
2160Sstevel@tonic-gate 	dev_t *devp, int *spectypep);
2170Sstevel@tonic-gate 
2181333Scth /*
2191333Scth  * Routines in ddi_v9_asm.s
2201333Scth  */
2211333Scth extern int do_peek(size_t, void *, void *);
2221333Scth extern int do_poke(size_t, void *, void *);
2231333Scth extern void peek_fault(void);
2241333Scth extern void poke_fault(void);
2251333Scth extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *);
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate /*
2280Sstevel@tonic-gate  * Helper functions
2290Sstevel@tonic-gate  */
2300Sstevel@tonic-gate char *i_ddi_strdup(char *, uint_t);
2310Sstevel@tonic-gate void i_ddi_prop_list_delete(ddi_prop_t *);
2320Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t);
2330Sstevel@tonic-gate int i_ddi_load_drvconf(major_t);
2340Sstevel@tonic-gate int i_ddi_unload_drvconf(major_t);
2350Sstevel@tonic-gate ddi_node_state_t i_ddi_node_state(dev_info_t *);
2361333Scth int i_ddi_devi_attached(dev_info_t *);
2370Sstevel@tonic-gate void i_ddi_parse_name(char *, char **, char **, char **);
2380Sstevel@tonic-gate void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t);
2390Sstevel@tonic-gate int i_ddi_detach_installed_driver(major_t, int);
2400Sstevel@tonic-gate void i_ddi_set_binding_name(dev_info_t *, char *);
2410Sstevel@tonic-gate void i_ddi_bind_devs();
2420Sstevel@tonic-gate void i_ddi_unbind_devs(major_t);
2430Sstevel@tonic-gate ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *);
2440Sstevel@tonic-gate struct devnames;
2450Sstevel@tonic-gate void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *);
2460Sstevel@tonic-gate void i_ddi_prop_list_rele(ddi_prop_list_t *, struct devnames *);
2470Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_search(dev_t, char *, uint_t, ddi_prop_t **);
2480Sstevel@tonic-gate int resolve_pathname(char *, dev_info_t **, dev_t *, int *);
2490Sstevel@tonic-gate int i_ddi_prompath_to_devfspath(char *, char *);
2500Sstevel@tonic-gate int i_ddi_attach_node_hierarchy(dev_info_t *);
2510Sstevel@tonic-gate dev_info_t *i_ddi_attach_pseudo_node(char *);
2520Sstevel@tonic-gate int i_ddi_attach_hw_nodes(char *);
2530Sstevel@tonic-gate int i_ddi_devs_attached(major_t);
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate /* non-DDI functions: wrapper around mod_hold/rele_dev_by_major() */
2560Sstevel@tonic-gate struct dev_ops *ddi_hold_driver(major_t);
2570Sstevel@tonic-gate void ddi_rele_driver(major_t);
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate /*
2600Sstevel@tonic-gate  * devid cache
2610Sstevel@tonic-gate  */
2620Sstevel@tonic-gate void i_ddi_devices_init(void);
2630Sstevel@tonic-gate void i_ddi_read_devices_files(void);
264878Sramat void i_ddi_clean_devices_files(void);
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate int i_ddi_devi_get_devid(dev_t, dev_info_t *, ddi_devid_t *);
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate int e_ddi_devid_discovery(ddi_devid_t);
2690Sstevel@tonic-gate 
2700Sstevel@tonic-gate int e_devid_cache_register(dev_info_t *, ddi_devid_t);
2710Sstevel@tonic-gate void e_devid_cache_unregister(dev_info_t *);
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate int e_devid_cache_to_devt_list(ddi_devid_t, char *, int *, dev_t **);
2740Sstevel@tonic-gate void e_devid_cache_free_devt_list(int, dev_t *);
2750Sstevel@tonic-gate 
2760Sstevel@tonic-gate /*
2770Sstevel@tonic-gate  * Resource control functions to lock down device memory.
2780Sstevel@tonic-gate  */
2790Sstevel@tonic-gate extern int i_ddi_incr_locked_memory(proc_t *, task_t *, kproject_t *,
2800Sstevel@tonic-gate 	zone_t *, rctl_qty_t);
2810Sstevel@tonic-gate extern void i_ddi_decr_locked_memory(proc_t *, task_t *, kproject_t *,
2820Sstevel@tonic-gate 	zone_t *, rctl_qty_t);
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate #endif	/* _KERNEL */
2850Sstevel@tonic-gate 
2860Sstevel@tonic-gate #ifdef	__cplusplus
2870Sstevel@tonic-gate }
2880Sstevel@tonic-gate #endif
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate #endif	/* _SYS_DDI_IMPLFUNCS_H */
291