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*11596SJason.Beloro@Sun.COM * Copyright 2010 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 #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <sys/obpdefs.h> 350Sstevel@tonic-gate #include <sys/vnode.h> 360Sstevel@tonic-gate #include <sys/types.h> 370Sstevel@tonic-gate #include <sys/task.h> 380Sstevel@tonic-gate #include <sys/project.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef _KERNEL 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * Declare implementation functions that sunddi functions can 440Sstevel@tonic-gate * call in order to perform their required task. Each kernel 450Sstevel@tonic-gate * architecture must provide them. 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate 480Sstevel@tonic-gate int 490Sstevel@tonic-gate i_ddi_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, 500Sstevel@tonic-gate off_t offset, off_t len, caddr_t *vaddrp); 510Sstevel@tonic-gate 520Sstevel@tonic-gate int 530Sstevel@tonic-gate i_ddi_apply_range(dev_info_t *dip, dev_info_t *rdip, struct regspec *rp); 540Sstevel@tonic-gate 550Sstevel@tonic-gate struct regspec * 560Sstevel@tonic-gate i_ddi_rnumber_to_regspec(dev_info_t *dip, int rnumber); 570Sstevel@tonic-gate 580Sstevel@tonic-gate 590Sstevel@tonic-gate int 600Sstevel@tonic-gate i_ddi_map_fault(dev_info_t *dip, dev_info_t *rdip, 610Sstevel@tonic-gate struct hat *hat, struct seg *seg, caddr_t addr, 620Sstevel@tonic-gate struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock); 630Sstevel@tonic-gate 640Sstevel@tonic-gate ddi_regspec_t 650Sstevel@tonic-gate i_ddi_get_regspec(dev_info_t *dip, dev_info_t *rdip, uint_t rnumber, 660Sstevel@tonic-gate off_t offset, off_t len); 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* 690Sstevel@tonic-gate * Implementation specific memory allocation and de-allocation routines. 700Sstevel@tonic-gate */ 710Sstevel@tonic-gate int 720Sstevel@tonic-gate i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attributes, 730Sstevel@tonic-gate size_t length, int cansleep, int streaming, 740Sstevel@tonic-gate ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, 750Sstevel@tonic-gate size_t *real_length, ddi_acc_hdl_t *handlep); 760Sstevel@tonic-gate 770Sstevel@tonic-gate int 780Sstevel@tonic-gate i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits, 790Sstevel@tonic-gate size_t length, int cansleep, int streaming, 800Sstevel@tonic-gate ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, 810Sstevel@tonic-gate uint_t *real_length, ddi_acc_hdl_t *handlep); 820Sstevel@tonic-gate 830Sstevel@tonic-gate void 841900Seota i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap); 850Sstevel@tonic-gate 860Sstevel@tonic-gate int 870Sstevel@tonic-gate i_ddi_devi_get_ppa(dev_info_t *dip); 880Sstevel@tonic-gate 890Sstevel@tonic-gate void 900Sstevel@tonic-gate i_ddi_devi_set_ppa(dev_info_t *dip, int ppa); 910Sstevel@tonic-gate 921900Seota void 931900Seota i_ddi_devacc_to_hatacc(ddi_device_acc_attr_t *devaccp, uint_t *hataccp); 941900Seota 951900Seota void 961900Seota i_ddi_cacheattr_to_hatacc(uint_t flags, uint_t *hataccp); 971900Seota 981900Seota boolean_t 991900Seota i_ddi_check_cache_attr(uint_t flags); 1001900Seota 1010Sstevel@tonic-gate /* 1020Sstevel@tonic-gate * Access and DMA handle fault set/clear routines 1030Sstevel@tonic-gate */ 1040Sstevel@tonic-gate void 1050Sstevel@tonic-gate i_ddi_acc_set_fault(ddi_acc_handle_t handle); 1060Sstevel@tonic-gate void 1070Sstevel@tonic-gate i_ddi_acc_clr_fault(ddi_acc_handle_t handle); 1080Sstevel@tonic-gate void 1090Sstevel@tonic-gate i_ddi_dma_set_fault(ddi_dma_handle_t handle); 1100Sstevel@tonic-gate void 1110Sstevel@tonic-gate i_ddi_dma_clr_fault(ddi_dma_handle_t handle); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* 1140Sstevel@tonic-gate * Event-handling functions for rootnex 1150Sstevel@tonic-gate * These provide the standard implementation of fault handling 1160Sstevel@tonic-gate */ 1170Sstevel@tonic-gate void 1180Sstevel@tonic-gate i_ddi_rootnex_init_events(dev_info_t *dip); 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate int 1210Sstevel@tonic-gate i_ddi_rootnex_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, 1220Sstevel@tonic-gate char *eventname, ddi_eventcookie_t *cookiep); 1230Sstevel@tonic-gate int 1240Sstevel@tonic-gate i_ddi_rootnex_add_eventcall(dev_info_t *dip, dev_info_t *rdip, 1250Sstevel@tonic-gate ddi_eventcookie_t eventid, void (*handler)(dev_info_t *dip, 1260Sstevel@tonic-gate ddi_eventcookie_t event, void *arg, void *impl_data), void *arg, 1270Sstevel@tonic-gate ddi_callback_id_t *cb_id); 1280Sstevel@tonic-gate int 1290Sstevel@tonic-gate i_ddi_rootnex_remove_eventcall(dev_info_t *devi, ddi_callback_id_t cb_id); 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate int 1320Sstevel@tonic-gate i_ddi_rootnex_post_event(dev_info_t *dip, dev_info_t *rdip, 1330Sstevel@tonic-gate ddi_eventcookie_t eventid, void *impl_data); 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* 1360Sstevel@tonic-gate * Clustering: Return the global devices path base, or 1370Sstevel@tonic-gate * the entire global devices path prefix. 1380Sstevel@tonic-gate */ 1390Sstevel@tonic-gate const char * 1400Sstevel@tonic-gate i_ddi_get_dpath_base(); 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate const char * 1430Sstevel@tonic-gate i_ddi_get_dpath_prefix(); 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* 1460Sstevel@tonic-gate * Search and return properties from the PROM 1470Sstevel@tonic-gate */ 1480Sstevel@tonic-gate int 1490Sstevel@tonic-gate impl_ddi_bus_prop_op(dev_t dev, dev_info_t *dip, 1500Sstevel@tonic-gate dev_info_t *ch_dip, ddi_prop_op_t prop_op, int mod_flags, 1510Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate /* 1540Sstevel@tonic-gate * Copy an integer from PROM to native machine representation 1550Sstevel@tonic-gate */ 1560Sstevel@tonic-gate int 1570Sstevel@tonic-gate impl_ddi_prop_int_from_prom(uchar_t *intp, int n); 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate extern int impl_ddi_sunbus_initchild(dev_info_t *); 1610Sstevel@tonic-gate extern void impl_ddi_sunbus_removechild(dev_info_t *); 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* 1640Sstevel@tonic-gate * Implementation specific access handle allocator and init. routines 1650Sstevel@tonic-gate */ 1660Sstevel@tonic-gate extern ddi_acc_handle_t impl_acc_hdl_alloc(int (*waitfp)(caddr_t), 1670Sstevel@tonic-gate caddr_t arg); 1680Sstevel@tonic-gate extern void impl_acc_hdl_free(ddi_acc_handle_t handle); 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate extern ddi_acc_hdl_t *impl_acc_hdl_get(ddi_acc_handle_t handle); 1710Sstevel@tonic-gate extern void impl_acc_hdl_init(ddi_acc_hdl_t *hp); 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate /* access error handling support */ 1740Sstevel@tonic-gate extern void impl_acc_err_init(ddi_acc_hdl_t *); 1751865Sdilpreet extern int impl_dma_check(dev_info_t *, const void *, const void *, 1761865Sdilpreet const void *); 1770Sstevel@tonic-gate extern int i_ddi_ontrap(ddi_acc_handle_t); 1780Sstevel@tonic-gate extern void i_ddi_notrap(ddi_acc_handle_t); 1790Sstevel@tonic-gate extern int i_ddi_prot_trampoline(); 1800Sstevel@tonic-gate extern int i_ddi_caut_trampoline(); 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate /* 1830Sstevel@tonic-gate * misc/bootdev entry points - these are private routines and subject 1840Sstevel@tonic-gate * to change. 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate extern int 1870Sstevel@tonic-gate i_devname_to_promname(char *dev_name, char *ret_buf, size_t); 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate extern int 1900Sstevel@tonic-gate i_promname_to_devname(char *prom_name, char *ret_buf); 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate extern char * 1930Sstevel@tonic-gate i_convert_boot_device_name(char *, char *, size_t *); 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate /* 1960Sstevel@tonic-gate * Nodeid management ... 1970Sstevel@tonic-gate */ 1980Sstevel@tonic-gate void impl_ddi_init_nodeid(void); 1990Sstevel@tonic-gate int impl_ddi_alloc_nodeid(int *nodeid); 2000Sstevel@tonic-gate int impl_ddi_take_nodeid(int nodeid, int kmflag); 2010Sstevel@tonic-gate void impl_ddi_free_nodeid(int nodeid); 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate /* 2040Sstevel@tonic-gate * minorname/devtspectype conversions 2050Sstevel@tonic-gate */ 2060Sstevel@tonic-gate extern char * 2070Sstevel@tonic-gate i_ddi_devtspectype_to_minorname(dev_info_t *dip, dev_t dev, int spec_type); 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate extern int 2100Sstevel@tonic-gate i_ddi_minorname_to_devtspectype(dev_info_t *dip, char *minor_name, 2110Sstevel@tonic-gate dev_t *devp, int *spectypep); 2120Sstevel@tonic-gate 2131333Scth /* 2141333Scth * Routines in ddi_v9_asm.s 2151333Scth */ 2161333Scth extern int do_peek(size_t, void *, void *); 2171333Scth extern int do_poke(size_t, void *, void *); 2181333Scth extern void peek_fault(void); 2191333Scth extern void poke_fault(void); 2201333Scth extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *); 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate /* 2230Sstevel@tonic-gate * Helper functions 2240Sstevel@tonic-gate */ 2250Sstevel@tonic-gate char *i_ddi_strdup(char *, uint_t); 2260Sstevel@tonic-gate void i_ddi_prop_list_delete(ddi_prop_t *); 2270Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t); 2280Sstevel@tonic-gate int i_ddi_load_drvconf(major_t); 2290Sstevel@tonic-gate int i_ddi_unload_drvconf(major_t); 2300Sstevel@tonic-gate ddi_node_state_t i_ddi_node_state(dev_info_t *); 2311333Scth int i_ddi_devi_attached(dev_info_t *); 2320Sstevel@tonic-gate void i_ddi_parse_name(char *, char **, char **, char **); 2330Sstevel@tonic-gate void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t); 2340Sstevel@tonic-gate int i_ddi_detach_installed_driver(major_t, int); 2350Sstevel@tonic-gate void i_ddi_set_binding_name(dev_info_t *, char *); 2360Sstevel@tonic-gate void i_ddi_bind_devs(); 2378831SJerry.Gilliam@Sun.COM int i_ddi_unbind_devs_by_alias(major_t, char *); 2380Sstevel@tonic-gate void i_ddi_unbind_devs(major_t); 2390Sstevel@tonic-gate ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *); 2400Sstevel@tonic-gate struct devnames; 2410Sstevel@tonic-gate void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *); 2420Sstevel@tonic-gate void i_ddi_prop_list_rele(ddi_prop_list_t *, struct devnames *); 2430Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_search(dev_t, char *, uint_t, ddi_prop_t **); 2440Sstevel@tonic-gate int resolve_pathname(char *, dev_info_t **, dev_t *, int *); 2450Sstevel@tonic-gate int i_ddi_prompath_to_devfspath(char *, char *); 2460Sstevel@tonic-gate int i_ddi_attach_node_hierarchy(dev_info_t *); 2470Sstevel@tonic-gate dev_info_t *i_ddi_attach_pseudo_node(char *); 2480Sstevel@tonic-gate int i_ddi_attach_hw_nodes(char *); 2490Sstevel@tonic-gate int i_ddi_devs_attached(major_t); 2505895Syz147064 int i_ddi_minor_node_count(dev_info_t *, const char *); 2517613SVikram.Hegde@Sun.COM int ddi_is_pci_dip(dev_info_t *dip); 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate /* non-DDI functions: wrapper around mod_hold/rele_dev_by_major() */ 2540Sstevel@tonic-gate struct dev_ops *ddi_hold_driver(major_t); 2550Sstevel@tonic-gate void ddi_rele_driver(major_t); 2560Sstevel@tonic-gate 2570Sstevel@tonic-gate /* 2582797Sjg * /etc/devices cache files management 2590Sstevel@tonic-gate */ 2600Sstevel@tonic-gate void i_ddi_devices_init(void); 2610Sstevel@tonic-gate void i_ddi_read_devices_files(void); 262878Sramat void i_ddi_clean_devices_files(void); 2630Sstevel@tonic-gate 2642797Sjg /* 2652797Sjg * devid cache 2662797Sjg */ 2672797Sjg void devid_cache_init(void); 2682797Sjg void devid_cache_read(void); 2692797Sjg void devid_cache_cleanup(void); 2700Sstevel@tonic-gate int i_ddi_devi_get_devid(dev_t, dev_info_t *, ddi_devid_t *); 2710Sstevel@tonic-gate int e_ddi_devid_discovery(ddi_devid_t); 2720Sstevel@tonic-gate int e_devid_cache_register(dev_info_t *, ddi_devid_t); 2730Sstevel@tonic-gate void e_devid_cache_unregister(dev_info_t *); 2740Sstevel@tonic-gate int e_devid_cache_to_devt_list(ddi_devid_t, char *, int *, dev_t **); 2750Sstevel@tonic-gate void e_devid_cache_free_devt_list(int, dev_t *); 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate /* 2784845Svikram * I/O retire persistent store 2794845Svikram */ 2804845Svikram void retire_store_init(void); 2814845Svikram void retire_store_read(void); 2824845Svikram int e_ddi_retire_persist(char *devpath); 2834845Svikram int e_ddi_retire_unpersist(char *devpath); 2844845Svikram int e_ddi_device_retired(char *devpath); 2854845Svikram 2864845Svikram /* 2870Sstevel@tonic-gate * Resource control functions to lock down device memory. 2880Sstevel@tonic-gate */ 2892768Ssl108498 extern int i_ddi_incr_locked_memory(proc_t *, rctl_qty_t); 2902768Ssl108498 extern void i_ddi_decr_locked_memory(proc_t *, rctl_qty_t); 2910Sstevel@tonic-gate 292*11596SJason.Beloro@Sun.COM /* 293*11596SJason.Beloro@Sun.COM * Direct I/O support functions 294*11596SJason.Beloro@Sun.COM */ 295*11596SJason.Beloro@Sun.COM extern void translate_devid(dev_info_t *dip); 296*11596SJason.Beloro@Sun.COM 2970Sstevel@tonic-gate #endif /* _KERNEL */ 2980Sstevel@tonic-gate 2990Sstevel@tonic-gate #ifdef __cplusplus 3000Sstevel@tonic-gate } 3010Sstevel@tonic-gate #endif 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate #endif /* _SYS_DDI_IMPLFUNCS_H */ 304