Module Name: src Committed By: jdolecek Date: Tue May 29 06:14:34 UTC 2018
Modified Files: src/sys/dev/isa: isadma.c isadmareg.h isareg.h Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/dev/isa/isadma.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/isa/isadmareg.h cvs rdiff -u -r1.9 -r1.10 src/sys/dev/isa/isareg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/isa/isadma.c diff -u src/sys/dev/isa/isadma.c:1.66 src/sys/dev/isa/isadma.c:1.67 --- src/sys/dev/isa/isadma.c:1.66 Sat Nov 13 13:52:03 2010 +++ src/sys/dev/isa/isadma.c Tue May 29 06:14:33 2018 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: isadma.c,v 1 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 @@ _isa_dmainit(struct isa_dma_state *ids, 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 @@ _isa_dmadestroy(struct isa_dma_state *id /* * 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); Index: src/sys/dev/isa/isadmareg.h diff -u src/sys/dev/isa/isadmareg.h:1.8 src/sys/dev/isa/isadmareg.h:1.9 --- src/sys/dev/isa/isadmareg.h:1.8 Mon Apr 28 20:23:52 2008 +++ src/sys/dev/isa/isadmareg.h Tue May 29 06:14:33 2018 @@ -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): */ Index: src/sys/dev/isa/isareg.h diff -u src/sys/dev/isa/isareg.h:1.9 src/sys/dev/isa/isareg.h:1.10 --- src/sys/dev/isa/isareg.h:1.9 Sun Dec 11 12:22:02 2005 +++ src/sys/dev/isa/isareg.h Tue May 29 06:14:33 2018 @@ -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 */