Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/macppc/dev first step to make dbdma less hackish



details:   https://anonhg.NetBSD.org/src/rev/25546b8bff35
branches:  trunk
changeset: 816646:25546b8bff35
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Jul 15 21:08:27 2016 +0000

description:
first step to make dbdma less hackish
- dbdma_alloc gets a new parameter to return the actual address of the
  buffer before being alignment-mangled so we can properly free it
- add dbdma_free which takes the pointer mentioned above
dbdma should really use bus_dma

diffstat:

 sys/arch/macppc/dev/dbdma.c |  15 ++++++++++++---
 sys/arch/macppc/dev/dbdma.h |   5 +++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diffs (59 lines):

diff -r 0c4db5d9d5f1 -r 25546b8bff35 sys/arch/macppc/dev/dbdma.c
--- a/sys/arch/macppc/dev/dbdma.c       Fri Jul 15 19:42:08 2016 +0000
+++ b/sys/arch/macppc/dev/dbdma.c       Fri Jul 15 21:08:27 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dbdma.c,v 1.11 2012/05/23 21:47:23 macallan Exp $      */
+/*     $NetBSD: dbdma.c,v 1.12 2016/07/15 21:08:27 macallan Exp $      */
 
 /*
  * Copyright 1991-1998 by Open Software Foundation, Inc. 
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dbdma.c,v 1.11 2012/05/23 21:47:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbdma.c,v 1.12 2016/07/15 21:08:27 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -115,12 +115,21 @@
 }
 
 dbdma_command_t        *
-dbdma_alloc(int size)
+dbdma_alloc(int size, void **fp)
 {
        u_int buf;
 
        buf = (u_int)kmem_alloc(size + 0x0f, KM_SLEEP);
+       if (fp != NULL) {
+        *fp = (void *)buf;
+        }
        buf = (buf + 0x0f) & ~0x0f;
 
        return (dbdma_command_t *)buf;
 }
+
+void
+dbdma_free(void *ptr, int size)
+{
+       kmem_free(ptr, size + 0x0f);
+}
diff -r 0c4db5d9d5f1 -r 25546b8bff35 sys/arch/macppc/dev/dbdma.h
--- a/sys/arch/macppc/dev/dbdma.h       Fri Jul 15 19:42:08 2016 +0000
+++ b/sys/arch/macppc/dev/dbdma.h       Fri Jul 15 21:08:27 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dbdma.h,v 1.5 2007/10/17 19:55:18 garbled Exp $        */
+/*     $NetBSD: dbdma.h,v 1.6 2016/07/15 21:08:27 macallan Exp $       */
 
 /*
  * Copyright 1991-1998 by Open Software Foundation, Inc. 
@@ -166,6 +166,7 @@
 void   dbdma_continue(dbdma_regmap_t *channel);
 void   dbdma_pause(dbdma_regmap_t *channel);
 
-dbdma_command_t        *dbdma_alloc(int);      /* Allocate command structures */
+dbdma_command_t        *dbdma_alloc(int, void **);     /* Allocate command structures */
+void   dbdma_free(void *, int);
 
 #endif /* !defined(_POWERMAC_DBDMA_H_) */



Home | Main Index | Thread Index | Old Index