Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/isa fix off-by-one in the mapping of the ISA DMA pag...



details:   https://anonhg.NetBSD.org/src/rev/3186e3f379ac
branches:  trunk
changeset: 319422:3186e3f379ac
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue May 29 06:14:33 2018 +0000

description:
fix off-by-one in the mapping of the ISA DMA page registers, they actually
start at 0x81; the code used bus_space_map() starting from 0x80 but
used +1 offset for actual I/O, now it maps starting 0x81 and does I/O
without offset

the reads and writes work exactly the same as before, but this frees
0x80 for being mapped independantly

patch provided in PR kern/52468 by Jonathan Chapman; checked against the spec
and also FreeBSD sys/x86/isa/isa_dma.c

diffstat:

 sys/dev/isa/isadma.c    |  24 ++++++++++++++----------
 sys/dev/isa/isadmareg.h |   5 ++++-
 sys/dev/isa/isareg.h    |   4 ++--
 3 files changed, 20 insertions(+), 13 deletions(-)

diffs (99 lines):

diff -r cf0f18461c39 -r 3186e3f379ac sys/dev/isa/isadma.c
--- a/sys/dev/isa/isadma.c      Tue May 29 06:07:26 2018 +0000
+++ b/sys/dev/isa/isadma.c      Tue May 29 06:14:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isadma.c,v 1.66 2010/11/13 13:52:03 uebayasi Exp $     */
+/*     $NetBSD: isadma.c,v 1.67 2018/05/29 06:14:33 jdolecek Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isadma.c,v 1.66 2010/11/13 13:52:03 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isadma.c,v 1.67 2018/05/29 06:14:33 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,15 +53,19 @@
 struct isa_mem *isa_mem_head;
 
 /*
- * High byte of DMA address is stored in this DMAPG register for
- * the Nth DMA channel.
+ * DMA Channel to Address Page Register offset mapping
+ *
+ * Offset from IO_DMAPG is stored in this 2D array -- first dimension is
+ * the DMA controller, second dimension is the DMA channel.
+ *
+ * e.g. dmapageport[0][1] gives us the offset for DMA ch 1 on DMA1
  */
-static int dmapageport[2][4] = {
-       {0x7, 0x3, 0x1, 0x2},
-       {0xf, 0xb, 0x9, 0xa}
+static const int dmapageport[2][4] = {
+       {0x6, 0x2, 0x0, 0x1},
+       {0xe, 0xa, 0x8, 0x9}
 };
 
-static u_int8_t dmamode[] = {
+static const u_int8_t dmamode[] = {
        /* write to device/read from device */
        DMA37MD_READ | DMA37MD_SINGLE,
        DMA37MD_WRITE | DMA37MD_SINGLE,
@@ -169,7 +173,7 @@
                if (bus_space_map(ids->ids_bst, IO_DMA2, DMA2_IOSIZE, 0,
                    &ids->ids_dma2h))
                        panic("_isa_dmainit: unable to map DMA controller #2");
-               if (bus_space_map(ids->ids_bst, IO_DMAPG, 0xf, 0,
+               if (bus_space_map(ids->ids_bst, IO_DMAPG, DMAPG_IOSIZE, 0,
                    &ids->ids_dmapgh))
                        panic("_isa_dmainit: unable to map DMA page registers");
 
@@ -211,7 +215,7 @@
        /*
         * Unmap the registers used by the ISA DMA controller.
         */
-       bus_space_unmap(ids->ids_bst, ids->ids_dmapgh, 0xf);
+       bus_space_unmap(ids->ids_bst, ids->ids_dmapgh, DMAPG_IOSIZE);
        bus_space_unmap(ids->ids_bst, ids->ids_dma2h, DMA2_IOSIZE);
        bus_space_unmap(ids->ids_bst, ids->ids_dma1h, DMA1_IOSIZE);
 
diff -r cf0f18461c39 -r 3186e3f379ac sys/dev/isa/isadmareg.h
--- a/sys/dev/isa/isadmareg.h   Tue May 29 06:07:26 2018 +0000
+++ b/sys/dev/isa/isadmareg.h   Tue May 29 06:14:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isadmareg.h,v 1.8 2008/04/28 20:23:52 martin Exp $     */
+/*     $NetBSD: isadmareg.h,v 1.9 2018/05/29 06:14:33 jdolecek Exp $   */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -47,6 +47,9 @@
 #define        ISA_DMA_MAXSIZE_DEFAULT(chan)                                   \
        (((chan) & 4) ? ISA_DMA_MAXSIZE_16BIT : ISA_DMA_MAXSIZE_8BIT)
 
+/* DMA Page Address Registers size */
+#define        DMAPG_IOSIZE    (1*15)
+
 /*
  * Register definitions for DMA controller 1 (channels 0..3):
  */
diff -r cf0f18461c39 -r 3186e3f379ac sys/dev/isa/isareg.h
--- a/sys/dev/isa/isareg.h      Tue May 29 06:07:26 2018 +0000
+++ b/sys/dev/isa/isareg.h      Tue May 29 06:14:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isareg.h,v 1.9 2005/12/11 12:22:02 christos Exp $      */
+/*     $NetBSD: isareg.h,v 1.10 2018/05/29 06:14:33 jdolecek Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -55,7 +55,7 @@
 #define        IO_PPI          0x061           /* Programmable Peripheral Interface */
 #define        IO_RTC          0x070           /* RTC */
 #define        IO_NMI          IO_RTC          /* NMI Control */
-#define        IO_DMAPG        0x080           /* DMA Page Registers */
+#define        IO_DMAPG        0x081           /* DMA Page Registers */
 #define        IO_ICU2         0x0A0           /* 8259A Interrupt Controller #2 */
 #define        IO_DMA2         0x0C0           /* 8237A DMA Controller #2 */
 #define        IO_NPX          0x0F0           /* Numeric Coprocessor */



Home | Main Index | Thread Index | Old Index