summaryrefslogtreecommitdiff
path: root/usr/src/uts/common
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 /usr/src/uts/common
parent88b44bf4e73233af70877930178dbff7f1c2992b (diff)
downloadillumos-gate-15e1afcd5e908ae29b1e6018838638befdc225a2.tar.gz
backout 998: breaks common closed drivers
Diffstat (limited to 'usr/src/uts/common')
-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
25 files changed, 670 insertions, 136 deletions
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,