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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*1333Scth * 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 860Sstevel@tonic-gate i_ddi_mem_free(caddr_t kaddr, int streaming); 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 940Sstevel@tonic-gate /* 950Sstevel@tonic-gate * Access and DMA handle fault set/clear routines 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate void 980Sstevel@tonic-gate i_ddi_acc_set_fault(ddi_acc_handle_t handle); 990Sstevel@tonic-gate void 1000Sstevel@tonic-gate i_ddi_acc_clr_fault(ddi_acc_handle_t handle); 1010Sstevel@tonic-gate void 1020Sstevel@tonic-gate i_ddi_dma_set_fault(ddi_dma_handle_t handle); 1030Sstevel@tonic-gate void 1040Sstevel@tonic-gate i_ddi_dma_clr_fault(ddi_dma_handle_t handle); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate /* 1070Sstevel@tonic-gate * Event-handling functions for rootnex 1080Sstevel@tonic-gate * These provide the standard implementation of fault handling 1090Sstevel@tonic-gate */ 1100Sstevel@tonic-gate void 1110Sstevel@tonic-gate i_ddi_rootnex_init_events(dev_info_t *dip); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate int 1140Sstevel@tonic-gate i_ddi_rootnex_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, 1150Sstevel@tonic-gate char *eventname, ddi_eventcookie_t *cookiep); 1160Sstevel@tonic-gate int 1170Sstevel@tonic-gate i_ddi_rootnex_add_eventcall(dev_info_t *dip, dev_info_t *rdip, 1180Sstevel@tonic-gate ddi_eventcookie_t eventid, void (*handler)(dev_info_t *dip, 1190Sstevel@tonic-gate ddi_eventcookie_t event, void *arg, void *impl_data), void *arg, 1200Sstevel@tonic-gate ddi_callback_id_t *cb_id); 1210Sstevel@tonic-gate int 1220Sstevel@tonic-gate i_ddi_rootnex_remove_eventcall(dev_info_t *devi, ddi_callback_id_t cb_id); 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate int 1250Sstevel@tonic-gate i_ddi_rootnex_post_event(dev_info_t *dip, dev_info_t *rdip, 1260Sstevel@tonic-gate ddi_eventcookie_t eventid, void *impl_data); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate /* 1290Sstevel@tonic-gate * Clustering: Return the global devices path base, or 1300Sstevel@tonic-gate * the entire global devices path prefix. 1310Sstevel@tonic-gate */ 1320Sstevel@tonic-gate const char * 1330Sstevel@tonic-gate i_ddi_get_dpath_base(); 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate const char * 1360Sstevel@tonic-gate i_ddi_get_dpath_prefix(); 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate /* 1390Sstevel@tonic-gate * Search and return properties from the PROM 1400Sstevel@tonic-gate */ 1410Sstevel@tonic-gate int 1420Sstevel@tonic-gate impl_ddi_bus_prop_op(dev_t dev, dev_info_t *dip, 1430Sstevel@tonic-gate dev_info_t *ch_dip, ddi_prop_op_t prop_op, int mod_flags, 1440Sstevel@tonic-gate char *name, caddr_t valuep, int *lengthp); 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate /* 1470Sstevel@tonic-gate * Copy an integer from PROM to native machine representation 1480Sstevel@tonic-gate */ 1490Sstevel@tonic-gate int 1500Sstevel@tonic-gate impl_ddi_prop_int_from_prom(uchar_t *intp, int n); 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate extern int impl_ddi_sunbus_initchild(dev_info_t *); 1540Sstevel@tonic-gate extern void impl_ddi_sunbus_removechild(dev_info_t *); 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate /* 1570Sstevel@tonic-gate * Implementation specific access handle allocator and init. routines 1580Sstevel@tonic-gate */ 1590Sstevel@tonic-gate extern ddi_acc_handle_t impl_acc_hdl_alloc(int (*waitfp)(caddr_t), 1600Sstevel@tonic-gate caddr_t arg); 1610Sstevel@tonic-gate extern void impl_acc_hdl_free(ddi_acc_handle_t handle); 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate extern ddi_acc_hdl_t *impl_acc_hdl_get(ddi_acc_handle_t handle); 1640Sstevel@tonic-gate extern void impl_acc_hdl_init(ddi_acc_hdl_t *hp); 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate /* access error handling support */ 1670Sstevel@tonic-gate extern void impl_acc_err_init(ddi_acc_hdl_t *); 1680Sstevel@tonic-gate extern int i_ddi_ontrap(ddi_acc_handle_t); 1690Sstevel@tonic-gate extern void i_ddi_notrap(ddi_acc_handle_t); 1700Sstevel@tonic-gate extern int i_ddi_prot_trampoline(); 1710Sstevel@tonic-gate extern int i_ddi_caut_trampoline(); 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate /* 1740Sstevel@tonic-gate * misc/bootdev entry points - these are private routines and subject 1750Sstevel@tonic-gate * to change. 1760Sstevel@tonic-gate */ 1770Sstevel@tonic-gate extern int 1780Sstevel@tonic-gate i_devname_to_promname(char *dev_name, char *ret_buf, size_t); 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate extern int 1810Sstevel@tonic-gate i_promname_to_devname(char *prom_name, char *ret_buf); 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate extern char * 1840Sstevel@tonic-gate i_convert_boot_device_name(char *, char *, size_t *); 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate /* 1870Sstevel@tonic-gate * Nodeid management ... 1880Sstevel@tonic-gate */ 1890Sstevel@tonic-gate void impl_ddi_init_nodeid(void); 1900Sstevel@tonic-gate int impl_ddi_alloc_nodeid(int *nodeid); 1910Sstevel@tonic-gate int impl_ddi_take_nodeid(int nodeid, int kmflag); 1920Sstevel@tonic-gate void impl_ddi_free_nodeid(int nodeid); 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate /* 1950Sstevel@tonic-gate * minorname/devtspectype conversions 1960Sstevel@tonic-gate */ 1970Sstevel@tonic-gate extern char * 1980Sstevel@tonic-gate i_ddi_devtspectype_to_minorname(dev_info_t *dip, dev_t dev, int spec_type); 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate extern int 2010Sstevel@tonic-gate i_ddi_minorname_to_devtspectype(dev_info_t *dip, char *minor_name, 2020Sstevel@tonic-gate dev_t *devp, int *spectypep); 2030Sstevel@tonic-gate 204*1333Scth /* 205*1333Scth * Routines in ddi_v9_asm.s 206*1333Scth */ 207*1333Scth extern int do_peek(size_t, void *, void *); 208*1333Scth extern int do_poke(size_t, void *, void *); 209*1333Scth extern void peek_fault(void); 210*1333Scth extern void poke_fault(void); 211*1333Scth extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *); 2120Sstevel@tonic-gate 2130Sstevel@tonic-gate /* 2140Sstevel@tonic-gate * Helper functions 2150Sstevel@tonic-gate */ 2160Sstevel@tonic-gate char *i_ddi_strdup(char *, uint_t); 2170Sstevel@tonic-gate void i_ddi_prop_list_delete(ddi_prop_t *); 2180Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t); 2190Sstevel@tonic-gate int i_ddi_load_drvconf(major_t); 2200Sstevel@tonic-gate int i_ddi_unload_drvconf(major_t); 2210Sstevel@tonic-gate ddi_node_state_t i_ddi_node_state(dev_info_t *); 222*1333Scth int i_ddi_devi_attached(dev_info_t *); 2230Sstevel@tonic-gate void i_ddi_parse_name(char *, char **, char **, char **); 2240Sstevel@tonic-gate void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t); 2250Sstevel@tonic-gate int i_ddi_detach_installed_driver(major_t, int); 2260Sstevel@tonic-gate void i_ddi_set_binding_name(dev_info_t *, char *); 2270Sstevel@tonic-gate void i_ddi_bind_devs(); 2280Sstevel@tonic-gate void i_ddi_unbind_devs(major_t); 2290Sstevel@tonic-gate ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *); 2300Sstevel@tonic-gate struct devnames; 2310Sstevel@tonic-gate void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *); 2320Sstevel@tonic-gate void i_ddi_prop_list_rele(ddi_prop_list_t *, struct devnames *); 2330Sstevel@tonic-gate ddi_prop_t *i_ddi_prop_search(dev_t, char *, uint_t, ddi_prop_t **); 2340Sstevel@tonic-gate int resolve_pathname(char *, dev_info_t **, dev_t *, int *); 2350Sstevel@tonic-gate int i_ddi_prompath_to_devfspath(char *, char *); 2360Sstevel@tonic-gate int i_ddi_attach_node_hierarchy(dev_info_t *); 2370Sstevel@tonic-gate dev_info_t *i_ddi_attach_pseudo_node(char *); 2380Sstevel@tonic-gate int i_ddi_attach_hw_nodes(char *); 2390Sstevel@tonic-gate int i_ddi_devs_attached(major_t); 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate /* non-DDI functions: wrapper around mod_hold/rele_dev_by_major() */ 2420Sstevel@tonic-gate struct dev_ops *ddi_hold_driver(major_t); 2430Sstevel@tonic-gate void ddi_rele_driver(major_t); 2440Sstevel@tonic-gate 2450Sstevel@tonic-gate /* 2460Sstevel@tonic-gate * devid cache 2470Sstevel@tonic-gate */ 2480Sstevel@tonic-gate void i_ddi_devices_init(void); 2490Sstevel@tonic-gate void i_ddi_read_devices_files(void); 250878Sramat void i_ddi_clean_devices_files(void); 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate int i_ddi_devi_get_devid(dev_t, dev_info_t *, ddi_devid_t *); 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate int e_ddi_devid_discovery(ddi_devid_t); 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate int e_devid_cache_register(dev_info_t *, ddi_devid_t); 2570Sstevel@tonic-gate void e_devid_cache_unregister(dev_info_t *); 2580Sstevel@tonic-gate 2590Sstevel@tonic-gate int e_devid_cache_to_devt_list(ddi_devid_t, char *, int *, dev_t **); 2600Sstevel@tonic-gate void e_devid_cache_free_devt_list(int, dev_t *); 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate /* 2630Sstevel@tonic-gate * Resource control functions to lock down device memory. 2640Sstevel@tonic-gate */ 2650Sstevel@tonic-gate extern int i_ddi_incr_locked_memory(proc_t *, task_t *, kproject_t *, 2660Sstevel@tonic-gate zone_t *, rctl_qty_t); 2670Sstevel@tonic-gate extern void i_ddi_decr_locked_memory(proc_t *, task_t *, kproject_t *, 2680Sstevel@tonic-gate zone_t *, rctl_qty_t); 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate #endif /* _KERNEL */ 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate #ifdef __cplusplus 2730Sstevel@tonic-gate } 2740Sstevel@tonic-gate #endif 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate #endif /* _SYS_DDI_IMPLFUNCS_H */ 277