*BSD News Article 8802


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!purdue!ames!olivea!uunet!mcsun!sun4nl!fwi.uva.nl!vdlinden
From: vdlinden@fwi.uva.nl (Frank van der Linden)
Newsgroups: comp.unix.bsd
Subject: patches for fd.c
Summary: this works for me
Keywords: additional fix for fd.c
Message-ID: <1992Dec12.192754.5327@fwi.uva.nl>
Date: 12 Dec 92 19:27:54 GMT
Sender: news@fwi.uva.nl
Organization: FWI, University of Amsterdam
Lines: 225
Nntp-Posting-Host: carol.fwi.uva.nl


 Hi,

 There was a message recently in comp.unix.bsd about the floppy driver
not being able to read 720K disks (Message by Jordan Hubbard I think).
A reply by terry@icarus.weber.edu said that a patch for this already existed
and would be part of the 386BSD interim release. (Patch by Per Ander Olausson).
 This patch fixes all problems except reading 360K floppies in 1.2M drives.
This can be fixed by reading the value for 'double stepping' from the right
place.Look around line 245:the old statement is between /* */.
I fixed this problem and append the diffs for fd.c and mtools at the end of
this message.

Onno van der Linden          c/o           vdlinden@fwi.uva.nl

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	fd.dif
#	mtools.dif
#
echo x - fd.dif
sed 's/^X//' >fd.dif << 'END-of-fd.dif'
X*** fd.c.orig	Mon Jun 29 06:25:24 1992
X--- fd.c	Sat Dec 12 16:07:17 1992
X***************
X*** 60,66 ****
X  #define b_cylin b_resid
X  #define b_step b_resid
X  #define FDBLK 512
X! #define NUMTYPES 4
X  
X  struct fd_type {
X  	int	sectrac;		/* sectors per track         */
X--- 60,66 ----
X  #define b_cylin b_resid
X  #define b_step b_resid
X  #define FDBLK 512
X! #define NUMTYPES 5
X  
X  struct fd_type {
X  	int	sectrac;		/* sectors per track         */
X***************
X*** 76,81 ****
X--- 76,82 ----
X  struct fd_type fd_types[NUMTYPES] = {
X   	{ 18,2,0xFF,0x1B,80,2880,1,0 },	/* 1.44 meg HD 3.5in floppy    */
X  	{ 15,2,0xFF,0x1B,80,2400,1,0 },	/* 1.2 meg HD floppy           */
X+ 	{ 9,2,0xFF,0x20,80,1440,1,2  }, /* 720k floppy in HD drive     */
X  	{ 9,2,0xFF,0x23,40,720,2,1 },	/* 360k floppy in 1.2meg drive */
X  	{ 9,2,0xFF,0x2A,40,720,1,1 },	/* 360k floppy in DD drive     */
X  };
X***************
X*** 211,218 ****
X   	int	unit, type, s;
X  
X   	unit = FDUNIT(minor(bp->b_dev));
X!  	/*type = FDTYPE(minor(bp->b_dev));*/
X! 	type = fd_unit[unit].type;
X  
X  #ifdef FDTEST
X  printf("fdstrat%d, blk = %d, bcount = %d, addr = %x|",
X--- 212,219 ----
X   	int	unit, type, s;
X  
X   	unit = FDUNIT(minor(bp->b_dev));
X!  	type = FDTYPE(minor(bp->b_dev));
X! 	/*type = fd_unit[unit].type;*/
X  
X  #ifdef FDTEST
X  printf("fdstrat%d, blk = %d, bcount = %d, addr = %x|",
X***************
X*** 242,248 ****
X  	}
X   	bp->b_cylin = blknum / (fd_types[type].sectrac * 2);
X  	dp = &fd_unit[unit].head;
X! 	dp->b_step = (fd_types[fd_unit[unit].type].steptrac);
X  	s = splbio();
X  	disksort(dp, bp);
X  	if (dp->b_active == 0) {
X--- 243,250 ----
X  	}
X   	bp->b_cylin = blknum / (fd_types[type].sectrac * 2);
X  	dp = &fd_unit[unit].head;
X! /*	dp->b_step = (fd_types[fd_unit[unit].type].steptrac); */
X! 	dp->b_step = (fd_types[type].steptrac);
X  	s = splbio();
X  	disksort(dp, bp);
X  	if (dp->b_active == 0) {
X***************
X*** 281,288 ****
X  int unit;
X  {
X  	fd_unit[unit].motor = 0;
X! 	if (unit) set_motor(0,0);
X! 	else set_motor(1,0);
X  }
X  
X  fd_turnon(unit)
X--- 283,289 ----
X  int unit;
X  {
X  	fd_unit[unit].motor = 0;
X! 	set_motor(unit,0);
X  }
X  
X  fd_turnon(unit)
X***************
X*** 327,339 ****
X  	int	flags;
X  {
X   	int unit = FDUNIT(minor(dev));
X!  	/*int type = FDTYPE(minor(dev));*/
X  	int s;
X  
X  	fdopenf = 1;
X  	/* check bounds */
X  	if (unit >= NFD) return(ENXIO);
X! 	/*if (type >= NUMTYPES) return(ENXIO);*/
X  
X  	/* Set proper disk type, only allow one type */
X  	return 0;
X--- 328,340 ----
X  	int	flags;
X  {
X   	int unit = FDUNIT(minor(dev));
X!  	int type = FDTYPE(minor(dev));
X  	int s;
X  
X  	fdopenf = 1;
X  	/* check bounds */
X  	if (unit >= NFD) return(ENXIO);
X! 	if (type >= NUMTYPES) return(ENXIO);
X  
X  	/* Set proper disk type, only allow one type */
X  	return 0;
X***************
X*** 442,449 ****
X  	dp = &fd_unit[fd_drive].head;
X  	bp = dp->b_actf;
X  	read = bp->b_flags & B_READ;
X!  	/*ft = &fd_types[FDTYPE(bp->b_dev)];*/
X!  	ft = &fd_types[fd_unit[fd_drive].type];
X  
X  	switch (fd_state) {
X  	case 1 : /* SEEK DONE, START DMA */
X--- 443,450 ----
X  	dp = &fd_unit[fd_drive].head;
X  	bp = dp->b_actf;
X  	read = bp->b_flags & B_READ;
X!  	ft = &fd_types[FDTYPE(bp->b_dev)];
X!  	/*ft = &fd_types[fd_unit[fd_drive].type];*/
X  
X  	switch (fd_state) {
X  	case 1 : /* SEEK DONE, START DMA */
X***************
X*** 470,476 ****
X  		sec = blknum %  (sectrac * 2);
X  		head = sec / sectrac;
X  		sec = sec % sectrac + 1;
X! fd_hddrv = ((head&1)<<2)+fd_drive;
X  
X  		if (read)  out_fdc(NE7CMD_READ);	/* READ */
X  		else out_fdc(NE7CMD_WRITE);		/* WRITE */
X--- 471,478 ----
X  		sec = blknum %  (sectrac * 2);
X  		head = sec / sectrac;
X  		sec = sec % sectrac + 1;
X! 
X! 		fd_hddrv = ((head&1)<<2)+fd_drive;
X  
X  		if (read)  out_fdc(NE7CMD_READ);	/* READ */
X  		else out_fdc(NE7CMD_WRITE);		/* WRITE */
END-of-fd.dif
echo x - mtools.dif
sed 's/^X//' >mtools.dif << 'END-of-mtools.dif'
X*** devices.c.0_1	Sat Jun 27 23:05:01 1992
X--- devices.c	Sat Aug 29 18:59:22 1992
X***************
X*** 20,34 ****
X  #ifdef __386BSD__
X  struct device devices[] = {
X  	{'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18}, /* 1.44m */
X! 	{'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15}, /* 1.2m */
X! 	{'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},  /* 720k */
X! 	{'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
X! 	{'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 8},  /* 320k */
X  	{'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18}, /* 1.44m */
X! 	{'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15}, /* 1.2m */
X! 	{'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},  /* 720k */
X! 	{'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
X! 	{'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 8},  /* 320k */
X  	{'\0', (char *) NULL, 0L, 0, 0, (int (*) ()) 0, 0, 0, 0}
X  };
X  #endif /* __386BSD__ */
X--- 20,36 ----
X  #ifdef __386BSD__
X  struct device devices[] = {
X  	{'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18}, /* 1.44m */
X! 	{'A', "/dev/rfd0b", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15}, /* 1.2m */
X! 	{'A', "/dev/rfd0c", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},  /* 720k */
X! 	{'A', "/dev/rfd0d", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
X! 	{'A', "/dev/rfd0e", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
X! 	{'A', "/dev/rfd0f", 0L, 12, 0, (int (*) ()) 0, 40, 2, 8},  /* 320k */
X  	{'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18}, /* 1.44m */
X! 	{'B', "/dev/rfd1b", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15}, /* 1.2m */
X! 	{'B', "/dev/rfd1c", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},  /* 720k */
X! 	{'B', "/dev/rfd1d", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
X! 	{'B', "/dev/rfd1e", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
X! 	{'B', "/dev/rfd1f", 0L, 12, 0, (int (*) ()) 0, 40, 2, 8},  /* 320k */
X  	{'\0', (char *) NULL, 0L, 0, 0, (int (*) ()) 0, 0, 0, 0}
X  };
X  #endif /* __386BSD__ */
END-of-mtools.dif
exit

-- 
  Frank van der Linden.                        Internet : vdlinden@fwi.uva.nl
* WARNING ---- The author of this message has once seen some AT&T Unix source *
* code, so now this message is probably copyrighted by them! You have been    *
* reading this entirely at your own risk..                                    *