[comp.os.minix] Bug fix for AT hard disk driver

evans@ditsyda.oz (Bruce Evans) (10/11/89)

I hope this fixes the following problems.

1) The hard disk doesn't work on IBM's original AT.
2) On some machines, fsck needs to be run before booting to make the hard
   disk work.

The initialization routine in at_wini.c doesn't try a reset when the drive
is not ready to start with, and disables the drive so the reset in the
main i/o routine never has a chance to fix things up. So initialization
only works if the BIOS has left the hardware in the right state.

This explains why running fsck from the boot menu sometimes helps.

Marty Leisner posted a fix involving different testing of the ready bits
in the hard disk controller's status port. I suspect this worked partly
by accepting a bad status during initialization, then fixing things up
with a reset later. I still don't understand all the bits, and am running
a version which tests fewer bits than 1.3 but more bits than Marty
(everything works here :-)).

Please try this fix *without* Marty's fix first.

Initialization in xt_wini.c always does a reset (slower?) so there is no
problem for XT drives.

There is another bug in writing off a bad drive: 1 bad drive disables all
drives. This only matters when you have a bad drive but leave it enabled
in the CMOS parameter RAM. I had this and was trying to use Minix to test
the bad drive, but gave up when the good drive was inaccessible.

The diff is relative to version 1.3d.

54667  16089 at_wini.c
45486    376 at_wini.c.cdif
64098  16075 at_wini.c~

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  at_wini.c.cdif
# Wrapped by evans@ditsyda on Thu Oct 12 00:37:35 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'at_wini.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'at_wini.c.cdif'\"
else
echo shar: Extracting \"'at_wini.c.cdif'\" \(376 characters\)
sed "s/^X//" >'at_wini.c.cdif' <<'END_OF_FILE'
X*** /user/1.3usr/sys/kernel/at_wini.c	Fri Aug 25 01:13:24 1989
X--- at_wini.c	Thu Oct 12 00:18:57 1989
X***************
X*** 447,450 ****
X    /* Initialize the controller */
X!   if ((nr_drives > 0) && (win_init() != OK))
X! 		nr_drives = 0;
X  
X--- 474,477 ----
X    /* Initialize the controller */
X!   if (nr_drives > 0 && win_init() != OK && w_reset() != OK)
X! 	nr_drives = 0;
X  
END_OF_FILE
if test 376 -ne `wc -c <'at_wini.c.cdif'`; then
    echo shar: \"'at_wini.c.cdif'\" unpacked with wrong size!
fi
# end of 'at_wini.c.cdif'
fi
echo shar: End of shell archive.
exit 0
-- 
Bruce Evans		evans@ditsyda.oz.au