Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/stand/lib Only use int13 extensions if the sec...



details:   https://anonhg.NetBSD.org/src/rev/d45a0da26682
branches:  trunk
changeset: 472386:d45a0da26682
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Wed Apr 28 23:24:42 1999 +0000

description:
Only use int13 extensions if the sectors can not be read through the
older CHS interface. This works around stupid BIOSs who report that
int13 extensions are present and functional, but fail when you actually
use them. Like Adaptec SCSI BIOSs.

diffstat:

 sys/arch/i386/stand/lib/biosdisk_ll.c                 |   7 +-
 sys/arch/i386/stand/lib/biosdisk_ll.h                 |   3 +-
 sys/arch/i386/stand/lib/crt/bootsect/start_bootsect.S |  60 +++++++++++++++++-
 3 files changed, 63 insertions(+), 7 deletions(-)

diffs (140 lines):

diff -r a6aaceaf10b4 -r d45a0da26682 sys/arch/i386/stand/lib/biosdisk_ll.c
--- a/sys/arch/i386/stand/lib/biosdisk_ll.c     Wed Apr 28 23:24:33 1999 +0000
+++ b/sys/arch/i386/stand/lib/biosdisk_ll.c     Wed Apr 28 23:24:42 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: biosdisk_ll.c,v 1.7 1999/03/30 17:55:49 drochner Exp $  */
+/*     $NetBSD: biosdisk_ll.c,v 1.8 1999/04/28 23:24:42 fvdl Exp $      */
 
 /*
  * Copyright (c) 1996
@@ -78,6 +78,7 @@
        d->sec = SPT(diskinfo);
        d->head = HEADS(diskinfo);
        d->cyl = CYL(diskinfo);
+       d->chs_sectors = d->sec * d->head * d->cyl;
 
        d->flags = 0;
        if ((d->dev & 0x80) && int13_extension(d->dev)) {
@@ -119,7 +120,9 @@
                int64_t sec;
        }               ext;
 
-       if (d->flags & BIOSDISK_EXT13) {
+       if ((dblk + num) >= d->chs_sectors) {
+               if (!(d->flags & BIOSDISK_EXT13))
+                       return -1;
                ext.size = sizeof(ext);
                ext.resvd = 0;
                ext.cnt = num;
diff -r a6aaceaf10b4 -r d45a0da26682 sys/arch/i386/stand/lib/biosdisk_ll.h
--- a/sys/arch/i386/stand/lib/biosdisk_ll.h     Wed Apr 28 23:24:33 1999 +0000
+++ b/sys/arch/i386/stand/lib/biosdisk_ll.h     Wed Apr 28 23:24:42 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: biosdisk_ll.h,v 1.5 1999/03/12 01:01:42 fvdl Exp $      */
+/*     $NetBSD: biosdisk_ll.h,v 1.6 1999/04/28 23:24:42 fvdl Exp $      */
 
 /*
  * Copyright (c) 1996
@@ -48,6 +48,7 @@
        int             dev;            /* BIOS device number */
        int             sec, head, cyl; /* geometry */
        int             flags;          /* see below */
+       int             chs_sectors;    /* # of sectors addressable by CHS */
 };
 #define        BIOSDISK_EXT13  1               /* BIOS supports int13 extension */
 
diff -r a6aaceaf10b4 -r d45a0da26682 sys/arch/i386/stand/lib/crt/bootsect/start_bootsect.S
--- a/sys/arch/i386/stand/lib/crt/bootsect/start_bootsect.S     Wed Apr 28 23:24:33 1999 +0000
+++ b/sys/arch/i386/stand/lib/crt/bootsect/start_bootsect.S     Wed Apr 28 23:24:42 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: start_bootsect.S,v 1.12 1999/04/01 19:36:09 drochner Exp $     */
+/*     $NetBSD: start_bootsect.S,v 1.13 1999/04/28 23:24:42 fvdl Exp $ */
        
 /*
  * BIOS bootsector startup
@@ -182,6 +182,7 @@
 #endif
 
        /* didn't find either NetBSD or 386BSD partitions */
+noboot:
        data32
        movl    $enoboot, %esi
        data32
@@ -190,6 +191,57 @@
 
 found:
 /*
+ * See if we night need int13 extensions. Compute the total number
+ * of CHS addressable sectors, and compare them to what we need
+ * The reason to avoid int13 extensions as much as possible, is
+ * that they're apparently buggy in some BIOSs.
+ */
+       pushl   %ebx            /* save partition entry */
+       pushl   %edx            /* save drive number */
+
+       data32
+       xorl    %ecx,%ecx
+       data32
+       xorl    %eax,%eax
+
+       movl    %ebx,%esi
+
+       movb    $8,%ah
+       int     $0x13
+
+       shrl    $8,%edx
+       incl    %edx            /* dx now has #heads */
+
+       movl    %ecx,%eax
+       andl    $0x3f,%eax      /* ax has #sectors */
+
+       movl    %ecx,%ebx
+       shrl    $8,%ecx
+       andl    $0xc0,%ebx
+       shll    $2,%ebx
+       orl     %ebx,%ecx
+       incl    %ecx            /* cx has #cylinders */
+
+       mul     %edx            /* h * s (will fit in 16 bits) */
+       data32
+       mul     %ecx            /* eax = c * h * s */
+       data32
+
+       data32
+       addr32
+       movl    8(%esi),%ebx
+       data32
+       addl    $LOADSZ+1, %ebx /* ebx = maximum sector # we need */
+
+       data32
+       cmpl    %eax, %ebx
+
+       popl    %edx
+       popl    %ebx
+       jl      tradint13
+
+1:
+/*
  * First we check for int13 extensions.
  * If they work, let's use them.
  * If not, revert to the traditional way of doing things.
@@ -205,8 +257,8 @@
  *                     %bx = 0xaa55
  *                     %cx = API subset bitmap, &1 -> extended disk access
  */
-       pushl   %ebx            /* save partition entry */
-       pushl   %edx            /* save drive number */
+       pushl   %ebx
+       pushl   %edx
        movb    $0x41, %ah
        data32
        movl    $0x55aa, %bx
@@ -355,7 +407,7 @@
        ret
 
 eread: .asciz          "Read error\r\n"
-enoboot: .asciz                "No bootable partition\r\n"
+enoboot: .asciz                "No NetBSD part\r\n"
 efail: .asciz          "Boot failed\r\n"
 
 /* throw in a partition in case we are block0 as well */



Home | Main Index | Thread Index | Old Index