NetBSD Problem Report #18591
Received: (qmail 20069 invoked by uid 605); 9 Oct 2002 04:08:45 -0000
Message-Id: <20021009040713.CEBF77B9@starfruit.itojun.org>
Date: Wed, 9 Oct 2002 13:07:13 +0900 (JST)
From: itojun@itojun.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: itojun@itojun.org
To: gnats-bugs@gnats.netbsd.org
Subject: biosboot bug: int13 func 0 needed after int13 func 2 error
X-Send-Pr-Version: 3.95
>Number: 18591
>Category: port-i386
>Synopsis: biosboot bug: int13 func 0 needed after int13 func 2 error
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: dyoung
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Oct 09 04:09:01 +0000 2002
>Closed-Date: Thu Oct 10 19:34:48 +0000 2002
>Last-Modified: Thu Oct 10 19:34:48 +0000 2002
>Originator: Jun-ichiro itojun Hagino
>Release: NetBSD 1.6I
>Organization:
itojun.org
>Environment:
System: NetBSD starfruit.itojun.org 1.6I NetBSD 1.6I (STARFRUIT) #5: Tue Oct 8 11:49:30 JST 2002 itojun@starfruit.itojun.org:/usr/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386
Architecture: i386
Machine: i386
>Description:
Subject: Re: [Soekris] booting NetBSD on net4521: fixed (PATCH)
From: David Young <dyoung@ojctech.com>
To: soekris-tech@lists.soekris.com
Date: Tue, 8 Oct 2002 22:55:04 -0500
Reply-To: dyoung@pobox.com
Delivery-Date: Wed Oct 9 13:01:14 2002
Mail-Followup-To: David Young <dyoung@che.onthejob.net>,
soekris-tech@lists.soekris.com
It is actually a bug in the NetBSD bootloader which causes problems on
CompactFlash cards with ID "Toshiba THNCF064MBA".
The bootloader commands the BIOS to load sectors using Interrupt 0x13,
function 2. According to "Ralf Brown's Interrupt List," when function 2
indicates an error, you are supposed to call Interrupt 0x13, function
0, to reset the disk. The NetBSD bootloader does no such thing. LILO,
which always works, does.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: netbsd-bugs@netbsd.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-i386/18591: biosboot bug: int13 func 0 needed after int13 func 2 error
Date: Wed, 9 Oct 2002 10:20:08 +0100
> It is actually a bug in the NetBSD bootloader which causes problems on
> CompactFlash cards with ID "Toshiba THNCF064MBA".
>
> The bootloader commands the BIOS to load sectors using Interrupt 0x13,
> function 2. According to "Ralf Brown's Interrupt List," when function 2
> indicates an error, you are supposed to call Interrupt 0x13, function
> 0, to reset the disk. The NetBSD bootloader does no such thing. LILO,
> which always works, does.
Is there any reason to suppose that this is change that makes
a difference to the problem being seen?
The boot loader shouldn't really see a disk read error, so the
error recovery path shouldn't be exercised.
When the boot fails, how far does it get.
(FWIW (and IIRC) there are some bugs in the asm boot code
that mean its operation is dependant on the BIOS having
cleared the top bits of some registers. I certainly fixed
some longstanding bugs when hacking it a while ago.)
David
--
David Laight: david@l8s.co.uk
From: itojun@iijlab.net
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: Re: port-i386/18591: biosboot bug: int13 func 0 needed after int13 func 2 error
Date: Wed, 09 Oct 2002 13:17:52 +0900
>>Synopsis: biosboot bug: int13 func 0 needed after int13 func 2 error
Return-Path: soekris-tech-admin@lists.soekris.com
Delivery-Date: Wed Oct 9 13:16:49 2002
Return-Path: <soekris-tech-admin@lists.soekris.com>
Received: from moaner.org (moaner.org [166.88.45.2])
by coconut.itojun.org (Postfix) with ESMTP id D9C6F4B23
for <itojun@itojun.org>; Wed, 9 Oct 2002 13:16:48 +0900 (JST)
Received: from moaner.org (localhost [127.0.0.1])
by moaner.org (8.12.5/8.12.5) with ESMTP id g994C6Hp042473;
Tue, 8 Oct 2002 21:12:07 -0700 (PDT)
(envelope-from soekris-tech-admin@lists.soekris.com)
Received: from che.onthejob.net (che.onthejob.net [63.146.38.195])
by moaner.org (8.12.5/8.12.5) with ESMTP id g994B8Hp042401
for <soekris-tech@lists.soekris.com>; Tue, 8 Oct 2002 21:11:08 -0700 (PDT)
(envelope-from dyoung@ojctech.com)
Received: (from dyoung@localhost)
by che.onthejob.net (8.9.3/8.9.3) id XAA13651
for soekris-tech@lists.soekris.com; Tue, 8 Oct 2002 23:11:07 -0500
From: David Young <dyoung@ojctech.com>
To: soekris-tech@lists.soekris.com
Subject: Re: [Soekris] booting NetBSD on net4521: fixed (PATCH)
Message-ID: <20021008231107.A13538@che.onthejob.net>
Reply-To: dyoung@pobox.com
Mail-Followup-To: David Young <dyoung@che.onthejob.net>,
soekris-tech@lists.soekris.com
References: <20021006165624.A8947@che.onthejob.net> <20021008225504.A12782@che.onthejob.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2.5i
In-Reply-To: <20021008225504.A12782@che.onthejob.net>; from dyoung@ojctech.com on Tue, Oct 08, 2002 at 10:55:04PM -0500
Sender: soekris-tech-admin@lists.soekris.com
Errors-To: soekris-tech-admin@lists.soekris.com
X-BeenThere: soekris-tech@lists.soekris.com
X-Mailman-Version: 2.0.10
Precedence: bulk
List-Help: <mailto:soekris-tech-request@lists.soekris.com?subject=help>
List-Post: <mailto:soekris-tech@lists.soekris.com>
List-Subscribe: <http://lists.soekris.com/mailman/listinfo/soekris-tech>,
<mailto:soekris-tech-request@lists.soekris.com?subject=subscribe>
List-Id: Technical Discussion on Soekris products <soekris-tech.lists.soekris.com>
List-Unsubscribe: <http://lists.soekris.com/mailman/listinfo/soekris-tech>,
<mailto:soekris-tech-request@lists.soekris.com?subject=unsubscribe>
List-Archive: <http://lists.soekris.com/pipermail/soekris-tech/>
Date: Tue, 8 Oct 2002 23:11:07 -0500
X-Filter: mailagent [version 3.0 PL73] for itojun@itojun.org
Oops. I forgot the patch:
Index: arch/i386/stand/lib/bios_disk.S
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/stand/lib/bios_disk.S,v
retrieving revision 1.8
diff -c -r1.8 bios_disk.S
*** arch/i386/stand/lib/bios_disk.S 2000/05/21 16:59:28 1.8
--- arch/i386/stand/lib/bios_disk.S 2002/10/09 03:24:29
***************
*** 59,64 ****
--- 59,99 ----
#define data32 .byte 0x66
/*
+ # BIOS call "INT 0x13 Function 0x0" to reset the disk subsystem
+ # Call with %ah = 0x0
+ # %dl = drive (0x80 for hard disk, 0x0 for floppy disk)
+ # Return:
+ # %al = 0x0 on success; err code on failure
+ */
+ ENTRY(biosdiskreset)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %ebx
+ push %edx
+ push %edi
+
+ movb 8(%ebp), %dl # device
+
+ call _C_LABEL(prot_to_real) # enter real mode
+
+ movb $0x0, %ah # subfunction
+ int $0x13
+ setc %bl
+ movb %ah, %bh # save error code
+
+ data32
+ call _C_LABEL(real_to_prot) # back to protected mode
+
+ xorl %eax, %eax
+ movw %bx, %ax # return value in %ax
+
+ pop %edi
+ pop %edx
+ popl %ebx
+ popl %ebp
+ ret
+
+ /*
# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
# Call with %ah = 0x2
# %al = number of sectors
Index: arch/i386/stand/lib/biosdisk_ll.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/stand/lib/biosdisk_ll.c,v
retrieving revision 1.11
diff -c -r1.11 biosdisk_ll.c
*** arch/i386/stand/lib/biosdisk_ll.c 2001/07/07 22:57:57 1.11
--- arch/i386/stand/lib/biosdisk_ll.c 2002/10/09 03:24:30
***************
*** 50,55 ****
--- 50,56 ----
extern int get_diskinfo __P((int));
extern void int13_getextinfo __P((int, struct biosdisk_ext13info *));
extern int int13_extension __P((int));
+ extern int biosdiskreset __P((int));
extern int biosread __P((int, int, int, int, int, char *));
extern int biosextread __P((int, void *));
static int do_read __P((struct biosdisk_ll *, int, int, char *));
***************
*** 130,137 ****
ext.seg = ourseg;
ext.sec = dblk;
! if (biosextread(d->dev, &ext))
return -1;
return ext.cnt;
} else {
--- 131,140 ----
ext.seg = ourseg;
ext.sec = dblk;
! if (biosextread(d->dev, &ext)) {
! (void)biosdiskreset(d->dev);
return -1;
+ }
return ext.cnt;
} else {
***************
*** 144,151 ****
if (nsec > num)
nsec = num;
! if (biosread(d->dev, cyl, head, sec, nsec, buf))
return -1;
return nsec;
}
--- 147,156 ----
if (nsec > num)
nsec = num;
! if (biosread(d->dev, cyl, head, sec, nsec, buf)) {
! (void)biosdiskreset(d->dev);
return -1;
+ }
return nsec;
}
Responsible-Changed-From-To: port-i386-maintainer->dyoung
Responsible-Changed-By: thorpej
Responsible-Changed-When: Wed Oct 9 07:01:53 PDT 2002
Responsible-Changed-Why:
dyoung has a patch for this problem.
From: Jason R Thorpe <thorpej@wasabisystems.com>
To: David Laight <david@l8s.co.uk>
Cc: netbsd-bugs@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: port-i386/18591: biosboot bug: int13 func 0 needed after int13 func 2 error
Date: Wed, 9 Oct 2002 07:01:35 -0700
On Wed, Oct 09, 2002 at 10:20:08AM +0100, David Laight wrote:
> Is there any reason to suppose that this is change that makes
> a difference to the problem being seen?
Yes.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
From: David Laight <david@l8s.co.uk>
To: netbsd-bugs@netbsd.org, gnats-bugs@gnats.netbsd.org
Cc:
Subject: Re: port-i386/18591: biosboot bug: int13 func 0 needed after int13 func 2 error
Date: Wed, 9 Oct 2002 16:17:16 +0100
> Yes.
ok
David
--
David Laight: david@l8s.co.uk
From: dyoung@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: pr/18591 CVS commit: syssrc/sys/arch/i386/stand/lib
Date: Thu, 10 Oct 2002 21:52:43 +0300 (EEST)
Module Name: syssrc
Committed By: dyoung
Date: Thu Oct 10 18:52:43 UTC 2002
Modified Files:
syssrc/sys/arch/i386/stand/lib: bios_disk.S biosdisk_ll.c
Log Message:
Introduce biosdiskreset(), and call it to reset the disk (with Int
0x13 Function 0) after a read error. This is a requirement mentioned
in most BIOS documentation.
This answers PR 18591.
Incidentally, on the Soekris Engineering net45x1 single-board
computer, this fixes a bug where the bootloader corrupts the kernel
while loading it from certain varieties of CompactFlash card
(especially varieties identified by NetBSD as <TOSHIBA THNCF064MBA>).
To generate a diff of this commit:
cvs rdiff -r1.8 -r1.9 syssrc/sys/arch/i386/stand/lib/bios_disk.S
cvs rdiff -r1.11 -r1.12 syssrc/sys/arch/i386/stand/lib/biosdisk_ll.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dyoung
State-Changed-When: Thu Oct 10 12:18:32 PDT 2002
State-Changed-Why:
My recent check-in fixes the bug.
>Unformatted:
My revisions to bios_disk.S and to biosdisk_ll.c (see above for rev.
numbers) fix this bug.
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.