xref: /onnv-gate/usr/src/uts/intel/sys/iommulib.h (revision 13050:515b1e9bea30)
17613SVikram.Hegde@Sun.COM /*
27613SVikram.Hegde@Sun.COM  * CDDL HEADER START
37613SVikram.Hegde@Sun.COM  *
47613SVikram.Hegde@Sun.COM  * The contents of this file are subject to the terms of the
57613SVikram.Hegde@Sun.COM  * Common Development and Distribution License (the "License").
67613SVikram.Hegde@Sun.COM  * You may not use this file except in compliance with the License.
77613SVikram.Hegde@Sun.COM  *
87613SVikram.Hegde@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97613SVikram.Hegde@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107613SVikram.Hegde@Sun.COM  * See the License for the specific language governing permissions
117613SVikram.Hegde@Sun.COM  * and limitations under the License.
127613SVikram.Hegde@Sun.COM  *
137613SVikram.Hegde@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147613SVikram.Hegde@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157613SVikram.Hegde@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167613SVikram.Hegde@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177613SVikram.Hegde@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187613SVikram.Hegde@Sun.COM  *
197613SVikram.Hegde@Sun.COM  * CDDL HEADER END
207613SVikram.Hegde@Sun.COM  */
217613SVikram.Hegde@Sun.COM /*
22*13050Sfrank.van.der.linden@oracle.com  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
237613SVikram.Hegde@Sun.COM  */
247613SVikram.Hegde@Sun.COM 
257613SVikram.Hegde@Sun.COM #ifndef	_SYS_IOMMULIB_H
267613SVikram.Hegde@Sun.COM #define	_SYS_IOMMULIB_H
277613SVikram.Hegde@Sun.COM 
287613SVikram.Hegde@Sun.COM #pragma ident	"@(#)iommulib.h	1.3	08/08/31 SMI"
297613SVikram.Hegde@Sun.COM 
307613SVikram.Hegde@Sun.COM #ifdef	__cplusplus
317613SVikram.Hegde@Sun.COM extern "C" {
327613SVikram.Hegde@Sun.COM #endif
337613SVikram.Hegde@Sun.COM 
347613SVikram.Hegde@Sun.COM #include <sys/ddi_impldefs.h>
358371SVikram.Hegde@Sun.COM #include <sys/smbios.h>
367613SVikram.Hegde@Sun.COM 
377613SVikram.Hegde@Sun.COM #ifdef	_KERNEL
387613SVikram.Hegde@Sun.COM 
397613SVikram.Hegde@Sun.COM typedef enum {
407613SVikram.Hegde@Sun.COM 	INVALID_VENDOR = 0,
417613SVikram.Hegde@Sun.COM 	AMD_IOMMU,
427613SVikram.Hegde@Sun.COM 	INTEL_IOMMU
437613SVikram.Hegde@Sun.COM } iommulib_vendor_t;
447613SVikram.Hegde@Sun.COM 
457613SVikram.Hegde@Sun.COM typedef enum {
467613SVikram.Hegde@Sun.COM 	IOMMU_OPS_VERSION_INVALID = 0,
47*13050Sfrank.van.der.linden@oracle.com 	IOMMU_OPS_VERSION_1 = 1,
48*13050Sfrank.van.der.linden@oracle.com 	IOMMU_OPS_VERSION_2 = 2
497613SVikram.Hegde@Sun.COM } iommulib_opsversion_t;
507613SVikram.Hegde@Sun.COM 
51*13050Sfrank.van.der.linden@oracle.com #define	IOMMU_OPS_VERSION IOMMU_OPS_VERSION_2
527613SVikram.Hegde@Sun.COM 
537613SVikram.Hegde@Sun.COM typedef struct iommulib_ops {
547613SVikram.Hegde@Sun.COM 	iommulib_opsversion_t	ilops_vers;
557613SVikram.Hegde@Sun.COM 	iommulib_vendor_t	ilops_vendor;
567613SVikram.Hegde@Sun.COM 	char			*ilops_id;
577613SVikram.Hegde@Sun.COM 	void			*ilops_data;
587613SVikram.Hegde@Sun.COM 
598215SVikram.Hegde@Sun.COM 	int	(*ilops_probe)(iommulib_handle_t handle, dev_info_t *rdip);
607613SVikram.Hegde@Sun.COM 
617613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_allochdl)(iommulib_handle_t handle,
627613SVikram.Hegde@Sun.COM 	    dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
637613SVikram.Hegde@Sun.COM 	    int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *dma_handlep);
647613SVikram.Hegde@Sun.COM 
657613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_freehdl)(iommulib_handle_t handle,
667613SVikram.Hegde@Sun.COM 	    dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle);
677613SVikram.Hegde@Sun.COM 
687613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_bindhdl)(iommulib_handle_t handle, dev_info_t *dip,
697613SVikram.Hegde@Sun.COM 	    dev_info_t *rdip, ddi_dma_handle_t dma_handle,
707613SVikram.Hegde@Sun.COM 	    struct ddi_dma_req *dmareq, ddi_dma_cookie_t *cookiep,
717613SVikram.Hegde@Sun.COM 	    uint_t *ccountp);
727613SVikram.Hegde@Sun.COM 
737613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_unbindhdl)(iommulib_handle_t handle,
747613SVikram.Hegde@Sun.COM 	    dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle);
757613SVikram.Hegde@Sun.COM 
767613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_sync)(iommulib_handle_t handle, dev_info_t *dip,
777613SVikram.Hegde@Sun.COM 	    dev_info_t *rdip, ddi_dma_handle_t dma_handle, off_t off,
787613SVikram.Hegde@Sun.COM 	    size_t len, uint_t cache_flags);
797613SVikram.Hegde@Sun.COM 
807613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_win)(iommulib_handle_t handle, dev_info_t *dip,
817613SVikram.Hegde@Sun.COM 	    dev_info_t *rdip, ddi_dma_handle_t dma_handle, uint_t win,
827613SVikram.Hegde@Sun.COM 	    off_t *offp, size_t *lenp, ddi_dma_cookie_t *cookiep,
837613SVikram.Hegde@Sun.COM 	    uint_t *ccountp);
847613SVikram.Hegde@Sun.COM 
85*13050Sfrank.van.der.linden@oracle.com 	int	(*ilops_dma_mapobject)(iommulib_handle_t handle,
86*13050Sfrank.van.der.linden@oracle.com 	    dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle,
87*13050Sfrank.van.der.linden@oracle.com 	    struct ddi_dma_req *dmareq, ddi_dma_obj_t *dmao);
88*13050Sfrank.van.der.linden@oracle.com 
89*13050Sfrank.van.der.linden@oracle.com 	int	(*ilops_dma_unmapobject)(iommulib_handle_t handle,
90*13050Sfrank.van.der.linden@oracle.com 	    dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle,
91*13050Sfrank.van.der.linden@oracle.com 	    ddi_dma_obj_t *dmao);
927613SVikram.Hegde@Sun.COM 
937613SVikram.Hegde@Sun.COM 	/* Obsolete DMA routines */
947613SVikram.Hegde@Sun.COM 
957613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_map)(iommulib_handle_t handle, dev_info_t *dip,
967613SVikram.Hegde@Sun.COM 	    dev_info_t *rdip, struct ddi_dma_req *dmareq,
977613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t *dma_handle);
987613SVikram.Hegde@Sun.COM 
997613SVikram.Hegde@Sun.COM 	int	(*ilops_dma_mctl)(iommulib_handle_t handle, dev_info_t *dip,
1007613SVikram.Hegde@Sun.COM 	    dev_info_t *rdip, ddi_dma_handle_t dma_handle,
1017613SVikram.Hegde@Sun.COM 	    enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
1027613SVikram.Hegde@Sun.COM 	    caddr_t *objpp, uint_t cache_flags);
1037613SVikram.Hegde@Sun.COM 
1047613SVikram.Hegde@Sun.COM } iommulib_ops_t;
1057613SVikram.Hegde@Sun.COM 
106*13050Sfrank.van.der.linden@oracle.com /*
107*13050Sfrank.van.der.linden@oracle.com  * Fake pointer value to indicate that a device will not use an IOMMU
108*13050Sfrank.van.der.linden@oracle.com  * for DMA (it's either set up for passthrough or uses a unity mapping).
109*13050Sfrank.van.der.linden@oracle.com  */
110*13050Sfrank.van.der.linden@oracle.com #define	IOMMU_HANDLE_UNUSED	(void *)-1
11110007SVikram.Hegde@Sun.COM 
11210007SVikram.Hegde@Sun.COM /*
113*13050Sfrank.van.der.linden@oracle.com  * IOMMU_UNITIALIZED() is true if it has not been determined whether
114*13050Sfrank.van.der.linden@oracle.com  * a device uses an IOMMU for DMA or not. After it has been determined,
115*13050Sfrank.van.der.linden@oracle.com  * the USED and UNUSED macros may be used to see if an IOMMU is being
116*13050Sfrank.van.der.linden@oracle.com  * used or not.
117*13050Sfrank.van.der.linden@oracle.com  *
118*13050Sfrank.van.der.linden@oracle.com  * IOMMU_USED() is true if a device uses an IOMMU for DMA
119*13050Sfrank.van.der.linden@oracle.com  *
120*13050Sfrank.van.der.linden@oracle.com  * IOMMU_UNUSED() is true if a device does not use an IOMMU for DMA
12110007SVikram.Hegde@Sun.COM  */
122*13050Sfrank.van.der.linden@oracle.com #define	IOMMU_USED(dip) \
123*13050Sfrank.van.der.linden@oracle.com 	(DEVI(dip)->devi_iommulib_handle != NULL && \
124*13050Sfrank.van.der.linden@oracle.com 	DEVI(dip)->devi_iommulib_handle != IOMMU_HANDLE_UNUSED)
125*13050Sfrank.van.der.linden@oracle.com #define	IOMMU_UNUSED(dip) \
126*13050Sfrank.van.der.linden@oracle.com 	(DEVI(dip)->devi_iommulib_handle == IOMMU_HANDLE_UNUSED)
127*13050Sfrank.van.der.linden@oracle.com #define	IOMMU_UNITIALIZED(dip) \
128*13050Sfrank.van.der.linden@oracle.com 	(DEVI(dip)->devi_iommulib_handle == NULL)
1297613SVikram.Hegde@Sun.COM 
1307613SVikram.Hegde@Sun.COM typedef enum {
1317613SVikram.Hegde@Sun.COM 	IOMMU_NEXOPS_VERSION_INVALID = 0,
132*13050Sfrank.van.der.linden@oracle.com 	IOMMU_NEXOPS_VERSION_1 = 1,
133*13050Sfrank.van.der.linden@oracle.com 	IOMMU_NEXOPS_VERSION_2 = 2
1347613SVikram.Hegde@Sun.COM } iommulib_nexops_version_t;
1357613SVikram.Hegde@Sun.COM 
136*13050Sfrank.van.der.linden@oracle.com #define	IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_2
1377613SVikram.Hegde@Sun.COM 
1387613SVikram.Hegde@Sun.COM typedef struct iommulib_nexops {
1397613SVikram.Hegde@Sun.COM 	iommulib_nexops_version_t	nops_vers;
1407613SVikram.Hegde@Sun.COM 	char			*nops_id;
1417613SVikram.Hegde@Sun.COM 	void			*nops_data;
1427613SVikram.Hegde@Sun.COM 
1437613SVikram.Hegde@Sun.COM 	int (*nops_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip,
1447613SVikram.Hegde@Sun.COM 	    ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
1457613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t *handlep);
1467613SVikram.Hegde@Sun.COM 
1477613SVikram.Hegde@Sun.COM 	int (*nops_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip,
1487613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t handle);
1497613SVikram.Hegde@Sun.COM 
1507613SVikram.Hegde@Sun.COM 	int (*nops_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip,
1517613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
1527613SVikram.Hegde@Sun.COM 	    ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1537613SVikram.Hegde@Sun.COM 
1547613SVikram.Hegde@Sun.COM 	int (*nops_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip,
1557613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t handle);
1567613SVikram.Hegde@Sun.COM 
1577613SVikram.Hegde@Sun.COM 	void (*nops_dma_reset_cookies)(dev_info_t *dip,
1587613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t handle);
1597613SVikram.Hegde@Sun.COM 
1607613SVikram.Hegde@Sun.COM 	int (*nops_dma_get_cookies)(dev_info_t *dip, ddi_dma_handle_t handle,
1618215SVikram.Hegde@Sun.COM 	    ddi_dma_cookie_t **cookiepp, uint_t *ccountp);
1628215SVikram.Hegde@Sun.COM 
1638215SVikram.Hegde@Sun.COM 	int (*nops_dma_set_cookies)(dev_info_t *dip, ddi_dma_handle_t handle,
1648215SVikram.Hegde@Sun.COM 	    ddi_dma_cookie_t *cookiep, uint_t ccount);
1658215SVikram.Hegde@Sun.COM 
1668215SVikram.Hegde@Sun.COM 	int (*nops_dma_clear_cookies)(dev_info_t *dip, ddi_dma_handle_t handle);
1678215SVikram.Hegde@Sun.COM 
1688215SVikram.Hegde@Sun.COM 	int (*nops_dma_get_sleep_flags)(ddi_dma_handle_t handle);
1697613SVikram.Hegde@Sun.COM 
1707613SVikram.Hegde@Sun.COM 	int (*nops_dma_sync)(dev_info_t *dip, dev_info_t *rdip,
1717613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
1727613SVikram.Hegde@Sun.COM 
1737613SVikram.Hegde@Sun.COM 	int (*nops_dma_win)(dev_info_t *dip, dev_info_t *rdip,
1747613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
1757613SVikram.Hegde@Sun.COM 	    ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1767613SVikram.Hegde@Sun.COM 
1777613SVikram.Hegde@Sun.COM 	int (*nops_dma_map)(dev_info_t *dip, dev_info_t *rdip,
1787613SVikram.Hegde@Sun.COM 	    struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
1797613SVikram.Hegde@Sun.COM 
1807613SVikram.Hegde@Sun.COM 	int (*nops_dma_mctl)(dev_info_t *dip, dev_info_t *rdip,
1817613SVikram.Hegde@Sun.COM 	    ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
1827613SVikram.Hegde@Sun.COM 	    size_t *lenp, caddr_t *objpp, uint_t cache_flags);
183*13050Sfrank.van.der.linden@oracle.com 
184*13050Sfrank.van.der.linden@oracle.com 	int (*nops_dmahdl_setprivate)(dev_info_t *dip, dev_info_t *rdip,
185*13050Sfrank.van.der.linden@oracle.com 	    ddi_dma_handle_t handle, void *priv);
1867613SVikram.Hegde@Sun.COM 
187*13050Sfrank.van.der.linden@oracle.com 	void * (*nops_dmahdl_getprivate)(dev_info_t *dip, dev_info_t *rdip,
188*13050Sfrank.van.der.linden@oracle.com 	    ddi_dma_handle_t handle);
189*13050Sfrank.van.der.linden@oracle.com } iommulib_nexops_t;
1907613SVikram.Hegde@Sun.COM 
1917613SVikram.Hegde@Sun.COM /*
1928215SVikram.Hegde@Sun.COM  * struct iommu_dip_private
1938215SVikram.Hegde@Sun.COM  *   private iommu structure hook on dev_info
1948215SVikram.Hegde@Sun.COM  */
1958215SVikram.Hegde@Sun.COM typedef struct iommu_private {
1968215SVikram.Hegde@Sun.COM 	/* pci seg, bus, dev, func */
1978215SVikram.Hegde@Sun.COM 	int		idp_seg;
1988215SVikram.Hegde@Sun.COM 	int		idp_bus;
1998215SVikram.Hegde@Sun.COM 	int		idp_devfn;
2008215SVikram.Hegde@Sun.COM 
2018215SVikram.Hegde@Sun.COM 	/* ppb information */
2028215SVikram.Hegde@Sun.COM 	boolean_t	idp_is_bridge;
2038215SVikram.Hegde@Sun.COM 	int		idp_bbp_type;
2048215SVikram.Hegde@Sun.COM 	int		idp_sec;
2058215SVikram.Hegde@Sun.COM 	int		idp_sub;
2068215SVikram.Hegde@Sun.COM 
2078215SVikram.Hegde@Sun.COM 	/* identifier for special devices */
2088215SVikram.Hegde@Sun.COM 	boolean_t	idp_is_display;
2098215SVikram.Hegde@Sun.COM 	boolean_t	idp_is_lpc;
2108215SVikram.Hegde@Sun.COM 
2118215SVikram.Hegde@Sun.COM 	/* domain ptr */
2128215SVikram.Hegde@Sun.COM 	void		*idp_intel_domain;
2138215SVikram.Hegde@Sun.COM } iommu_private_t;
2148215SVikram.Hegde@Sun.COM 
2158215SVikram.Hegde@Sun.COM #define	INTEL_IOMMU_PRIVATE(i)	(dmar_domain_state_t *)(i)
2168215SVikram.Hegde@Sun.COM 
2178215SVikram.Hegde@Sun.COM typedef struct gfx_entry {
21810423SVikram.Hegde@Sun.COM 	int g_ref;
2198215SVikram.Hegde@Sun.COM 	dev_info_t *g_dip;
2208215SVikram.Hegde@Sun.COM 	struct gfx_entry *g_prev;
2218215SVikram.Hegde@Sun.COM 	struct gfx_entry *g_next;
2228215SVikram.Hegde@Sun.COM } gfx_entry_t;
2238215SVikram.Hegde@Sun.COM 
2248215SVikram.Hegde@Sun.COM /*
2257613SVikram.Hegde@Sun.COM  * Interfaces for nexus drivers - typically rootnex
2267613SVikram.Hegde@Sun.COM  */
2277613SVikram.Hegde@Sun.COM 
2287613SVikram.Hegde@Sun.COM int iommulib_nexus_register(dev_info_t *dip, iommulib_nexops_t *nexops,
2297613SVikram.Hegde@Sun.COM     iommulib_nexhandle_t *handle);
2307613SVikram.Hegde@Sun.COM 
2317613SVikram.Hegde@Sun.COM int iommulib_nexus_unregister(iommulib_nexhandle_t handle);
2327613SVikram.Hegde@Sun.COM 
233*13050Sfrank.van.der.linden@oracle.com int iommulib_nex_open(dev_info_t *dip, dev_info_t *rdip);
2347613SVikram.Hegde@Sun.COM void iommulib_nex_close(dev_info_t *rdip);
2357613SVikram.Hegde@Sun.COM 
2367613SVikram.Hegde@Sun.COM int iommulib_nexdma_allochdl(dev_info_t *dip, dev_info_t *rdip,
2377613SVikram.Hegde@Sun.COM     ddi_dma_attr_t *attr, int (*waitfp)(caddr_t),
2387613SVikram.Hegde@Sun.COM     caddr_t arg, ddi_dma_handle_t *dma_handlep);
2397613SVikram.Hegde@Sun.COM 
2407613SVikram.Hegde@Sun.COM int iommulib_nexdma_freehdl(dev_info_t *dip, dev_info_t *rdip,
2417613SVikram.Hegde@Sun.COM     ddi_dma_handle_t dma_handle);
2427613SVikram.Hegde@Sun.COM 
2437613SVikram.Hegde@Sun.COM int iommulib_nexdma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
2447613SVikram.Hegde@Sun.COM     ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq,
2457613SVikram.Hegde@Sun.COM     ddi_dma_cookie_t *cookiep, uint_t *ccountp);
2467613SVikram.Hegde@Sun.COM 
2477613SVikram.Hegde@Sun.COM int iommulib_nexdma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
2487613SVikram.Hegde@Sun.COM     ddi_dma_handle_t dma_handle);
2497613SVikram.Hegde@Sun.COM 
2507613SVikram.Hegde@Sun.COM int iommulib_nexdma_sync(dev_info_t *dip, dev_info_t *rdip,
2517613SVikram.Hegde@Sun.COM     ddi_dma_handle_t dma_handle, off_t off, size_t len,
2527613SVikram.Hegde@Sun.COM     uint_t cache_flags);
2537613SVikram.Hegde@Sun.COM 
2547613SVikram.Hegde@Sun.COM int iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip,
2557613SVikram.Hegde@Sun.COM     ddi_dma_handle_t dma_handle, uint_t win, off_t *offp, size_t *lenp,
2567613SVikram.Hegde@Sun.COM     ddi_dma_cookie_t *cookiep, uint_t *ccountp);
2577613SVikram.Hegde@Sun.COM 
2587613SVikram.Hegde@Sun.COM int iommulib_nexdma_map(dev_info_t *dip, dev_info_t *rdip,
2597613SVikram.Hegde@Sun.COM     struct ddi_dma_req *dmareq, ddi_dma_handle_t *dma_handle);
2607613SVikram.Hegde@Sun.COM 
2617613SVikram.Hegde@Sun.COM int iommulib_nexdma_mctl(dev_info_t *dip, dev_info_t *rdip,
2627613SVikram.Hegde@Sun.COM     ddi_dma_handle_t dma_handle, enum ddi_dma_ctlops request,
2637613SVikram.Hegde@Sun.COM     off_t *offp, size_t *lenp, caddr_t *objpp, uint_t cache_flags);
2647613SVikram.Hegde@Sun.COM 
265*13050Sfrank.van.der.linden@oracle.com int iommulib_nexdma_mapobject(dev_info_t *dip, dev_info_t *rdip,
266*13050Sfrank.van.der.linden@oracle.com     ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq,
267*13050Sfrank.van.der.linden@oracle.com     ddi_dma_obj_t *dmao);
268*13050Sfrank.van.der.linden@oracle.com int iommulib_nexdma_unmapobject(dev_info_t *dip, dev_info_t *rdip,
269*13050Sfrank.van.der.linden@oracle.com     ddi_dma_handle_t dma_handle, ddi_dma_obj_t *dmao);
270*13050Sfrank.van.der.linden@oracle.com 
2717613SVikram.Hegde@Sun.COM /*
2727613SVikram.Hegde@Sun.COM  * Interfaces for IOMMU drivers provided by IOMMULIB
2737613SVikram.Hegde@Sun.COM  */
2747613SVikram.Hegde@Sun.COM 
2757613SVikram.Hegde@Sun.COM int iommulib_iommu_register(dev_info_t *dip, iommulib_ops_t *ops,
2767613SVikram.Hegde@Sun.COM     iommulib_handle_t *handle);
2777613SVikram.Hegde@Sun.COM 
2787613SVikram.Hegde@Sun.COM int iommulib_iommu_unregister(iommulib_handle_t handle);
2797613SVikram.Hegde@Sun.COM 
2807613SVikram.Hegde@Sun.COM int iommulib_iommu_getunitid(iommulib_handle_t handle, uint64_t *unitidp);
2817613SVikram.Hegde@Sun.COM 
2827613SVikram.Hegde@Sun.COM dev_info_t *iommulib_iommu_getdip(iommulib_handle_t handle);
2837613SVikram.Hegde@Sun.COM 
2847613SVikram.Hegde@Sun.COM iommulib_ops_t *iommulib_iommu_getops(iommulib_handle_t handle);
2857613SVikram.Hegde@Sun.COM 
2867613SVikram.Hegde@Sun.COM void *iommulib_iommu_getdata(iommulib_handle_t handle);
2877613SVikram.Hegde@Sun.COM 
2887613SVikram.Hegde@Sun.COM 
2897613SVikram.Hegde@Sun.COM /* Interfaces for IOMMU drivers provided by NEXUS drivers (typically rootnex) */
2907613SVikram.Hegde@Sun.COM 
2917613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_allochdl(dev_info_t *dip, dev_info_t *rdip,
2927613SVikram.Hegde@Sun.COM     ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
2937613SVikram.Hegde@Sun.COM     ddi_dma_handle_t *handlep);
2947613SVikram.Hegde@Sun.COM 
2957613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
2967613SVikram.Hegde@Sun.COM     ddi_dma_handle_t handle);
2977613SVikram.Hegde@Sun.COM 
2987613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
2997613SVikram.Hegde@Sun.COM     ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
3007613SVikram.Hegde@Sun.COM     ddi_dma_cookie_t *cookiep, uint_t *ccountp);
3017613SVikram.Hegde@Sun.COM 
3027613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
3037613SVikram.Hegde@Sun.COM     ddi_dma_handle_t handle);
3047613SVikram.Hegde@Sun.COM 
3057613SVikram.Hegde@Sun.COM void iommulib_iommu_dma_reset_cookies(dev_info_t *dip, ddi_dma_handle_t handle);
3067613SVikram.Hegde@Sun.COM 
3077613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_get_cookies(dev_info_t *dip, ddi_dma_handle_t handle,
3088215SVikram.Hegde@Sun.COM     ddi_dma_cookie_t **cookiepp, uint_t *ccountp);
3098215SVikram.Hegde@Sun.COM 
3108215SVikram.Hegde@Sun.COM int iommulib_iommu_dma_set_cookies(dev_info_t *dip, ddi_dma_handle_t handle,
3118215SVikram.Hegde@Sun.COM     ddi_dma_cookie_t *cookiep, uint_t ccount);
3128215SVikram.Hegde@Sun.COM 
3138215SVikram.Hegde@Sun.COM int iommulib_iommu_dma_clear_cookies(dev_info_t *dip, ddi_dma_handle_t handle);
3148215SVikram.Hegde@Sun.COM 
3158215SVikram.Hegde@Sun.COM int iommulib_iommu_dma_get_sleep_flags(dev_info_t *dip,
3168215SVikram.Hegde@Sun.COM     ddi_dma_handle_t handle);
3177613SVikram.Hegde@Sun.COM 
3187613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_sync(dev_info_t *dip, dev_info_t *rdip,
3197613SVikram.Hegde@Sun.COM     ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
3207613SVikram.Hegde@Sun.COM 
3217613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_win(dev_info_t *dip, dev_info_t *rdip,
3227613SVikram.Hegde@Sun.COM     ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
3237613SVikram.Hegde@Sun.COM     ddi_dma_cookie_t *cookiep, uint_t *ccountp);
3247613SVikram.Hegde@Sun.COM 
3257613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_map(dev_info_t *dip, dev_info_t *rdip,
3267613SVikram.Hegde@Sun.COM     struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
3277613SVikram.Hegde@Sun.COM 
3287613SVikram.Hegde@Sun.COM int iommulib_iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
3297613SVikram.Hegde@Sun.COM     ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
3307613SVikram.Hegde@Sun.COM     size_t *lenp, caddr_t *objpp, uint_t cache_flags);
3317613SVikram.Hegde@Sun.COM 
332*13050Sfrank.van.der.linden@oracle.com int iommulib_iommu_dmahdl_setprivate(dev_info_t *dip, dev_info_t *rdip,
333*13050Sfrank.van.der.linden@oracle.com     ddi_dma_handle_t handle, void *priv);
334*13050Sfrank.van.der.linden@oracle.com 
335*13050Sfrank.van.der.linden@oracle.com void *iommulib_iommu_dmahdl_getprivate(dev_info_t *dip, dev_info_t *rdip,
336*13050Sfrank.van.der.linden@oracle.com     ddi_dma_handle_t handle);
337*13050Sfrank.van.der.linden@oracle.com 
338*13050Sfrank.van.der.linden@oracle.com 
3398371SVikram.Hegde@Sun.COM /*
3408371SVikram.Hegde@Sun.COM  * For SMBIOS access from IOMMU drivers
3418371SVikram.Hegde@Sun.COM  */
3428371SVikram.Hegde@Sun.COM extern smbios_hdl_t *iommulib_smbios;
3438371SVikram.Hegde@Sun.COM 
3447613SVikram.Hegde@Sun.COM #endif	/* _KERNEL */
3457613SVikram.Hegde@Sun.COM 
3467613SVikram.Hegde@Sun.COM #ifdef	__cplusplus
3477613SVikram.Hegde@Sun.COM }
3487613SVikram.Hegde@Sun.COM #endif
3497613SVikram.Hegde@Sun.COM 
3507613SVikram.Hegde@Sun.COM #endif	/* _SYS_IOMMULIB_H */
351