NetBSD-Bugs archive

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

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



>Number:         52468
>Category:       kern
>Synopsis:       ISA DMA incorrectly maps I/O port 0x80 for page address registers
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 06 20:40:00 +0000 2017
>Originator:     Jonathan Chapman
>Release:        NetBSD/i386 7.1
>Organization:
glitchwrks.com
>Environment:
NetBSD netbsd-ipc.bv.theglitchworks.net 7.1 NetBSD 7.1 (IPC) #28: Sun Aug  6 15:58:18 EDT 2017  glitch%netbsd-ipc.bv.theglitchworks.net@localhost:/usr/src/sys/arch/i386/compile/IPC i386
>Description:
While developing an ISA bus driver for NetBSD, I found that I could not bus_space_map() I/O port 0x80, which is typically where the PC BIOS writes POST debug codes. You can plug in a little board with a hex display and view these codes; some software also will write to 0x80 after the OS has taken over as a status display.

I was able to map my driver onto port 0x300 (I have a POST display card that supports this) and verify the driver was functioning correctly. Going through /usr/src/sys/dev/isa/isareg.h I discovered that the ISA DMA system was mapping its DMA page address registers starting at 0x80. /usr/src/sys/dev/isa/isadma.c showed that a 16-byte block was being mapped here. The DMA registers do not start at 0x80, they begin at 0x81 and extend to 0x8F, which this patch corrects.
>How-To-Repeat:
Attempt to bus_space_map() a one-byte I/O port at 0x80 on an ISA bus with an ISA DMA controller attached.
>Fix:
The following two patches apply cleanly to the 7.1 source and resolve the problem.

*** usr/src/sys/dev/isa/isareg.h.orig	2017-08-06 16:25:21.671407088 -0400
--- usr/src/sys/dev/isa/isareg.h	2017-08-06 16:30:10.668423204 -0400
***************
*** 55,61 ****
  #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_ICU2		0x0A0		/* 8259A Interrupt Controller #2 */
  #define	IO_DMA2		0x0C0		/* 8237A DMA Controller #2 */
  #define	IO_NPX		0x0F0		/* Numeric Coprocessor */
--- 55,61 ----
  #define	IO_PPI		0x061		/* Programmable Peripheral Interface */
  #define	IO_RTC		0x070		/* RTC */
  #define	IO_NMI		IO_RTC		/* NMI Control */
! #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 */


*** usr/src/sys/dev/isa/isadma.c.orig	2017-08-06 16:25:29.462596254 -0400
--- usr/src/sys/dev/isa/isadma.c	2017-08-06 16:30:14.680520599 -0400
*************** _isa_dmainit(struct isa_dma_state *ids,
*** 169,175 ****
  		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,
  		    &ids->ids_dmapgh))
  			panic("_isa_dmainit: unable to map DMA page registers");
  
--- 169,175 ----
  		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, 0xe, 0,
  		    &ids->ids_dmapgh))
  			panic("_isa_dmainit: unable to map DMA page registers");
  



Home | Main Index | Thread Index | Old Index