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 */ 211900Seota 220Sstevel@tonic-gate /* 23*4845Svikram * Copyright 2007 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 861900Seota 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 941900Seota void 951900Seota i_ddi_devacc_to_hatacc(ddi_device_acc_attr_t *devaccp, uint_t *hataccp); 961900Seota 971900Seota void 981900Seota i_ddi_cacheattr_to_hatacc(uint_t flags, uint_t *hataccp); 991900Seota 1001900Seota boolean_t 1011900Seota i_ddi_check_cache_attr(uint_t flags); 1021900Seota 1030Sstevel@tonic-gate /* 1040Sstevel@tonic-gate * Access and DMA handle fault set/clear routines 1050Sstevel@tonic-gate */ 1060Sstevel@tonic-gate void 1070Sstevel@tonic-gate i_ddi_acc_set_fault(ddi_acc_handle_t handle); 1080Sstevel@tonic-gate void 1090Sstevel@tonic-gate i_ddi_acc_clr_fault(ddi_acc_handle_t handle); 1100Sstevel@tonic-gate void 1110Sstevel@tonic-gate i_ddi_dma_set_fault(ddi_dma_handle_t handle); 1120Sstevel@tonic-gate void 1130Sstevel@tonic-gate i_ddi_dma_clr_fault(ddi_dma_handle_t handle); 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* 1160Sstevel@tonic-gate * Event-handling functions for rootnex 1170Sstevel@tonic-gate * These provide the standard implementation of fault handling 1180Sstevel@tonic-gate */ 1190Sstevel@tonic-gate void 1200Sstevel@tonic-gate i_ddi_rootnex_init_events(dev_info_t *dip); 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate int 1230Sstevel@tonic-gate i_ddi_rootnex_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, 1240Sstevel@tonic-gate char *eventname, ddi_eventcookie_t *cookiep); 1250Sstevel@tonic-gate int 1260Sstevel@tonic-gate i_ddi_rootnex_add_eventcall(dev_info_t *dip, dev_info_t *rdip, 1270Sstevel@tonic-gate ddi_eventcookie_t eventid, void (*handler)(dev_info_t *dip, 1280Sstevel@tonic-gate ddi_eventcookie_t event, void *arg, void *impl_data), void *arg, 1290Sstevel@tonic-gate ddi_callback_id_t *cb_id); 1300Sstevel@tonic-gate int 1310Sstevel@tonic-gate i_ddi_rootnex_remove_eventcall(dev_info_t *devi, ddi_callback_id_t cb_id); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate int 1340Sstevel@tonic-gate i_ddi_rootnex_post_event(dev_info_t *dip, dev_info_t *rdip, 1350Sstevel@tonic-gate ddi_eventcookie_t eventid, void *impl_data); 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* 1380Sstevel@tonic-gate * Clustering: Return the global devices path base, or 1390Sstevel@tonic-gate * the entire global devices path prefix. 1400Sstevel@tonic-gate */ 1410Sstevel@tonic-gate const char * 1420Sstevel@tonic-gate i_ddi_get_dpath_base(); 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate const char * 1450Sstevel@tonic-gate i_ddi_get_dpath_prefix(); 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* 1480Sstevel@tonic-gate * Search and return properties from the PROM 1490Sstevel@tonic-gate */ 1500Sstevel@tonic-gate int 1510Sstevel@tonic-gate impl_ddi_bus_prop_op(dev_t dev, dev_info_t *dip, 1520Sstevel@tonic-gate dev_info_t *ch_dip, ddi_prop_op_t prop_op, int mod_flags, 1530Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate /* 1560Sstevel@tonic-gate * Copy an integer from PROM to native machine representation 1570Sstevel@tonic-gate */ 1580Sstevel@tonic-gate int 1590Sstevel@tonic-gate impl_ddi_prop_int_from_prom(uchar_t *intp, int n); 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate extern int impl_ddi_sunbus_initchild(dev_info_t *); 1630Sstevel@tonic-gate extern void impl_ddi_sunbus_removechild(dev_info_t *); 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate /* 1660Sstevel@tonic-gate * Implementation specific access handle allocator and init. routines 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate extern ddi_acc_handle_t impl_acc_hdl_alloc(int (*waitfp)(caddr_t), 1690Sstevel@tonic-gate caddr_t arg); 1700Sstevel@tonic-gate extern void impl_acc_hdl_free(ddi_acc_handle_t handle); 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate extern ddi_acc_hdl_t *impl_acc_hdl_get(ddi_acc_handle_t handle); 1730Sstevel@tonic-gate extern void impl_acc_hdl_init(ddi_acc_hdl_t *hp); 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate /* access error handling support */ 1760Sstevel@tonic-gate extern void impl_acc_err_init(ddi_acc_hdl_t *); 1771865Sdilpreet extern int impl_dma_check(dev_info_t *, const void *, const void *, 1781865Sdilpreet const void *); 1790Sstevel@tonic-gate extern int i_ddi_ontrap(ddi_acc_handle_t); 1800Sstevel@tonic-gate extern void i_ddi_notrap(ddi_acc_handle_t); 1810Sstevel@tonic-gate extern int i_ddi_prot_trampoline(); 1820Sstevel@tonic-gate extern int i_ddi_caut_trampoline(); 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate /* 1850Sstevel@tonic-gate * misc/bootdev entry points - these are private routines and subject 1860Sstevel@tonic-gate * to change. 1870Sstevel@tonic-gate */ 1880Sstevel@tonic-gate extern int 1890Sstevel@tonic-gate i_devname_to_promname(char *dev_name, char *ret_buf, size_t); 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate extern int 1920Sstevel@tonic-gate i_promname_to_devname(char *prom_name, char *ret_buf); 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate extern char * 1950Sstevel@tonic-gate i_convert_boot_device_name(char *, char *, size_t *); 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate /* 1980Sstevel@tonic-gate * Nodeid management ... 1990Sstevel@tonic-gate */ 2000Sstevel@tonic-gate void impl_ddi_init_nodeid(void); 2010Sstevel@tonic-gate int impl_ddi_alloc_nodeid(int *nodeid); 2020Sstevel@tonic-gate int impl_ddi_take_nodeid(int nodeid, int kmflag); 2030Sstevel@tonic-gate void impl_ddi_free_nodeid(int nodeid); 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate /* 2060Sstevel@tonic-gate * minorname/devtspectype conversions 2070Sstevel@tonic-gate */ 2080Sstevel@tonic-gate extern char * 2090Sstevel@tonic-gate i_ddi_devtspectype_to_minorname(dev_info_t *dip, dev_t dev, int spec_type); 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate extern int 2120Sstevel@tonic-gate i_ddi_minorname_to_devtspectype(dev_info_t *dip, char *minor_name, 2130Sstevel@tonic-gate dev_t *devp, int *spectypep); 2140Sstevel@tonic-gate 2151333Scth /* 2161333Scth * Routines in ddi_v9_asm.s 2171333Scth */ 2181333Scth extern int do_peek(size_t, void *, void *); 2191333Scth extern int do_poke(size_t, void *, void *); 2201333Scth extern void peek_fault(void); 2211333Scth extern void poke_fault(void); 2221333Scth extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *); 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate /* 2250Sstevel@tonic-gate * Helper functions 2260Sstevel@tonic-gate */ 2270Sstevel@tonic-gate char *i_ddi_strdup(char *, uint_t); 2280Sstevel@tonic-gate void i_ddi_prop_list_delete(ddi_prop_t *); 2290Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t); 2300Sstevel@tonic-gate int i_ddi_load_drvconf(major_t); 2310Sstevel@tonic-gate int i_ddi_unload_drvconf(major_t); 2320Sstevel@tonic-gate ddi_node_state_t i_ddi_node_state(dev_info_t *); 2331333Scth int i_ddi_devi_attached(dev_info_t *); 2340Sstevel@tonic-gate void i_ddi_parse_name(char *, char **, char **, char **); 2350Sstevel@tonic-gate void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t); 2360Sstevel@tonic-gate int i_ddi_detach_installed_driver(major_t, int); 2370Sstevel@tonic-gate void i_ddi_set_binding_name(dev_info_t *, char *); 2380Sstevel@tonic-gate void i_ddi_bind_devs(); 2390Sstevel@tonic-gate void i_ddi_unbind_devs(major_t); 2400Sstevel@tonic-gate ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *); 2410Sstevel@tonic-gate struct devnames; 2420Sstevel@tonic-gate void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *); 2430Sstevel@tonic-gate void i_ddi_prop_list_rele(ddi_prop_list_t *, struct devnames *); 2440Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_search(dev_t, char *, uint_t, ddi_prop_t **); 2450Sstevel@tonic-gate int resolve_pathname(char *, dev_info_t **, dev_t *, int *); 2460Sstevel@tonic-gate int i_ddi_prompath_to_devfspath(char *, char *); 2470Sstevel@tonic-gate int i_ddi_attach_node_hierarchy(dev_info_t *); 2480Sstevel@tonic-gate dev_info_t *i_ddi_attach_pseudo_node(char *); 2490Sstevel@tonic-gate int i_ddi_attach_hw_nodes(char *); 2500Sstevel@tonic-gate int i_ddi_devs_attached(major_t); 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate /* non-DDI functions: wrapper around mod_hold/rele_dev_by_major() */ 2530Sstevel@tonic-gate struct dev_ops *ddi_hold_driver(major_t); 2540Sstevel@tonic-gate void ddi_rele_driver(major_t); 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate /* 2572797Sjg * /etc/devices cache files management 2580Sstevel@tonic-gate */ 2590Sstevel@tonic-gate void i_ddi_devices_init(void); 2600Sstevel@tonic-gate void i_ddi_read_devices_files(void); 261878Sramat void i_ddi_clean_devices_files(void); 2620Sstevel@tonic-gate 2632797Sjg /* 2642797Sjg * devid cache 2652797Sjg */ 2662797Sjg void devid_cache_init(void); 2672797Sjg void devid_cache_read(void); 2682797Sjg void devid_cache_cleanup(void); 2690Sstevel@tonic-gate int i_ddi_devi_get_devid(dev_t, dev_info_t *, ddi_devid_t *); 2700Sstevel@tonic-gate int e_ddi_devid_discovery(ddi_devid_t); 2710Sstevel@tonic-gate int e_devid_cache_register(dev_info_t *, ddi_devid_t); 2720Sstevel@tonic-gate void e_devid_cache_unregister(dev_info_t *); 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 /* 277*4845Svikram * I/O retire persistent store 278*4845Svikram */ 279*4845Svikram void retire_store_init(void); 280*4845Svikram void retire_store_read(void); 281*4845Svikram int e_ddi_retire_persist(char *devpath); 282*4845Svikram int e_ddi_retire_unpersist(char *devpath); 283*4845Svikram int e_ddi_device_retired(char *devpath); 284*4845Svikram 285*4845Svikram /* 2860Sstevel@tonic-gate * Resource control functions to lock down device memory. 2870Sstevel@tonic-gate */ 2882768Ssl108498 extern int i_ddi_incr_locked_memory(proc_t *, rctl_qty_t); 2892768Ssl108498 extern void i_ddi_decr_locked_memory(proc_t *, rctl_qty_t); 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate #endif /* _KERNEL */ 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate #ifdef __cplusplus 2940Sstevel@tonic-gate } 2950Sstevel@tonic-gate #endif 2960Sstevel@tonic-gate 2970Sstevel@tonic-gate #endif /* _SYS_DDI_IMPLFUNCS_H */ 298