Subject: port-i386/3780: bus_space_write_2() should be bus_space_write_1() in fd.c
To: None <gnats-bugs@gnats.netbsd.org>
From: None <frueauf@ira.uka.de>
List: netbsd-bugs
Date: 06/24/1997 00:08:31
>Number:         3780
>Category:       port-i386
>Synopsis:       bus_space_write_2() should be bus_space_write_1() in fd.c
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 23 15:35:04 1997
>Last-Modified:
>Originator:     Thorsten Frueauf
>Organization:
private
	
>Release:        <NetBSD-current source date> NetBSD current 22.06.1997
>Environment:
	
System: NetBSD cyberlap 1.2G NetBSD 1.2G (CYBERLAP) #16: Mon Jun 23 23:08:55 CEST 1997 frueauf@cyberlap:/usr/src/sys/arch/i386/compile/CYBERLAP i386


>Description:
	
Since I upgraded my Toshiba Tecra 500CDT from 1.2 to current, the floppy drive
was no longer recogniced - just "fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2".

>How-To-Repeat:
	
Try to get a the floppy drive of a Toshiba Tecra 500CDT recogniced with a
current kernel.

>Fix:
	
The following patch worked for me:

fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec

Apply it to /src/sys/arch/i386/isa/fd.c:

*** fd.c-1.106	Sun Jun 22 14:44:33 1997
--- fd.c	Mon Jun 23 23:08:27 1997
***************
*** 267,275 ****
  		return 0;
  
  	/* reset */
! 	bus_space_write_2(iot, ioh, fdout, 0);
  	delay(100);
! 	bus_space_write_2(iot, ioh, fdout, FDO_FRST);
  
  	/* see if it can handle a command */
  	if (out_fdc(iot, ioh, NE7CMD_SPECIFY) < 0)
--- 267,275 ----
  		return 0;
  
  	/* reset */
! 	bus_space_write_1(iot, ioh, fdout, 0);
  	delay(100);
! 	bus_space_write_1(iot, ioh, fdout, FDO_FRST);
  
  	/* see if it can handle a command */
  	if (out_fdc(iot, ioh, NE7CMD_SPECIFY) < 0)
***************
*** 287,295 ****
  			goto out;
  
  		/* reset it again */
! 		bus_space_write_2(iot, ioh, fdout, 0);
  		delay(100);
! 		bus_space_write_2(iot, ioh, fdout, FDO_FRST);
  	}
  #endif
  
--- 287,295 ----
  			goto out;
  
  		/* reset it again */
! 		bus_space_write_1(iot, ioh, fdout, 0);
  		delay(100);
! 		bus_space_write_1(iot, ioh, fdout, FDO_FRST);
  	}
  #endif
  
***************
*** 435,441 ****
  		return 0;
  
  	/* select drive and turn on motor */
! 	bus_space_write_2(iot, ioh, fdout, drive | FDO_FRST | FDO_MOEN(drive));
  	/* wait for motor to spin up */
  	delay(250000);
  	out_fdc(iot, ioh, NE7CMD_RECAL);
--- 435,441 ----
  		return 0;
  
  	/* select drive and turn on motor */
! 	bus_space_write_1(iot, ioh, fdout, drive | FDO_FRST | FDO_MOEN(drive));
  	/* wait for motor to spin up */
  	delay(250000);
  	out_fdc(iot, ioh, NE7CMD_RECAL);
***************
*** 709,715 ****
  	for (n = 0; n < 4; n++)
  		if ((fd = fdc->sc_fd[n]) && (fd->sc_flags & FD_MOTOR))
  			status |= FDO_MOEN(n);
! 	bus_space_write_2(fdc->sc_iot, fdc->sc_ioh, fdout, status);
  }
  
  void
--- 709,715 ----
  	for (n = 0; n < 4; n++)
  		if ((fd = fdc->sc_fd[n]) && (fd->sc_flags & FD_MOTOR))
  			status |= FDO_MOEN(n);
! 	bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, status);
  }
  
  void
***************
*** 783,789 ****
  	while ((bus_space_read_1(iot, ioh, fdsts) & NE7_RQM) == 0 && i-- > 0);
  	if (i <= 0)
  		return -1;
! 	bus_space_write_2(iot, ioh, fddata, x);
  	return 0;
  }
  
--- 783,789 ----
  	while ((bus_space_read_1(iot, ioh, fdsts) & NE7_RQM) == 0 && i-- > 0);
  	if (i <= 0)
  		return -1;
! 	bus_space_write_1(iot, ioh, fddata, x);
  	return 0;
  }
  
***************
*** 1049,1055 ****
  		    bp->b_data + fd->sc_skip, fd->sc_nbytes,
  		    NULL, read, BUS_DMA_NOWAIT);
  #endif
! 		bus_space_write_2(iot, ioh, fdctl, type->rate);
  #ifdef FD_DEBUG
  		printf("fdcintr: %s drive %d track %d head %d sec %d nblks %d\n",
  			read ? "read" : "write", fd->sc_drive, fd->sc_cylin,
--- 1049,1055 ----
  		    bp->b_data + fd->sc_skip, fd->sc_nbytes,
  		    NULL, read, BUS_DMA_NOWAIT);
  #endif
! 		bus_space_write_1(iot, ioh, fdctl, type->rate);
  #ifdef FD_DEBUG
  		printf("fdcintr: %s drive %d track %d head %d sec %d nblks %d\n",
  			read ? "read" : "write", fd->sc_drive, fd->sc_cylin,
>Audit-Trail:
>Unformatted:
bus_space_write_2() should be bus_space_write_1() in fd.c