iommulib.h revision 94f1124e84b3daba182b39a5df7b044074cb1c71
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde/*
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * CDDL HEADER START
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde *
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * The contents of this file are subject to the terms of the
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Common Development and Distribution License (the "License").
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * You may not use this file except in compliance with the License.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde *
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * or http://www.opensolaris.org/os/licensing.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * See the License for the specific language governing permissions
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * and limitations under the License.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde *
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * When distributing Covered Code, include this CDDL HEADER in each
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * If applicable, add the following below this CDDL HEADER, with the
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * fields enclosed by brackets "[]" replaced with your own identifying
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * information: Portions Copyright [yyyy] [name of copyright owner]
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde *
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * CDDL HEADER END
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde/*
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Use is subject to license terms.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#ifndef _SYS_IOMMULIB_H
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#define _SYS_IOMMULIB_H
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#pragma ident "@(#)iommulib.h 1.3 08/08/31 SMI"
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#ifdef __cplusplus
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeextern "C" {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#endif
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#include <sys/ddi_impldefs.h>
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#ifdef _KERNEL
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef enum {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde INVALID_VENDOR = 0,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde AMD_IOMMU,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde INTEL_IOMMU
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde} iommulib_vendor_t;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef enum {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde IOMMU_OPS_VERSION_INVALID = 0,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde IOMMU_OPS_VERSION_1 = 1
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde} iommulib_opsversion_t;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#define IOMMU_OPS_VERSION IOMMU_OPS_VERSION_1
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef struct iommulib_ops {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde iommulib_opsversion_t ilops_vers;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde iommulib_vendor_t ilops_vendor;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde char *ilops_id;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde void *ilops_data;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*ilops_probe)(iommulib_handle_t handle, dev_info_t *rdip);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_allochdl)(iommulib_handle_t handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *dma_handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_freehdl)(iommulib_handle_t handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_bindhdl)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *rdip, ddi_dma_handle_t dma_handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_cookie_t *cookiep,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_unbindhdl)(iommulib_handle_t handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_sync)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *rdip, ddi_dma_handle_t dma_handle, off_t off,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde size_t len, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_win)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *rdip, ddi_dma_handle_t dma_handle, uint_t win,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde off_t *offp, size_t *lenp, ddi_dma_cookie_t *cookiep,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde /* Obsolete DMA routines */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_map)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *rdip, struct ddi_dma_req *dmareq,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t *dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_mctl)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *rdip, ddi_dma_handle_t dma_handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde caddr_t *objpp, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde} iommulib_ops_t;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#define IOMMU_USED(dip) (DEVI(dip)->devi_iommulib_handle != NULL)
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef enum {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde IOMMU_NEXOPS_VERSION_INVALID = 0,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde IOMMU_NEXOPS_VERSION_1 = 1
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde} iommulib_nexops_version_t;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#define IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_1
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef struct iommulib_nexops {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde iommulib_nexops_version_t nops_vers;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde char *nops_id;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde void *nops_data;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t *handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde void (*nops_dma_reset_cookies)(dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_get_cookies)(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde ddi_dma_cookie_t **cookiepp, uint_t *ccountp);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*nops_dma_set_cookies)(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t ccount);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*nops_dma_clear_cookies)(dev_info_t *dip, ddi_dma_handle_t handle);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*nops_dma_get_sleep_flags)(ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_sync)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_win)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_map)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_mctl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde size_t *lenp, caddr_t *objpp, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde} iommulib_nexops_t;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdestruct iommulib_nex;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef struct iommulib_nex *iommulib_nexhandle_t;
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde/*
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde * struct iommu_dip_private
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde * private iommu structure hook on dev_info
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdetypedef struct iommu_private {
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* pci seg, bus, dev, func */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int idp_seg;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int idp_bus;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int idp_devfn;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* ppb information */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde boolean_t idp_is_bridge;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int idp_bbp_type;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int idp_sec;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int idp_sub;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* identifier for special devices */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde boolean_t idp_is_display;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde boolean_t idp_is_lpc;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* domain ptr */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde void *idp_intel_domain;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde} iommu_private_t;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde#define INTEL_IOMMU_PRIVATE(i) (dmar_domain_state_t *)(i)
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdetypedef struct gfx_entry {
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde dev_info_t *g_dip;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde struct gfx_entry *g_prev;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde struct gfx_entry *g_next;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde} gfx_entry_t;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde/*
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Interfaces for nexus drivers - typically rootnex
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexus_register(dev_info_t *dip, iommulib_nexops_t *nexops,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde iommulib_nexhandle_t *handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexus_unregister(iommulib_nexhandle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nex_open(dev_info_t *rdip, uint_t *errorp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdevoid iommulib_nex_close(dev_info_t *rdip);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_allochdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_attr_t *attr, int (*waitfp)(caddr_t),
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde caddr_t arg, ddi_dma_handle_t *dma_handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_freehdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_sync(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, off_t off, size_t len,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, uint_t win, off_t *offp, size_t *lenp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_map(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_handle_t *dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_mctl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, enum ddi_dma_ctlops request,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde off_t *offp, size_t *lenp, caddr_t *objpp, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde/*
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Interfaces for IOMMU drivers provided by IOMMULIB
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_register(dev_info_t *dip, iommulib_ops_t *ops,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde iommulib_handle_t *handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_unregister(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_getunitid(iommulib_handle_t handle, uint64_t *unitidp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdedev_info_t *iommulib_iommu_getdip(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeiommulib_ops_t *iommulib_iommu_getops(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdevoid *iommulib_iommu_getdata(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde/* Interfaces for IOMMU drivers provided by NEXUS drivers (typically rootnex) */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_allochdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t *handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdevoid iommulib_iommu_dma_reset_cookies(dev_info_t *dip, ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_get_cookies(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde ddi_dma_cookie_t **cookiepp, uint_t *ccountp);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdeint iommulib_iommu_dma_set_cookies(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t ccount);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdeint iommulib_iommu_dma_clear_cookies(dev_info_t *dip, ddi_dma_handle_t handle);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdeint iommulib_iommu_dma_get_sleep_flags(dev_info_t *dip,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_sync(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_win(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_cookie_t *cookiep, uint_t *ccountp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_map(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde size_t *lenp, caddr_t *objpp, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#endif /* _KERNEL */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#ifdef __cplusplus
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde}
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#endif
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#endif /* _SYS_IOMMULIB_H */