Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Add an untested implementation of bus_dmama...



details:   https://anonhg.NetBSD.org/src/rev/ec6a24a69224
branches:  trunk
changeset: 769959:ec6a24a69224
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Wed Sep 28 01:33:26 2011 +0000

description:
Add an untested implementation of bus_dmamap_load_raw(9).

diffstat:

 sys/arch/x86/x86/bus_dma.c |  43 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 5 deletions(-)

diffs (66 lines):

diff -r 0b51484f25fb -r ec6a24a69224 sys/arch/x86/x86/bus_dma.c
--- a/sys/arch/x86/x86/bus_dma.c        Tue Sep 27 23:44:18 2011 +0000
+++ b/sys/arch/x86/x86/bus_dma.c        Wed Sep 28 01:33:26 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.63 2011/09/27 23:44:18 dyoung Exp $      */
+/*     $NetBSD: bus_dma.c,v 1.64 2011/09/28 01:33:26 dyoung Exp $      */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.63 2011/09/27 23:44:18 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.64 2011/09/28 01:33:26 dyoung Exp $");
 
 /*
  * The following is included because _bus_dma_uiomove is derived from
@@ -716,11 +716,44 @@
  */
 static int
 _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
-    bus_dma_segment_t *segs, int nsegs,
-    bus_size_t size, int flags)
+    bus_dma_segment_t *segs, int nsegs, bus_size_t size0, int flags)
 {
+       bus_size_t size;
+       int i, error = 0;
 
-       panic("_bus_dmamap_load_raw: not implemented");
+       /*
+        * Make sure that on error condition we return "no valid mappings."
+        */
+       map->dm_mapsize = 0;
+       map->dm_nsegs = 0;
+       KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+
+       if (size0 > map->_dm_size)
+               return EINVAL;
+
+       for (i = 0, size = size0; i < nsegs && size > 0; i++) {
+               bus_dma_segment_t *ds = &segs[i];
+               bus_size_t sgsize;
+
+               sgsize = MIN(ds->ds_len, size);
+               if (sgsize == 0)
+                       continue;
+               error = _bus_dmamap_load_busaddr(t, map, ds->ds_addr, sgsize);
+               if (error != 0)
+                       break;
+               size -= sgsize;
+       }
+
+       if (error != 0) {
+               map->dm_mapsize = 0;
+               map->dm_nsegs = 0;
+               return error;
+       }
+
+       /* XXX TBD bounce */
+
+       map->dm_mapsize = size0;
+       return 0;
 }
 
 /*



Home | Main Index | Thread Index | Old Index