[comp.os.minix] Compaq Deskpro and portable III patch

cs00chs@unccvax.UUCP (charles spell) (11/12/89)

A few articles back I mentioned a fix for the Compaq Deskpro (originally
written to patch the Compaq portable III hard disk controller). I am
re-posting it on ast's request. There is only a brief description of how it
works in the comment lines below. Read the patch code for details.
This article can be obtained via anonymous ftp bugs.nosc.mil(128.49.16.1):
cd /pub/Minix/articles; mget 2025*
The original article follows this line. It is a shar containing two patches.

The follow fixes for a Compaq were previously reported but
were not incorporated in the 1.3 update.  I suspect the at_wini.c
fix may be helpful to other troublesome hardware as well.  
----cut here---------------cut here---------------------cut here-------------
#!/bin/sh
# This is  a shell archive (shar).
# Here are the changes to make MINIX v1.3d run on a Compaq Portable III.
# Only two files are involved, both in the kernel directory, at_wini.c
# and printer.c. Context diff files are included for both files. The
# changes are minor: (a) the P III's video mimics color but it uses the
# mono printer port address, (b) The disk controller (if it has been given
# a command that will generate a hardware interrupt) doesn't like for its
# status to be checked until after the hardware interrupt has occurred.
# The change to at_wini.c has also been tested and found to work on an
# AT-Clone with a WD controller.
#     Jim Smith, Orlando Technical RBBS, 407/647-1147 (USA)

echo x - at_wini.c.cdif
sed '/^X/s///' > at_wini.c.cdif << '/'
X*** at_wini.c	Sat Nov 26 18:10:47 1988
X--- wini.c	Tue Nov 29 13:59:21 1988
X***************
X*** 213,227 ****
X    if (wn->wn_opcode == DISK_READ) {
X  	for (i=0; i<BLOCK_SIZE/SECTOR_SIZE; i++) {
X  		receive(HARDWARE, &w_mess);
X  /*		old_state = lock(); */
X  		dma_read((unsigned)(usr_buf >> 4), (unsigned)(usr_buf & 0x0F));
X  /*		restore(old_state); */
X  		usr_buf += 0x200;
X  		if (win_results() != OK) {
X  			w_need_reset = TRUE;
X  			return(ERR);
X  		}
X! 	}
X  	r = OK;
X    } else {
X  	for (i=0; i<MAX_WIN_RETRY && (r&8) == 0; i++)
X--- 213,247 ----
X    if (wn->wn_opcode == DISK_READ) {
X  	for (i=0; i<BLOCK_SIZE/SECTOR_SIZE; i++) {
X  		receive(HARDWARE, &w_mess);
X+ 		if (win_results() != OK) {	/* added by jhs */
X+ 			w_need_reset = TRUE;	/* added by jhs */
X+ 			return(ERR);		/* added by jhs */
X+ 		}				/* added by jhs */
X  /*		old_state = lock(); */
X  		dma_read((unsigned)(usr_buf >> 4), (unsigned)(usr_buf & 0x0F));
X  /*		restore(old_state); */
X  		usr_buf += 0x200;
X+ 	}	   /* moved from below next statement by jhs */
X+ 
X+ /* The next statement originally sampled status of the disk controller	*/
X+ /* after the first sector of a block was read, before the HARDWARE int	*/
X+ /* for the 2nd sector. On a Compaq Portable III, reading status be-	*/
X+ /* fore the HARDWARE int occurs clears the controller's HARDWARE int	*/
X+ /* and it never occurs, leaving the wini task blocked, waiting for a	*/
X+ /* HARDWARE interrupt! I moved the "win_results()" test up so that it	*/
X+ /* immediately follows the HARDWARE int at the beginning of the DISK-	*/
X+ /* READ for-loop. This change has been found to work properly on	*/
X+ /* an AT-Clone with WD controller, as well as with the Compaq P III.	*/
X+ /* I'm not sure the "win_results()" test is required after reading the  */
X+ /* last sector of a block. It works, however, if we again check 	*/
X+ /* win_results() here, so I left it in.					*/
X+ /*	Jim Smith, Orlando Technical RBBS 407/647-1147 (USA)		*/
X+ 
X  		if (win_results() != OK) {
X  			w_need_reset = TRUE;
X  			return(ERR);
X  		}
X! /*	}	*/ /* moved up above previous statement by jhs */
X  	r = OK;
X    } else {
X  	for (i=0; i<MAX_WIN_RETRY && (r&8) == 0; i++)
/
echo x - printer.c.cdif
sed '/^X/s///' > printer.c.cdif << '/'
X*** printer.c.orig	Tue Nov 29 12:55:52 1988
X--- printer.c	Tue Nov 29 14:05:33 1988
X***************
X*** 39,46 ****
X  #define NO_PAPER        0x20	/* status bit saying that paper is up */
X  #define OFF_LINE        0x10	/* status bit saying that printer not online*/
X  #define PR_ERROR        0x08	/* something is wrong with the printer */
X! #define PR_COLOR_BASE  0x378	/* printer port when color display used */
X! #define PR_MONO_BASE   0x3BC	/* printer port when mono display used */
X  #define LOW_FOUR         0xF	/* mask for low-order 4 bits */
X  #define CANCELED        -999	/* indicates that command has been killed */
X  #define DELAY_COUNT      100	/* regulates delay between characters */
X--- 39,48 ----
X  #define NO_PAPER        0x20	/* status bit saying that paper is up */
X  #define OFF_LINE        0x10	/* status bit saying that printer not online*/
X  #define PR_ERROR        0x08	/* something is wrong with the printer */
X! /* #define PR_COLOR_BASE  0x378	*//* printer port when color display used */
X! /* #define PR_MONO_BASE   0x3BC	*//* printer port when mono display used */
X! #define PR_COLOR_BASE  0x3BC	/* printer port when color display used */
X! #define PR_MONO_BASE   0x378	/* printer port when mono display used */
X  #define LOW_FOUR         0xF	/* mask for low-order 4 bits */
X  #define CANCELED        -999	/* indicates that command has been killed */
X  #define DELAY_COUNT      100	/* regulates delay between characters */
/

nfs@notecnirp.Princeton.EDU (Norbert Schlenker) (11/13/89)

In article <1719@unccvax.UUCP> cs00chs@unccvax.UUCP (charles spell) writes:
>A few articles back I mentioned a fix for the Compaq Deskpro (originally
>written to patch the Compaq portable III hard disk controller). I am
>re-posting it on ast's request. There is only a brief description of how it
>works in the comment lines below. Read the patch code for details.
>This article can be obtained via anonymous ftp bugs.nosc.mil(128.49.16.1):
>...

This has been a problem since day one.  Not only do Compaq machines need this,
but my Toshiba needs it too.  I have seen reports from people using at least
three other types of machines which are aided by this fix.

I have yet to see anyone report a problem on a controller which worked with
the original code but would not work with the patched code.  Since Bruce 
Evan's protected mode patches incorporated this fix (I hope I remember this
correctly :-)), and multitudes are using that code without complaint, it
can't be too wrong.

I sincerely hope that some soon-to-come release includes it.

Norbert