summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2012-03-02 19:01:23 -0500
committerRichard Lowe <richlowe@richlowe.net>2012-03-02 19:01:23 -0500
commit15e1afcd5e908ae29b1e6018838638befdc225a2 (patch)
tree3bbbffe597d2f2e0d037ef18cbaaf932447e1377
parent88b44bf4e73233af70877930178dbff7f1c2992b (diff)
downloadillumos-joyent-15e1afcd5e908ae29b1e6018838638befdc225a2.tar.gz
backout 998: breaks common closed drivers
-rw-r--r--usr/src/man/man9f/Intro.9f20
-rw-r--r--usr/src/man/man9f/Makefile33
-rw-r--r--usr/src/man/man9f/ddi_dma_addr_setup.9f156
-rw-r--r--usr/src/man/man9f/ddi_dma_buf_setup.9f138
-rw-r--r--usr/src/man/man9f/ddi_dma_coff.9f117
-rw-r--r--usr/src/man/man9f/ddi_dma_curwin.9f113
-rw-r--r--usr/src/man/man9f/ddi_dma_devalign.9f113
-rw-r--r--usr/src/man/man9f/ddi_dma_free.9f95
-rw-r--r--usr/src/man/man9f/ddi_dma_get_attr.9f93
-rw-r--r--usr/src/man/man9f/ddi_dma_htoc.9f114
-rw-r--r--usr/src/man/man9f/ddi_dma_movwin.9f155
-rw-r--r--usr/src/man/man9f/ddi_dma_nextseg.9f144
-rw-r--r--usr/src/man/man9f/ddi_dma_nextwin.9f155
-rw-r--r--usr/src/man/man9f/ddi_dma_segtocookie.9f149
-rw-r--r--usr/src/man/man9f/ddi_dma_setup.9f182
-rw-r--r--usr/src/man/man9f/ddi_dmae.9f24
-rw-r--r--usr/src/man/man9f/ddi_iopb_alloc.9f163
-rw-r--r--usr/src/man/man9f/ddi_mem_alloc.9f180
-rw-r--r--usr/src/man/man9s/ddi_dmae_req.9s14
-rw-r--r--usr/src/pkg/manifests/system-kernel.man9f.inc18
-rw-r--r--usr/src/uts/common/io/1394/nx1394.c11
-rw-r--r--usr/src/uts/common/io/blkdev/blkdev.c6
-rw-r--r--usr/src/uts/common/io/bofi.c230
-rw-r--r--usr/src/uts/common/io/fcoe/fcoe.c5
-rw-r--r--usr/src/uts/common/io/fdc.c5
-rw-r--r--usr/src/uts/common/io/fibre-channel/impl/fctl.c8
-rw-r--r--usr/src/uts/common/io/pci-ide/pci-ide.c6
-rw-r--r--usr/src/uts/common/io/pciex/pcieb.c5
-rw-r--r--usr/src/uts/common/io/pshot.c5
-rw-r--r--usr/src/uts/common/io/scsi/impl/scsi_hba.c3
-rw-r--r--usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c5
-rw-r--r--usr/src/uts/common/io/usb/usb_ia/usb_ia.c5
-rw-r--r--usr/src/uts/common/io/usb/usb_mid/usb_mid.c5
-rw-r--r--usr/src/uts/common/io/usb/usba/hubdi.c3
-rw-r--r--usr/src/uts/common/io/warlock/ddi_dki_comm.inc49
-rw-r--r--usr/src/uts/common/os/devcfg.c9
-rw-r--r--usr/src/uts/common/os/sunddi.c308
-rw-r--r--usr/src/uts/common/sys/ddi_impldefs.h2
-rw-r--r--usr/src/uts/common/sys/ddi_implfuncs.h9
-rw-r--r--usr/src/uts/common/sys/ddi_obsolete.h38
-rw-r--r--usr/src/uts/common/sys/ddidmareq.h29
-rw-r--r--usr/src/uts/common/sys/devops.h38
-rw-r--r--usr/src/uts/common/sys/dma_engine.h12
-rw-r--r--usr/src/uts/common/sys/sunddi.h5
-rw-r--r--usr/src/uts/common/xen/io/xpvd.c5
-rw-r--r--usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c5
-rw-r--r--usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c34
-rw-r--r--usr/src/uts/i86pc/io/immu_dvma.c33
-rw-r--r--usr/src/uts/i86pc/io/isa.c3
-rw-r--r--usr/src/uts/i86pc/io/pci/pci.c5
-rw-r--r--usr/src/uts/i86pc/io/pciex/npe.c6
-rw-r--r--usr/src/uts/i86pc/io/rootnex.c269
-rw-r--r--usr/src/uts/i86pc/ml/offsets.in2
-rw-r--r--usr/src/uts/i86pc/os/ddi_impl.c45
-rw-r--r--usr/src/uts/intel/io/iommulib.c84
-rw-r--r--usr/src/uts/intel/io/pci/pci_pci.c5
-rw-r--r--usr/src/uts/intel/sys/iommulib.h45
-rw-r--r--usr/src/uts/sparc/ml/sparc_ddi.s29
-rw-r--r--usr/src/uts/sun/io/socal.c6
-rw-r--r--usr/src/uts/sun4/io/ebus.c5
-rw-r--r--usr/src/uts/sun4/io/px/px_dma.c251
-rw-r--r--usr/src/uts/sun4/io/px/px_mmu.c3
-rw-r--r--usr/src/uts/sun4/ml/offsets.in3
-rw-r--r--usr/src/uts/sun4/os/ddi_impl.c41
-rw-r--r--usr/src/uts/sun4u/io/iommu.c330
-rw-r--r--usr/src/uts/sun4u/io/isadma.c5
-rw-r--r--usr/src/uts/sun4u/io/pci/db21554.c5
-rw-r--r--usr/src/uts/sun4u/io/pci/pci_dma.c191
-rw-r--r--usr/src/uts/sun4u/io/pci/pci_iommu.c134
-rw-r--r--usr/src/uts/sun4u/io/pci/pci_pci.c5
-rw-r--r--usr/src/uts/sun4u/io/pci/simba.c5
-rw-r--r--usr/src/uts/sun4u/io/pmubus.c5
-rw-r--r--usr/src/uts/sun4u/io/sysiosbus.c5
-rw-r--r--usr/src/uts/sun4u/montecarlo/io/acebus.c5
-rw-r--r--usr/src/uts/sun4u/serengeti/io/ssm.c5
-rw-r--r--usr/src/uts/sun4u/sys/iommu.h7
76 files changed, 4223 insertions, 335 deletions
diff --git a/usr/src/man/man9f/Intro.9f b/usr/src/man/man9f/Intro.9f
index e88df92fc2..6b31e63e6b 100644
--- a/usr/src/man/man9f/Intro.9f
+++ b/usr/src/man/man9f/Intro.9f
@@ -1,10 +1,9 @@
'\" te
-.\" Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
.\" Copyright (c) 2005, Sun Microsystems, Inc., All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH INTRO 9F "Feb 06, 2012"
+.TH INTRO 9F "Mar 11, 2008"
.SH NAME
Intro, intro \- introduction to DDI/DKI functions
.SH DESCRIPTION
@@ -352,16 +351,29 @@ _
\fBddi_device_zero\fR Solaris DDI
\fBddi_devmap_segmap\fR Solaris DDI
\fBddi_dma_addr_bind_handle\fR Solaris DDI
+\fBddi_dma_addr_setup\fR Solaris DDI
\fBddi_dma_alloc_handle\fR Solaris DDI
\fBddi_dma_buf_bind_handle\fR Solaris DDI
+\fBddi_dma_buf_setup\fR Solaris DDI
\fBddi_dma_burstsizes\fR Solaris DDI
+\fBddi_dma_coff\fR Solaris SPARC DDI
+\fBddi_dma_curwin\fR Solaris SPARC DDI
+\fBddi_dma_devalign\fR Solaris DDI
+\fBddi_dma_free\fR Solaris DDI
\fBddi_dma_free_handle\fR Solaris DDI
\fBddi_dma_getwin\fR Solaris DDI
+\fBddi_dma_get_attr\fR Solaris DDI
+\fBddi_dma_htoc\fR Solaris SPARC DDI
\fBddi_dma_mem_alloc\fR Solaris DDI
\fBddi_dma_mem_free\fR Solaris DDI
+\fBddi_dma_movwin\fR Solaris SPARC DDI
\fBddi_dma_nextcookie\fR Solaris DDI
+\fBddi_dma_nextseg\fR Solaris DDI
+\fBddi_dma_nextwin\fR Solaris DDI
\fBddi_dma_numwin\fR Solaris DDI
+\fBddi_dma_segtocookie\fR Solaris DDI
\fBddi_dma_set_sbus64\fR Solaris DDI
+\fBddi_dma_setup\fR Solaris DDI
\fBddi_dma_sync\fR Solaris DDI
\fBddi_dma_unbind_handle\fR Solaris DDI
\fBddi_dmae\fR Solaris x86 DDI
@@ -463,12 +475,16 @@ _
\fBddi_io_rep_putl\fR Solaris DDI
\fBddi_io_rep_putw\fR Solaris DDI
\fBddi_iomin\fR Solaris DDI
+\fBddi_iopb_alloc\fR Solaris DDI
+\fBddi_iopb_free\fR Solaris DDI
\fBddi_log_sysevent\fR Solaris DDI
\fBddi_map_regs\fR Solaris DDI
\fBddi_mapdev\fR Solaris DDI
\fBddi_mapdev_intercept\fR Solaris DDI
\fBddi_mapdev_nointercept\fR Solaris DDI
\fBddi_mapdev_set_device_acc_attr\fR Solaris DDI
+\fBddi_mem_alloc\fR Solaris DDI
+\fBddi_mem_free\fR Solaris DDI
\fBddi_mem_get16\fR Solaris DDI
\fBddi_mem_get32\fR Solaris DDI
\fBddi_mem_get64\fR Solaris DDI
diff --git a/usr/src/man/man9f/Makefile b/usr/src/man/man9f/Makefile
index ce8b852e26..719a150e50 100644
--- a/usr/src/man/man9f/Makefile
+++ b/usr/src/man/man9f/Makefile
@@ -1,16 +1,4 @@
-#
-# This file and its contents are supplied under the terms of the
-# Common Development and Distribution License ("CDDL"), version 1.0.
-# You may only use this file in accordance with the terms of version
-# 1.0 of the CDDL.
-#
-# A full copy of the text of the CDDL should have accompanied this
-# source. A copy of the CDDL is also available via the Internet at
-# http://www.illumos.org/license/CDDL.
-#
-
# Copyright 2011, Richard Lowe
-# Copyright 2012 Garrett D'Amore <garrett@damore>. All rights reserved.
include ../../Makefile.master
@@ -144,16 +132,29 @@ MANFILES = ASSERT.9f \
ddi_device_zero.9f \
ddi_devid_compare.9f \
ddi_dma_addr_bind_handle.9f \
+ ddi_dma_addr_setup.9f \
ddi_dma_alloc_handle.9f \
ddi_dma_buf_bind_handle.9f \
+ ddi_dma_buf_setup.9f \
ddi_dma_burstsizes.9f \
+ ddi_dma_coff.9f \
+ ddi_dma_curwin.9f \
+ ddi_dma_devalign.9f \
+ ddi_dma_free.9f \
ddi_dma_free_handle.9f \
+ ddi_dma_get_attr.9f \
ddi_dma_getwin.9f \
+ ddi_dma_htoc.9f \
ddi_dma_mem_alloc.9f \
ddi_dma_mem_free.9f \
+ ddi_dma_movwin.9f \
ddi_dma_nextcookie.9f \
+ ddi_dma_nextseg.9f \
+ ddi_dma_nextwin.9f \
ddi_dma_numwin.9f \
+ ddi_dma_segtocookie.9f \
ddi_dma_set_sbus64.9f \
+ ddi_dma_setup.9f \
ddi_dma_sync.9f \
ddi_dma_unbind_handle.9f \
ddi_dmae.9f \
@@ -199,8 +200,10 @@ MANFILES = ASSERT.9f \
ddi_io_rep_get8.9f \
ddi_io_rep_put8.9f \
ddi_iomin.9f \
+ ddi_iopb_alloc.9f \
ddi_log_sysevent.9f \
ddi_map_regs.9f \
+ ddi_mem_alloc.9f \
ddi_mem_get8.9f \
ddi_mem_put8.9f \
ddi_mem_rep_get8.9f \
@@ -749,6 +752,8 @@ MANSOFILES = SIZEOF_PTR.9f \
ddi_io_rep_putb.9f \
ddi_io_rep_putl.9f \
ddi_io_rep_putw.9f \
+ ddi_iopb_free.9f \
+ ddi_mem_free.9f \
ddi_mem_get16.9f \
ddi_mem_get32.9f \
ddi_mem_get64.9f \
@@ -1473,8 +1478,12 @@ ddi_io_rep_putb.9f := SOSRC = man9f/ddi_io_rep_put8.9f
ddi_io_rep_putl.9f := SOSRC = man9f/ddi_io_rep_put8.9f
ddi_io_rep_putw.9f := SOSRC = man9f/ddi_io_rep_put8.9f
+ddi_iopb_free.9f := SOSRC = man9f/ddi_iopb_alloc.9f
+
ddi_unmap_regs.9f := SOSRC = man9f/ddi_map_regs.9f
+ddi_mem_free.9f := SOSRC = man9f/ddi_mem_alloc.9f
+
ddi_mem_get16.9f := SOSRC = man9f/ddi_mem_get8.9f
ddi_mem_get32.9f := SOSRC = man9f/ddi_mem_get8.9f
ddi_mem_get64.9f := SOSRC = man9f/ddi_mem_get8.9f
diff --git a/usr/src/man/man9f/ddi_dma_addr_setup.9f b/usr/src/man/man9f/ddi_dma_addr_setup.9f
new file mode 100644
index 0000000000..52f3a367be
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_addr_setup.9f
@@ -0,0 +1,156 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_ADDR_SETUP 9F "Apr 04, 2006"
+.SH NAME
+ddi_dma_addr_setup \- easier DMA setup for use with virtual addresses
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+\fBint\fR \fBddi_dma_addr_setup\fR(\fBdev_info_t *\fR\fIdip\fR, \fBstruct as *\fR\fIas\fR, \fBcaddr_t\fR \fIaddr\fR,
+ \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fIflags\fR, \fBint (*\fR\fIwaitfp\fR) (caddr_t), \fBcaddr_t\fR \fIarg\fR,
+ \fBddi_dma_lim_t *\fR \fIlim\fR, \fBddi_dma_handle_t *\fR\fIhandlep\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_addr_bind_handle\fR(9F) should be used
+instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIdip\fR\fR
+.ad
+.RS 11n
+A pointer to the device's \fBdev_info\fR structure.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIas\fR\fR
+.ad
+.RS 11n
+A pointer to an address space structure. Should be set to \fINULL\fR, which
+implies kernel address space.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIaddr\fR\fR
+.ad
+.RS 11n
+Virtual address of the memory object.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlen\fR\fR
+.ad
+.RS 11n
+Length of the memory object in bytes.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIflags\fR\fR
+.ad
+.RS 11n
+Flags that would go into the \fBddi_dma_req\fR structure (see
+\fBddi_dma_req\fR(9S)).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIwaitfp\fR\fR
+.ad
+.RS 11n
+The address of a function to call back later if resources aren't available now.
+The special function addresses \fBDDI_DMA_SLEEP\fR and \fBDDI_DMA_DONTWAIT\fR
+(see \fBddi_dma_req\fR(9S)) are taken to mean, respectively, wait until
+resources are available or, do not wait at all and do not schedule a callback.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIarg\fR\fR
+.ad
+.RS 11n
+Argument to be passed to a callback function, if such a function is specified.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlim\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBDMA\fR limits structure for this device (see
+\fBddi_dma_lim_sparc\fR(9S) or \fBddi_dma_lim_x86\fR(9S)). If this pointer is
+\fINULL\fR, a default set of \fBDMA\fR limits is assumed.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIhandlep\fR\fR
+.ad
+.RS 11n
+Pointer to a \fBDMA\fR handle. See \fBddi_dma_setup\fR(9F) for a discussion of
+handle.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_addr_setup()\fR function is an interface to
+\fBddi_dma_setup\fR(9F). It uses its arguments to construct an appropriate
+\fBddi_dma_req\fR structure and calls \fBddi_dma_setup\fR(9F) with it.
+.SH RETURN VALUES
+.sp
+.LP
+See \fBddi_dma_setup\fR(9F) for the possible return values for this function.
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_addr_setup()\fR can be called from user, interrupt, or kernel
+context, except when \fIwaitfp\fR is set to \fBDDI_DMA_SLEEP\fR, in which case
+it cannot be called from interrupt context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_buf_setup\fR(9F), \fBddi_dma_free\fR(9F),
+\fBddi_dma_htoc\fR(9F), \fBddi_dma_setup\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBddi_iopb_alloc\fR(9F), \fBddi_dma_lim_sparc\fR(9S),
+\fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_buf_setup.9f b/usr/src/man/man9f/ddi_dma_buf_setup.9f
new file mode 100644
index 0000000000..017aae75eb
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_buf_setup.9f
@@ -0,0 +1,138 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_BUF_SETUP 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_buf_setup \- easier DMA setup for use with buffer structures
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_buf_setup\fR(\fBdev_info_t *\fR\fIdip\fR, \fBstruct buf *\fR\fIbp\fR, \fBuint_t\fR \fIflags\fR,
+ \fBint (*\fR\fIwaitfp\fR) (caddr_t),, \fBcaddr_t\fR \fIarg\fR, \fBddi_dma_lim_t *\fR\fIlim\fR,
+ \fBddi_dma_handle_t *\fR\fIhandlep\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_buf_bind_handle\fR(9F) should be used
+instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIdip\fR\fR
+.ad
+.RS 11n
+A pointer to the device's \fBdev_info\fR structure.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIbp\fR\fR
+.ad
+.RS 11n
+A pointer to a system buffer structure (see \fBbuf\fR(9S)).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIflags\fR\fR
+.ad
+.RS 11n
+Flags that go into a \fBddi_dma_req\fR structure (see \fBddi_dma_req\fR(9S)).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIwaitfp\fR\fR
+.ad
+.RS 11n
+The address of a function to call back later if resources aren't available now.
+The special function addresses \fBDDI_DMA_SLEEP\fR and \fBDDI_DMA_DONTWAIT\fR
+(see \fBddi_dma_req\fR(9S)) are taken to mean, respectively, wait until
+resources are available, or do not wait at all and do not schedule a callback.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIarg\fR\fR
+.ad
+.RS 11n
+Argument to be passed to a callback function, if such a function is specified.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlim\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBDMA\fR limits structure for this device (see
+\fBddi_dma_lim_sparc\fR(9S) or \fBddi_dma_lim_x86\fR(9S)). If this pointer is
+\fINULL\fR, a default set of \fBDMA\fR limits is assumed.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIhandlep\fR\fR
+.ad
+.RS 11n
+Pointer to a \fBDMA\fR handle. See \fBddi_dma_setup\fR(9F) for a discussion of
+handle.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_buf_setup()\fR function is an interface to
+\fBddi_dma_setup\fR(9F). It uses its arguments to construct an appropriate
+\fBddi_dma_req\fR structure and calls \fBddi_dma_setup()\fR with it.
+.SH RETURN VALUES
+.sp
+.LP
+See \fBddi_dma_setup\fR(9F) for the possible return values for this function.
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_buf_setup()\fR function can be called from user, interrupt, or
+kernel context, except when \fIwaitfp\fR is set to \fBDDI_DMA_SLEEP\fR, in
+which case it cannot be called from interrupt context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_addr_setup\fR(9F), \fBddi_dma_free\fR(9F),
+\fBddi_dma_htoc\fR(9F), \fBddi_dma_setup\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBphysio\fR(9F), \fBbuf\fR(9S), \fBddi_dma_lim_sparc\fR(9S),
+\fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_coff.9f b/usr/src/man/man9f/ddi_dma_coff.9f
new file mode 100644
index 0000000000..b8609b2fd0
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_coff.9f
@@ -0,0 +1,117 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_COFF 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_coff \- convert a DMA cookie to an offset within a DMA handle.
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/conf.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_coff\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBddi_dma_cookie_t *\fR\fIcookiep\fR,
+ \fBoff_t *\fR\fIoffp\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+Solaris SPARC DDI (Solaris SPARC DDI). This interface is obsolete.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 11n
+The \fIhandle\fR filled in by a call to \fBddi_dma_setup\fR(9F).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIcookiep\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBDMA\fR cookie (see \fBddi_dma_cookie\fR(9S)) that contains
+the appropriate address, length and bus type to be used in programming the
+\fBDMA\fR engine.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIoffp\fR\fR
+.ad
+.RS 11n
+A pointer to an offset to be filled in.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_coff()\fR function converts the values in \fBDMA\fR cookie
+pointed to by \fIcookiep\fR to an offset (in bytes) from the beginning of the
+object that the DMA\fBhandle\fR has mapped.
+.sp
+.LP
+The \fBddi_dma_coff()\fR function allows a driver to update a \fBDMA\fR cookie
+with values it reads from its device's \fBDMA\fR engine after a transfer
+completes and convert that value into an offset into the object that is mapped
+for \fBDMA\fR.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_coff()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+Successfully filled in \fIoffp\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Failed to successfully fill in \fIoffp\fR.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_coff()\fR function can be called from user, interrupt, or kernel
+context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for descriptions of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Interface Stability Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBddi_dma_setup\fR(9F), \fBddi_dma_sync\fR(9F), \fBddi_dma_cookie\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_curwin.9f b/usr/src/man/man9f/ddi_dma_curwin.9f
new file mode 100644
index 0000000000..b04a98c114
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_curwin.9f
@@ -0,0 +1,113 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_CURWIN 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_curwin \- report current DMA window offset and size
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/conf.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_curwin\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBoff_t *\fR\fIoffp\fR, \fBuint_t *\fR\fIlenp\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_getwin\fR(9F) should be used instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 10n
+The \fBDMA\fR handle filled in by a call to \fBddi_dma_setup\fR(9F).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIoffp\fR\fR
+.ad
+.RS 10n
+A pointer to a value which will be filled in with the current offset from the
+beginning of the object that is mapped for \fBDMA\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlenp\fR\fR
+.ad
+.RS 10n
+A pointer to a value which will be filled in with the size, in bytes, of the
+current window onto the object that is mapped for \fBDMA\fR.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_curwin()\fR function reports the current \fBDMA\fR window offset
+and size. If a \fBDMA\fR mapping allows partial mapping, that is if the
+\fBDDI_DMA_PARTIAL\fR flag in the \fBddi_dma_req\fR(9S) structure is set, its
+current (effective) \fBDMA\fR window offset and size can be obtained by a call
+to \fBddi_dma_curwin()\fR.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_curwin()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+The current length and offset can be established.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Otherwise.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_curwin()\fR function can be called from user, interrupt, or
+kernel context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_getwin\fR(9F), \fBddi_dma_movwin\fR(9F),
+\fBddi_dma_setup\fR(9F), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_devalign.9f b/usr/src/man/man9f/ddi_dma_devalign.9f
new file mode 100644
index 0000000000..913c73e6f2
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_devalign.9f
@@ -0,0 +1,113 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_DEVALIGN 9F "Apr 04, 2006"
+.SH NAME
+ddi_dma_devalign \- find DMA mapping alignment and minimum transfer size
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/conf.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_devalign\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBuint_t *\fR\fIalignment\fR,
+ \fBuint_t *\fR\fIminxfr\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+Solaris DDI specific (Solaris DDI). This interface is obsolete.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 13n
+The DMA\fBhandle\fR filled in by a successful call to \fBddi_dma_setup\fR(9F).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIalignment\fR\fR
+.ad
+.RS 13n
+A pointer to an unsigned integer to be filled in with the minimum required
+alignment for \fBDMA\fR. The alignment is guaranteed to be a power of two.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIminxfr\fR\fR
+.ad
+.RS 13n
+A pointer to an unsigned integer to be filled in with the minimum effective
+transfer size (see \fBddi_iomin\fR(9F), \fBddi_dma_lim_sparc\fR(9S) and
+\fBddi_dma_lim_x86\fR(9S)). This also is guaranteed to be a power of two.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_devalign()\fR Function determines after a successful \fBDMA\fR
+mapping (see \fBddi_dma_setup\fR(9F)) the minimum required data alignment and
+minimum \fBDMA\fR transfer size.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_devalign()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+The \fIalignment\fR and \fIminxfr\fR values have been filled.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+The handle was illegal.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_devalign()\fR function can be called from user, interrupt, or
+kernel context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for descriptions of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Interface Stability Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBddi_dma_setup\fR(9F), \fBddi_iomin\fR(9F), \fBddi_dma_lim_sparc\fR(9S),
+\fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_free.9f b/usr/src/man/man9f/ddi_dma_free.9f
new file mode 100644
index 0000000000..4d9a794846
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_free.9f
@@ -0,0 +1,95 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_FREE 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_free \- release system DMA resources
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_free\fR(\fBddi_dma_handle_t\fR \fIhandle\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_free_handle\fR(9F) should be used
+instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 10n
+The handle filled in by a call to \fBddi_dma_setup\fR(9F).
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_free()\fR function releases system \fBDMA\fR resources set up by
+\fBddi_dma_setup\fR(9F). When a \fBDMA\fR transfer completes, the driver should
+free up system \fBDMA\fR resources established by a call to
+\fBddi_dma_setup\fR(9F). This is done by a call to \fBddi_dma_free()\fR.
+\fBddi_dma_free()\fR does an implicit \fBddi_dma_sync\fR(9F) for you so any
+further synchronization steps are not necessary.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_free()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+Successfully released resources
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Failed to free resources
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_free()\fR function can be called from user, interrupt, or kernel
+context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_addr_setup\fR(9F), \fBddi_dma_buf_setup\fR(9F),
+\fBddi_dma_free_handle\fR(9F), \fBddi_dma_htoc\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_get_attr.9f b/usr/src/man/man9f/ddi_dma_get_attr.9f
new file mode 100644
index 0000000000..5557280c5e
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_get_attr.9f
@@ -0,0 +1,93 @@
+'\" te
+.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_GET_ATTR 9F "Oct 12, 2005"
+.SH NAME
+ddi_dma_get_attr \- get the device DMA attribute structure from a DMA handle
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_get_attr\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBddi_dma_attr_t *\fR\fIattrp\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+Solaris DDI specific (Solaris DDI). This interface is obsolete.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 10n
+The handle filled in by a call to \fBddi_dma_alloc_handle\fR(9F).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIattrp\fR\fR
+.ad
+.RS 10n
+Pointer to a buffer suitable for holding a DMA attribute structure. See
+\fBddi_dma_attr\fR(9S).
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+\fBddi_dma_get_attr()\fR is used to get a \fBddi_dma_attr\fR(9S) structure.
+This structure describes the attributes of the DMA data path to which any
+memory object bound to the given handle will be subject.
+.SH RETURN VALUES
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 19n
+Successfully passed back attribute structure in buffer pointed to by
+\fIattrp\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_BADATTR\fR\fR
+.ad
+.RS 19n
+A valid attribute structure could not be passed back.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+\fBddi_dma_get_attr()\fR can be called from any context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for descriptions of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Interface Stability Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBddi_dma_alloc_handle\fR(9F), \fBddi_dma_attr\fR(9S)
diff --git a/usr/src/man/man9f/ddi_dma_htoc.9f b/usr/src/man/man9f/ddi_dma_htoc.9f
new file mode 100644
index 0000000000..f2157ba6d8
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_htoc.9f
@@ -0,0 +1,114 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_HTOC 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_htoc \- convert a DMA handle to a DMA address cookie
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/conf.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_htoc\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBoff_t\fR \fIoff\fR,
+ \fBddi_dma_cookie_t *\fR\fIcookiep\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_addr_bind_handle\fR(9F) or
+\fBddi_dma_buf_bind_handle\fR(9F) should be used instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 11n
+The handle filled in by a call to \fBddi_dma_setup\fR(9F).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIoff\fR\fR
+.ad
+.RS 11n
+An offset into the object that \fIhandle\fR maps.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIcookiep\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBddi_dma_cookie\fR(9S) structure.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_htoc()\fR function takes a \fBDMA\fR handle (established by
+\fBddi_dma_setup\fR(9F)), and fills in the cookie pointed to by \fIcookiep\fR
+with the appropriate address, length, and bus type to be used to program the
+\fBDMA\fR engine.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_htoc()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+Successfully filled in the cookie pointed to by \fIcookiep\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Failed to successfully fill in the cookie.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_htoc()\fR function can be called from user, interrupt, or kernel
+context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_addr_bind_handle\fR(9F),
+\fBddi_dma_addr_setup\fR(9F), \fBddi_dma_buf_bind_handle\fR(9F),
+\fBddi_dma_buf_setup\fR(9F), \fBddi_dma_setup\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBddi_dma_cookie\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_movwin.9f b/usr/src/man/man9f/ddi_dma_movwin.9f
new file mode 100644
index 0000000000..52ebc3170f
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_movwin.9f
@@ -0,0 +1,155 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_MOVWIN 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_movwin \- shift current DMA window
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_movwin\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBoff_t *\fR\fIoffp\fR,
+ \fBuint_t *\fR\fIlenp\fR, \fBddi_dma_cookie_t *\fR\fIcookiep\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_getwin\fR(9F) should be used instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 11n
+The \fBDMA\fR handle filled in by a call to \fBddi_dma_setup\fR(9F).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIoffp\fR\fR
+.ad
+.RS 11n
+A pointer to an offset to set the \fBDMA\fR window to. Upon a successful
+return, it will be filled in with the new offset from the beginning of the
+object resources are allocated for.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlenp\fR\fR
+.ad
+.RS 11n
+A pointer to a value which must either be the current size of the \fBDMA\fR
+window (as known from a call to \fBddi_dma_curwin\fR(9F) or from a previous
+call to \fBddi_dma_movwin()\fR). Upon a successful return, it will be filled in
+with the size, in bytes, of the current window.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIcookiep\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBDMA\fR cookie (see \fBddi_dma_cookie\fR(9S)). Upon a
+successful return, cookiep is filled in just as if an implicit
+\fBddi_dma_htoc\fR(9F) had been made.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_movwin()\fR function shifts the current \fBDMA\fR window. If a
+\fBDMA\fR request allows the system to allocate resources for less than the
+entire object by setting the \fBDDI_DMA_PARTIAL\fR flag in the
+\fBddi_dma_req\fR(9S) structure, the current \fBDMA\fR window can be shifted by
+a call to \fBddi_dma_movwin()\fR.
+.sp
+.LP
+The caller must first determine the current \fBDMA\fR window size by a call to
+\fBddi_dma_curwin\fR(9F). Using the current offset and size of the window thus
+retrieved, the caller of \fBddi_dma_movwin()\fR may change the window onto the
+object by changing the offset by a value which is some multiple of the size of
+the \fBDMA\fR window.
+.sp
+.LP
+The \fBddi_dma_movwin()\fR function takes care of underlying resource
+synchronizations required to \fBshift\fR the window. However, if you want to
+\fBaccess\fR the data prior to or after moving the window, further
+synchronizations using \fBddi_dma_sync\fR(9F) are required.
+.sp
+.LP
+This function is normally called from an interrupt routine. The first
+invocation of the \fBDMA\fR engine is done from the driver. All subsequent
+invocations of the \fBDMA\fR engine are done from the interrupt routine. The
+interrupt routine checks to see if the request has been completed. If it has,
+it returns without invoking another \fBDMA\fR transfer. Otherwise it calls
+\fBddi_dma_movwin()\fR to shift the current window and starts another \fBDMA\fR
+transfer.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_movwin()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+The current length and offset are legal and have been set.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Otherwise.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_movwin()\fR function can be called from user, interrupt, or
+kernel context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_curwin\fR(9F), \fBddi_dma_getwin\fR(9F),
+\fBddi_dma_htoc\fR(9F), \fBddi_dma_setup\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBddi_dma_cookie\fR(9S), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
+.SH WARNINGS
+.sp
+.LP
+The caller must guarantee that the resources used by the object are inactive
+prior to calling this function.
diff --git a/usr/src/man/man9f/ddi_dma_nextseg.9f b/usr/src/man/man9f/ddi_dma_nextseg.9f
new file mode 100644
index 0000000000..7b791d1ada
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_nextseg.9f
@@ -0,0 +1,144 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_NEXTSEG 9F "Apr 04, 2006"
+.SH NAME
+ddi_dma_nextseg \- get next DMA segment
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_nextseg\fR(\fBddi_dma_win_t\fR \fIwin\fR, \fBddi_dma_seg_t\fR \fIseg\fR,
+ \fBddi_dma_seg_t *\fR\fInseg\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_nextcookie\fR(9F) should be used
+instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIwin\fR\fR
+.ad
+.RS 8n
+A \fBDMA\fR window.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIseg\fR\fR
+.ad
+.RS 8n
+The current \fBDMA\fR segment or \fINULL\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fInseg\fR\fR
+.ad
+.RS 8n
+A pointer to the next \fBDMA\fR segment to be filled in. If \fIseg\fR is
+\fINULL\fR, a pointer to the first segment within the specified window is
+returned.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_nextseg()\fR function gets the next \fBDMA\fR segment within the
+specified window \fIwin\fR. If the current segment is \fINULL\fR, the first
+\fBDMA\fR segment within the window is returned.
+.sp
+.LP
+A \fBDMA\fR segment is always required for a \fBDMA\fR window. A \fBDMA\fR
+segment is a contiguous portion of a \fBDMA\fR window (see
+\fBddi_dma_nextwin\fR(9F)) which is entirely addressable by the device for a
+data transfer operation.
+.sp
+.LP
+An example where multiple \fBDMA\fR segments are allocated is where the system
+does not contain \fBDVMA\fR capabilities and the object may be non-contiguous.
+In this example the object will be broken into smaller contiguous \fBDMA\fR
+segments. Another example is where the device has an upper limit on its
+transfer size (for example an 8-bit address register) and has expressed this in
+the \fBDMA\fR limit structure (see \fBddi_dma_lim_sparc\fR(9S) or
+\fBddi_dma_lim_x86\fR(9S)). In this example the object will be broken into
+smaller addressable \fBDMA\fR segments.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_nextseg()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 17n
+Successfully filled in the next segment pointer.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_DONE\fR\fR
+.ad
+.RS 17n
+There is no next segment. The current segment is the final segment within the
+specified window.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_STALE\fR\fR
+.ad
+.RS 17n
+\fIwin\fR does not refer to the currently active window.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_nextseg()\fR function can be called from user, interrupt, or
+kernel context.
+.SH EXAMPLES
+.sp
+.LP
+For an example, see \fBddi_dma_segtocookie\fR(9F).
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_addr_setup\fR(9F), \fBddi_dma_buf_setup\fR(9F),
+\fBddi_dma_nextcookie\fR(9F), \fBddi_dma_nextwin\fR(9F),
+\fBddi_dma_segtocookie\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBddi_dma_lim_sparc\fR(9S), \fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_nextwin.9f b/usr/src/man/man9f/ddi_dma_nextwin.9f
new file mode 100644
index 0000000000..d6beb38562
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_nextwin.9f
@@ -0,0 +1,155 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_NEXTWIN 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_nextwin \- get next DMA window
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_nextwin\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBddi_dma_win_t\fR \fIwin\fR,
+ \fBddi_dma_win_t *\fR\fInwin\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_getwin\fR(9F) should be used instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIhandle\fR\fR
+.ad
+.RS 10n
+A \fBDMA\fR handle.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIwin\fR\fR
+.ad
+.RS 10n
+The current \fBDMA\fR window or \fINULL\fR.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fInwin\fR\fR
+.ad
+.RS 10n
+A pointer to the next \fBDMA\fR window to be filled in. If \fIwin\fR is
+\fINULL\fR, a pointer to the first window within the object is returned.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_nextwin()\fR function shifts the current \fBDMA\fR window
+\fIwin\fR within the object referred to by \fIhandle\fR to the next \fBDMA\fR
+window \fInwin\fR. If the current window is \fINULL\fR, the first window within
+the object is returned. A \fBDMA\fR window is a portion of a \fBDMA\fR object
+or might be the entire object. A \fBDMA\fR window has system resources
+allocated to it and is prepared to accept data transfers. Examples of system
+resources are \fBDVMA\fR mapping resources and intermediate transfer buffer
+resources.
+.sp
+.LP
+All \fBDMA\fR objects require a window. If the \fBDMA\fR window represents the
+whole \fBDMA\fR object it has system resources allocated for the entire data
+transfer. However, if the system is unable to setup the entire \fBDMA\fR object
+due to system resource limitations, the driver writer may allow the system to
+allocate system resources for less than the entire \fBDMA\fR object. This can
+be accomplished by specifying the \fBDDI_DMA_PARTIAL\fR flag as a parameter to
+\fBddi_dma_buf_setup\fR(9F) or \fBddi_dma_addr_setup\fR(9F) or as part of a
+\fBddi_dma_req\fR(9S) structure in a call to \fBddi_dma_setup\fR(9F).
+.sp
+.LP
+Only the window that has resources allocated is valid per object at any one
+time. The currently valid window is the one that was most recently returned
+from \fBddi_dma_nextwin()\fR. Furthermore, because a call to
+\fBddi_dma_nextwin()\fR will reallocate system resources to the new window, the
+previous window will become invalid. It is a \fBsevere\fR error to call
+\fBddi_dma_nextwin()\fR before any transfers into the current window are
+complete.
+.sp
+.LP
+The \fBddi_dma_nextwin()\fR function takes care of underlying memory
+synchronizations required to shift the window. However, if you want to access
+the data before or after moving the window, further synchronizations using
+\fBddi_dma_sync\fR(9F) are required.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_nextwin()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 17n
+Successfully filled in the next window pointer.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_DONE\fR\fR
+.ad
+.RS 17n
+There is no next window. The current window is the final window within the
+specified object.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_STALE\fR\fR
+.ad
+.RS 17n
+\fIwin\fR does not refer to the currently active window.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_nextwin()\fR function can be called from user, interrupt, or
+kernel context.
+.SH EXAMPLES
+.sp
+.LP
+For an example see \fBddi_dma_segtocookie\fR(9F).
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_addr_setup\fR(9F), \fBddi_dma_buf_setup\fR(9F),
+\fBddi_dma_getwin\fR(9F), \fBddi_dma_nextseg\fR(9F),
+\fBddi_dma_segtocookie\fR(9F), \fBddi_dma_sync\fR(9F), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_segtocookie.9f b/usr/src/man/man9f/ddi_dma_segtocookie.9f
new file mode 100644
index 0000000000..26fe29913f
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_segtocookie.9f
@@ -0,0 +1,149 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_SEGTOCOOKIE 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_segtocookie \- convert a DMA segment to a DMA address cookie
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_segtocookie\fR(\fBddi_dma_seg_t\fR \fIseg\fR, \fBoff_t *\fR\fIoffp\fR, \fBoff_t *\fR\fIlenp\fR,
+ \fBddi_dma_cookie_t *\fR\fIcookiep\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. \fBddi_dma_nextcookie\fR(9F) should be used
+instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIseg\fR\fR
+.ad
+.RS 11n
+A \fBDMA\fR segment.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIoffp\fR\fR
+.ad
+.RS 11n
+A pointer to an \fBoff_t\fR. Upon a successful return, it is filled in with the
+offset. This segment is addressing within the object.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlenp\fR\fR
+.ad
+.RS 11n
+The byte length. This segment is addressing within the object.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIcookiep\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBDMA\fR cookie (see \fBddi_dma_cookie\fR(9S)).
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_segtocookie()\fR function takes a \fBDMA\fR segment and fills in
+the cookie pointed to by \fIcookiep\fR with the appropriate address, length,
+and bus type to be used to program the \fBDMA\fR engine.
+\fBddi_dma_segtocookie()\fR also fills in \fI*offp\fR and \fI*lenp\fR, which
+specify the range within the object.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_segtocookie()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+Successfully filled in all values.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Failed to successfully fill in all values.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_segtocookie()\fR function can be called from user, interrupt, or
+kernel context.
+.SH EXAMPLES
+.LP
+\fBExample 1 \fR\fBddi_dma_segtocookie()\fR example
+.sp
+.in +2
+.nf
+for (win = NULL; (retw = ddi_dma_nextwin(handle, win, &nwin)) !=
+ DDI_DMA_DONE; win = nwin) {
+ if (retw != DDI_SUCCESS) {
+ /* do error handling */
+ } else {
+ for (seg = NULL; (rets = ddi_dma_nextseg(nwin, seg, &nseg)) !=
+ DDI_DMA_DONE; seg = nseg) {
+ if (rets != DDI_SUCCESS) {
+
+ /* do error handling */
+ } else {
+ ddi_dma_segtocookie(nseg, &off, &len, &cookie);
+
+ /* program DMA engine */
+ }
+ }
+ }
+}
+.fi
+.in -2
+
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_nextcookie\fR(9F). \fBddi_dma_nextseg\fR(9F),
+\fBddi_dma_nextwin\fR(9F), \fBddi_dma_sync\fR(9F), \fBddi_dma_cookie\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9f/ddi_dma_setup.9f b/usr/src/man/man9f/ddi_dma_setup.9f
new file mode 100644
index 0000000000..fd245658ad
--- /dev/null
+++ b/usr/src/man/man9f/ddi_dma_setup.9f
@@ -0,0 +1,182 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_DMA_SETUP 9F "Jan 16, 2006"
+.SH NAME
+ddi_dma_setup \- setup DMA resources
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+
+
+\fBint\fR \fBddi_dma_setup\fR(\fBdev_info_t *\fR\fIdip\fR, \fBddi_dma_req_t *\fR\fIdmareqp\fR,
+ \fBddi_dma_handle_t *\fR\fIhandlep\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+This interface is obsolete. The functions \fBddi_dma_addr_bind_handle\fR(9F),
+\fBddi_dma_alloc_handle\fR(9F), \fBddi_dma_buf_bind_handle\fR(9F),
+\fBddi_dma_free_handle\fR(9F), and \fBddi_dma_unbind_handle\fR(9F) should be
+used instead.
+.SH PARAMETERS
+.sp
+.ne 2
+.na
+\fB\fIdip\fR\fR
+.ad
+.RS 11n
+A pointer to the device's \fBdev_info\fR structure.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIdmareqp\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBDMA\fR request structure (see \fBddi_dma_req\fR(9S)).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIhandlep\fR\fR
+.ad
+.RS 11n
+A pointer to a \fBDMA\fR handle to be filled in. See below for a discussion of
+a handle. If \fIhandlep\fR is \fINULL\fR, the call to \fBddi_dma_setup()\fR is
+considered an advisory call, in which case no resources are allocated, but a
+value indicating the legality and the feasibility of the request is returned.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_dma_setup()\fR function allocates resources for a memory object such
+that a device can perform \fBDMA\fR to or from that object.
+.sp
+.LP
+A call to \fBddi_dma_setup()\fR informs the system that device referred to by
+\fIdip\fR wishes to perform \fBDMA\fR to or from a memory object. The memory
+object, the device's \fBDMA\fR capabilities, the device driver's policy on
+whether to wait for resources, are all specified in the \fBddi_dma_req\fR
+structure pointed to by \fIdmareqp\fR.
+.sp
+.LP
+A successful call to \fBddi_dma_setup()\fR fills in the value pointed to by
+\fIhandlep\fR. This is an opaque object called a \fBDMA\fR handle. This handle
+is then used in subsequent \fBDMA\fR calls, until \fBddi_dma_free\fR(9F) is
+called.
+.sp
+.LP
+Again a \fBDMA\fR handle is opaque\(emdrivers may \fBnot\fR attempt to
+interpret its value. When a driver wants to enable its \fBDMA\fR engine, it
+must retrieve the appropriate address to supply to its \fBDMA\fR engine using a
+call to \fBddi_dma_htoc\fR(9F), which takes a pointer to a \fBDMA\fR handle
+and returns the appropriate \fBDMA\fR address.
+.sp
+.LP
+When \fBDMA\fR transfer completes, the driver should free up the allocated
+\fBDMA\fR resources by calling \fBddi_dma_free()\fR
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_dma_setup()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_MAPPED\fR\fR
+.ad
+.RS 23n
+Successfully allocated resources for the object. In the case of an
+\fBadvisory\fR call, this indicates that the request is legal.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_PARTIAL_MAP\fR\fR
+.ad
+.RS 23n
+Successfully allocated resources for a \fBpart\fR of the object. This is
+acceptable when partial transfers are allowed using a flag setting in the
+\fBddi_dma_req\fR structure (see \fBddi_dma_req\fR(9S) and
+\fBddi_dma_movwin\fR(9F)).
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_NORESOURCES\fR\fR
+.ad
+.RS 23n
+When no resources are available.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_NOMAPPING\fR\fR
+.ad
+.RS 23n
+The object cannot be reached by the device requesting the resources.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_DMA_TOOBIG\fR\fR
+.ad
+.RS 23n
+The object is too big and exceeds the available resources. The maximum size
+varies depending on machine and configuration.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_dma_setup()\fR function can be called from user, interrupt, or
+kernel context, except when the \fBdmar_fp\fR member of the \fBddi_dma_req\fR
+structure pointed to by \fIdmareqp\fR is set to \fBDDI_DMA_SLEEP\fR, in which
+case it cannot be called from interrupt context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_addr_bind_handle\fR(9F),
+\fBddi_dma_alloc_handle\fR(9F), \fBddi_dma_buf_bind_handle\fR(9F),
+\fBddi_dma_free_handle\fR(9F),
+\fBddi_dma_unbind_handle\fR(9F)\fBddi_dma_addr_setup\fR(9F),
+\fBddi_dma_buf_setup\fR(9F), \fBddi_dma_free\fR(9F), \fBddi_dma_htoc\fR(9F),
+\fBddi_dma_movwin\fR(9F), \fBddi_dma_sync\fR(9F), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
+.SH NOTES
+.sp
+.LP
+The construction of the \fBddi_dma_req\fR structure is complicated. Use of the
+provided interface functions such as \fBddi_dma_buf_setup\fR(9F) simplifies
+this task.
diff --git a/usr/src/man/man9f/ddi_dmae.9f b/usr/src/man/man9f/ddi_dmae.9f
index e54621aa15..449b3a965a 100644
--- a/usr/src/man/man9f/ddi_dmae.9f
+++ b/usr/src/man/man9f/ddi_dmae.9f
@@ -1,10 +1,9 @@
'\" te
.\" Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
-.\" Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH DDI_DMAE 9F "Feb 02, 2012"
+.TH DDI_DMAE 9F "Apr 04, 2006"
.SH NAME
ddi_dmae, ddi_dmae_alloc, ddi_dmae_release, ddi_dmae_prog, ddi_dmae_disable,
ddi_dmae_enable, ddi_dmae_stop, ddi_dmae_getcnt, ddi_dmae_1stparty,
@@ -140,8 +139,8 @@ A pointer to a \fBDMA\fR engine request structure. See \fBddi_dmae_req\fR(9S).
\fB\fIcookiep\fR\fR
.ad
.RS 12n
-A pointer to a \fBddi_dma_cookie\fR(9S) object,
-which contains the address and count.
+A pointer to a \fBddi_dma_cookie\fR(9S) object, obtained from
+\fBddi_dma_segtocookie\fR(9F), which contains the address and count.
.RE
.sp
@@ -186,7 +185,8 @@ functions:
If the device is capable of acting as a true bus master, then the driver should
program the device's \fBDMA\fR registers directly and not make use of the
\fBDMA\fR engine functions described here. The driver should obtain the
-\fBDMA\fR address and count from \fBddi_dma_cookie\fR(9S).
+\fBDMA\fR address and count from \fBddi_dma_segtocookie\fR(9F). See
+\fBddi_dma_cookie\fR(9S) for a description of a \fBDMA\fR cookie.
.RE
.sp
@@ -254,15 +254,15 @@ count. Once the channel has been programmed, subsequent calls to
no changes to the programming are required other than the address and count
values. It disables the channel prior to setup, and enables the channel before
returning. The \fBDMA\fR address and count are specified by passing
-\fBddi_dmae_prog()\fR a \fBDMA\fR cookie.
+\fBddi_dmae_prog()\fR a cookie obtained from \fBddi_dma_segtocookie\fR(9F).
Other \fBDMA\fR engine parameters are specified by the \fBDMA\fR engine request
structure passed in through \fIdmaereqp\fR. The fields of that structure are
documented in \fBddi_dmae_req\fR(9S).
.sp
.LP
Before using \fBddi_dmae_prog()\fR, you must allocate system \fBDMA\fR
-resources using \fBDMA\fR setup functions such as \fBddi_dma_mem_alloc\fR(9F).
-\fBddi_dma_addr_bind_handle\fR(9F) can then be used to retrieve a cookie which
+resources using \fBDMA\fR setup functions such as \fBddi_dma_buf_setup\fR(9F).
+\fBddi_dma_segtocookie\fR(9F) can then be used to retrieve a cookie which
contains the address and count. Then this cookie is passed to
\fBddi_dmae_prog()\fR.
.SS "\fBddi_dmae_disable()\fR"
@@ -299,7 +299,7 @@ When operating in \fBddi_dmae_1stparty()\fR mode, the \fBDMA\fR channel must
first be allocated using \fBddi_dmae_alloc()\fR and then configured using
\fBddi_dmae_1stparty()\fR. The driver then programs the device to perform the
I/O, including the necessary \fBDMA\fR address and count values obtained from
-the \fBddi_dma_cookie\fR(9S).
+\fBddi_dma_segtocookie\fR(9F).
.SS "\fBddi_dmae_getlim()\fR"
.sp
.LP
@@ -313,7 +313,8 @@ engine. Drivers for devices that perform their own bus mastering or use
first-party \fBDMA\fR must create and initialize their own \fBDMA\fR limit
structures; they should not use \fBddi_dmae_getlim()\fR. The \fBDMA\fR limit
structure must be passed to the \fBDMA\fR setup routines so that they will know
-how to break the \fBDMA\fR request into windows. If the device has any
+how to break the \fBDMA\fR request into windows and segments (see
+\fBddi_dma_nextseg\fR(9F) and \fBddi_dma_nextwin\fR(9F)). If the device has any
particular restrictions on transfer size or granularity (such as the size of
disk sector), the driver should further restrict the values in the structure
members before passing them to the \fBDMA\fR setup routines. The driver must
@@ -392,6 +393,7 @@ Architecture x86
.LP
\fBisa\fR(4), \fBattributes\fR(5), \fBddi_dma_buf_setup\fR(9F),
\fBddi_dma_getwin\fR(9F), \fBddi_dma_nextcookie\fR(9F),
-\fBddi_dma_mem_alloc\fR(9F), \fBddi_dma_addr_bind_handle\fR(9F), \fBddi_dma_attr\fR(9S),
+\fBddi_dma_nextseg\fR(9F), \fBddi_dma_nextwin\fR(9F),
+\fBddi_dma_segtocookie\fR(9F), \fBddi_dma_setup\fR(9F), \fBddi_dma_attr\fR(9S),
\fBddi_dma_cookie\fR(9S), \fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S),
\fBddi_dmae_req\fR(9S)
diff --git a/usr/src/man/man9f/ddi_iopb_alloc.9f b/usr/src/man/man9f/ddi_iopb_alloc.9f
new file mode 100644
index 0000000000..fbbbb0ca70
--- /dev/null
+++ b/usr/src/man/man9f/ddi_iopb_alloc.9f
@@ -0,0 +1,163 @@
+'\" te
+.\" Copyright (c) 2006, Sun Microsystems, Inc.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_IOPB_ALLOC 9F "Apr 04, 2006"
+.SH NAME
+ddi_iopb_alloc, ddi_iopb_free \- allocate and free non-sequentially accessed
+memory
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+\fBint\fR \fBddi_iopb_alloc\fR(\fBdev_info_t *\fR\fIdip\fR, \fBddi_dma_lim_t *\fR\fIlimits\fR,
+ \fBuint_t\fR \fIlength\fR, \fBcaddr_t *\fR\fIiopbp\fR);
+.fi
+
+.LP
+.nf
+\fBvoid\fR \fBddi_iopb_free\fR(\fBcaddr_t\fR \fIiopb\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+These interfaces are obsolete. Use \fBddi_dma_mem_alloc\fR(9F) instead of
+\fBddi_iopb_alloc()\fR. Use \fBddi_dma_mem_free\fR(9F) instead of
+\fBddi_iopb_free()\fR.
+.SH PARAMETERS
+.SS "\fBddi_iopb_alloc()\fR"
+.sp
+.ne 2
+.na
+\fB\fIdip\fR\fR
+.ad
+.RS 10n
+A pointer to the device's \fBdev_info\fR structure.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlimits\fR\fR
+.ad
+.RS 10n
+A pointer to a \fBDMA \fRlimits structure for this device (see
+\fBddi_dma_lim_sparc\fR(9S) or \fBddi_dma_lim_x86\fR(9S)). If this pointer is
+\fINULL\fR, a default set of \fBDMA \fRlimits is assumed.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlength\fR\fR
+.ad
+.RS 10n
+The length in bytes of the desired allocation.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIiopbp\fR\fR
+.ad
+.RS 10n
+A pointer to a \fBcaddr_t\fR. On a successful return, \fI*iopbp\fR points to
+the allocated storage.
+.RE
+
+.SS "\fBddi_iopb_free()\fR"
+.sp
+.ne 2
+.na
+\fB\fIiopb\fR\fR
+.ad
+.RS 8n
+The \fIiopb\fR returned from a successful call to \fBddi_iopb_alloc()\fR.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_iopb_alloc()\fR function allocates memory for \fBDMA\fR transfers
+and should be used if the device accesses memory in a non-sequential fashion,
+or if synchronization steps using \fBddi_dma_sync\fR(9F) should be as
+lightweight as possible, due to frequent use on small objects. This type of
+access is commonly known as \fIconsistent\fR access. The allocation will obey
+the alignment and padding constraints as specified in the \fIlimits\fR argument
+and other limits imposed by the system.
+.sp
+.LP
+Note that you still must use \fBDMA\fR resource allocation functions (see
+\fBddi_dma_setup\fR(9F)) to establish \fBDMA\fR resources for the memory
+allocated using \fBddi_iopb_alloc()\fR.
+.sp
+.LP
+In order to make the view of a memory object shared between a \fBCPU\fR and a
+\fBDMA\fR device consistent, explicit synchronization steps using
+\fBddi_dma_sync\fR(9F) or \fBddi_dma_free\fR(9F) are still required. The
+\fBDMA\fR resources will be allocated so that these synchronization steps are
+as efficient as possible.
+.sp
+.LP
+The \fBddi_iopb_free()\fR function frees up memory allocated by
+\fBddi_iopb_alloc()\fR.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_iopb_alloc()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+Memory successfully allocated.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Allocation failed.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+These functions can be called from user, interrupt, or kernel context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_free\fR(9F), \fBddi_dma_mem_alloc\fR(9F),
+\fBddi_dma_mem_free\fR(9F), \fBddi_dma_setup\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBddi_mem_alloc\fR(9F), \fBddi_dma_lim_sparc\fR(9S),
+\fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
+.SH NOTES
+.sp
+.LP
+This function uses scarce system resources. Use it selectively.
diff --git a/usr/src/man/man9f/ddi_mem_alloc.9f b/usr/src/man/man9f/ddi_mem_alloc.9f
new file mode 100644
index 0000000000..c8baf915f3
--- /dev/null
+++ b/usr/src/man/man9f/ddi_mem_alloc.9f
@@ -0,0 +1,180 @@
+'\" te
+.\" Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
+.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
+.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
+.TH DDI_MEM_ALLOC 9F "Apr 04, 2006"
+.SH NAME
+ddi_mem_alloc, ddi_mem_free \- allocate and free sequentially accessed memory
+.SH SYNOPSIS
+.LP
+.nf
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+\fBint\fR \fBddi_mem_alloc\fR(\fBdev_info_t *\fR\fIdip\fR, \fBddi_dma_lim_t *\fR\fIlimits\fR,
+ \fBuint_t\fR \fIlength\fR, \fBuint_t\fR \fIflags\fR, \fBcaddr_t *\fR\fIkaddrp\fR,
+ \fBuint_t *\fR\fIreal_length\fR);
+.fi
+
+.LP
+.nf
+\fBvoid\fR \fBddi_mem_free\fR(\fBcaddr_t\fR \fIkaddr\fR);
+.fi
+
+.SH INTERFACE LEVEL
+.sp
+.LP
+These interfaces are obsolete. \fBddi_dma_mem_alloc\fR(9F) and
+\fBddi_dma_mem_free\fR(9F) should be used instead.
+.SH PARAMETERS
+.SS "\fBddi_mem_alloc()\fR"
+.sp
+.ne 2
+.na
+\fB\fIdip\fR\fR
+.ad
+.RS 15n
+A pointer to the device's \fBdev_info\fR structure.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlimits\fR\fR
+.ad
+.RS 15n
+A pointer to a \fBDMA\fR limits structure for this device (see
+\fBddi_dma_lim_sparc\fR(9S) or \fBddi_dma_lim_x86\fR(9S)). If this pointer is
+\fINULL\fR, a default set of \fBDMA\fR limits is assumed.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIlength\fR\fR
+.ad
+.RS 15n
+The length in bytes of the desired allocation.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIflags\fR\fR
+.ad
+.RS 15n
+The possible flags \fB1\fR and \fB0\fR are taken to mean, respectively, wait
+until memory is available, or do not wait.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIkaddrp\fR\fR
+.ad
+.RS 15n
+On a successful return, *\fIkaddrp\fR points to the allocated memory.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fIreal_length\fR\fR
+.ad
+.RS 15n
+The length in bytes that was allocated. Alignment and padding requirements may
+cause \fBddi_mem_alloc()\fR to allocate more memory than requested in
+\fIlength\fR.
+.RE
+
+.SS "\fBddi_mem_free()\fR"
+.sp
+.ne 2
+.na
+\fB\fIkaddr\fR\fR
+.ad
+.RS 9n
+The memory returned from a successful call to \fBddi_mem_alloc()\fR.
+.RE
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBddi_mem_alloc()\fR function allocates memory for \fBDMA\fR transfers and
+should be used if the device is performing sequential, unidirectional,
+block-sized and block-aligned transfers to or from memory. This type of access
+is commonly known as \fBstreaming\fR access. The allocation will obey the
+alignment and padding constraints as specified by the \fIlimits\fR argument and
+other limits imposed by the system.
+.sp
+.LP
+Note that you must still use \fBDMA\fR resource allocation functions (see
+\fBddi_dma_setup\fR(9F)) to establish \fBDMA\fR resources for the memory
+allocated using \fBddi_mem_alloc()\fR. \fBddi_mem_alloc()\fR returns the actual
+size of the allocated memory object. Because of padding and alignment
+requirements, the actual size might be larger than the requested size.
+\fBddi_dma_setup\fR(9F) requires the actual length.
+.sp
+.LP
+In order to make the view of a memory object shared between a \fBCPU\fR and a
+\fBDMA\fR device consistent, explicit synchronization steps using
+\fBddi_dma_sync\fR(9F) or \fBddi_dma_free\fR(9F) are required.
+.sp
+.LP
+The \fBddi_mem_free()\fR function frees up memory allocated by
+\fBddi_mem_alloc()\fR.
+.SH RETURN VALUES
+.sp
+.LP
+The \fBddi_mem_alloc()\fR function returns:
+.sp
+.ne 2
+.na
+\fB\fBDDI_SUCCESS\fR\fR
+.ad
+.RS 15n
+Memory successfully allocated.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBDDI_FAILURE\fR\fR
+.ad
+.RS 15n
+Allocation failed.
+.RE
+
+.SH CONTEXT
+.sp
+.LP
+The \fBddi_mem_alloc()\fR function can be called from user, interrupt, or
+kernel context, except when \fIflags\fR is set to \fB1\fR, in which case it
+cannot be called from interrupt context.
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for a description of the following attributes:
+.sp
+
+.sp
+.TS
+box;
+c | c
+l | l .
+ATTRIBUTE TYPE ATTRIBUTE VALUE
+_
+Stability Level Obsolete
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBattributes\fR(5), \fBddi_dma_free\fR(9F), \fBddi_dma_mem_alloc\fR(9F),
+\fBddi_dma_mem_free\fR(9F), \fBddi_dma_setup\fR(9F), \fBddi_dma_sync\fR(9F),
+\fBddi_iopb_alloc\fR(9F), \fBddi_dma_lim_sparc\fR(9S),
+\fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S)
+.sp
+.LP
+\fIWriting Device Drivers\fR
diff --git a/usr/src/man/man9s/ddi_dmae_req.9s b/usr/src/man/man9s/ddi_dmae_req.9s
index 9969daa83b..38b30162f6 100644
--- a/usr/src/man/man9s/ddi_dmae_req.9s
+++ b/usr/src/man/man9s/ddi_dmae_req.9s
@@ -1,10 +1,9 @@
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
-.\" Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH DDI_DMAE_REQ 9S "Feb 06, 2012"
+.TH DDI_DMAE_REQ 9S "Nov 18, 2004"
.SH NAME
ddi_dmae_req \- DMA engine request structure
.SH SYNOPSIS
@@ -107,8 +106,9 @@ Under the second option, the driver chooses to use the chaining feature, in
which case, (a) it should leave the size of the scatter/gather list alone, and
(b) it must set the \fBDMAE_BUF_CHAIN\fR flag in the \fBddi_dmae_req\fR
structure. Before calling \fBddi_dmae_prog()\fR, the driver must \fIprefetch\fR
-cookies until either (1) the end of the DMA window is
-reached, or (2) the size of the
+cookies by repeatedly calling \fBddi_dma_nextseg\fR(9F) and
+\fBddi_dma_segtocookie\fR(9F) until either (1) the end of the DMA window is
+reached (\fBddi_dma_nextseg\fR(9F) returns \fBNULL\fR), or (2) the size of the
scatter/gather list is reached, whichever occurs first. These cookies must be
saved by the driver until they are requested by the nexus driver calling the
driver's \fBnextcookie\fR routine. The driver's \fBnextcookie\fR routine must
@@ -148,8 +148,8 @@ number of segments remaining in the window.
.el o
Second, on some bus architectures, the driver's \fBnextcookie\fR routine can be
called from a high-level interrupt routine. If the cookies were not prefetched,
-the \fBnextcookie\fR routine would have to call \fBDMA\fR functions
-from a high-level interrupt routine, which is not
+the \fBnextcookie\fR routine would have to call \fBddi_dma_nextseg()\fR and
+\fBddi_dma_segtocookie()\fR from a high-level interrupt routine, which is not
recommended.
.RE
When breaking a \fBDMA\fR window into segments, the system arranges for the end
@@ -223,5 +223,5 @@ Architecture x86
.SH SEE ALSO
.sp
.LP
-\fBisa\fR(4), \fBattributes\fR(5),
+\fBisa\fR(4), \fBattributes\fR(5), \fBddi_dma_segtocookie\fR(9F),
\fBddi_dmae\fR(9F), \fBddi_dma_lim_x86\fR(9S), \fBddi_dma_req\fR(9S)
diff --git a/usr/src/pkg/manifests/system-kernel.man9f.inc b/usr/src/pkg/manifests/system-kernel.man9f.inc
index 7851241dff..93dd7e5cdc 100644
--- a/usr/src/pkg/manifests/system-kernel.man9f.inc
+++ b/usr/src/pkg/manifests/system-kernel.man9f.inc
@@ -10,7 +10,6 @@
#
# Copyright 2011, Richard Lowe
-# Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
file path=usr/share/man/man9f/ASSERT.9f
file path=usr/share/man/man9f/Intro.9f
@@ -317,16 +316,29 @@ file path=usr/share/man/man9f/ddi_devid_unregister.9f
file path=usr/share/man/man9f/ddi_devid_valid.9f
file path=usr/share/man/man9f/ddi_devmap_segmap.9f
file path=usr/share/man/man9f/ddi_dma_addr_bind_handle.9f
+file path=usr/share/man/man9f/ddi_dma_addr_setup.9f
file path=usr/share/man/man9f/ddi_dma_alloc_handle.9f
file path=usr/share/man/man9f/ddi_dma_buf_bind_handle.9f
+file path=usr/share/man/man9f/ddi_dma_buf_setup.9f
file path=usr/share/man/man9f/ddi_dma_burstsizes.9f
+file path=usr/share/man/man9f/ddi_dma_coff.9f
+file path=usr/share/man/man9f/ddi_dma_curwin.9f
+file path=usr/share/man/man9f/ddi_dma_devalign.9f
+file path=usr/share/man/man9f/ddi_dma_free.9f
file path=usr/share/man/man9f/ddi_dma_free_handle.9f
+file path=usr/share/man/man9f/ddi_dma_get_attr.9f
file path=usr/share/man/man9f/ddi_dma_getwin.9f
+file path=usr/share/man/man9f/ddi_dma_htoc.9f
file path=usr/share/man/man9f/ddi_dma_mem_alloc.9f
file path=usr/share/man/man9f/ddi_dma_mem_free.9f
+file path=usr/share/man/man9f/ddi_dma_movwin.9f
file path=usr/share/man/man9f/ddi_dma_nextcookie.9f
+file path=usr/share/man/man9f/ddi_dma_nextseg.9f
+file path=usr/share/man/man9f/ddi_dma_nextwin.9f
file path=usr/share/man/man9f/ddi_dma_numwin.9f
+file path=usr/share/man/man9f/ddi_dma_segtocookie.9f
file path=usr/share/man/man9f/ddi_dma_set_sbus64.9f
+file path=usr/share/man/man9f/ddi_dma_setup.9f
file path=usr/share/man/man9f/ddi_dma_sync.9f
file path=usr/share/man/man9f/ddi_dma_unbind_handle.9f
file path=usr/share/man/man9f/ddi_dmae.9f
@@ -438,8 +450,12 @@ file path=usr/share/man/man9f/ddi_io_rep_putb.9f
file path=usr/share/man/man9f/ddi_io_rep_putl.9f
file path=usr/share/man/man9f/ddi_io_rep_putw.9f
file path=usr/share/man/man9f/ddi_iomin.9f
+file path=usr/share/man/man9f/ddi_iopb_alloc.9f
+file path=usr/share/man/man9f/ddi_iopb_free.9f
file path=usr/share/man/man9f/ddi_log_sysevent.9f
file path=usr/share/man/man9f/ddi_map_regs.9f
+file path=usr/share/man/man9f/ddi_mem_alloc.9f
+file path=usr/share/man/man9f/ddi_mem_free.9f
file path=usr/share/man/man9f/ddi_mem_get16.9f
file path=usr/share/man/man9f/ddi_mem_get32.9f
file path=usr/share/man/man9f/ddi_mem_get64.9f
diff --git a/usr/src/uts/common/io/1394/nx1394.c b/usr/src/uts/common/io/1394/nx1394.c
index 216b70a319..cc710b8417 100644
--- a/usr/src/uts/common/io/1394/nx1394.c
+++ b/usr/src/uts/common/io/1394/nx1394.c
@@ -23,9 +23,8 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* nx1394.c
@@ -73,7 +72,7 @@ struct bus_ops nx1394_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
i_ddi_map_fault, /* XXXX bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
nx1394_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
@@ -392,7 +391,7 @@ nx1394_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
#if defined(DEBUG)
event_name = ndi_event_cookie_to_name(hal->hal_ndi_event_hdl, cookie);
if (event_name == NULL)
- event_name = "";
+ event_name = "";
#endif
TNF_PROBE_4_DEBUG(nx1394_add_eventcall_exit, S1394_TNF_SL_NEXUS_STACK,
"", tnf_opaque, parent_dip, (void *)dip, tnf_opaque, requestor_dip,
@@ -431,7 +430,7 @@ nx1394_remove_eventcall(dev_info_t *dip, ddi_callback_id_t cb_id)
#if defined(DEBUG)
event_name = ndi_event_cookie_to_name(hal->hal_ndi_event_hdl, cookie);
if (event_name == NULL)
- event_name = "";
+ event_name = "";
TNF_PROBE_4_DEBUG(nx1394_remove_eventcall_exit,
S1394_TNF_SL_NEXUS_STACK, "", tnf_opaque, parent_dip, (void *)dip,
diff --git a/usr/src/uts/common/io/blkdev/blkdev.c b/usr/src/uts/common/io/blkdev/blkdev.c
index 7b722f126c..f7d6cff7a1 100644
--- a/usr/src/uts/common/io/blkdev/blkdev.c
+++ b/usr/src/uts/common/io/blkdev/blkdev.c
@@ -20,8 +20,10 @@
*/
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#include <sys/types.h>
@@ -1678,7 +1680,7 @@ bd_mod_init(struct dev_ops *devops)
NULL, /* bus_add_intrspec (OBSOLETE) */
NULL, /* bus_remove_intrspec (OBSOLETE) */
i_ddi_map_fault, /* bus_map_fault */
- NULL, /* bus_dma_map (OBSOLETE) */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl, /* bus_dma_allochdl */
ddi_dma_freehdl, /* bus_dma_freehdl */
ddi_dma_bindhdl, /* bus_dma_bindhdl */
diff --git a/usr/src/uts/common/io/bofi.c b/usr/src/uts/common/io/bofi.c
index 6554d29f76..80b69bd07b 100644
--- a/usr/src/uts/common/io/bofi.c
+++ b/usr/src/uts/common/io/bofi.c
@@ -22,9 +22,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/types.h>
@@ -164,6 +161,8 @@ static int bofi_errdef_check_w(struct bofi_errstate *,
struct acc_log_elem **);
static int bofi_map(dev_info_t *, dev_info_t *, ddi_map_req_t *,
off_t, off_t, caddr_t *);
+static int bofi_dma_map(dev_info_t *, dev_info_t *,
+ struct ddi_dma_req *, ddi_dma_handle_t *);
static int bofi_dma_allochdl(dev_info_t *, dev_info_t *,
ddi_dma_attr_t *, int (*)(caddr_t), caddr_t,
ddi_dma_handle_t *);
@@ -210,7 +209,7 @@ static struct bus_ops bofi_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ bofi_dma_map,
bofi_dma_allochdl,
bofi_dma_freehdl,
bofi_dma_bindhdl,
@@ -3335,6 +3334,174 @@ xbcopy(void *from, void *to, u_longlong_t len)
/*
+ * our ddi_dma_map routine
+ */
+static int
+bofi_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep)
+{
+ struct bofi_shadow *hp, *xhp;
+ int maxrnumber = 0;
+ int retval = DDI_DMA_NORESOURCES;
+ auto struct ddi_dma_req dmareq;
+ int sleep;
+ struct bofi_shadow *dhashp;
+ struct bofi_shadow *hhashp;
+ ddi_dma_impl_t *mp;
+ unsigned long pagemask = ddi_ptob(rdip, 1) - 1;
+
+ /*
+ * if driver_list is set, only intercept those drivers
+ */
+ if (handlep == NULL || !driver_under_test(rdip))
+ return (save_bus_ops.bus_dma_map(dip, rdip, dmareqp, handlep));
+
+ sleep = (dmareqp->dmar_fp == DDI_DMA_SLEEP) ? KM_SLEEP : KM_NOSLEEP;
+ /*
+ * allocate shadow handle structure and fill it in
+ */
+ hp = kmem_zalloc(sizeof (struct bofi_shadow), sleep);
+ if (hp == NULL)
+ goto error;
+ (void) strncpy(hp->name, ddi_get_name(rdip), NAMESIZE);
+ hp->instance = ddi_get_instance(rdip);
+ hp->dip = rdip;
+ hp->flags = dmareqp->dmar_flags;
+ if (dmareqp->dmar_object.dmao_type == DMA_OTYP_PAGES) {
+ hp->map_flags = B_PAGEIO;
+ hp->map_pp = dmareqp->dmar_object.dmao_obj.pp_obj.pp_pp;
+ } else if (dmareqp->dmar_object.dmao_obj.virt_obj.v_priv != NULL) {
+ hp->map_flags = B_SHADOW;
+ hp->map_pplist = dmareqp->dmar_object.dmao_obj.virt_obj.v_priv;
+ } else {
+ hp->map_flags = 0;
+ }
+ hp->link = NULL;
+ hp->type = BOFI_DMA_HDL;
+ /*
+ * get a kernel virtual mapping
+ */
+ hp->addr = ddi_dmareq_mapin(dmareqp, &hp->mapaddr, &hp->len);
+ if (hp->addr == NULL)
+ goto error;
+ if (bofi_sync_check) {
+ /*
+ * Take a copy and pass pointers to this up to nexus instead.
+ * Data will be copied from the original on explicit
+ * and implicit ddi_dma_sync()
+ *
+ * - maintain page alignment because some devices assume it.
+ */
+ hp->origaddr = hp->addr;
+ hp->allocaddr = ddi_umem_alloc(
+ ((uintptr_t)hp->addr & pagemask) + hp->len, sleep,
+ &hp->umem_cookie);
+ if (hp->allocaddr == NULL)
+ goto error;
+ hp->addr = hp->allocaddr + ((uintptr_t)hp->addr & pagemask);
+ if (dmareqp->dmar_flags & DDI_DMA_WRITE)
+ xbcopy(hp->origaddr, hp->addr, hp->len);
+ dmareq = *dmareqp;
+ dmareq.dmar_object.dmao_size = hp->len;
+ dmareq.dmar_object.dmao_type = DMA_OTYP_VADDR;
+ dmareq.dmar_object.dmao_obj.virt_obj.v_as = &kas;
+ dmareq.dmar_object.dmao_obj.virt_obj.v_addr = hp->addr;
+ dmareq.dmar_object.dmao_obj.virt_obj.v_priv = NULL;
+ dmareqp = &dmareq;
+ }
+ /*
+ * call nexus to do the real work
+ */
+ retval = save_bus_ops.bus_dma_map(dip, rdip, dmareqp, handlep);
+ if (retval != DDI_SUCCESS)
+ goto error2;
+ /*
+ * now set dma_handle to point to real handle
+ */
+ hp->hdl.dma_handle = *handlep;
+ /*
+ * unset DMP_NOSYNC
+ */
+ mp = (ddi_dma_impl_t *)*handlep;
+ mp->dmai_rflags &= ~DMP_NOSYNC;
+ mp->dmai_fault_check = bofi_check_dma_hdl;
+ /*
+ * bind and unbind are cached in devinfo - must overwrite them
+ * - note that our bind and unbind are quite happy dealing with
+ * any handles for this devinfo that were previously allocated
+ */
+ if (save_bus_ops.bus_dma_bindhdl == DEVI(rdip)->devi_bus_dma_bindfunc)
+ DEVI(rdip)->devi_bus_dma_bindfunc = bofi_dma_bindhdl;
+ if (save_bus_ops.bus_dma_unbindhdl ==
+ DEVI(rdip)->devi_bus_dma_unbindfunc)
+ DEVI(rdip)->devi_bus_dma_unbindfunc = bofi_dma_unbindhdl;
+ mutex_enter(&bofi_low_mutex);
+ mutex_enter(&bofi_mutex);
+ /*
+ * get an "rnumber" for this handle - really just seeking to
+ * get a unique number - generally only care for early allocated
+ * handles - so we get as far as INT_MAX, just stay there
+ */
+ dhashp = HDL_DHASH(hp->dip);
+ for (xhp = dhashp->dnext; xhp != dhashp; xhp = xhp->dnext)
+ if (ddi_name_to_major(xhp->name) ==
+ ddi_name_to_major(hp->name) &&
+ xhp->instance == hp->instance &&
+ xhp->type == BOFI_DMA_HDL)
+ if (xhp->rnumber >= maxrnumber) {
+ if (xhp->rnumber == INT_MAX)
+ maxrnumber = INT_MAX;
+ else
+ maxrnumber = xhp->rnumber + 1;
+ }
+ hp->rnumber = maxrnumber;
+ /*
+ * add to dhash, hhash and inuse lists
+ */
+ hp->next = shadow_list.next;
+ shadow_list.next->prev = hp;
+ hp->prev = &shadow_list;
+ shadow_list.next = hp;
+ hhashp = HDL_HHASH(*handlep);
+ hp->hnext = hhashp->hnext;
+ hhashp->hnext->hprev = hp;
+ hp->hprev = hhashp;
+ hhashp->hnext = hp;
+ dhashp = HDL_DHASH(hp->dip);
+ hp->dnext = dhashp->dnext;
+ dhashp->dnext->dprev = hp;
+ hp->dprev = dhashp;
+ dhashp->dnext = hp;
+ /*
+ * chain on any pre-existing errdefs that apply to this
+ * acc_handle and corrupt if required (as there is an implicit
+ * ddi_dma_sync() in this call)
+ */
+ chain_on_errdefs(hp);
+ mutex_exit(&bofi_mutex);
+ mutex_exit(&bofi_low_mutex);
+ return (retval);
+error:
+ if (dmareqp->dmar_fp != DDI_DMA_DONTWAIT) {
+ /*
+ * what to do here? Wait a bit and try again
+ */
+ (void) timeout((void (*)())dmareqp->dmar_fp,
+ dmareqp->dmar_arg, 10);
+ }
+error2:
+ if (hp) {
+ ddi_dmareq_mapout(hp->mapaddr, hp->len, hp->map_flags,
+ hp->map_pp, hp->map_pplist);
+ if (bofi_sync_check && hp->allocaddr)
+ ddi_umem_free(hp->umem_cookie);
+ kmem_free(hp, sizeof (struct bofi_shadow));
+ }
+ return (retval);
+}
+
+
+/*
* our ddi_dma_allochdl routine
*/
static int
@@ -3836,11 +4003,14 @@ bofi_dma_ctl(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags)
{
+ struct bofi_link *lp, *next_lp;
+ struct bofi_errent *ep;
struct bofi_shadow *hp;
struct bofi_shadow *hhashp;
int retval;
int i;
struct bofi_shadow *dummyhp;
+ ddi_dma_impl_t *mp;
/*
* get nexus to do real work
@@ -3919,6 +4089,58 @@ bofi_dma_ctl(dev_info_t *dip, dev_info_t *rdip,
sizeof (struct bofi_shadow *));
kmem_free(dummyhp, sizeof (struct bofi_shadow));
return (retval);
+ case DDI_DMA_FREE:
+ /*
+ * ddi_dma_free case - remove from dhash, hhash and inuse lists
+ */
+ hp->hnext->hprev = hp->hprev;
+ hp->hprev->hnext = hp->hnext;
+ hp->dnext->dprev = hp->dprev;
+ hp->dprev->dnext = hp->dnext;
+ hp->next->prev = hp->prev;
+ hp->prev->next = hp->next;
+ /*
+ * free any errdef link structures tagged on to this
+ * shadow handle
+ */
+ for (lp = hp->link; lp != NULL; ) {
+ next_lp = lp->link;
+ /*
+ * there is an implicit sync_for_cpu on free -
+ * may need to corrupt
+ */
+ ep = lp->errentp;
+ if ((ep->errdef.access_type & BOFI_DMA_R) &&
+ (hp->flags & DDI_DMA_READ) &&
+ (ep->state & BOFI_DEV_ACTIVE)) {
+ do_dma_corrupt(hp, ep, DDI_DMA_SYNC_FORCPU,
+ 0, hp->len);
+ }
+ lp->link = bofi_link_freelist;
+ bofi_link_freelist = lp;
+ lp = next_lp;
+ }
+ hp->link = NULL;
+ mutex_exit(&bofi_mutex);
+ mutex_exit(&bofi_low_mutex);
+
+ if (bofi_sync_check && (hp->flags & DDI_DMA_READ))
+ if (hp->allocaddr)
+ xbcopy(hp->addr, hp->origaddr, hp->len);
+ ddi_dmareq_mapout(hp->mapaddr, hp->len, hp->map_flags,
+ hp->map_pp, hp->map_pplist);
+ if (bofi_sync_check && hp->allocaddr)
+ ddi_umem_free(hp->umem_cookie);
+ kmem_free(hp, sizeof (struct bofi_shadow));
+ return (retval);
+ case DDI_DMA_MOVWIN:
+ mp = (ddi_dma_impl_t *)handle;
+ mp->dmai_rflags &= ~DMP_NOSYNC;
+ break;
+ case DDI_DMA_NEXTWIN:
+ mp = (ddi_dma_impl_t *)handle;
+ mp->dmai_rflags &= ~DMP_NOSYNC;
+ break;
default:
break;
}
diff --git a/usr/src/uts/common/io/fcoe/fcoe.c b/usr/src/uts/common/io/fcoe/fcoe.c
index f2550c3008..5c58dfb01c 100644
--- a/usr/src/uts/common/io/fcoe/fcoe.c
+++ b/usr/src/uts/common/io/fcoe/fcoe.c
@@ -22,9 +22,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* The following notice accompanied the original version of this file:
@@ -159,7 +156,7 @@ static struct bus_ops fcoe_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
i_ddi_map_fault, /* bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl, /* bus_dma_allochdl */
ddi_dma_freehdl, /* bus_dma_freehdl */
ddi_dma_bindhdl, /* bus_dma_bindhdl */
diff --git a/usr/src/uts/common/io/fdc.c b/usr/src/uts/common/io/fdc.c
index fdfc73a4fa..444b6b46e5 100644
--- a/usr/src/uts/common/io/fdc.c
+++ b/usr/src/uts/common/io/fdc.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
@@ -217,7 +214,7 @@ struct bus_ops fdc_bus_ops = {
0, /* int (*bus_add_intrspec)(); */
0, /* void (*bus_remove_intrspec)(); */
i_ddi_map_fault,
- 0,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/common/io/fibre-channel/impl/fctl.c b/usr/src/uts/common/io/fibre-channel/impl/fctl.c
index 634de6c6dd..747df29d08 100644
--- a/usr/src/uts/common/io/fibre-channel/impl/fctl.c
+++ b/usr/src/uts/common/io/fibre-channel/impl/fctl.c
@@ -21,11 +21,7 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- */
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
-/*
+ *
* Fibre channel Transport Library (fctl)
*
* Function naming conventions:
@@ -176,7 +172,7 @@ static struct bus_ops fctl_fca_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
i_ddi_map_fault, /* bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl, /* bus_dma_allochdl */
ddi_dma_freehdl, /* bus_dma_freehdl */
ddi_dma_bindhdl, /* bus_dma_bindhdl */
diff --git a/usr/src/uts/common/io/pci-ide/pci-ide.c b/usr/src/uts/common/io/pci-ide/pci-ide.c
index 7afa702ca4..c885fed6a0 100644
--- a/usr/src/uts/common/io/pci-ide/pci-ide.c
+++ b/usr/src/uts/common/io/pci-ide/pci-ide.c
@@ -21,9 +21,7 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
+
/*
* PCI-IDE bus nexus driver
@@ -131,7 +129,7 @@ struct bus_ops pciide_bus_ops = {
0,
0,
i_ddi_map_fault,
- 0,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/common/io/pciex/pcieb.c b/usr/src/uts/common/io/pciex/pcieb.c
index e01f132156..0aba544755 100644
--- a/usr/src/uts/common/io/pciex/pcieb.c
+++ b/usr/src/uts/common/io/pciex/pcieb.c
@@ -21,9 +21,6 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* Common x86 and SPARC PCI-E to PCI bus bridge nexus driver
@@ -99,7 +96,7 @@ static struct bus_ops pcieb_bus_ops = {
0,
0,
i_ddi_map_fault,
- 0,
+ ddi_dma_map,
pcieb_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/common/io/pshot.c b/usr/src/uts/common/io/pshot.c
index bc5c328d6b..a1d69ea9ae 100644
--- a/usr/src/uts/common/io/pshot.c
+++ b/usr/src/uts/common/io/pshot.c
@@ -22,9 +22,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* pseudo bus nexus driver
@@ -308,7 +305,7 @@ static struct bus_ops pshot_bus_ops = {
NULL, /* bus_add_interspec */
NULL, /* bus_remove_interspec */
i_ddi_map_fault, /* bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl, /* bus_dma_allochdl */
ddi_dma_freehdl, /* bus_dma_freehdl */
ddi_dma_bindhdl, /* bus_dma_bindhdl */
diff --git a/usr/src/uts/common/io/scsi/impl/scsi_hba.c b/usr/src/uts/common/io/scsi/impl/scsi_hba.c
index 252bd5316e..6d9c00840f 100644
--- a/usr/src/uts/common/io/scsi/impl/scsi_hba.c
+++ b/usr/src/uts/common/io/scsi/impl/scsi_hba.c
@@ -21,7 +21,6 @@
/*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#include <sys/note.h>
@@ -294,7 +293,7 @@ static struct bus_ops scsi_hba_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
scsi_hba_map_fault, /* bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl, /* bus_dma_allochdl */
ddi_dma_freehdl, /* bus_dma_freehdl */
ddi_dma_bindhdl, /* bus_dma_bindhdl */
diff --git a/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c b/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c
index 9ca1fa0f54..beba53c65f 100644
--- a/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c
+++ b/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c
@@ -22,9 +22,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* The Data Transfer Interface driver for Host Wire Adapter device
@@ -255,7 +252,7 @@ static struct bus_ops hwahc_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
NULL, /* bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/common/io/usb/usb_ia/usb_ia.c b/usr/src/uts/common/io/usb/usb_ia/usb_ia.c
index 243b995ed7..579aae37a7 100644
--- a/usr/src/uts/common/io/usb/usb_ia/usb_ia.c
+++ b/usr/src/uts/common/io/usb/usb_ia/usb_ia.c
@@ -22,9 +22,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
@@ -133,7 +130,7 @@ static struct bus_ops usb_ia_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
NULL, /* XXXX bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/common/io/usb/usb_mid/usb_mid.c b/usr/src/uts/common/io/usb/usb_mid/usb_mid.c
index faacf41a79..7c6b507b72 100644
--- a/usr/src/uts/common/io/usb/usb_mid/usb_mid.c
+++ b/usr/src/uts/common/io/usb/usb_mid/usb_mid.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
@@ -145,7 +142,7 @@ static struct bus_ops usb_mid_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
NULL, /* XXXX bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/common/io/usb/usba/hubdi.c b/usr/src/uts/common/io/usb/usba/hubdi.c
index de454de41c..23ab998f0e 100644
--- a/usr/src/uts/common/io/usb/usba/hubdi.c
+++ b/usr/src/uts/common/io/usb/usba/hubdi.c
@@ -20,7 +20,6 @@
*/
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
/*
@@ -113,7 +112,7 @@ struct bus_ops usba_hubdi_busops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
usba_hubdi_map_fault, /* bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/common/io/warlock/ddi_dki_comm.inc b/usr/src/uts/common/io/warlock/ddi_dki_comm.inc
index 75e51bdbbb..4667eddcb0 100644
--- a/usr/src/uts/common/io/warlock/ddi_dki_comm.inc
+++ b/usr/src/uts/common/io/warlock/ddi_dki_comm.inc
@@ -23,9 +23,7 @@
* All rights reserved. Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ddi_dki_comm.inc - Part of a pseudo-kernel to use when analyzing drivers
@@ -190,6 +188,22 @@ ddi_dma_setup(
}
int
+ddi_dma_pp_setup(
+ dev_info_t *a,
+ struct page *b,
+ off_t c,
+ uint_t d,
+ uint_t e,
+ int (*fp)(),
+ caddr_t f,
+ ddi_dma_lim_t *g,
+ ddi_dma_handle_t *h)
+{
+ struct bus_ops *ops;
+ (*ops->bus_dma_map)(0, 0, 0, 0);
+}
+
+int
ddi_dma_mctl(dev_info_t *a, dev_info_t *b, ddi_dma_handle_t c,
enum ddi_dma_ctlops d, off_t *e, size_t *f, caddr_t *g,
uint_t h)
@@ -220,6 +234,35 @@ ddi_dma_coff(ddi_dma_handle_t h, ddi_dma_cookie_t *c, off_t *o)
}
int
+ddi_dma_movwin(ddi_dma_handle_t h, off_t *o, size_t *l, ddi_dma_cookie_t *c)
+{
+ struct bus_ops *ops;
+ (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0);
+}
+
+int
+ddi_dma_curwin(ddi_dma_handle_t h, off_t *o, size_t *l)
+{
+ struct bus_ops *ops;
+ (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0);
+}
+
+int
+ddi_dma_nextwin(register ddi_dma_handle_t h, ddi_dma_win_t win,
+ ddi_dma_win_t *nwin)
+{
+ struct bus_ops *ops;
+ (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0);
+}
+
+int
+ddi_dma_nextseg(ddi_dma_win_t win, ddi_dma_seg_t seg, ddi_dma_seg_t *nseg)
+{
+ struct bus_ops *ops;
+ (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0);
+}
+
+int
ddi_dma_get_error(ddi_dma_handle_t h, uint_t len, caddr_t errblk)
{
struct bus_ops *ops;
diff --git a/usr/src/uts/common/os/devcfg.c b/usr/src/uts/common/os/devcfg.c
index d11c6fb7b7..b2f6db6cdd 100644
--- a/usr/src/uts/common/os/devcfg.c
+++ b/usr/src/uts/common/os/devcfg.c
@@ -20,8 +20,9 @@
*/
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+/*
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#include <sys/note.h>
@@ -3184,6 +3185,7 @@ ddi_optimize_dtree(dev_info_t *devi)
* Set the unoptimized values
*/
DEVI(devi)->devi_bus_map_fault = pdevi;
+ DEVI(devi)->devi_bus_dma_map = pdevi;
DEVI(devi)->devi_bus_dma_allochdl = pdevi;
DEVI(devi)->devi_bus_dma_freehdl = pdevi;
DEVI(devi)->devi_bus_dma_bindhdl = pdevi;
@@ -3210,6 +3212,11 @@ ddi_optimize_dtree(dev_info_t *devi)
"bus_map_fault");
}
+ if (ddi_dma_map == b->bus_dma_map) {
+ DEVI(devi)->devi_bus_dma_map = pdevi->devi_bus_dma_map;
+ debug_dtree(devi, DEVI(devi)->devi_bus_dma_map, "bus_dma_map");
+ }
+
if (ddi_dma_allochdl == b->bus_dma_allochdl) {
DEVI(devi)->devi_bus_dma_allochdl =
pdevi->devi_bus_dma_allochdl;
diff --git a/usr/src/uts/common/os/sunddi.c b/usr/src/uts/common/os/sunddi.c
index 8daea07d18..ee3fa51b95 100644
--- a/usr/src/uts/common/os/sunddi.c
+++ b/usr/src/uts/common/os/sunddi.c
@@ -21,7 +21,6 @@
/*
* Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#include <sys/note.h>
@@ -737,6 +736,145 @@ static ddi_dma_lim_t standard_limits = {
#endif
+int
+ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp,
+ ddi_dma_handle_t *handlep)
+{
+ int (*funcp)() = ddi_dma_map;
+ struct bus_ops *bop;
+#if defined(__sparc)
+ auto ddi_dma_lim_t dma_lim;
+
+ if (dmareqp->dmar_limits == (ddi_dma_lim_t *)0) {
+ dma_lim = standard_limits;
+ } else {
+ dma_lim = *dmareqp->dmar_limits;
+ }
+ dmareqp->dmar_limits = &dma_lim;
+#endif
+#if defined(__x86)
+ if (dmareqp->dmar_limits == (ddi_dma_lim_t *)0)
+ return (DDI_FAILURE);
+#endif
+
+ /*
+ * Handle the case that the requester is both a leaf
+ * and a nexus driver simultaneously by calling the
+ * requester's bus_dma_map function directly instead
+ * of ddi_dma_map.
+ */
+ bop = DEVI(dip)->devi_ops->devo_bus_ops;
+ if (bop && bop->bus_dma_map)
+ funcp = bop->bus_dma_map;
+ return ((*funcp)(dip, dip, dmareqp, handlep));
+}
+
+int
+ddi_dma_addr_setup(dev_info_t *dip, struct as *as, caddr_t addr, size_t len,
+ uint_t flags, int (*waitfp)(), caddr_t arg,
+ ddi_dma_lim_t *limits, ddi_dma_handle_t *handlep)
+{
+ int (*funcp)() = ddi_dma_map;
+ ddi_dma_lim_t dma_lim;
+ struct ddi_dma_req dmareq;
+ struct bus_ops *bop;
+
+ if (len == 0) {
+ return (DDI_DMA_NOMAPPING);
+ }
+ if (limits == (ddi_dma_lim_t *)0) {
+ dma_lim = standard_limits;
+ } else {
+ dma_lim = *limits;
+ }
+ dmareq.dmar_limits = &dma_lim;
+ dmareq.dmar_flags = flags;
+ dmareq.dmar_fp = waitfp;
+ dmareq.dmar_arg = arg;
+ dmareq.dmar_object.dmao_size = len;
+ dmareq.dmar_object.dmao_type = DMA_OTYP_VADDR;
+ dmareq.dmar_object.dmao_obj.virt_obj.v_as = as;
+ dmareq.dmar_object.dmao_obj.virt_obj.v_addr = addr;
+ dmareq.dmar_object.dmao_obj.virt_obj.v_priv = NULL;
+
+ /*
+ * Handle the case that the requester is both a leaf
+ * and a nexus driver simultaneously by calling the
+ * requester's bus_dma_map function directly instead
+ * of ddi_dma_map.
+ */
+ bop = DEVI(dip)->devi_ops->devo_bus_ops;
+ if (bop && bop->bus_dma_map)
+ funcp = bop->bus_dma_map;
+
+ return ((*funcp)(dip, dip, &dmareq, handlep));
+}
+
+int
+ddi_dma_buf_setup(dev_info_t *dip, struct buf *bp, uint_t flags,
+ int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits,
+ ddi_dma_handle_t *handlep)
+{
+ int (*funcp)() = ddi_dma_map;
+ ddi_dma_lim_t dma_lim;
+ struct ddi_dma_req dmareq;
+ struct bus_ops *bop;
+
+ if (limits == (ddi_dma_lim_t *)0) {
+ dma_lim = standard_limits;
+ } else {
+ dma_lim = *limits;
+ }
+ dmareq.dmar_limits = &dma_lim;
+ dmareq.dmar_flags = flags;
+ dmareq.dmar_fp = waitfp;
+ dmareq.dmar_arg = arg;
+ dmareq.dmar_object.dmao_size = (uint_t)bp->b_bcount;
+
+ if (bp->b_flags & B_PAGEIO) {
+ dmareq.dmar_object.dmao_type = DMA_OTYP_PAGES;
+ dmareq.dmar_object.dmao_obj.pp_obj.pp_pp = bp->b_pages;
+ dmareq.dmar_object.dmao_obj.pp_obj.pp_offset =
+ (uint_t)(((uintptr_t)bp->b_un.b_addr) & MMU_PAGEOFFSET);
+ } else {
+ dmareq.dmar_object.dmao_type = DMA_OTYP_BUFVADDR;
+ dmareq.dmar_object.dmao_obj.virt_obj.v_addr = bp->b_un.b_addr;
+ if (bp->b_flags & B_SHADOW) {
+ dmareq.dmar_object.dmao_obj.virt_obj.v_priv =
+ bp->b_shadow;
+ } else {
+ dmareq.dmar_object.dmao_obj.virt_obj.v_priv = NULL;
+ }
+
+ /*
+ * If the buffer has no proc pointer, or the proc
+ * struct has the kernel address space, or the buffer has
+ * been marked B_REMAPPED (meaning that it is now
+ * mapped into the kernel's address space), then
+ * the address space is kas (kernel address space).
+ */
+ if ((bp->b_proc == NULL) || (bp->b_proc->p_as == &kas) ||
+ (bp->b_flags & B_REMAPPED)) {
+ dmareq.dmar_object.dmao_obj.virt_obj.v_as = 0;
+ } else {
+ dmareq.dmar_object.dmao_obj.virt_obj.v_as =
+ bp->b_proc->p_as;
+ }
+ }
+
+ /*
+ * Handle the case that the requester is both a leaf
+ * and a nexus driver simultaneously by calling the
+ * requester's bus_dma_map function directly instead
+ * of ddi_dma_map.
+ */
+ bop = DEVI(dip)->devi_ops->devo_bus_ops;
+ if (bop && bop->bus_dma_map)
+ funcp = bop->bus_dma_map;
+
+ return ((*funcp)(dip, dip, &dmareq, handlep));
+}
+
#if !defined(__sparc)
/*
* Request bus_dma_ctl parent to fiddle with a dma request.
@@ -770,18 +908,79 @@ ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
#define HD ((ddi_dma_impl_t *)h)->dmai_rdip
+int
+ddi_dma_kvaddrp(ddi_dma_handle_t h, off_t off, size_t len, caddr_t *kp)
+{
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_KVADDR, &off, &len, kp, 0));
+}
+
+int
+ddi_dma_htoc(ddi_dma_handle_t h, off_t o, ddi_dma_cookie_t *c)
+{
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_HTOC, &o, 0, (caddr_t *)c, 0));
+}
+
+int
+ddi_dma_coff(ddi_dma_handle_t h, ddi_dma_cookie_t *c, off_t *o)
+{
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_COFF,
+ (off_t *)c, 0, (caddr_t *)o, 0));
+}
+
+int
+ddi_dma_movwin(ddi_dma_handle_t h, off_t *o, size_t *l, ddi_dma_cookie_t *c)
+{
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_MOVWIN, o,
+ l, (caddr_t *)c, 0));
+}
+
+int
+ddi_dma_curwin(ddi_dma_handle_t h, off_t *o, size_t *l)
+{
+ if ((((ddi_dma_impl_t *)h)->dmai_rflags & DDI_DMA_PARTIAL) == 0)
+ return (DDI_FAILURE);
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_REPWIN, o, l, 0, 0));
+}
+
+int
+ddi_dma_nextwin(ddi_dma_handle_t h, ddi_dma_win_t win,
+ ddi_dma_win_t *nwin)
+{
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_NEXTWIN, (off_t *)&win, 0,
+ (caddr_t *)nwin, 0));
+}
+
+int
+ddi_dma_nextseg(ddi_dma_win_t win, ddi_dma_seg_t seg, ddi_dma_seg_t *nseg)
+{
+ ddi_dma_handle_t h = (ddi_dma_handle_t)win;
+
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_NEXTSEG, (off_t *)&win,
+ (size_t *)&seg, (caddr_t *)nseg, 0));
+}
+
+#if (defined(__i386) && !defined(__amd64)) || defined(__sparc)
/*
- * This routine is left in place to satisfy link dependencies
- * for any 3rd party nexus drivers that rely on it. It is never
- * called, though.
+ * This routine is Obsolete and should be removed from ALL architectures
+ * in a future release of Solaris.
+ *
+ * It is deliberately NOT ported to amd64; please fix the code that
+ * depends on this routine to use ddi_dma_nextcookie(9F).
+ *
+ * NOTE: even though we fixed the pointer through a 32-bit param issue (the fix
+ * is a side effect to some other cleanup), we're still not going to support
+ * this interface on x64.
*/
-/*ARGSUSED*/
int
-ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
- struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep)
+ddi_dma_segtocookie(ddi_dma_seg_t seg, off_t *o, off_t *l,
+ ddi_dma_cookie_t *cookiep)
{
- return (DDI_FAILURE);
+ ddi_dma_handle_t h = (ddi_dma_handle_t)seg;
+
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_SEGTOC, o, (size_t *)l,
+ (caddr_t *)cookiep, 0));
}
+#endif /* (__i386 && !__amd64) || __sparc */
#if !defined(__sparc)
@@ -791,6 +990,20 @@ ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
*/
int
+ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep)
+{
+ int (*funcp)(dev_info_t *, dev_info_t *, struct ddi_dma_req *,
+ ddi_dma_handle_t *);
+
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_map;
+
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_map;
+ return ((*funcp)(dip, rdip, dmareqp, handlep));
+}
+
+int
ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep)
{
@@ -916,9 +1129,66 @@ ddi_dma_unbind_handle(ddi_dma_handle_t h)
#endif /* !__sparc */
+int
+ddi_dma_free(ddi_dma_handle_t h)
+{
+ return (ddi_dma_mctl(HD, HD, h, DDI_DMA_FREE, 0, 0, 0, 0));
+}
+
+int
+ddi_iopb_alloc(dev_info_t *dip, ddi_dma_lim_t *limp, uint_t len, caddr_t *iopbp)
+{
+ ddi_dma_lim_t defalt;
+ size_t size = len;
+
+ if (!limp) {
+ defalt = standard_limits;
+ limp = &defalt;
+ }
+ return (i_ddi_mem_alloc_lim(dip, limp, size, 0, 0, 0,
+ iopbp, NULL, NULL));
+}
+
+void
+ddi_iopb_free(caddr_t iopb)
+{
+ i_ddi_mem_free(iopb, NULL);
+}
+
+int
+ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length,
+ uint_t flags, caddr_t *kaddrp, uint_t *real_length)
+{
+ ddi_dma_lim_t defalt;
+ size_t size = length;
+
+ if (!limits) {
+ defalt = standard_limits;
+ limits = &defalt;
+ }
+ return (i_ddi_mem_alloc_lim(dip, limits, size, flags & 0x1,
+ 1, 0, kaddrp, real_length, NULL));
+}
+
+void
+ddi_mem_free(caddr_t kaddr)
+{
+ i_ddi_mem_free(kaddr, NULL);
+}
+
/*
- * DMA burst sizes, and transfer minimums
+ * DMA attributes, alignment, burst sizes, and transfer minimums
*/
+int
+ddi_dma_get_attr(ddi_dma_handle_t handle, ddi_dma_attr_t *attrp)
+{
+ ddi_dma_impl_t *dimp = (ddi_dma_impl_t *)handle;
+
+ if (attrp == NULL)
+ return (DDI_FAILURE);
+ *attrp = dimp->dmai_attr;
+ return (DDI_SUCCESS);
+}
int
ddi_dma_burstsizes(ddi_dma_handle_t handle)
@@ -932,6 +1202,26 @@ ddi_dma_burstsizes(ddi_dma_handle_t handle)
}
int
+ddi_dma_devalign(ddi_dma_handle_t handle, uint_t *alignment, uint_t *mineffect)
+{
+ ddi_dma_impl_t *dimp = (ddi_dma_impl_t *)handle;
+
+ if (!dimp || !alignment || !mineffect)
+ return (DDI_FAILURE);
+ if (!(dimp->dmai_rflags & DDI_DMA_SBUS_64BIT)) {
+ *alignment = 1 << ddi_ffs(dimp->dmai_burstsizes);
+ } else {
+ if (dimp->dmai_burstsizes & 0xff0000) {
+ *alignment = 1 << ddi_ffs(dimp->dmai_burstsizes >> 16);
+ } else {
+ *alignment = 1 << ddi_ffs(dimp->dmai_burstsizes);
+ }
+ }
+ *mineffect = dimp->dmai_minxfer;
+ return (DDI_SUCCESS);
+}
+
+int
ddi_iomin(dev_info_t *a, int i, int stream)
{
int r;
diff --git a/usr/src/uts/common/sys/ddi_impldefs.h b/usr/src/uts/common/sys/ddi_impldefs.h
index 3380c6b314..0699d1cbce 100644
--- a/usr/src/uts/common/sys/ddi_impldefs.h
+++ b/usr/src/uts/common/sys/ddi_impldefs.h
@@ -20,7 +20,6 @@
*/
/*
* Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#ifndef _SYS_DDI_IMPLDEFS_H
@@ -161,6 +160,7 @@ struct dev_info {
/* logical parents for busop primitives */
struct dev_info *devi_bus_map_fault; /* bus_map_fault parent */
+ struct dev_info *devi_bus_dma_map; /* bus_dma_map parent */
struct dev_info *devi_bus_dma_allochdl; /* bus_dma_newhdl parent */
struct dev_info *devi_bus_dma_freehdl; /* bus_dma_freehdl parent */
struct dev_info *devi_bus_dma_bindhdl; /* bus_dma_bindhdl parent */
diff --git a/usr/src/uts/common/sys/ddi_implfuncs.h b/usr/src/uts/common/sys/ddi_implfuncs.h
index 23413cffef..d095aff6f8 100644
--- a/usr/src/uts/common/sys/ddi_implfuncs.h
+++ b/usr/src/uts/common/sys/ddi_implfuncs.h
@@ -23,9 +23,6 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#ifndef _SYS_DDI_IMPLFUNCS_H
#define _SYS_DDI_IMPLFUNCS_H
@@ -77,6 +74,12 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attributes,
ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
size_t *real_length, ddi_acc_hdl_t *handlep);
+int
+i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits,
+ size_t length, int cansleep, int streaming,
+ ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
+ uint_t *real_length, ddi_acc_hdl_t *handlep);
+
void
i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap);
diff --git a/usr/src/uts/common/sys/ddi_obsolete.h b/usr/src/uts/common/sys/ddi_obsolete.h
index 7123b47af2..f93d89fb7e 100644
--- a/usr/src/uts/common/sys/ddi_obsolete.h
+++ b/usr/src/uts/common/sys/ddi_obsolete.h
@@ -2,9 +2,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#ifndef _SYS_DDI_OBSOLETE_H
#define _SYS_DDI_OBSOLETE_H
@@ -36,9 +33,38 @@ int ddi_iomin(dev_info_t *dip, int initial, int streaming);
extern long strtol(const char *, char **, int);
extern unsigned long strtoul(const char *, char **, int);
-/* we'd really like to remove this; unbundled nexus drivers might have it */
-int ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
- struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
+int ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp,
+ ddi_dma_handle_t *handlep);
+int ddi_dma_addr_setup(dev_info_t *dip, struct as *as, caddr_t addr, size_t len,
+ uint_t flags, int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits,
+ ddi_dma_handle_t *handlep);
+int ddi_dma_buf_setup(dev_info_t *dip, struct buf *bp, uint_t flags,
+ int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits,
+ ddi_dma_handle_t *handlep);
+int ddi_dma_kvaddrp(ddi_dma_handle_t, off_t, size_t, caddr_t *);
+int ddi_dma_htoc(ddi_dma_handle_t handle, off_t off, ddi_dma_cookie_t *cookiep);
+int ddi_dma_coff(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep,
+ off_t *offp);
+int ddi_dma_curwin(ddi_dma_handle_t handle, off_t *offp, size_t *lenp);
+int ddi_dma_nextwin(ddi_dma_handle_t, ddi_dma_win_t, ddi_dma_win_t *);
+int ddi_dma_nextseg(ddi_dma_win_t, ddi_dma_seg_t, ddi_dma_seg_t *);
+int ddi_dma_segtocookie(ddi_dma_seg_t, off_t *, off_t *, ddi_dma_cookie_t *);
+int ddi_dma_free(ddi_dma_handle_t handle);
+int ddi_iopb_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length,
+ caddr_t *iopbp);
+void ddi_iopb_free(caddr_t iopb);
+int ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length,
+ uint_t flags, caddr_t *kaddrp, uint_t *real_length);
+void ddi_mem_free(caddr_t kaddr);
+int ddi_dma_get_attr(ddi_dma_handle_t handle, ddi_dma_attr_t *attrp);
+int ddi_dma_devalign(ddi_dma_handle_t handle, uint_t *alignment,
+ uint_t *mineffect);
+void ddi_dmalim_merge(ddi_dma_lim_t *limit, ddi_dma_lim_t *modifier);
+
+#if defined(__sparc)
+int ddi_dma_movwin(ddi_dma_handle_t, off_t *offp, size_t *lenp,
+ ddi_dma_cookie_t *);
+#endif
uint8_t ddi_mem_get8(ddi_acc_handle_t handle, uint8_t *host_addr);
uint16_t ddi_mem_get16(ddi_acc_handle_t handle, uint16_t *host_addr);
diff --git a/usr/src/uts/common/sys/ddidmareq.h b/usr/src/uts/common/sys/ddidmareq.h
index e7b2b5f30f..aac53a6555 100644
--- a/usr/src/uts/common/sys/ddidmareq.h
+++ b/usr/src/uts/common/sys/ddidmareq.h
@@ -21,9 +21,6 @@
/*
* Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#ifndef _SYS_DDIDMAREQ_H
#define _SYS_DDIDMAREQ_H
@@ -715,21 +712,21 @@ typedef struct ddi_dma_req {
*/
enum ddi_dma_ctlops {
- DDI_DMA_FREE, /* obsolete - do not use */
- DDI_DMA_SYNC, /* obsolete - do not use */
- DDI_DMA_HTOC, /* obsolete - do not use */
- DDI_DMA_KVADDR, /* obsolete - do not use */
- DDI_DMA_MOVWIN, /* obsolete - do not use */
- DDI_DMA_REPWIN, /* obsolete - do not use */
- DDI_DMA_GETERR, /* obsolete - do not use */
- DDI_DMA_COFF, /* obsolete - do not use */
- DDI_DMA_NEXTWIN, /* obsolete - do not use */
- DDI_DMA_NEXTSEG, /* obsolete - do not use */
- DDI_DMA_SEGTOC, /* obsolete - do not use */
+ DDI_DMA_FREE, /* free reference to object */
+ DDI_DMA_SYNC, /* synchronize cache references */
+ DDI_DMA_HTOC, /* return DMA cookie for handle */
+ DDI_DMA_KVADDR, /* return kernel virtual address */
+ DDI_DMA_MOVWIN, /* change mapped DMA window on object */
+ DDI_DMA_REPWIN, /* report current window on DMA object */
+ DDI_DMA_GETERR, /* report any post-transfer DMA errors */
+ DDI_DMA_COFF, /* convert a DMA cookie to an offset */
+ DDI_DMA_NEXTWIN, /* get next window within object */
+ DDI_DMA_NEXTSEG, /* get next segment within window */
+ DDI_DMA_SEGTOC, /* return segment DMA cookie */
DDI_DMA_RESERVE, /* reserve some DVMA range */
DDI_DMA_RELEASE, /* free preallocated DVMA range */
- DDI_DMA_RESETH, /* obsolete - do not use */
- DDI_DMA_CKSYNC, /* obsolete - do not use */
+ DDI_DMA_RESETH, /* reset next cookie ptr in handle */
+ DDI_DMA_CKSYNC, /* sync intermediate buffer to cookies */
DDI_DMA_IOPB_ALLOC, /* get contiguous DMA-able memory */
DDI_DMA_IOPB_FREE, /* return contiguous DMA-able memory */
DDI_DMA_SMEM_ALLOC, /* get contiguous DMA-able memory */
diff --git a/usr/src/uts/common/sys/devops.h b/usr/src/uts/common/sys/devops.h
index 9e2bf1f7cc..6efcdcc257 100644
--- a/usr/src/uts/common/sys/devops.h
+++ b/usr/src/uts/common/sys/devops.h
@@ -22,9 +22,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#ifndef _SYS_DEVOPS_H
#define _SYS_DEVOPS_H
@@ -77,12 +74,10 @@ extern "C" {
* c XXwrite DDI/DKI
* c XXioctl DDI/DKI
* c XXdevmap DDI(Sun)
- * c XXmmap DKI(Obsolete)
+ * c XXmmap DKI
* c XXsegmap DKI
* c XXchpoll DDI/DKI
* c XXprop_op DDI(Sun)
- * c XXaread DDI(Sun)
- * c XXawrite DDI(Sun)
*/
struct cb_ops {
@@ -134,33 +129,14 @@ struct cb_ops {
* they will be called from outside the ddi.
*
* bus_map - Map/unmap/control IU -> device mappings.
- * bus_get_intrspec - obsolete, not called
- * bus_add_intrspec - obsolete, not called
- * bus_remove_intrspec - obsolete, not called
+ * bus_get_intrspec - get interrupt specification by number
+ * bus_add_intrspec - add interrupt specification, return cookie
+ * bus_remove_intrspec - remove interrupt specification
* bus_map_fault - bus fault handler
- * bus_dma_map - obsolete, not called
- * bus_dma_allochdl - allocate a DMA handle
- * bus_dma_freehdl - free a DMA handle
- * bus_dma_bindhdl - bind a DMA handle to physical mapping
- * bus_dma_unbindhdl - unbind a DMA handle to physical mapping
- * bus_dma_flush - flush DMA caches
- * bus_dma_win - access DMA windows
- * bus_dma_ctl - control dma mapping (legacy use only)
+ * bus_dma_map - setup dma mapping
+ * bus_dma_mapctl - control (and free) dma mapping
* bus_ctl - generic control operations
- * bus_prop_op - request for property
- * bus_get_eventcookie - get an event cookie
- * bus_add_eventcall - event call management
- * bus_remove_eventcall - event call management
- * bus_post_event - post an event
- * bus_config - child node configuration
- * bus_unconfig - child node unconfiguration
- * bus_fm_init - FMA support
- * bus_fm_fini - FMA support
- * bus_fm_access_enter - FMA support
- * bus_fm_access_exit - FMA support
- * bus_power - power management
- * bus_intr_op - control interrupt mappings
- * bus_hp_op - hotplug support
+ * bus_prop_op _ request for property
*/
#define BUSO_REV_3 3
diff --git a/usr/src/uts/common/sys/dma_engine.h b/usr/src/uts/common/sys/dma_engine.h
index 80f75ec8ef..7e3e492e8e 100644
--- a/usr/src/uts/common/sys/dma_engine.h
+++ b/usr/src/uts/common/sys/dma_engine.h
@@ -19,11 +19,6 @@
*
* CDDL HEADER END
*/
-
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
-
/*
* Copyright 1998 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -39,6 +34,8 @@
#ifndef _SYS_DMAENGINE_H
#define _SYS_DMAENGINE_H
+#pragma ident "%Z%%M% %I% %E% SMI"
+
#include <sys/types.h>
#include <sys/dditypes.h>
@@ -235,8 +232,9 @@ int ddi_dmae_1stparty(dev_info_t *dip, int chnl);
* ddi_dmae_prog() can have dmaereqp set to NULL if only the address and
* count have to be updated.
*
- * cookiep - pointer to a ddi_dma_cookie object which contains address,
- * count and intermediate memory mapping information.
+ * cookiep - pointer to a ddi_dma_cookie object obtained from
+ * ddi_dma_segtocookie(), which contains address, count and intermediate
+ * memory mapping information.
*/
int ddi_dmae_prog(dev_info_t *dip, struct ddi_dmae_req *dmaereqp,
diff --git a/usr/src/uts/common/sys/sunddi.h b/usr/src/uts/common/sys/sunddi.h
index 1eaf3a4feb..26cafb882f 100644
--- a/usr/src/uts/common/sys/sunddi.h
+++ b/usr/src/uts/common/sys/sunddi.h
@@ -21,7 +21,6 @@
/*
* Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#ifndef _SYS_SUNDDI_H
@@ -1736,6 +1735,10 @@ ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v);
*/
int
+ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
+
+int
ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
diff --git a/usr/src/uts/common/xen/io/xpvd.c b/usr/src/uts/common/xen/io/xpvd.c
index 7c655becbf..b122e03fc1 100644
--- a/usr/src/uts/common/xen/io/xpvd.c
+++ b/usr/src/uts/common/xen/io/xpvd.c
@@ -23,9 +23,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* Host to hypervisor virtual devices nexus driver
@@ -126,7 +123,7 @@ struct bus_ops xpvd_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c b/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c
index 7cf06ba394..35fb4b6af5 100644
--- a/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c
+++ b/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c
@@ -28,9 +28,6 @@
* All rights reserved.
*/
/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
-/*
* This module implements a nexus driver for the ACPI virtual bus.
* It does not handle any of the DDI functions passed up to it by the child
* drivers, but instead allows them to bubble up to the root node.
@@ -90,7 +87,7 @@ static struct bus_ops acpinex_bus_ops = {
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
i_ddi_map_fault, /* bus_map_fault */
- NULL, /* bus_dma_map */
+ ddi_dma_map, /* bus_dma_map */
ddi_dma_allochdl, /* bus_dma_allochdl */
ddi_dma_freehdl, /* bus_dma_freehdl */
ddi_dma_bindhdl, /* bus_dma_bindhdl */
diff --git a/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c b/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c
index b5ab7d9cf6..59c004458b 100644
--- a/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c
+++ b/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c
@@ -21,7 +21,6 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#include <sys/sunddi.h>
@@ -64,6 +63,13 @@ static int amd_iommu_mapobject(iommulib_handle_t handle, dev_info_t *dip,
struct ddi_dma_req *dmareq, ddi_dma_obj_t *dmao);
static int amd_iommu_unmapobject(iommulib_handle_t handle, dev_info_t *dip,
dev_info_t *rdip, ddi_dma_handle_t dma_handle, ddi_dma_obj_t *dmao);
+static int amd_iommu_map(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, struct ddi_dma_req *dmareq,
+ ddi_dma_handle_t *dma_handle);
+static int amd_iommu_mctl(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, ddi_dma_handle_t dma_handle,
+ enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
+ caddr_t *objpp, uint_t cache_flags);
static int unmap_current_window(amd_iommu_t *iommu, dev_info_t *rdip,
ddi_dma_cookie_t *cookie_array, uint_t ccount, int ncookies, int locked);
@@ -106,6 +112,8 @@ struct iommulib_ops amd_iommulib_ops = {
amd_iommu_win,
amd_iommu_mapobject,
amd_iommu_unmapobject,
+ amd_iommu_map,
+ amd_iommu_mctl
};
static kmutex_t amd_iommu_pgtable_lock;
@@ -1888,6 +1896,30 @@ out:
return (error);
}
+/* Obsoleted DMA routines */
+
+/*ARGSUSED*/
+static int
+amd_iommu_map(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, struct ddi_dma_req *dmareq,
+ ddi_dma_handle_t *dma_handle)
+{
+ ASSERT(0);
+ return (iommulib_iommu_dma_map(dip, rdip, dmareq, dma_handle));
+}
+
+/*ARGSUSED*/
+static int
+amd_iommu_mctl(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, ddi_dma_handle_t dma_handle,
+ enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
+ caddr_t *objpp, uint_t cache_flags)
+{
+ ASSERT(0);
+ return (iommulib_iommu_dma_mctl(dip, rdip, dma_handle,
+ request, offp, lenp, objpp, cache_flags));
+}
+
/*ARGSUSED*/
static int
amd_iommu_mapobject(iommulib_handle_t handle, dev_info_t *dip,
diff --git a/usr/src/uts/i86pc/io/immu_dvma.c b/usr/src/uts/i86pc/io/immu_dvma.c
index efc30c3d64..4dfa9c05b4 100644
--- a/usr/src/uts/i86pc/io/immu_dvma.c
+++ b/usr/src/uts/i86pc/io/immu_dvma.c
@@ -26,9 +26,6 @@
* Copyright (c) 2009, Intel Corporation.
* All rights reserved.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* DVMA code
@@ -108,6 +105,13 @@ static int immu_mapobject(iommulib_handle_t handle, dev_info_t *dip,
struct ddi_dma_req *dmareq, ddi_dma_obj_t *dmao);
static int immu_unmapobject(iommulib_handle_t handle, dev_info_t *dip,
dev_info_t *rdip, ddi_dma_handle_t dma_handle, ddi_dma_obj_t *dmao);
+static int immu_map(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, struct ddi_dma_req *dmareq,
+ ddi_dma_handle_t *dma_handle);
+static int immu_mctl(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, ddi_dma_handle_t dma_handle,
+ enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
+ caddr_t *objpp, uint_t cachefl);
/* static Globals */
@@ -150,6 +154,8 @@ struct iommulib_ops immulib_ops = {
immu_win,
immu_mapobject,
immu_unmapobject,
+ immu_map,
+ immu_mctl
};
/*
@@ -3177,3 +3183,24 @@ immu_unmapobject(iommulib_handle_t handle, dev_info_t *dip,
return (DDI_SUCCESS);
return (immu_unmap_dvmaseg(rdip, dmao));
}
+
+/*ARGSUSED*/
+static int
+immu_map(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, struct ddi_dma_req *dmareq,
+ ddi_dma_handle_t *dma_handle)
+{
+ ASSERT(0);
+ return (DDI_FAILURE);
+}
+
+/*ARGSUSED*/
+static int
+immu_mctl(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, ddi_dma_handle_t dma_handle,
+ enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
+ caddr_t *objpp, uint_t cachefl)
+{
+ ASSERT(0);
+ return (DDI_FAILURE);
+}
diff --git a/usr/src/uts/i86pc/io/isa.c b/usr/src/uts/i86pc/io/isa.c
index b94cc6fbb4..d2bb59ca99 100644
--- a/usr/src/uts/i86pc/io/isa.c
+++ b/usr/src/uts/i86pc/io/isa.c
@@ -20,7 +20,6 @@
*/
/*
* Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
/*
@@ -169,7 +168,7 @@ struct bus_ops isa_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
isa_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/i86pc/io/pci/pci.c b/usr/src/uts/i86pc/io/pci/pci.c
index b67b466cd1..d3e4148b40 100644
--- a/usr/src/uts/i86pc/io/pci/pci.c
+++ b/usr/src/uts/i86pc/io/pci/pci.c
@@ -22,9 +22,6 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* Host to PCI local bus driver
@@ -66,7 +63,7 @@ struct bus_ops pci_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/i86pc/io/pciex/npe.c b/usr/src/uts/i86pc/io/pciex/npe.c
index a0728cb7e2..0342d7caf2 100644
--- a/usr/src/uts/i86pc/io/pciex/npe.c
+++ b/usr/src/uts/i86pc/io/pciex/npe.c
@@ -25,10 +25,6 @@
*/
/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
-
-/*
* Host to PCI-Express local bus driver
*/
@@ -91,7 +87,7 @@ struct bus_ops npe_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/i86pc/io/rootnex.c b/usr/src/uts/i86pc/io/rootnex.c
index 10b7fcb84b..ab2ffb503e 100644
--- a/usr/src/uts/i86pc/io/rootnex.c
+++ b/usr/src/uts/i86pc/io/rootnex.c
@@ -24,7 +24,6 @@
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2011 Bayard G. Bell. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
/*
@@ -195,6 +194,8 @@ static int rootnex_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
static int rootnex_map_fault(dev_info_t *dip, dev_info_t *rdip,
struct hat *hat, struct seg *seg, caddr_t addr,
struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
+static int rootnex_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
static int rootnex_dma_allochdl(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
ddi_dma_handle_t *handlep);
@@ -265,7 +266,7 @@ static struct bus_ops rootnex_bus_ops = {
NULL,
NULL,
rootnex_map_fault,
- 0,
+ rootnex_dma_map,
rootnex_dma_allochdl,
rootnex_dma_freehdl,
rootnex_dma_bindhdl,
@@ -337,6 +338,8 @@ static iommulib_nexops_t iommulib_nexops = {
rootnex_coredma_get_sleep_flags,
rootnex_coredma_sync,
rootnex_coredma_win,
+ rootnex_dma_map,
+ rootnex_dma_mctl,
rootnex_coredma_hdl_setprivate,
rootnex_coredma_hdl_getprivate
};
@@ -5000,9 +5003,91 @@ rootnex_coredma_hdl_getprivate(dev_info_t *dip, dev_info_t *rdip,
*/
/*
+ * rootnex_dma_map()
+ * called from ddi_dma_setup()
+ * NO IOMMU in 32 bit mode. The below routines doesn't work in 64 bit mode.
+ */
+/* ARGSUSED */
+static int
+rootnex_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep)
+{
+#if defined(__amd64)
+ /*
+ * this interface is not supported in 64-bit x86 kernel. See comment in
+ * rootnex_dma_mctl()
+ */
+ return (DDI_DMA_NORESOURCES);
+
+#else /* 32-bit x86 kernel */
+ ddi_dma_handle_t *lhandlep;
+ ddi_dma_handle_t lhandle;
+ ddi_dma_cookie_t cookie;
+ ddi_dma_attr_t dma_attr;
+ ddi_dma_lim_t *dma_lim;
+ uint_t ccnt;
+ int e;
+
+
+ /*
+ * if the driver is just testing to see if it's possible to do the bind,
+ * we'll use local state. Otherwise, use the handle pointer passed in.
+ */
+ if (handlep == NULL) {
+ lhandlep = &lhandle;
+ } else {
+ lhandlep = handlep;
+ }
+
+ /* convert the limit structure to a dma_attr one */
+ dma_lim = dmareq->dmar_limits;
+ dma_attr.dma_attr_version = DMA_ATTR_V0;
+ dma_attr.dma_attr_addr_lo = dma_lim->dlim_addr_lo;
+ dma_attr.dma_attr_addr_hi = dma_lim->dlim_addr_hi;
+ dma_attr.dma_attr_minxfer = dma_lim->dlim_minxfer;
+ dma_attr.dma_attr_seg = dma_lim->dlim_adreg_max;
+ dma_attr.dma_attr_count_max = dma_lim->dlim_ctreg_max;
+ dma_attr.dma_attr_granular = dma_lim->dlim_granular;
+ dma_attr.dma_attr_sgllen = dma_lim->dlim_sgllen;
+ dma_attr.dma_attr_maxxfer = dma_lim->dlim_reqsize;
+ dma_attr.dma_attr_burstsizes = dma_lim->dlim_burstsizes;
+ dma_attr.dma_attr_align = MMU_PAGESIZE;
+ dma_attr.dma_attr_flags = 0;
+
+ e = rootnex_dma_allochdl(dip, rdip, &dma_attr, dmareq->dmar_fp,
+ dmareq->dmar_arg, lhandlep);
+ if (e != DDI_SUCCESS) {
+ return (e);
+ }
+
+ e = rootnex_dma_bindhdl(dip, rdip, *lhandlep, dmareq, &cookie, &ccnt);
+ if ((e != DDI_DMA_MAPPED) && (e != DDI_DMA_PARTIAL_MAP)) {
+ (void) rootnex_dma_freehdl(dip, rdip, *lhandlep);
+ return (e);
+ }
+
+ /*
+ * if the driver is just testing to see if it's possible to do the bind,
+ * free up the local state and return the result.
+ */
+ if (handlep == NULL) {
+ (void) rootnex_dma_unbindhdl(dip, rdip, *lhandlep);
+ (void) rootnex_dma_freehdl(dip, rdip, *lhandlep);
+ if (e == DDI_DMA_MAPPED) {
+ return (DDI_DMA_MAPOK);
+ } else {
+ return (DDI_DMA_NOMAPPING);
+ }
+ }
+
+ return (e);
+#endif /* defined(__amd64) */
+}
+
+/*
* rootnex_dma_mctl()
*
- * We don't support this legacy interface any more on x86.
+ * No IOMMU in 32 bit mode. The below routine doesn't work in 64 bit mode.
*/
/* ARGSUSED */
static int
@@ -5010,11 +5095,185 @@ rootnex_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, caddr_t *objpp,
uint_t cache_flags)
{
+#if defined(__amd64)
+ /*
+ * DDI_DMA_SMEM_ALLOC & DDI_DMA_IOPB_ALLOC we're changed to have a
+ * common implementation in genunix, so they no longer have x86
+ * specific functionality which called into dma_ctl.
+ *
+ * The rest of the obsoleted interfaces were never supported in the
+ * 64-bit x86 kernel. For s10, the obsoleted DDI_DMA_SEGTOC interface
+ * was not ported to the x86 64-bit kernel do to serious x86 rootnex
+ * implementation issues.
+ *
+ * If you can't use DDI_DMA_SEGTOC; DDI_DMA_NEXTSEG, DDI_DMA_FREE, and
+ * DDI_DMA_NEXTWIN are useless since you can get to the cookie, so we
+ * reflect that now too...
+ *
+ * Even though we fixed the pointer problem in DDI_DMA_SEGTOC, we are
+ * not going to put this functionality into the 64-bit x86 kernel now.
+ * It wasn't ported to the 64-bit kernel for s10, no reason to change
+ * that in a future release.
+ */
+ return (DDI_FAILURE);
+
+#else /* 32-bit x86 kernel */
+ ddi_dma_cookie_t lcookie;
+ ddi_dma_cookie_t *cookie;
+ rootnex_window_t *window;
+ ddi_dma_impl_t *hp;
+ rootnex_dma_t *dma;
+ uint_t nwin;
+ uint_t ccnt;
+ size_t len;
+ off_t off;
+ int e;
+
+
/*
- * The only thing dma_mctl is usef for anymore is legacy SPARC
- * dvma and sbus-specific routines.
+ * DDI_DMA_SEGTOC, DDI_DMA_NEXTSEG, and DDI_DMA_NEXTWIN are a little
+ * hacky since were optimizing for the current interfaces and so we can
+ * cleanup the mess in genunix. Hopefully we will remove the this
+ * obsoleted routines someday soon.
*/
+
+ switch (request) {
+
+ case DDI_DMA_SEGTOC: /* ddi_dma_segtocookie() */
+ hp = (ddi_dma_impl_t *)handle;
+ cookie = (ddi_dma_cookie_t *)objpp;
+
+ /*
+ * convert segment to cookie. We don't distinguish between the
+ * two :-)
+ */
+ *cookie = *hp->dmai_cookie;
+ *lenp = cookie->dmac_size;
+ *offp = cookie->dmac_type & ~ROOTNEX_USES_COPYBUF;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTSEG: /* ddi_dma_nextseg() */
+ hp = (ddi_dma_impl_t *)handle;
+ dma = (rootnex_dma_t *)hp->dmai_private;
+
+ if ((*lenp != NULL) && ((uintptr_t)*lenp != (uintptr_t)hp)) {
+ return (DDI_DMA_STALE);
+ }
+
+ /* handle the case where we don't have any windows */
+ if (dma->dp_window == NULL) {
+ /*
+ * if seg == NULL, and we don't have any windows,
+ * return the first cookie in the sgl.
+ */
+ if (*lenp == NULL) {
+ dma->dp_current_cookie = 0;
+ hp->dmai_cookie = dma->dp_cookies;
+ *objpp = (caddr_t)handle;
+ return (DDI_SUCCESS);
+
+ /* if we have more cookies, go to the next cookie */
+ } else {
+ if ((dma->dp_current_cookie + 1) >=
+ dma->dp_sglinfo.si_sgl_size) {
+ return (DDI_DMA_DONE);
+ }
+ dma->dp_current_cookie++;
+ hp->dmai_cookie++;
+ return (DDI_SUCCESS);
+ }
+ }
+
+ /* We have one or more windows */
+ window = &dma->dp_window[dma->dp_current_win];
+
+ /*
+ * if seg == NULL, return the first cookie in the current
+ * window
+ */
+ if (*lenp == NULL) {
+ dma->dp_current_cookie = 0;
+ hp->dmai_cookie = window->wd_first_cookie;
+
+ /*
+ * go to the next cookie in the window then see if we done with
+ * this window.
+ */
+ } else {
+ if ((dma->dp_current_cookie + 1) >=
+ window->wd_cookie_cnt) {
+ return (DDI_DMA_DONE);
+ }
+ dma->dp_current_cookie++;
+ hp->dmai_cookie++;
+ }
+ *objpp = (caddr_t)handle;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTWIN: /* ddi_dma_nextwin() */
+ hp = (ddi_dma_impl_t *)handle;
+ dma = (rootnex_dma_t *)hp->dmai_private;
+
+ if ((*offp != NULL) && ((uintptr_t)*offp != (uintptr_t)hp)) {
+ return (DDI_DMA_STALE);
+ }
+
+ /* if win == NULL, return the first window in the bind */
+ if (*offp == NULL) {
+ nwin = 0;
+
+ /*
+ * else, go to the next window then see if we're done with all
+ * the windows.
+ */
+ } else {
+ nwin = dma->dp_current_win + 1;
+ if (nwin >= hp->dmai_nwin) {
+ return (DDI_DMA_DONE);
+ }
+ }
+
+ /* switch to the next window */
+ e = rootnex_dma_win(dip, rdip, handle, nwin, &off, &len,
+ &lcookie, &ccnt);
+ ASSERT(e == DDI_SUCCESS);
+ if (e != DDI_SUCCESS) {
+ return (DDI_DMA_STALE);
+ }
+
+ /* reset the cookie back to the first cookie in the window */
+ if (dma->dp_window != NULL) {
+ window = &dma->dp_window[dma->dp_current_win];
+ hp->dmai_cookie = window->wd_first_cookie;
+ } else {
+ hp->dmai_cookie = dma->dp_cookies;
+ }
+
+ *objpp = (caddr_t)handle;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_FREE: /* ddi_dma_free() */
+ (void) rootnex_dma_unbindhdl(dip, rdip, handle);
+ (void) rootnex_dma_freehdl(dip, rdip, handle);
+ if (rootnex_state->r_dvma_call_list_id) {
+ ddi_run_callback(&rootnex_state->r_dvma_call_list_id);
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_IOPB_ALLOC: /* get contiguous DMA-able memory */
+ case DDI_DMA_SMEM_ALLOC: /* get contiguous DMA-able memory */
+ /* should never get here, handled in genunix */
+ ASSERT(0);
+ return (DDI_FAILURE);
+
+ case DDI_DMA_KVADDR:
+ case DDI_DMA_GETERR:
+ case DDI_DMA_COFF:
+ return (DDI_FAILURE);
+ }
+
return (DDI_FAILURE);
+#endif /* defined(__amd64) */
}
/*
diff --git a/usr/src/uts/i86pc/ml/offsets.in b/usr/src/uts/i86pc/ml/offsets.in
index d867ade973..20e0c972d4 100644
--- a/usr/src/uts/i86pc/ml/offsets.in
+++ b/usr/src/uts/i86pc/ml/offsets.in
@@ -1,6 +1,5 @@
\
\ Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
-\ Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
\
\ CDDL HEADER START
\
@@ -242,6 +241,7 @@ ddi_dma_impl
dev_info
devi_ops DEVI_DEV_OPS
devi_bus_ctl
+ devi_bus_dma_map
devi_bus_dma_ctl
devi_bus_dma_allochdl
devi_bus_dma_freehdl
diff --git a/usr/src/uts/i86pc/os/ddi_impl.c b/usr/src/uts/i86pc/os/ddi_impl.c
index 60347c6168..a1ae318703 100644
--- a/usr/src/uts/i86pc/os/ddi_impl.c
+++ b/usr/src/uts/i86pc/os/ddi_impl.c
@@ -21,7 +21,6 @@
/*
* Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
/*
@@ -1713,6 +1712,50 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attr,
return (DDI_SUCCESS);
}
+/*
+ * covert old DMA limits structure to DMA attribute structure
+ * and continue
+ */
+int
+i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits,
+ size_t length, int cansleep, int streaming,
+ ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
+ uint_t *real_length, ddi_acc_hdl_t *ap)
+{
+ ddi_dma_attr_t dma_attr, *attrp;
+ size_t rlen;
+ int ret;
+
+ if (limits == NULL) {
+ return (DDI_FAILURE);
+ }
+
+ /*
+ * set up DMA attribute structure to pass to i_ddi_mem_alloc()
+ */
+ attrp = &dma_attr;
+ attrp->dma_attr_version = DMA_ATTR_V0;
+ attrp->dma_attr_addr_lo = (uint64_t)limits->dlim_addr_lo;
+ attrp->dma_attr_addr_hi = (uint64_t)limits->dlim_addr_hi;
+ attrp->dma_attr_count_max = (uint64_t)limits->dlim_ctreg_max;
+ attrp->dma_attr_align = 1;
+ attrp->dma_attr_burstsizes = (uint_t)limits->dlim_burstsizes;
+ attrp->dma_attr_minxfer = (uint32_t)limits->dlim_minxfer;
+ attrp->dma_attr_maxxfer = (uint64_t)limits->dlim_reqsize;
+ attrp->dma_attr_seg = (uint64_t)limits->dlim_adreg_max;
+ attrp->dma_attr_sgllen = limits->dlim_sgllen;
+ attrp->dma_attr_granular = (uint32_t)limits->dlim_granular;
+ attrp->dma_attr_flags = 0;
+
+ ret = i_ddi_mem_alloc(dip, attrp, length, cansleep, streaming,
+ accattrp, kaddrp, &rlen, ap);
+ if (ret == DDI_SUCCESS) {
+ if (real_length)
+ *real_length = (uint_t)rlen;
+ }
+ return (ret);
+}
+
/* ARGSUSED */
void
i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap)
diff --git a/usr/src/uts/intel/io/iommulib.c b/usr/src/uts/intel/io/iommulib.c
index f3a78bded9..8f36f92894 100644
--- a/usr/src/uts/intel/io/iommulib.c
+++ b/usr/src/uts/intel/io/iommulib.c
@@ -20,7 +20,6 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#pragma ident "@(#)iommulib.c 1.6 08/09/07 SMI"
@@ -246,6 +245,21 @@ iommulib_nexus_register(dev_info_t *dip, iommulib_nexops_t *nexops,
return (DDI_FAILURE);
}
+ /* Check for legacy ops */
+ if (nexops->nops_dma_map == NULL) {
+ cmn_err(CE_WARN, "%s: %s%d: NULL legacy nops_dma_map op. "
+ "Failing registration for ops vector: %p", f,
+ driver, instance, (void *)nexops);
+ return (DDI_FAILURE);
+ }
+
+ if (nexops->nops_dma_mctl == NULL) {
+ cmn_err(CE_WARN, "%s: %s%d: NULL legacy nops_dma_mctl op. "
+ "Failing registration for ops vector: %p", f,
+ driver, instance, (void *)nexops);
+ return (DDI_FAILURE);
+ }
+
nexp = kmem_zalloc(sizeof (iommulib_nex_t), KM_SLEEP);
mutex_enter(&iommulib_lock);
@@ -436,6 +450,21 @@ iommulib_iommu_register(dev_info_t *dip, iommulib_ops_t *ops,
return (DDI_FAILURE);
}
+ /* Check for legacy ops */
+ if (ops->ilops_dma_map == NULL) {
+ cmn_err(CE_WARN, "%s: %s%d: NULL legacy dma_map op. "
+ "Failing registration for ops vector: %p", f,
+ driver, instance, (void *)ops);
+ return (DDI_FAILURE);
+ }
+
+ if (ops->ilops_dma_mctl == NULL) {
+ cmn_err(CE_WARN, "%s: %s%d: NULL legacy dma_mctl op. "
+ "Failing registration for ops vector: %p", f,
+ driver, instance, (void *)ops);
+ return (DDI_FAILURE);
+ }
+
unitp = kmem_zalloc(sizeof (iommulib_unit_t), KM_SLEEP);
mutex_enter(&iommulib_lock);
if (iommulib_fini == 1) {
@@ -728,6 +757,37 @@ iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip,
win, offp, lenp, cookiep, ccountp));
}
+/* Obsolete DMA routines */
+
+int
+iommulib_nexdma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *dma_handle)
+{
+ iommulib_handle_t handle = DEVI(rdip)->devi_iommulib_handle;
+ iommulib_unit_t *unitp = handle;
+
+ ASSERT(unitp);
+
+ /* No need to grab lock - the handle is reference counted */
+ return (unitp->ilu_ops->ilops_dma_map(handle, dip, rdip, dmareq,
+ dma_handle));
+}
+
+int
+iommulib_nexdma_mctl(dev_info_t *dip, dev_info_t *rdip,
+ ddi_dma_handle_t dma_handle, enum ddi_dma_ctlops request,
+ off_t *offp, size_t *lenp, caddr_t *objpp, uint_t cache_flags)
+{
+ iommulib_handle_t handle = DEVI(rdip)->devi_iommulib_handle;
+ iommulib_unit_t *unitp = (iommulib_unit_t *)handle;
+
+ ASSERT(unitp);
+
+ /* No need to grab lock - the handle is reference counted */
+ return (unitp->ilu_ops->ilops_dma_mctl(handle, dip, rdip, dma_handle,
+ request, offp, lenp, objpp, cache_flags));
+}
+
int
iommulib_nexdma_mapobject(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq,
@@ -868,6 +928,28 @@ iommulib_iommu_dma_win(dev_info_t *dip, dev_info_t *rdip,
}
int
+iommulib_iommu_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep)
+{
+ iommulib_nexops_t *nexops;
+
+ nexops = &DEVI(dip)->devi_iommulib_nex_handle->nex_ops;
+ return (nexops->nops_dma_map(dip, rdip, dmareq, handlep));
+}
+
+int
+iommulib_iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
+ ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
+ size_t *lenp, caddr_t *objpp, uint_t cache_flags)
+{
+ iommulib_nexops_t *nexops;
+
+ nexops = &DEVI(dip)->devi_iommulib_nex_handle->nex_ops;
+ return (nexops->nops_dma_mctl(dip, rdip, handle, request, offp, lenp,
+ objpp, cache_flags));
+}
+
+int
iommulib_iommu_dmahdl_setprivate(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, void *priv)
{
diff --git a/usr/src/uts/intel/io/pci/pci_pci.c b/usr/src/uts/intel/io/pci/pci_pci.c
index 9f0ed4d67f..a0ade1d026 100644
--- a/usr/src/uts/intel/io/pci/pci_pci.c
+++ b/usr/src/uts/intel/io/pci/pci_pci.c
@@ -22,9 +22,6 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* PCI to PCI bus bridge nexus driver
@@ -96,7 +93,7 @@ struct bus_ops ppb_bus_ops = {
0,
0,
i_ddi_map_fault,
- 0,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/intel/sys/iommulib.h b/usr/src/uts/intel/sys/iommulib.h
index 7fb525edec..aa456ac8bb 100644
--- a/usr/src/uts/intel/sys/iommulib.h
+++ b/usr/src/uts/intel/sys/iommulib.h
@@ -20,12 +20,13 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#ifndef _SYS_IOMMULIB_H
#define _SYS_IOMMULIB_H
+#pragma ident "@(#)iommulib.h 1.3 08/08/31 SMI"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,11 +45,10 @@ typedef enum {
typedef enum {
IOMMU_OPS_VERSION_INVALID = 0,
IOMMU_OPS_VERSION_1 = 1,
- IOMMU_OPS_VERSION_2 = 2,
- IOMMU_OPS_VERSION_3 = 3
+ IOMMU_OPS_VERSION_2 = 2
} iommulib_opsversion_t;
-#define IOMMU_OPS_VERSION IOMMU_OPS_VERSION_3
+#define IOMMU_OPS_VERSION IOMMU_OPS_VERSION_2
typedef struct iommulib_ops {
iommulib_opsversion_t ilops_vers;
@@ -90,6 +90,17 @@ typedef struct iommulib_ops {
dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle,
ddi_dma_obj_t *dmao);
+ /* Obsolete DMA routines */
+
+ int (*ilops_dma_map)(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, struct ddi_dma_req *dmareq,
+ ddi_dma_handle_t *dma_handle);
+
+ int (*ilops_dma_mctl)(iommulib_handle_t handle, dev_info_t *dip,
+ dev_info_t *rdip, ddi_dma_handle_t dma_handle,
+ enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
+ caddr_t *objpp, uint_t cache_flags);
+
} iommulib_ops_t;
/*
@@ -119,11 +130,10 @@ typedef struct iommulib_ops {
typedef enum {
IOMMU_NEXOPS_VERSION_INVALID = 0,
IOMMU_NEXOPS_VERSION_1 = 1,
- IOMMU_NEXOPS_VERSION_2 = 2,
- IOMMU_NEXOPS_VERSION_3 = 3
+ IOMMU_NEXOPS_VERSION_2 = 2
} iommulib_nexops_version_t;
-#define IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_3
+#define IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_2
typedef struct iommulib_nexops {
iommulib_nexops_version_t nops_vers;
@@ -164,6 +174,13 @@ typedef struct iommulib_nexops {
ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
ddi_dma_cookie_t *cookiep, uint_t *ccountp);
+ int (*nops_dma_map)(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
+
+ int (*nops_dma_mctl)(dev_info_t *dip, dev_info_t *rdip,
+ ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
+ size_t *lenp, caddr_t *objpp, uint_t cache_flags);
+
int (*nops_dmahdl_setprivate)(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, void *priv);
@@ -238,6 +255,13 @@ int iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t dma_handle, uint_t win, off_t *offp, size_t *lenp,
ddi_dma_cookie_t *cookiep, uint_t *ccountp);
+int iommulib_nexdma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *dma_handle);
+
+int iommulib_nexdma_mctl(dev_info_t *dip, dev_info_t *rdip,
+ ddi_dma_handle_t dma_handle, enum ddi_dma_ctlops request,
+ off_t *offp, size_t *lenp, caddr_t *objpp, uint_t cache_flags);
+
int iommulib_nexdma_mapobject(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq,
ddi_dma_obj_t *dmao);
@@ -298,6 +322,13 @@ int iommulib_iommu_dma_win(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
ddi_dma_cookie_t *cookiep, uint_t *ccountp);
+int iommulib_iommu_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
+
+int iommulib_iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
+ ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
+ size_t *lenp, caddr_t *objpp, uint_t cache_flags);
+
int iommulib_iommu_dmahdl_setprivate(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, void *priv);
diff --git a/usr/src/uts/sparc/ml/sparc_ddi.s b/usr/src/uts/sparc/ml/sparc_ddi.s
index 7497459b4a..a14d1fa2a0 100644
--- a/usr/src/uts/sparc/ml/sparc_ddi.s
+++ b/usr/src/uts/sparc/ml/sparc_ddi.s
@@ -23,9 +23,8 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Assembler routines to make some DDI routines go faster.
@@ -168,6 +167,30 @@ ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t op, void *a, void *v)
/* ARGSUSED */
int
+ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep)
+{
+ return (DDI_SUCCESS);
+}
+
+#else /* lint */
+
+ ENTRY(ddi_dma_map)
+ ldn [%o0 + DEVI_BUS_DMA_MAP], %o0
+ ! dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_map;
+ ldn [%o0 + DEVI_DEV_OPS], %g1 ! dip->dev_ops
+ ldn [%g1 + DEVI_BUS_OPS], %g1 ! dip->dev_ops->devo_bus_ops
+ ldn [%g1 + OPS_MAP], %g1 ! dip->dev_ops->devo_bus_ops->bus_dma_map
+ jmpl %g1, %g0 ! bop off to new routine
+ nop ! as if we had never been here
+ SET_SIZE(ddi_dma_map)
+
+#endif /* lint */
+
+#if defined(lint)
+
+/* ARGSUSED */
+int
ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep)
{
diff --git a/usr/src/uts/sun/io/socal.c b/usr/src/uts/sun/io/socal.c
index 084c59f0d5..6064218c37 100644
--- a/usr/src/uts/sun/io/socal.c
+++ b/usr/src/uts/sun/io/socal.c
@@ -23,9 +23,7 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
+
/*
* socal - Serial Optical Channel Arbitrated Loop host adapter driver.
@@ -310,7 +308,7 @@ static struct bus_ops socal_bus_ops = {
0, /* int (*bus_add_intrspec)(); */
0, /* void (*bus_remove_intrspec)(); */
i_ddi_map_fault, /* int (*bus_map_fault)() */
- 0, /* int (*bus_dma_map)() */
+ ddi_dma_map, /* int (*bus_dma_map)() */
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4/io/ebus.c b/usr/src/uts/sun4/io/ebus.c
index 19001588d5..d8d15f484b 100644
--- a/usr/src/uts/sun4/io/ebus.c
+++ b/usr/src/uts/sun4/io/ebus.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/types.h>
@@ -129,7 +126,7 @@ static struct bus_ops ebus_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4/io/px/px_dma.c b/usr/src/uts/sun4/io/px/px_dma.c
index 148699c267..aa06547597 100644
--- a/usr/src/uts/sun4/io/px/px_dma.c
+++ b/usr/src/uts/sun4/io/px/px_dma.c
@@ -22,9 +22,6 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* PCI Express nexus DVMA and DMA core routines:
@@ -897,6 +894,107 @@ px_dvma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp,
uint_t cache_flags)
{
switch (cmd) {
+ case DDI_DMA_SYNC:
+ return (px_lib_dma_sync(dip, rdip, (ddi_dma_handle_t)mp,
+ *offp, *lenp, cache_flags));
+
+ case DDI_DMA_HTOC: {
+ int ret;
+ off_t wo_off, off = *offp; /* wo_off: wnd's obj offset */
+ uint_t win_size = mp->dmai_winsize;
+ ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)objp;
+
+ if (off >= mp->dmai_object.dmao_size) {
+ cmn_err(CE_WARN, "%s%d invalid dma_htoc offset %lx",
+ NAMEINST(mp->dmai_rdip), off);
+ return (DDI_FAILURE);
+ }
+ off += mp->dmai_roffset;
+ ret = px_dma_win(dip, rdip, (ddi_dma_handle_t)mp,
+ off / win_size, &wo_off, NULL, cp, NULL); /* lenp == NULL */
+ if (ret)
+ return (ret);
+ DBG(DBG_DMA_CTL, dip, "HTOC:cookie=%x+%lx off=%lx,%lx\n",
+ cp->dmac_address, cp->dmac_size, off, *offp);
+
+ /* adjust cookie addr/len if we are not on window boundary */
+ ASSERT((off % win_size) == (off -
+ (PX_DMA_CURWIN(mp) ? mp->dmai_roffset : 0) - wo_off));
+ off = PX_DMA_CURWIN(mp) ? off % win_size : *offp;
+ ASSERT(cp->dmac_size > off);
+ cp->dmac_laddress += off;
+ cp->dmac_size -= off;
+ DBG(DBG_DMA_CTL, dip, "HTOC:mp=%p cookie=%x+%lx off=%lx,%lx\n",
+ mp, cp->dmac_address, cp->dmac_size, off, wo_off);
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_REPWIN:
+ *offp = mp->dmai_offset;
+ *lenp = mp->dmai_size;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_MOVWIN: {
+ off_t off = *offp;
+ if (off >= mp->dmai_object.dmao_size)
+ return (DDI_FAILURE);
+ off += mp->dmai_roffset;
+ return (px_dma_win(dip, rdip, (ddi_dma_handle_t)mp,
+ off / mp->dmai_winsize, offp, lenp,
+ (ddi_dma_cookie_t *)objp, NULL));
+ }
+
+ case DDI_DMA_NEXTWIN: {
+ px_window_t win = PX_DMA_CURWIN(mp);
+ if (offp) {
+ if (*(px_window_t *)offp != win) {
+ /* window not active */
+ *(px_window_t *)objp = win; /* return cur win */
+ return (DDI_DMA_STALE);
+ }
+ win++;
+ } else /* map win 0 */
+ win = 0;
+ if (win >= mp->dmai_nwin) {
+ *(px_window_t *)objp = win - 1;
+ return (DDI_DMA_DONE);
+ }
+ if (px_dma_win(dip, rdip, (ddi_dma_handle_t)mp,
+ win, 0, 0, 0, 0)) {
+ *(px_window_t *)objp = win - 1;
+ return (DDI_FAILURE);
+ }
+ *(px_window_t *)objp = win;
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTSEG:
+ if (*(px_window_t *)offp != PX_DMA_CURWIN(mp))
+ return (DDI_DMA_STALE);
+ if (lenp) /* only 1 seg allowed */
+ return (DDI_DMA_DONE);
+
+ /* return mp as seg 0 */
+ *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_SEGTOC:
+ MAKE_DMA_COOKIE((ddi_dma_cookie_t *)objp, mp->dmai_mapping,
+ mp->dmai_size);
+ *offp = mp->dmai_offset;
+ *lenp = mp->dmai_size;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_COFF: {
+ ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)offp;
+ if (cp->dmac_address < mp->dmai_mapping ||
+ (cp->dmac_address + cp->dmac_size) >
+ (mp->dmai_mapping + mp->dmai_size))
+ return (DDI_FAILURE);
+ *objp = (caddr_t)(cp->dmac_address - mp->dmai_mapping +
+ mp->dmai_offset);
+ }
+ return (DDI_SUCCESS);
default:
DBG(DBG_DMA_CTL, dip, "unknown command (%x): rdip=%s%d\n",
cmd, ddi_driver_name(rdip), ddi_get_instance(rdip));
@@ -1245,6 +1343,153 @@ px_dma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp,
uint_t cache_flags)
{
switch (cmd) {
+ case DDI_DMA_SYNC:
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_HTOC: {
+ off_t off = *offp;
+ ddi_dma_cookie_t *loop_cp, *cp;
+ px_dma_win_t *win_p = mp->dmai_winlst;
+
+ if (off >= mp->dmai_object.dmao_size)
+ return (DDI_FAILURE);
+
+ /* locate window */
+ while (win_p->win_offset + win_p->win_size <= off)
+ win_p = win_p->win_next;
+
+ loop_cp = cp = (ddi_dma_cookie_t *)(win_p + 1);
+ mp->dmai_offset = win_p->win_offset;
+ mp->dmai_size = win_p->win_size;
+ mp->dmai_mapping = cp->dmac_laddress; /* cookie0 start addr */
+
+ /* adjust cookie addr/len if we are not on cookie boundary */
+ off -= win_p->win_offset; /* offset within window */
+ for (; off >= loop_cp->dmac_size; loop_cp++)
+ off -= loop_cp->dmac_size; /* offset within cookie */
+
+ mp->dmai_cookie = loop_cp + 1;
+ win_p->win_curseg = loop_cp - cp;
+ cp = (ddi_dma_cookie_t *)objp;
+ MAKE_DMA_COOKIE(cp, loop_cp->dmac_laddress + off,
+ loop_cp->dmac_size - off);
+
+ DBG(DBG_DMA_CTL, dip,
+ "HTOC: cookie - dmac_laddress=%p dmac_size=%x\n",
+ cp->dmac_laddress, cp->dmac_size);
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_REPWIN:
+ *offp = mp->dmai_offset;
+ *lenp = mp->dmai_size;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_MOVWIN: {
+ off_t off = *offp;
+ ddi_dma_cookie_t *cp;
+ px_dma_win_t *win_p = mp->dmai_winlst;
+
+ if (off >= mp->dmai_object.dmao_size)
+ return (DDI_FAILURE);
+
+ /* locate window */
+ while (win_p->win_offset + win_p->win_size <= off)
+ win_p = win_p->win_next;
+
+ cp = (ddi_dma_cookie_t *)(win_p + 1);
+ mp->dmai_offset = win_p->win_offset;
+ mp->dmai_size = win_p->win_size;
+ mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */
+ mp->dmai_cookie = cp + 1;
+ win_p->win_curseg = 0;
+
+ *(ddi_dma_cookie_t *)objp = *cp;
+ *offp = win_p->win_offset;
+ *lenp = win_p->win_size;
+ DBG(DBG_DMA_CTL, dip,
+ "HTOC: cookie - dmac_laddress=%p dmac_size=%x\n",
+ cp->dmac_laddress, cp->dmac_size);
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTWIN: {
+ px_dma_win_t *win_p = *(px_dma_win_t **)offp;
+ px_dma_win_t **nw_pp = (px_dma_win_t **)objp;
+ ddi_dma_cookie_t *cp;
+ if (!win_p) {
+ *nw_pp = mp->dmai_winlst;
+ return (DDI_SUCCESS);
+ }
+
+ if (win_p->win_offset != mp->dmai_offset)
+ return (DDI_DMA_STALE);
+ if (!win_p->win_next)
+ return (DDI_DMA_DONE);
+ win_p = win_p->win_next;
+ cp = (ddi_dma_cookie_t *)(win_p + 1);
+ mp->dmai_offset = win_p->win_offset;
+ mp->dmai_size = win_p->win_size;
+ mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */
+ mp->dmai_cookie = cp + 1;
+ win_p->win_curseg = 0;
+ *nw_pp = win_p;
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTSEG: {
+ px_dma_win_t *w_p = *(px_dma_win_t **)offp;
+ if (w_p->win_offset != mp->dmai_offset)
+ return (DDI_DMA_STALE);
+ if (w_p->win_curseg + 1 >= w_p->win_ncookies)
+ return (DDI_DMA_DONE);
+ w_p->win_curseg++;
+ }
+ *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_SEGTOC: {
+ px_dma_win_t *win_p = mp->dmai_winlst;
+ off_t off = mp->dmai_offset;
+ ddi_dma_cookie_t *cp;
+ int i;
+
+ /* locate active window */
+ for (; win_p->win_offset != off; win_p = win_p->win_next)
+ ;
+ cp = (ddi_dma_cookie_t *)(win_p + 1);
+ for (i = 0; i < win_p->win_curseg; i++, cp++)
+ off += cp->dmac_size;
+ *offp = off;
+ *lenp = cp->dmac_size;
+ *(ddi_dma_cookie_t *)objp = *cp; /* copy cookie */
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_COFF: {
+ px_dma_win_t *win_p;
+ ddi_dma_cookie_t *cp;
+ uint64_t addr, key = ((ddi_dma_cookie_t *)offp)->dmac_laddress;
+ size_t win_off;
+
+ for (win_p = mp->dmai_winlst; win_p; win_p = win_p->win_next) {
+ int i;
+ win_off = 0;
+ cp = (ddi_dma_cookie_t *)(win_p + 1);
+ for (i = 0; i < win_p->win_ncookies; i++, cp++) {
+ size_t sz = cp->dmac_size;
+
+ addr = cp->dmac_laddress;
+ if ((addr <= key) && (addr + sz >= key))
+ goto found;
+ win_off += sz;
+ }
+ }
+ return (DDI_FAILURE);
+found:
+ *objp = (caddr_t)(win_p->win_offset + win_off + (key - addr));
+ return (DDI_SUCCESS);
+ }
default:
DBG(DBG_DMA_CTL, dip, "unknown command (%x): rdip=%s%d\n",
cmd, ddi_driver_name(rdip), ddi_get_instance(rdip));
diff --git a/usr/src/uts/sun4/io/px/px_mmu.c b/usr/src/uts/sun4/io/px/px_mmu.c
index 967edf917c..0c68271053 100644
--- a/usr/src/uts/sun4/io/px/px_mmu.c
+++ b/usr/src/uts/sun4/io/px/px_mmu.c
@@ -20,7 +20,6 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
/*
@@ -258,7 +257,7 @@ px_mmu_unmap_pages(px_mmu_t *mmu_p, ddi_dma_impl_t *mp, px_dvma_addr_t dvma_pg,
/*
* px_mmu_map_window - map a dvma window into the mmu
- * used by: px_dma_win()
+ * used by: px_dma_win(), px_dma_ctlops() - DDI_DMA_MOVWIN, DDI_DMA_NEXTWIN
* return value: none
*/
/*ARGSUSED*/
diff --git a/usr/src/uts/sun4/ml/offsets.in b/usr/src/uts/sun4/ml/offsets.in
index 4f6d19ba01..377cfbd319 100644
--- a/usr/src/uts/sun4/ml/offsets.in
+++ b/usr/src/uts/sun4/ml/offsets.in
@@ -1,6 +1,5 @@
\ offsets.in: input file to produce assym.h using the stabs program
\ Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
-\ Copyright 2012 Garrett D'Amore <garett@damore.org>. All rights reserved.
\
\ CDDL HEADER START
\
@@ -467,6 +466,7 @@ syncq SQ_SIZE
sq_exitwait
bus_ops BUS_OPS_SIZE
+ bus_dma_map OPS_MAP
bus_dma_allochdl OPS_ALLOCHDL
bus_dma_freehdl OPS_FREEHDL
bus_dma_bindhdl OPS_BINDHDL
@@ -489,6 +489,7 @@ dev_info DEVI_SIZE
devi_bus_dma_flush
devi_bus_dma_unbindfunc
devi_bus_ctl
+ devi_bus_dma_map
devi_bus_dma_ctl
kstat_io
diff --git a/usr/src/uts/sun4/os/ddi_impl.c b/usr/src/uts/sun4/os/ddi_impl.c
index 6769c48b9d..f3efc433c5 100644
--- a/usr/src/uts/sun4/os/ddi_impl.c
+++ b/usr/src/uts/sun4/os/ddi_impl.c
@@ -23,9 +23,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* sun4 specific DDI implementation
@@ -1212,6 +1209,44 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attr,
}
}
+/*
+ * covert old DMA limits structure to DMA attribute structure
+ * and continue
+ */
+int
+i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits,
+ size_t length, int cansleep, int streaming,
+ ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp,
+ uint_t *real_length, ddi_acc_hdl_t *ap)
+{
+ ddi_dma_attr_t dma_attr, *attrp;
+ size_t rlen;
+ int ret;
+
+ ASSERT(limits);
+ attrp = &dma_attr;
+ attrp->dma_attr_version = DMA_ATTR_V0;
+ attrp->dma_attr_addr_lo = (uint64_t)limits->dlim_addr_lo;
+ attrp->dma_attr_addr_hi = (uint64_t)limits->dlim_addr_hi;
+ attrp->dma_attr_count_max = (uint64_t)-1;
+ attrp->dma_attr_align = 1;
+ attrp->dma_attr_burstsizes = (uint_t)limits->dlim_burstsizes;
+ attrp->dma_attr_minxfer = (uint32_t)limits->dlim_minxfer;
+ attrp->dma_attr_maxxfer = (uint64_t)-1;
+ attrp->dma_attr_seg = (uint64_t)limits->dlim_cntr_max;
+ attrp->dma_attr_sgllen = 1;
+ attrp->dma_attr_granular = 1;
+ attrp->dma_attr_flags = 0;
+
+ ret = i_ddi_mem_alloc(dip, attrp, length, cansleep, streaming,
+ accattrp, kaddrp, &rlen, ap);
+ if (ret == DDI_SUCCESS) {
+ if (real_length)
+ *real_length = (uint_t)rlen;
+ }
+ return (ret);
+}
+
/* ARGSUSED */
void
i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap)
diff --git a/usr/src/uts/sun4u/io/iommu.c b/usr/src/uts/sun4u/io/iommu.c
index 75937f0b0f..66d7a46dc2 100644
--- a/usr/src/uts/sun4u/io/iommu.c
+++ b/usr/src/uts/sun4u/io/iommu.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/types.h>
#include <sys/param.h>
@@ -62,7 +59,12 @@
#define IOMMU_DMAMCTL_SYNC_DEBUG 0x8
#define IOMMU_DMAMCTL_HTOC_DEBUG 0x10
#define IOMMU_DMAMCTL_KVADDR_DEBUG 0x20
+#define IOMMU_DMAMCTL_NEXTWIN_DEBUG 0x40
+#define IOMMU_DMAMCTL_NEXTSEG_DEBUG 0x80
+#define IOMMU_DMAMCTL_MOVWIN_DEBUG 0x100
+#define IOMMU_DMAMCTL_REPWIN_DEBUG 0x200
#define IOMMU_DMAMCTL_GETERR_DEBUG 0x400
+#define IOMMU_DMAMCTL_COFF_DEBUG 0x800
#define IOMMU_DMAMCTL_DMA_FREE_DEBUG 0x1000
#define IOMMU_REGISTERS_DEBUG 0x2000
#define IOMMU_DMA_SETUP_DEBUG 0x4000
@@ -1302,6 +1304,85 @@ iommu_map_window(ddi_dma_impl_t *mp, off_t newoff, size_t winsize)
}
+int
+iommu_dma_map(dev_info_t *dip, dev_info_t *rdip,
+ struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep)
+{
+ ddi_dma_lim_t *dma_lim = dmareq->dmar_limits;
+ ddi_dma_impl_t *mp;
+ ddi_dma_attr_t *dma_attr;
+ struct dma_impl_priv *mppriv;
+ ioaddr_t addrlow, addrhigh;
+ ioaddr_t segalign;
+ int rval;
+ struct sbus_soft_state *softsp =
+ (struct sbus_soft_state *)ddi_get_soft_state(sbusp,
+ ddi_get_instance(dip));
+
+ addrlow = dma_lim->dlim_addr_lo;
+ addrhigh = dma_lim->dlim_addr_hi;
+ if ((addrhigh <= addrlow) ||
+ (addrhigh < (ioaddr_t)softsp->iommu_dvma_base)) {
+ return (DDI_DMA_NOMAPPING);
+ }
+
+ /*
+ * Setup DMA burstsizes and min-xfer counts.
+ */
+ (void) iommu_dma_lim_setup(dip, rdip, softsp, &dma_lim->dlim_burstsizes,
+ (uint_t)dma_lim->dlim_burstsizes, &dma_lim->dlim_minxfer,
+ dmareq->dmar_flags);
+
+ if (dma_lim->dlim_burstsizes == 0)
+ return (DDI_DMA_NOMAPPING);
+ /*
+ * If not an advisory call, get a DMA handle
+ */
+ if (!handlep) {
+ return (DDI_DMA_MAPOK);
+ }
+
+ mppriv = kmem_zalloc(sizeof (*mppriv),
+ (dmareq->dmar_fp == DDI_DMA_SLEEP) ? KM_SLEEP : KM_NOSLEEP);
+ if (mppriv == NULL) {
+ if (dmareq->dmar_fp != DDI_DMA_DONTWAIT) {
+ ddi_set_callback(dmareq->dmar_fp,
+ dmareq->dmar_arg, &softsp->dvma_call_list_id);
+ }
+ return (DDI_DMA_NORESOURCES);
+ }
+ mp = (ddi_dma_impl_t *)mppriv;
+ mp->dmai_rdip = rdip;
+ mp->dmai_rflags = dmareq->dmar_flags & DMP_DDIFLAGS;
+ mp->dmai_minxfer = dma_lim->dlim_minxfer;
+ mp->dmai_burstsizes = dma_lim->dlim_burstsizes;
+ mp->dmai_offset = 0;
+ mp->dmai_ndvmapages = 0;
+ mp->dmai_minfo = 0;
+ mp->dmai_inuse = 0;
+ segalign = dma_lim->dlim_cntr_max;
+ /* See if the DMA engine has any limit restrictions. */
+ if (segalign == UINT32_MAX && addrhigh == UINT32_MAX &&
+ addrlow == 0) {
+ mp->dmai_rflags |= DMP_NOLIMIT;
+ }
+ mppriv->softsp = softsp;
+ mppriv->phys_sync_flag = va_to_pa((caddr_t)&mppriv->sync_flag);
+ dma_attr = &mp->dmai_attr;
+ dma_attr->dma_attr_align = 1;
+ dma_attr->dma_attr_addr_lo = addrlow;
+ dma_attr->dma_attr_addr_hi = addrhigh;
+ dma_attr->dma_attr_seg = segalign;
+ dma_attr->dma_attr_burstsizes = dma_lim->dlim_burstsizes;
+ rval = iommu_dma_bindhdl(dip, rdip, (ddi_dma_handle_t)mp,
+ dmareq, NULL, NULL);
+ if (rval && (rval != DDI_DMA_PARTIAL_MAP)) {
+ kmem_free(mppriv, sizeof (*mppriv));
+ } else {
+ *handlep = (ddi_dma_handle_t)mp;
+ }
+ return (rval);
+}
/*ARGSUSED*/
int
@@ -1309,11 +1390,57 @@ iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
off_t *offp, size_t *lenp, caddr_t *objp, uint_t cache_flags)
{
+ ioaddr_t addr;
+ uint_t offset;
pgcnt_t npages;
+ size_t size;
+ ddi_dma_cookie_t *cp;
ddi_dma_impl_t *mp = (ddi_dma_impl_t *)handle;
DPRINTF(IOMMU_DMAMCTL_DEBUG, ("dma_mctl: handle %p ", (void *)mp));
switch (request) {
+ case DDI_DMA_FREE:
+ {
+ struct dma_impl_priv *mppriv = (struct dma_impl_priv *)mp;
+ struct sbus_soft_state *softsp = mppriv->softsp;
+ ASSERT(softsp != NULL);
+
+ /*
+ * 'Free' the dma mappings.
+ */
+ addr = (ioaddr_t)(mp->dmai_mapping & ~IOMMU_PAGEOFFSET);
+ npages = mp->dmai_ndvmapages;
+ size = iommu_ptob(npages);
+
+ DPRINTF(IOMMU_DMAMCTL_DMA_FREE_DEBUG, ("iommu_dma_mctl dmafree:"
+ "freeing vaddr %x for %x pages.\n", addr,
+ mp->dmai_ndvmapages));
+ /* sync the entire object */
+ if (!(mp->dmai_rflags & DDI_DMA_CONSISTENT)) {
+ /* flush stream write buffers */
+ sync_stream_buf(softsp, addr, npages,
+ (int *)&mppriv->sync_flag, mppriv->phys_sync_flag);
+ }
+
+#if defined(DEBUG) && defined(IO_MEMDEBUG)
+ iommu_remove_mappings(mp);
+#endif /* DEBUG && IO_MEMDEBUG */
+
+ ASSERT(npages > (uint_t)0);
+ if (mp->dmai_rflags & DMP_NOLIMIT)
+ vmem_free(softsp->dvma_arena,
+ (void *)(uintptr_t)addr, size);
+ else
+ vmem_xfree(softsp->dvma_arena,
+ (void *)(uintptr_t)addr, size);
+
+ kmem_free(mppriv, sizeof (*mppriv));
+
+ if (softsp->dvma_call_list_id != 0)
+ ddi_run_callback(&softsp->dvma_call_list_id);
+
+ break;
+ }
case DDI_DMA_SET_SBUS64:
{
@@ -1324,6 +1451,203 @@ iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
DDI_DMA_SBUS_64BIT));
}
+ case DDI_DMA_HTOC:
+ DPRINTF(IOMMU_DMAMCTL_HTOC_DEBUG, ("htoc off %lx mapping %lx "
+ "size %x\n", *offp, mp->dmai_mapping,
+ mp->dmai_size));
+
+ if ((uint_t)(*offp) >= mp->dmai_size)
+ return (DDI_FAILURE);
+
+ cp = (ddi_dma_cookie_t *)objp;
+ cp->dmac_notused = 0;
+ cp->dmac_address = (mp->dmai_mapping + (uint_t)(*offp));
+ cp->dmac_size =
+ mp->dmai_mapping + mp->dmai_size - cp->dmac_address;
+ cp->dmac_type = 0;
+
+ break;
+
+ case DDI_DMA_KVADDR:
+ /*
+ * If a physical address mapping has percolated this high,
+ * that is an error (maybe?).
+ */
+ if (mp->dmai_rflags & DMP_PHYSADDR) {
+ DPRINTF(IOMMU_DMAMCTL_KVADDR_DEBUG, ("kvaddr of phys "
+ "mapping\n"));
+ return (DDI_FAILURE);
+ }
+
+ return (DDI_FAILURE);
+
+ case DDI_DMA_NEXTWIN:
+ {
+ ddi_dma_win_t *owin, *nwin;
+ uint_t winsize, newoff;
+ int rval;
+
+ DPRINTF(IOMMU_DMAMCTL_NEXTWIN_DEBUG, ("nextwin\n"));
+
+ mp = (ddi_dma_impl_t *)handle;
+ owin = (ddi_dma_win_t *)offp;
+ nwin = (ddi_dma_win_t *)objp;
+ if (mp->dmai_rflags & DDI_DMA_PARTIAL) {
+ if (*owin == NULL) {
+ DPRINTF(IOMMU_DMAMCTL_NEXTWIN_DEBUG,
+ ("nextwin: win == NULL\n"));
+ mp->dmai_offset = 0;
+ *nwin = (ddi_dma_win_t)mp;
+ return (DDI_SUCCESS);
+ }
+
+ offset = (uint_t)(mp->dmai_mapping & IOMMU_PAGEOFFSET);
+ winsize = iommu_ptob(mp->dmai_ndvmapages -
+ iommu_btopr(offset));
+
+ newoff = (uint_t)(mp->dmai_offset + winsize);
+ if (newoff > mp->dmai_object.dmao_size -
+ mp->dmai_minxfer)
+ return (DDI_DMA_DONE);
+
+ if ((rval = iommu_map_window(mp, newoff, winsize))
+ != DDI_SUCCESS)
+ return (rval);
+ } else {
+ DPRINTF(IOMMU_DMAMCTL_NEXTWIN_DEBUG, ("nextwin: no "
+ "partial mapping\n"));
+ if (*owin != NULL)
+ return (DDI_DMA_DONE);
+ mp->dmai_offset = 0;
+ *nwin = (ddi_dma_win_t)mp;
+ }
+ break;
+ }
+
+ case DDI_DMA_NEXTSEG:
+ {
+ ddi_dma_seg_t *oseg, *nseg;
+
+ DPRINTF(IOMMU_DMAMCTL_NEXTSEG_DEBUG, ("nextseg:\n"));
+
+ oseg = (ddi_dma_seg_t *)lenp;
+ if (*oseg != NULL)
+ return (DDI_DMA_DONE);
+ nseg = (ddi_dma_seg_t *)objp;
+ *nseg = *((ddi_dma_seg_t *)offp);
+ break;
+ }
+
+ case DDI_DMA_SEGTOC:
+ {
+ ddi_dma_seg_impl_t *seg;
+
+ seg = (ddi_dma_seg_impl_t *)handle;
+ cp = (ddi_dma_cookie_t *)objp;
+ cp->dmac_notused = 0;
+ cp->dmac_address = (ioaddr_t)seg->dmai_mapping;
+ cp->dmac_size = *lenp = seg->dmai_size;
+ cp->dmac_type = 0;
+ *offp = seg->dmai_offset;
+ break;
+ }
+
+ case DDI_DMA_MOVWIN:
+ {
+ uint_t winsize;
+ uint_t newoff;
+ int rval;
+
+ offset = (uint_t)(mp->dmai_mapping & IOMMU_PAGEOFFSET);
+ winsize = iommu_ptob(mp->dmai_ndvmapages - iommu_btopr(offset));
+
+ DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("movwin off %lx len %lx "
+ "winsize %x\n", *offp, *lenp, winsize));
+
+ if ((mp->dmai_rflags & DDI_DMA_PARTIAL) == 0)
+ return (DDI_FAILURE);
+
+ if (*lenp != (uint_t)-1 && *lenp != winsize) {
+ DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("bad length\n"));
+ return (DDI_FAILURE);
+ }
+ newoff = (uint_t)*offp;
+ if (newoff & (winsize - 1)) {
+ DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("bad off\n"));
+ return (DDI_FAILURE);
+ }
+
+ if (newoff == mp->dmai_offset) {
+ /*
+ * Nothing to do...
+ */
+ break;
+ }
+
+ /*
+ * Check out new address...
+ */
+ if (newoff > mp->dmai_object.dmao_size - mp->dmai_minxfer) {
+ DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("newoff out of "
+ "range\n"));
+ return (DDI_FAILURE);
+ }
+
+ rval = iommu_map_window(mp, newoff, winsize);
+ if (rval != DDI_SUCCESS)
+ return (rval);
+
+ if ((cp = (ddi_dma_cookie_t *)objp) != 0) {
+ cp->dmac_notused = 0;
+ cp->dmac_address = (ioaddr_t)mp->dmai_mapping;
+ cp->dmac_size = mp->dmai_size;
+ cp->dmac_type = 0;
+ }
+ *offp = (off_t)newoff;
+ *lenp = (uint_t)winsize;
+ break;
+ }
+
+ case DDI_DMA_REPWIN:
+ if ((mp->dmai_rflags & DDI_DMA_PARTIAL) == 0) {
+ DPRINTF(IOMMU_DMAMCTL_REPWIN_DEBUG, ("repwin fail\n"));
+ return (DDI_FAILURE);
+ }
+
+ *offp = (off_t)mp->dmai_offset;
+
+ addr = mp->dmai_ndvmapages -
+ iommu_btopr(mp->dmai_mapping & IOMMU_PAGEOFFSET);
+
+ *lenp = (uint_t)iommu_ptob(addr);
+
+ DPRINTF(IOMMU_DMAMCTL_REPWIN_DEBUG, ("repwin off %lx len %x\n",
+ mp->dmai_offset, mp->dmai_size));
+
+ break;
+
+ case DDI_DMA_GETERR:
+ DPRINTF(IOMMU_DMAMCTL_GETERR_DEBUG,
+ ("iommu_dma_mctl: geterr\n"));
+
+ break;
+
+ case DDI_DMA_COFF:
+ cp = (ddi_dma_cookie_t *)offp;
+ addr = cp->dmac_address;
+
+ if (addr < mp->dmai_mapping ||
+ addr >= mp->dmai_mapping + mp->dmai_size)
+ return (DDI_FAILURE);
+
+ *objp = (caddr_t)(addr - mp->dmai_mapping);
+
+ DPRINTF(IOMMU_DMAMCTL_COFF_DEBUG, ("coff off %lx mapping %lx "
+ "size %x\n", (ulong_t)*objp, mp->dmai_mapping,
+ mp->dmai_size));
+
+ break;
+
case DDI_DMA_RESERVE:
{
struct ddi_dma_req *dmareq = (struct ddi_dma_req *)offp;
diff --git a/usr/src/uts/sun4u/io/isadma.c b/usr/src/uts/sun4u/io/isadma.c
index 610391baa1..2372b3b11b 100644
--- a/usr/src/uts/sun4u/io/isadma.c
+++ b/usr/src/uts/sun4u/io/isadma.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/conf.h>
@@ -93,7 +90,7 @@ static struct bus_ops isadma_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/io/pci/db21554.c b/usr/src/uts/sun4u/io/pci/db21554.c
index f51ad8c0e6..5a08ae7b5d 100644
--- a/usr/src/uts/sun4u/io/pci/db21554.c
+++ b/usr/src/uts/sun4u/io/pci/db21554.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
@@ -280,7 +277,7 @@ struct bus_ops db_bus_ops = {
0,
0,
i_ddi_map_fault,
- 0,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/io/pci/pci_dma.c b/usr/src/uts/sun4u/io/pci/pci_dma.c
index 9814a69e68..5a614bf28d 100644
--- a/usr/src/uts/sun4u/io/pci/pci_dma.c
+++ b/usr/src/uts/sun4u/io/pci/pci_dma.c
@@ -22,9 +22,6 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* PCI nexus DVMA and DMA core routines:
@@ -1113,6 +1110,106 @@ pci_dvma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp,
uint_t cache_flags)
{
switch (cmd) {
+ case DDI_DMA_SYNC:
+ return (pci_dma_sync(dip, rdip, (ddi_dma_handle_t)mp,
+ *offp, *lenp, cache_flags));
+
+ case DDI_DMA_HTOC: {
+ int ret;
+ off_t wo_off, off = *offp; /* wo_off: wnd's obj offset */
+ uint_t win_size = mp->dmai_winsize;
+ ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)objp;
+
+ if (off >= mp->dmai_object.dmao_size) {
+ cmn_err(CE_WARN, "%s%d invalid dma_htoc offset %lx",
+ NAMEINST(mp->dmai_rdip), off);
+ return (DDI_FAILURE);
+ }
+ off += mp->dmai_roffset;
+ ret = pci_dma_win(dip, rdip, (ddi_dma_handle_t)mp,
+ off / win_size, &wo_off, NULL, cp, NULL); /* lenp == NULL */
+ if (ret)
+ return (ret);
+ DEBUG4(DBG_DMA_CTL, dip, "HTOC:cookie=%x+%lx off=%lx,%lx\n",
+ cp->dmac_address, cp->dmac_size, off, *offp);
+
+ /* adjust cookie addr/len if we are not on window boundary */
+ ASSERT((off % win_size) == (off -
+ (PCI_DMA_CURWIN(mp) ? mp->dmai_roffset : 0) - wo_off));
+ off = PCI_DMA_CURWIN(mp) ? off % win_size : *offp;
+ ASSERT(cp->dmac_size > off);
+ cp->dmac_laddress += off;
+ cp->dmac_size -= off;
+ DEBUG5(DBG_DMA_CTL, dip,
+ "HTOC:mp=%p cookie=%x+%lx off=%lx,%lx\n",
+ mp, cp->dmac_address, cp->dmac_size, off, wo_off);
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_REPWIN:
+ *offp = mp->dmai_offset;
+ *lenp = mp->dmai_size;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_MOVWIN: {
+ off_t off = *offp;
+ if (off >= mp->dmai_object.dmao_size)
+ return (DDI_FAILURE);
+ off += mp->dmai_roffset;
+ return (pci_dma_win(dip, rdip, (ddi_dma_handle_t)mp,
+ off / mp->dmai_winsize, offp, lenp,
+ (ddi_dma_cookie_t *)objp, NULL));
+ }
+
+ case DDI_DMA_NEXTWIN: {
+ window_t win = PCI_DMA_CURWIN(mp);
+ if (offp) {
+ if (*(window_t *)offp != win) { /* window not active */
+ *(window_t *)objp = win; /* return cur win */
+ return (DDI_DMA_STALE);
+ }
+ win++;
+ } else /* map win 0 */
+ win = 0;
+ if (win >= mp->dmai_nwin) {
+ *(window_t *)objp = win - 1;
+ return (DDI_DMA_DONE);
+ }
+ if (pci_dma_win(dip, rdip, (ddi_dma_handle_t)mp,
+ win, 0, 0, 0, 0)) {
+ *(window_t *)objp = win - 1;
+ return (DDI_FAILURE);
+ }
+ *(window_t *)objp = win;
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTSEG:
+ if (*(window_t *)offp != PCI_DMA_CURWIN(mp))
+ return (DDI_DMA_STALE);
+ if (lenp) /* only 1 seg allowed */
+ return (DDI_DMA_DONE);
+ /* return mp as seg 0 */
+ *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_SEGTOC:
+ MAKE_DMA_COOKIE((ddi_dma_cookie_t *)objp, mp->dmai_mapping,
+ mp->dmai_size);
+ *offp = mp->dmai_offset;
+ *lenp = mp->dmai_size;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_COFF: {
+ ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)offp;
+ if (cp->dmac_address < mp->dmai_mapping ||
+ (cp->dmac_address + cp->dmac_size) >
+ (mp->dmai_mapping + mp->dmai_size))
+ return (DDI_FAILURE);
+ *objp = (caddr_t)(cp->dmac_address - mp->dmai_mapping +
+ mp->dmai_offset);
+ }
+ return (DDI_SUCCESS);
case DDI_DMA_REMAP:
if (pci_dvma_remap_enabled)
@@ -1427,6 +1524,8 @@ pci_dma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp,
uint_t cache_flags)
{
switch (cmd) {
+ case DDI_DMA_SYNC: /* XXX */
+ return (DDI_SUCCESS);
case DDI_DMA_HTOC: {
off_t off = *offp;
@@ -1462,6 +1561,92 @@ pci_dma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp,
}
return (DDI_SUCCESS);
+ case DDI_DMA_REPWIN:
+ *offp = mp->dmai_offset;
+ *lenp = mp->dmai_size;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_MOVWIN: {
+ off_t off = *offp;
+ ddi_dma_cookie_t *cp;
+ pci_dma_win_t *win_p = mp->dmai_winlst;
+
+ if (off >= mp->dmai_object.dmao_size)
+ return (DDI_FAILURE);
+
+ /* locate window */
+ while (win_p->win_offset + win_p->win_size <= off)
+ win_p = win_p->win_next;
+
+ cp = (ddi_dma_cookie_t *)(win_p + 1);
+ mp->dmai_offset = win_p->win_offset;
+ mp->dmai_size = win_p->win_size;
+ mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */
+ mp->dmai_cookie = cp + 1;
+ win_p->win_curseg = 0;
+
+ *(ddi_dma_cookie_t *)objp = *cp;
+ *offp = win_p->win_offset;
+ *lenp = win_p->win_size;
+ DEBUG2(DBG_DMA_CTL, dip,
+ "HTOC: cookie - dmac_laddress=%p dmac_size=%x\n",
+ cp->dmac_laddress, cp->dmac_size);
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTWIN: {
+ pci_dma_win_t *win_p = *(pci_dma_win_t **)offp;
+ pci_dma_win_t **nw_pp = (pci_dma_win_t **)objp;
+ ddi_dma_cookie_t *cp;
+ if (!win_p) {
+ *nw_pp = mp->dmai_winlst;
+ return (DDI_SUCCESS);
+ }
+
+ if (win_p->win_offset != mp->dmai_offset)
+ return (DDI_DMA_STALE);
+ if (!win_p->win_next)
+ return (DDI_DMA_DONE);
+ win_p = win_p->win_next;
+ cp = (ddi_dma_cookie_t *)(win_p + 1);
+ mp->dmai_offset = win_p->win_offset;
+ mp->dmai_size = win_p->win_size;
+ mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */
+ mp->dmai_cookie = cp + 1;
+ win_p->win_curseg = 0;
+ *nw_pp = win_p;
+ }
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_NEXTSEG: {
+ pci_dma_win_t *w_p = *(pci_dma_win_t **)offp;
+ if (w_p->win_offset != mp->dmai_offset)
+ return (DDI_DMA_STALE);
+ if (w_p->win_curseg + 1 >= w_p->win_ncookies)
+ return (DDI_DMA_DONE);
+ w_p->win_curseg++;
+ }
+ *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp;
+ return (DDI_SUCCESS);
+
+ case DDI_DMA_SEGTOC: {
+ pci_dma_win_t *win_p = mp->dmai_winlst;
+ off_t off = mp->dmai_offset;
+ ddi_dma_cookie_t *cp;
+ int i;
+
+ /* locate active window */
+ for (; win_p->win_offset != off; win_p = win_p->win_next)
+ ;
+ cp = (ddi_dma_cookie_t *)(win_p + 1);
+ for (i = 0; i < win_p->win_curseg; i++, cp++)
+ off += cp->dmac_size;
+ *offp = off;
+ *lenp = cp->dmac_size;
+ *(ddi_dma_cookie_t *)objp = *cp; /* copy cookie */
+ }
+ return (DDI_SUCCESS);
+
case DDI_DMA_COFF: {
pci_dma_win_t *win_p;
ddi_dma_cookie_t *cp;
diff --git a/usr/src/uts/sun4u/io/pci/pci_iommu.c b/usr/src/uts/sun4u/io/pci/pci_iommu.c
index cc225aa0dc..0ae6e22e96 100644
--- a/usr/src/uts/sun4u/io/pci/pci_iommu.c
+++ b/usr/src/uts/sun4u/io/pci/pci_iommu.c
@@ -22,9 +22,8 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
/*
* PCI iommu initialization and configuration
@@ -79,26 +78,26 @@ iommu_create(pci_t *pci_p)
* Determine the virtual address of iommu registers.
*/
iommu_p->iommu_ctrl_reg =
- (uint64_t *)(a + COMMON_IOMMU_CTRL_REG_OFFSET);
+ (uint64_t *)(a + COMMON_IOMMU_CTRL_REG_OFFSET);
iommu_p->iommu_tsb_base_addr_reg =
- (uint64_t *)(a + COMMON_IOMMU_TSB_BASE_ADDR_REG_OFFSET);
+ (uint64_t *)(a + COMMON_IOMMU_TSB_BASE_ADDR_REG_OFFSET);
iommu_p->iommu_flush_page_reg =
- (uint64_t *)(a + COMMON_IOMMU_FLUSH_PAGE_REG_OFFSET);
+ (uint64_t *)(a + COMMON_IOMMU_FLUSH_PAGE_REG_OFFSET);
/*
* Configure the rest of the iommu parameters according to:
* tsb_size and dvma_end
*/
iommu_p->iommu_tsb_vaddr = /* retrieve TSB VA reserved by system */
- iommu_tsb_cookie_to_va(pci_p->pci_tsb_cookie);
+ iommu_tsb_cookie_to_va(pci_p->pci_tsb_cookie);
iommu_p->iommu_tsb_entries = tsb_entries =
- IOMMU_TSBSIZE_TO_TSBENTRIES(iommu_p->iommu_tsb_size);
+ IOMMU_TSBSIZE_TO_TSBENTRIES(iommu_p->iommu_tsb_size);
iommu_p->iommu_tsb_paddr = va_to_pa((caddr_t)iommu_p->iommu_tsb_vaddr);
iommu_p->iommu_dvma_cache_locks =
- kmem_zalloc(pci_dvma_page_cache_entries, KM_SLEEP);
+ kmem_zalloc(pci_dvma_page_cache_entries, KM_SLEEP);
iommu_p->iommu_dvma_base = iommu_p->iommu_dvma_end + 1
- - (tsb_entries * IOMMU_PAGE_SIZE);
+ - (tsb_entries * IOMMU_PAGE_SIZE);
iommu_p->dvma_base_pg = IOMMU_BTOP(iommu_p->iommu_dvma_base);
iommu_p->iommu_dvma_reserve = tsb_entries >> 1;
iommu_p->dvma_end_pg = IOMMU_BTOP(iommu_p->iommu_dvma_end);
@@ -111,29 +110,29 @@ iommu_create(pci_t *pci_p)
*/
pci_dvma_range.dvma_base = (uint32_t)iommu_p->iommu_dvma_base;
pci_dvma_range.dvma_len = (uint32_t)
- iommu_p->iommu_dvma_end - iommu_p->iommu_dvma_base + 1;
+ iommu_p->iommu_dvma_end - iommu_p->iommu_dvma_base + 1;
(void) ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP,
- "virtual-dma", (caddr_t)&pci_dvma_range,
- sizeof (pci_dvma_range));
+ "virtual-dma", (caddr_t)&pci_dvma_range,
+ sizeof (pci_dvma_range));
DEBUG2(DBG_ATTACH, dip, "iommu_create: ctrl=%p, tsb=%p\n",
- iommu_p->iommu_ctrl_reg, iommu_p->iommu_tsb_base_addr_reg);
+ iommu_p->iommu_ctrl_reg, iommu_p->iommu_tsb_base_addr_reg);
DEBUG2(DBG_ATTACH, dip, "iommu_create: page_flush=%p, ctx_flush=%p\n",
- iommu_p->iommu_flush_page_reg, iommu_p->iommu_flush_ctx_reg);
+ iommu_p->iommu_flush_page_reg, iommu_p->iommu_flush_ctx_reg);
DEBUG2(DBG_ATTACH, dip, "iommu_create: tsb vaddr=%p tsb_paddr=%p\n",
- iommu_p->iommu_tsb_vaddr, iommu_p->iommu_tsb_paddr);
+ iommu_p->iommu_tsb_vaddr, iommu_p->iommu_tsb_paddr);
DEBUG1(DBG_ATTACH, dip, "iommu_create: allocated size=%x\n",
- iommu_tsb_cookie_to_size(pci_p->pci_tsb_cookie));
+ iommu_tsb_cookie_to_size(pci_p->pci_tsb_cookie));
DEBUG2(DBG_ATTACH, dip, "iommu_create: fast tsb tte addr: %x + %x\n",
- iommu_p->iommu_tsb_vaddr,
- pci_dvma_page_cache_entries * pci_dvma_page_cache_clustsz);
+ iommu_p->iommu_tsb_vaddr,
+ pci_dvma_page_cache_entries * pci_dvma_page_cache_clustsz);
DEBUG3(DBG_ATTACH, dip,
- "iommu_create: tsb size=%x, tsb entries=%x, dvma base=%x\n",
- iommu_p->iommu_tsb_size, iommu_p->iommu_tsb_entries,
- iommu_p->iommu_dvma_base);
+ "iommu_create: tsb size=%x, tsb entries=%x, dvma base=%x\n",
+ iommu_p->iommu_tsb_size, iommu_p->iommu_tsb_entries,
+ iommu_p->iommu_dvma_base);
DEBUG2(DBG_ATTACH, dip,
- "iommu_create: dvma_cache_locks=%x cache_entries=%x\n",
- iommu_p->iommu_dvma_cache_locks, pci_dvma_page_cache_entries);
+ "iommu_create: dvma_cache_locks=%x cache_entries=%x\n",
+ iommu_p->iommu_dvma_cache_locks, pci_dvma_page_cache_entries);
/*
* zero out the area to be used for iommu tsb
@@ -145,16 +144,16 @@ iommu_create(pci_t *pci_p)
* Reserve 'size' bytes of low dvma space for fast track cache.
*/
(void) snprintf(map_name, sizeof (map_name), "%s%d_dvma",
- ddi_driver_name(dip), ddi_get_instance(dip));
+ ddi_driver_name(dip), ddi_get_instance(dip));
cache_size = IOMMU_PTOB(pci_dvma_page_cache_entries *
- pci_dvma_page_cache_clustsz);
+ pci_dvma_page_cache_clustsz);
iommu_p->iommu_dvma_fast_end = iommu_p->iommu_dvma_base +
- cache_size - 1;
+ cache_size - 1;
iommu_p->iommu_dvma_map = vmem_create(map_name,
- (void *)(iommu_p->iommu_dvma_fast_end + 1),
- IOMMU_PTOB(tsb_entries) - cache_size, IOMMU_PAGE_SIZE,
- NULL, NULL, NULL, IOMMU_PAGE_SIZE, VM_SLEEP);
+ (void *)(iommu_p->iommu_dvma_fast_end + 1),
+ IOMMU_PTOB(tsb_entries) - cache_size, IOMMU_PAGE_SIZE,
+ NULL, NULL, NULL, IOMMU_PAGE_SIZE, VM_SLEEP);
mutex_init(&iommu_p->dvma_debug_lock, NULL, MUTEX_DRIVER, NULL);
@@ -230,13 +229,14 @@ iommu_configure(iommu_t *iommu_p)
dev_info_t *dip = iommu_p->iommu_pci_p->pci_dip;
dev_info_t *cdip = NULL;
volatile uint64_t ctl_val = (uint64_t)
- ((iommu_p->iommu_tsb_size << COMMON_IOMMU_CTRL_TSB_SZ_SHIFT) |
- (0 /* 8k page */ << COMMON_IOMMU_CTRL_TBW_SZ_SHIFT) |
- COMMON_IOMMU_CTRL_ENABLE | COMMON_IOMMU_CTRL_DIAG_ENABLE |
- (pci_lock_tlb ? COMMON_IOMMU_CTRL_LCK_ENABLE : 0));
+ ((iommu_p->iommu_tsb_size << COMMON_IOMMU_CTRL_TSB_SZ_SHIFT) |
+ (0 /* 8k page */ << COMMON_IOMMU_CTRL_TBW_SZ_SHIFT) |
+ COMMON_IOMMU_CTRL_ENABLE |
+ COMMON_IOMMU_CTRL_DIAG_ENABLE |
+ (pci_lock_tlb ? COMMON_IOMMU_CTRL_LCK_ENABLE : 0));
DEBUG2(DBG_ATTACH, dip, "iommu_configure: iommu_ctl=%08x.%08x\n",
- HI32(ctl_val), LO32(ctl_val));
+ HI32(ctl_val), LO32(ctl_val));
if (!pci_preserve_iommu_tsb || !(*iommu_p->iommu_tsb_base_addr_reg)) {
*iommu_p->iommu_ctrl_reg = COMMON_IOMMU_CTRL_DIAG_ENABLE;
iommu_tlb_flushall(iommu_p);
@@ -247,7 +247,7 @@ iommu_configure(iommu_t *iommu_p)
uint32_t *reg_p;
int reg_len;
if (ddi_getlongprop(DDI_DEV_T_ANY, cdip, DDI_PROP_DONTPASS,
- "reg", (caddr_t)&reg_p, &reg_len) != DDI_PROP_SUCCESS)
+ "reg", (caddr_t)&reg_p, &reg_len) != DDI_PROP_SUCCESS)
continue;
cfgpa += (*reg_p) & (PCI_CONF_ADDR_MASK ^ PCI_REG_REG_M);
kmem_free(reg_p, reg_len);
@@ -274,45 +274,45 @@ iommu_map_pages(iommu_t *iommu_p, ddi_dma_impl_t *mp,
ASSERT(pfn_last <= mp->dmai_ndvmapages);
DEBUG5(DBG_MAP_WIN, dip,
- "iommu_map_pages:%x+%x=%x npages=0x%x pfn_index=0x%x\n",
- (uint_t)iommu_p->dvma_base_pg, (uint_t)pg_index, dvma_pg,
- (uint_t)npages, (uint_t)pfn_index);
+ "iommu_map_pages:%x+%x=%x npages=0x%x pfn_index=0x%x\n",
+ (uint_t)iommu_p->dvma_base_pg, (uint_t)pg_index, dvma_pg,
+ (uint_t)npages, (uint_t)pfn_index);
for (i = pfn_index; i < pfn_last; i++, pg_index++, tte_addr++) {
iopfn_t pfn = PCI_GET_MP_PFN(mp, i);
volatile uint64_t cur_tte = IOMMU_PTOB(pfn) | tte;
DEBUG3(DBG_MAP_WIN, dip, "iommu_map_pages: mp=%p pg[%x]=%x\n",
- mp, i, (uint_t)pfn);
+ mp, i, (uint_t)pfn);
DEBUG3(DBG_MAP_WIN, dip,
- "iommu_map_pages: pg_index=%x tte=%08x.%08x\n",
- pg_index, HI32(cur_tte), LO32(cur_tte));
+ "iommu_map_pages: pg_index=%x tte=%08x.%08x\n",
+ pg_index, HI32(cur_tte), LO32(cur_tte));
ASSERT(TTE_IS_INVALID(*tte_addr));
*tte_addr = cur_tte;
#ifdef DEBUG
if (pfn == 0 && pci_warn_pp0)
cmn_err(CE_WARN, "%s%d <%p> doing DMA to pp0\n",
- ddi_driver_name(mp->dmai_rdip),
- ddi_get_instance(mp->dmai_rdip), mp);
+ ddi_driver_name(mp->dmai_rdip),
+ ddi_get_instance(mp->dmai_rdip), mp);
#endif
}
ASSERT(tte_addr == iommu_p->iommu_tsb_vaddr + pg_index);
#ifdef DEBUG
if (HAS_REDZONE(mp)) {
DEBUG1(DBG_MAP_WIN, dip, "iommu_map_pages: redzone pg=%x\n",
- pg_index);
+ pg_index);
ASSERT(TTE_IS_INVALID(iommu_p->iommu_tsb_vaddr[pg_index]));
}
#endif
if (DVMA_DBG_ON(iommu_p))
pci_dvma_alloc_debug(iommu_p, (char *)mp->dmai_mapping,
- mp->dmai_size, mp);
+ mp->dmai_size, mp);
}
/*
* iommu_map_window - map a dvma window into the iommu
*
- * used by: pci_dma_win(), pci_dma_ctlops() - DDI_DMA_MOVWIN
+ * used by: pci_dma_win(), pci_dma_ctlops() - DDI_DMA_MOVWIN, DDI_DMA_NEXTWIN
*
* return value: none
*/
@@ -404,7 +404,7 @@ iommu_unmap_window(iommu_t *iommu_p, ddi_dma_impl_t *mp)
if (DVMA_DBG_ON(iommu_p))
pci_dvma_free_debug(iommu_p, (char *)mp->dmai_mapping,
- mp->dmai_size, mp);
+ mp->dmai_size, mp);
}
int
@@ -465,11 +465,11 @@ iommu_tlb_flushall(iommu_t *iommu_p)
{
int i;
uint64_t base = (uint64_t)(iommu_p->iommu_ctrl_reg) -
- COMMON_IOMMU_CTRL_REG_OFFSET;
+ COMMON_IOMMU_CTRL_REG_OFFSET;
volatile uint64_t *tlb_tag = (volatile uint64_t *)
- (base + COMMON_IOMMU_TLB_TAG_DIAG_ACC_OFFSET);
+ (base + COMMON_IOMMU_TLB_TAG_DIAG_ACC_OFFSET);
volatile uint64_t *tlb_data = (volatile uint64_t *)
- (base + COMMON_IOMMU_TLB_DATA_DIAG_ACC_OFFSET);
+ (base + COMMON_IOMMU_TLB_DATA_DIAG_ACC_OFFSET);
for (i = 0; i < IOMMU_TLB_ENTRIES; i++)
tlb_tag[i] = tlb_data[i] = 0ull;
}
@@ -486,32 +486,32 @@ iommu_preserve_tsb(iommu_t *iommu_p)
uint64_t *base_tte_addr;
DEBUG3(DBG_ATTACH, dip,
- "iommu_tsb_base_addr_reg=0x%08x (0x%08x.0x%08x)\n",
- iommu_p->iommu_tsb_base_addr_reg,
- (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg >> 32),
- (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg & 0xffffffff));
+ "iommu_tsb_base_addr_reg=0x%08x (0x%08x.0x%08x)\n",
+ iommu_p->iommu_tsb_base_addr_reg,
+ (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg >> 32),
+ (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg & 0xffffffff));
obp_tsb_size = IOMMU_CTL_TO_TSBSIZE(ctl);
obp_tsb_entries = IOMMU_TSBSIZE_TO_TSBENTRIES(obp_tsb_size);
base_pg_index = iommu_p->dvma_end_pg - obp_tsb_entries + 1;
base_tte_addr = iommu_p->iommu_tsb_vaddr +
- (iommu_p->iommu_tsb_entries - obp_tsb_entries);
+ (iommu_p->iommu_tsb_entries - obp_tsb_entries);
/*
* old darwin prom does not set tsb size correctly, bail out.
*/
if ((obp_tsb_size == IOMMU_DARWIN_BOGUS_TSBSIZE) &&
- (CHIP_TYPE(iommu_p->iommu_pci_p) == PCI_CHIP_SABRE))
- return;
+ (CHIP_TYPE(iommu_p->iommu_pci_p) == PCI_CHIP_SABRE))
+ return;
DEBUG3(DBG_ATTACH, dip, "iommu_preserve_tsb: kernel info\n"
- "iommu_tsb_vaddr=%08x copy to base_tte_addr=%08x "
- "base_pg_index=%x\n", iommu_p->iommu_tsb_vaddr,
- base_tte_addr, base_pg_index);
+ "iommu_tsb_vaddr=%08x copy to base_tte_addr=%08x "
+ "base_pg_index=%x\n", iommu_p->iommu_tsb_vaddr,
+ base_tte_addr, base_pg_index);
DEBUG3(DBG_ATTACH | DBG_CONT, dip, "iommu_preserve_tsb: obp info "
- "obp_tsb_entries=0x%x obp_tsb_pa=%08x.%08x\n", obp_tsb_entries,
- (uint32_t)(obp_tsb_pa >> 32), (uint32_t)obp_tsb_pa);
+ "obp_tsb_entries=0x%x obp_tsb_pa=%08x.%08x\n", obp_tsb_entries,
+ (uint32_t)(obp_tsb_pa >> 32), (uint32_t)obp_tsb_pa);
for (i = 0; i < obp_tsb_entries; i++) {
uint64_t tte = lddphys(obp_tsb_pa + i * 8);
@@ -524,8 +524,8 @@ iommu_preserve_tsb(iommu_t *iommu_p)
base_tte_addr[i] = tte;
DEBUG3(DBG_ATTACH | DBG_CONT, dip,
- "\npreserve_tsb: (%x)=%08x.%08x\n", base_tte_addr + i,
- (uint_t)(tte >> 32), (uint_t)(tte & 0xffffffff));
+ "\npreserve_tsb: (%x)=%08x.%08x\n", base_tte_addr + i,
+ (uint_t)(tte >> 32), (uint_t)(tte & 0xffffffff));
/*
* permanantly reserve this page from dvma address space
@@ -534,7 +534,7 @@ iommu_preserve_tsb(iommu_t *iommu_p)
va = (caddr_t)(IOMMU_PTOB(base_pg_index + i));
(void) vmem_xalloc(iommu_p->iommu_dvma_map, IOMMU_PAGE_SIZE,
- IOMMU_PAGE_SIZE, 0, 0, va, va + IOMMU_PAGE_SIZE,
- VM_NOSLEEP | VM_BESTFIT | VM_PANIC);
+ IOMMU_PAGE_SIZE, 0, 0, va, va + IOMMU_PAGE_SIZE,
+ VM_NOSLEEP | VM_BESTFIT | VM_PANIC);
}
}
diff --git a/usr/src/uts/sun4u/io/pci/pci_pci.c b/usr/src/uts/sun4u/io/pci/pci_pci.c
index 0196c3d2b4..8ec953f18b 100644
--- a/usr/src/uts/sun4u/io/pci/pci_pci.c
+++ b/usr/src/uts/sun4u/io/pci/pci_pci.c
@@ -22,9 +22,6 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
* Sun4u PCI to PCI bus bridge nexus driver
@@ -111,7 +108,7 @@ struct bus_ops ppb_bus_ops = {
0,
0,
i_ddi_map_fault,
- 0,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/io/pci/simba.c b/usr/src/uts/sun4u/io/pci/simba.c
index fbce93e6a6..480117ce24 100644
--- a/usr/src/uts/sun4u/io/pci/simba.c
+++ b/usr/src/uts/sun4u/io/pci/simba.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
/*
@@ -126,7 +123,7 @@ struct bus_ops simba_bus_ops = {
0,
0,
i_ddi_map_fault,
- 0,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/io/pmubus.c b/usr/src/uts/sun4u/io/pmubus.c
index 66a969c698..502ace5b73 100644
--- a/usr/src/uts/sun4u/io/pmubus.c
+++ b/usr/src/uts/sun4u/io/pmubus.c
@@ -22,9 +22,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/types.h>
@@ -98,7 +95,7 @@ static struct bus_ops pmubus_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/io/sysiosbus.c b/usr/src/uts/sun4u/io/sysiosbus.c
index 71ec224b19..fbfde87d14 100644
--- a/usr/src/uts/sun4u/io/sysiosbus.c
+++ b/usr/src/uts/sun4u/io/sysiosbus.c
@@ -23,9 +23,6 @@
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/types.h>
#include <sys/conf.h>
@@ -311,7 +308,7 @@ static struct bus_ops sbus_bus_ops = {
0,
0,
i_ddi_map_fault,
- 0,
+ iommu_dma_map,
iommu_dma_allochdl,
iommu_dma_freehdl,
iommu_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/montecarlo/io/acebus.c b/usr/src/uts/sun4u/montecarlo/io/acebus.c
index f1c92ea5b2..5c7ffcf8ba 100644
--- a/usr/src/uts/sun4u/montecarlo/io/acebus.c
+++ b/usr/src/uts/sun4u/montecarlo/io/acebus.c
@@ -23,9 +23,6 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/types.h>
@@ -102,7 +99,7 @@ static struct bus_ops acebus_bus_ops = {
NULL,
NULL,
i_ddi_map_fault,
- NULL,
+ ddi_dma_map,
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/serengeti/io/ssm.c b/usr/src/uts/sun4u/serengeti/io/ssm.c
index ccd68ed9b5..4aba952a86 100644
--- a/usr/src/uts/sun4u/serengeti/io/ssm.c
+++ b/usr/src/uts/sun4u/serengeti/io/ssm.c
@@ -23,9 +23,6 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#include <sys/types.h>
#include <sys/conf.h>
#include <sys/ddi.h>
@@ -164,7 +161,7 @@ static struct bus_ops ssm_bus_ops = {
0, /* add_intrspec */
0, /* remove_intrspec */
i_ddi_map_fault, /* map_fault */
- 0, /* dma_map */
+ ddi_dma_map, /* dma_map */
ddi_dma_allochdl,
ddi_dma_freehdl,
ddi_dma_bindhdl,
diff --git a/usr/src/uts/sun4u/sys/iommu.h b/usr/src/uts/sun4u/sys/iommu.h
index f2731f4699..947427280d 100644
--- a/usr/src/uts/sun4u/sys/iommu.h
+++ b/usr/src/uts/sun4u/sys/iommu.h
@@ -23,13 +23,12 @@
* Copyright (c) 1991-2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
-/*
- * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
- */
#ifndef _SYS_IOMMU_H
#define _SYS_IOMMU_H
+#pragma ident "%Z%%M% %I% %E% SMI"
+
#if defined(_KERNEL) && !defined(_ASM)
#include <sys/sunddi.h>
#include <sys/sysiosbus.h>
@@ -132,6 +131,8 @@ extern int iommu_init(struct sbus_soft_state *, caddr_t);
extern int iommu_resume_init(struct sbus_soft_state *);
extern int iommu_dma_mctl(dev_info_t *, dev_info_t *, ddi_dma_handle_t,
enum ddi_dma_ctlops, off_t *, size_t *, caddr_t *, uint_t);
+extern int iommu_dma_map(dev_info_t *, dev_info_t *, struct ddi_dma_req *,
+ ddi_dma_handle_t *);
extern int iommu_dma_allochdl(dev_info_t *, dev_info_t *, ddi_dma_attr_t *,
int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *);
extern int iommu_dma_freehdl(dev_info_t *, dev_info_t *, ddi_dma_handle_t);