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

Re: _bus_dmamem_alloc_range()



濱嶋です。

aiuのD/Aコンバータがunsignedなのに気づいたら、モノラルのwavファイルが
audioplayで再生できるところまできました。mp3は実装が不充分なのか鳴りま
せんでした。

>> ところでこのコードをこのままにしておくとまた取り残されてしまいそうなの
>> で、この部分(hpcmipsのbus_dma)だけでもマージをお願いしたいのですが、こ
>> こに流せばよろしいでしょうか?
> 
> はい。そうしてください。

よろしくお願いします。


diff -ru /sys/arch/hpcmips/include/bus_dma_hpcmips.h sys/arch/hpcmips/include/bus_dma_hpcmips.h
--- /sys/arch/hpcmips/include/bus_dma_hpcmips.h	Sun Nov 18 17:19:40 2001
+++ sys/arch/hpcmips/include/bus_dma_hpcmips.h	Sun Jan  6 20:45:47 2002
@@ -73,4 +73,9 @@
 extern struct bus_dma_tag_hpcmips hpcmips_default_bus_dma_tag;
 bus_dma_protos(_hpcmips)
 
+int	_hpcmips_bd_mem_alloc_range __P((bus_dma_tag_t tag, bus_size_t size,
+	    bus_size_t alignment, bus_size_t boundary,
+	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
+	    vaddr_t low, vaddr_t high));
+
 #endif /* _BUS_DMA_HPCMIPS_H_ */
diff -ru /sys/arch/hpcmips/hpcmips/bus_dma.c sys/arch/hpcmips/hpcmips/bus_dma.c
--- /sys/arch/hpcmips/hpcmips/bus_dma.c	Sun Nov 18 17:19:39 2001
+++ sys/arch/hpcmips/hpcmips/bus_dma.c	Sun Jan  6 17:45:00 2002
@@ -512,22 +512,42 @@
     int flags)
 {
 	extern paddr_t avail_start, avail_end;		/* XXX */
-	vaddr_t curaddr, lastaddr;
 	psize_t high;
+
+	high = avail_end - PAGE_SIZE;
+
+	return (_hpcmips_bd_mem_alloc_range(t, size, alignment, boundary,
+	    segs, nsegs, rsegs, flags, avail_start, high));
+}
+
+/*
+ * Allocate physical memory from the given physical address range.
+ * Called by DMA-safe memory allocation methods.
+ */
+int
+_hpcmips_bd_mem_alloc_range(bus_dma_tag_t t, bus_size_t size,
+    bus_size_t alignment, bus_size_t boundary,
+    bus_dma_segment_t *segs, int nsegs, int *rsegs,
+    int flags, paddr_t low, paddr_t high)
+{
+	vaddr_t curaddr, lastaddr;
 	struct vm_page *m;
 	struct pglist mlist;
 	int curseg, error;
+#ifdef DIAGNOSTIC
+	extern paddr_t avail_start, avail_end;		/* XXX */
 
+	high = high<(avail_end - PAGE_SIZE)? high: (avail_end - PAGE_SIZE);
+	low = low>avail_start? low: avail_start;
+#endif
 	/* Always round the size. */
 	size = round_page(size);
 
-	high = avail_end - PAGE_SIZE;
-
 	/*
 	 * Allocate pages from the VM system.
 	 */
 	TAILQ_INIT(&mlist);
-	error = uvm_pglistalloc(size, avail_start, high, alignment, boundary,
+	error = uvm_pglistalloc(size, low, high, alignment, boundary,
 	    &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
 	if (error)
 		return (error);
@@ -545,7 +565,7 @@
 	for (; m != NULL; m = m->pageq.tqe_next) {
 		curaddr = VM_PAGE_TO_PHYS(m);
 #ifdef DIAGNOSTIC
-		if (curaddr < avail_start || curaddr >= high) {
+		if (curaddr < low || curaddr >= high) {
 			printf("uvm_pglistalloc returned non-sensical"
 			    " address 0x%lx\n", curaddr);
 			panic("_hpcmips_bd_mem_alloc");