summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-06-06 05:43:14 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-06-06 05:43:14 +0000
commitf4e5d68bcd3927bf4124d5b83fe246911d8c0c92 (patch)
treebf52ee0553f1b89e9c188d0ac2117a7752918d63 /sys/arch
parent14f56fd54d50cc1c9bba30f5d386b6b2c78908ad (diff)
It might be a good idea to commit all the diff. *sigh*.
now this builds
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/i386/bus_dma.c11
-rw-r--r--sys/arch/i386/include/bus.h48
2 files changed, 56 insertions, 3 deletions
diff --git a/sys/arch/i386/i386/bus_dma.c b/sys/arch/i386/i386/bus_dma.c
index 05d80f09d66..0c784c7310e 100644
--- a/sys/arch/i386/i386/bus_dma.c
+++ b/sys/arch/i386/i386/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.16 2009/04/20 00:42:06 oga Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.17 2009/06/06 05:43:13 oga Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -601,7 +601,13 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
/* Always round the size. */
size = round_page(size);
- TAILQ_INIT(&mlist);
+ segs[0]._ds_boundary = boundary;
+ segs[0]._ds_align = alignment;
+ if (flags & BUS_DMA_SG) {
+ boundary = 0;
+ alignment = 0;
+ }
+
/*
* Allocate pages from the VM system.
* For non-ISA mappings first try higher memory segments.
@@ -610,6 +616,7 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
if (flags & BUS_DMA_ZERO)
plaflag |= UVM_PLA_ZERO;
+ TAILQ_INIT(&mlist);
if (high <= ISA_DMA_BOUNCE_THRESHOLD || (error = uvm_pglistalloc(size,
round_page(ISA_DMA_BOUNCE_THRESHOLD), high, alignment, boundary,
&mlist, nsegs, plaflag)))
diff --git a/sys/arch/i386/include/bus.h b/sys/arch/i386/include/bus.h
index 2153068440c..ae42970834b 100644
--- a/sys/arch/i386/include/bus.h
+++ b/sys/arch/i386/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.48 2009/04/20 00:42:06 oga Exp $ */
+/* $OpenBSD: bus.h,v 1.49 2009/06/06 05:43:13 oga Exp $ */
/* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */
/*-
@@ -66,6 +66,8 @@
#ifndef _I386_BUS_H_
#define _I386_BUS_H_
+#include <sys/mutex.h>
+
#include <machine/pio.h>
/*
@@ -454,6 +456,7 @@ void bus_space_copy_4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
#define BUS_DMA_WRITE 0x0400 /* mapping is memory -> device only */
#define BUS_DMA_NOCACHE 0x0800 /* map memory uncached */
#define BUS_DMA_ZERO 0x1000 /* dmamem_alloc return zeroed mem */
+#define BUS_DMA_SG 0x2000 /* Internal. memory is for SG map */
/* Forwards needed by prototypes below. */
struct mbuf;
@@ -480,6 +483,13 @@ typedef struct bus_dmamap *bus_dmamap_t;
struct bus_dma_segment {
bus_addr_t ds_addr; /* DMA address */
bus_size_t ds_len; /* length of transfer */
+ /*
+ * Ugh. need this so can pass alignment down from bus_dmamem_alloc
+ * to scatter gather maps. only the first one is used so the rest is
+ * wasted space. bus_dma could do with fixing the api for this.
+ */
+ bus_size_t _ds_boundary; /* don't cross */
+ bus_size_t _ds_align; /* align to me */
};
typedef struct bus_dma_segment bus_dma_segment_t;
@@ -611,4 +621,40 @@ int _bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size,
bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
paddr_t low, paddr_t high);
+struct extent;
+
+/* Scatter gather bus_dma functions. */
+struct sg_cookie {
+ struct mutex sg_mtx;
+ struct extent *sg_ex;
+ void *sg_hdl;
+ void (*bind_page)(void *, bus_addr_t, paddr_t, int);
+ void (*unbind_page)(void *, bus_addr_t);
+ void (*flush_tlb)(void *);
+};
+
+struct sg_cookie *sg_dmatag_init(char *, void *, bus_addr_t, bus_size_t,
+ void (*)(void *, vaddr_t, paddr_t, int),
+ void (*)(void *, vaddr_t), void (*)(void *));
+void sg_dmatag_destroy(struct sg_cookie *);
+int sg_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
+ bus_size_t, int, bus_dmamap_t *);
+void sg_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
+void sg_dmamap_set_alignment(bus_dma_tag_t, bus_dmamap_t, u_long);
+int sg_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t,
+ struct proc *, int);
+int sg_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
+ struct mbuf *, int);
+int sg_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t, struct uio *, int);
+int sg_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, bus_dma_segment_t *,
+ int, bus_size_t, int);
+void sg_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
+int sg_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t,
+ struct proc *, int, int *, int);
+int sg_dmamap_load_physarray(bus_dma_tag_t, bus_dmamap_t, paddr_t *,
+ int, int, int *, int);
+int sg_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t,
+ bus_dma_segment_t *, int, int *, int);
+
+
#endif /* _I386_BUS_H_ */