NetBSD-Bugs archive

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

Re: kern/52468: ISA DMA incorrectly maps I/O port 0x80 for page address registers



The following reply was made to PR kern/52468; it has been noted by GNATS.

From: glitch <glitch%glitchwrks.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/52468: ISA DMA incorrectly maps I/O port 0x80 for page
 address registers
Date: Mon, 7 Aug 2017 18:22:50 -0400

 New patch implementing the offset change as just a decrement of the values in the dmapageport 2D array. Adjusted comments to reflect this.
 
 We were talking about what was best last night on IRC, I don't think anyone had a strong opinion one way or the other.
 
 diff -uNr usr_orig/src/sys/dev/isa/isadma.c usr/src/sys/dev/isa/isadma.c
 --- usr_orig/src/sys/dev/isa/isadma.c	2010-11-13 08:52:03.000000000 -0500
 +++ usr/src/sys/dev/isa/isadma.c	2017-08-07 18:19:33.083500767 -0400
 @@ -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 -uNr usr_orig/src/sys/dev/isa/isadmareg.h usr/src/sys/dev/isa/isadmareg.h
 --- usr_orig/src/sys/dev/isa/isadmareg.h	2008-04-28 16:23:52.000000000 -0400
 +++ usr/src/sys/dev/isa/isadmareg.h	2017-08-06 17:43:47.508172970 -0400
 @@ -47,6 +47,10 @@
  #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 -uNr usr_orig/src/sys/dev/isa/isareg.h usr/src/sys/dev/isa/isareg.h
 --- usr_orig/src/sys/dev/isa/isareg.h	2005-12-11 07:22:02.000000000 -0500
 +++ usr/src/sys/dev/isa/isareg.h	2017-08-06 16:30:10.000000000 -0400
 @@ -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