*BSD News Article 8710


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!hp9000.csc.cuhk.hk!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!olivea!charnel!rat!ucselx!crash!fpm
From: fpm@crash.cts.com (Frank Maclachlan)
Newsgroups: comp.unix.bsd
Subject: Re: [386BSD] Troublesome SCSI problems with VL-BUS machine
Summary: Patch for 386bsd stage 1 floppy boot
Keywords: 386BSD floppy boot patch
Message-ID: <1992Dec08.132820.29435@crash>
Date: 8 Dec 92 21:28:19 GMT
References: <1992Dec1.185127.4785@umr.edu> <1992Dec03.193746.7352@kithrup.COM>
Organization: CTS Network Services (crash, ctsnet), El Cajon, CA
Lines: 114

In article <1992Dec03.193746.7352@kithrup.COM> wilson@moria.cygnus.com (jim Wilson) writes:

>This motherboard won't boot from any available floppy boot disk.  I believe
>that this is a bug in the 386bsd floppy disk bootblocks, but don't know enough
>about pc hardware (yet!) to fix it myself.
>
>I know of two ways to boot 386bsd from a floppy on this motherboard:
>1) From the CMOS screen, change the LPT1 IRQ from 7 to 5.  (And while you're
>   at it, turn off the shadow bios too.)  You can now boot from any 386bsd
>   boot floppy.  After installing 386bsd on your hard disk, change the LPT1
>   IRQ back to 7 so you can use it.  Simply disabling LPT1 does not work, you
>   must change its IRQ.  Also, note, if you ever want to boot from a floppy
>   again, you must go toggle the IRQ again.
>2) Edit a dist.fs file with emacs, search for `<^F', and change the ^F to ^G.
>   Write the file to a floppy, and you can now boot from it.  (This changes
>   an instruction in the boot blocks (fdbootblk.c) from cmpb $0x6,%al to
>   cmpb $0x7,%al.  This is a horrible hack, but it works.)  You should also
>   do the same thing to a fixit.fs file.

The relevant code from the stage 1 floppy boot, '/sys/i386/stand/fdbootblk.c',
is polling for an interrupt from the floppy disk controller on interrupt
level 6 (line 251).  Jim's patch modifies the poll loop to wait for an
interrupt on IRQ 7 (normally the first line printer); this seems like the
wrong thing to do.  The problem, I think, is in line 179 wo enable interrupts *only* from
the floppy controller.  I suspect that Jim's system is generating *lots* of
interrupts from the printer port.

Also, Ákihiro Higashi, in article
<1992Sep11.051554.29192@mlab.nttdocomo.co.jp>, reported that he
had to change 3rd & 4th "NOP"s to "JMP .+2"s on his COMPAQ 486/50L.
'NOP' is a delay macro which alters the AL register.  The specific
ange 3rd & 4th "NOP"s to "JMP .+2"s on his COMPAQ 486/50L.
'NOP' is a delay macro which alters the AL register.  The specific
instances mentioned involve code resetting the DMA controller's first/last
flip-flop and then programming the DMA controller's mode register.
The initialization byte for the mode register is clobbered by a NOP
(I am amazed that the boot works on most systems!).  This can be fixed
by rearranging the code slightly.

I have not had a problem w/ the floppy boot, so I can't really test the
efficacy of my changes; I can still boot from the floppy, so I don't
think I've broken anything.  I would appreciate any feedback from those
of you who have had problems.  If it works, I'll send a bug report to
Nate Williams for inclusion in the buglist.

The patch to the boot follows:

*** fdbootblk.c.ORIG	Sun Jun 21 23:56:47 1992
--- fdbootblk.c	Fri Nov 13 22:46:17 1992
***************
*** 176,182 ****
  	outb	%al,$0x20
  
  	NOP
! 	movb	$0x07,%al
  	outb	%al,$0x21
  	NOP
   8:
--- 176,182 ----
  	outb	%al,$0x20
  
  	NOP
! 	movb	$0xbf,%al	# enable floppy interrupt, mask out rest
  	outb	%al,$0x21
  	NOP
   8:
***************
*** 185,196 ****
  
  	/* Set read/write bytes */
  	xorl	%edx,%edx
! 	movb	$0x0c,%dl	# outb(0xC,0x46); outb(0xB,0x46);
! 	movb	$0x46,%al
! 	outb	%al,%dx
  	NOP
  	decb	%dx
! 	outb	%al,%dx
  
  	/* Send start address */
  	movb	$0x04,%dl	# outb(0x4, addr);
--- 185,196 ----
  
  	/* Set read/write bytes */
  	xorl	%edx,%edx
! 	movb	$0x0c,%dl	# outb(0xC,junk); outb(0xB,0x46);
! 	outb	%al,%dx		# reset DMA controller first/last flip-flop
  	NOP
  	decb	%dx
! 	movb	$0x46,%al	# single mode, write mem, chan 2
! 	outb	%al,%dx		# output DMA controller mode byte
  
  	/* Send start address */
  	movb	$0x04,%dl	# outb(0x4, addr);
--

Fortunately, these changes do not shift the boot code, so a binary patch
is possible.  The changes to the first sector on the disk (fixit.fs or
dist.fs) are given below:

Offset    Old    New
------    ----   ----
0x00e1    0x07   0xbf
0x00f2    0xb0   0xee
0x00f3    0x46   0xe4
0x00f4    0xee   0x84
0x00f5    0xe4   0x4a
0x00f6    0x84   0xb0
0x00f7    0x4a   0x46

		Hope this helps,
		Frank
--
UUCP: {hplabs!hp-sdd ucsd nosc}!crash!fpm
INET: fpm@crash.cts.com