Module Name:    src
Committed By:   dyoung
Date:           Wed Sep 28 01:33:26 UTC 2011

Modified Files:
        src/sys/arch/x86/x86: bus_dma.c

Log Message:
Add an untested implementation of bus_dmamap_load_raw(9).


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/x86/x86/bus_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/bus_dma.c
diff -u src/sys/arch/x86/x86/bus_dma.c:1.63 src/sys/arch/x86/x86/bus_dma.c:1.64
--- src/sys/arch/x86/x86/bus_dma.c:1.63	Tue Sep 27 23:44:18 2011
+++ src/sys/arch/x86/x86/bus_dma.c	Wed Sep 28 01:33:26 2011
@@ -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 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bu
  */
 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;
+
+	/*
+	 * 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;
 
-	panic("_bus_dmamap_load_raw: not implemented");
+		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;
 }
 
 /*

Reply via email to