Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fdisk Only use int13 extensions if the sectors can not ...
details: https://anonhg.NetBSD.org/src/rev/287ca72b3dd5
branches: trunk
changeset: 472387:287ca72b3dd5
user: fvdl <fvdl%NetBSD.org@localhost>
date: Wed Apr 28 23:27:01 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.
For the bootselector, there was no space to get the CHS info from
the BIOS. Instead, use a flag that can be set by fdisk. fdisk will
set it if one of the partitions on the disk is out of CHS reach
for this disk/BIOS, so that the bootselector will use int13 extensions.
This isn't so bad, because it needs to be configured via fdisk anyway.
Change the mbr manualpage to reflect some shorter error messages.
diffstat:
sbin/fdisk/fdisk.c | 14 +++++-
sbin/fdisk/mbr/mbr.8 | 8 +-
sbin/fdisk/mbr/mbr.S | 75 ++++++++++++++++++++++++++++++++++-
sbin/fdisk/mbr_bootsel/mbr_bootsel.S | 28 +++++++------
4 files changed, 102 insertions(+), 23 deletions(-)
diffs (253 lines):
diff -r d45a0da26682 -r 287ca72b3dd5 sbin/fdisk/fdisk.c
--- a/sbin/fdisk/fdisk.c Wed Apr 28 23:24:42 1999 +0000
+++ b/sbin/fdisk/fdisk.c Wed Apr 28 23:27:01 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdisk.c,v 1.34 1999/04/17 01:38:00 fvdl Exp $ */
+/* $NetBSD: fdisk.c,v 1.35 1999/04/28 23:27:01 fvdl Exp $ */
/*
* Mach Operating System
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.34 1999/04/17 01:38:00 fvdl Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.35 1999/04/28 23:27:01 fvdl Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -90,6 +90,7 @@
} __attribute__((packed));
#define BFL_SELACTIVE 0x01
+#define BFL_EXTINT13 0x02
#define SCAN_ENTER 0x1c
#define SCAN_F1 0x3b
@@ -865,6 +866,15 @@
mbs->defkey = SCAN_F1 + item;
done:
+ for (i = 0; i < NMBRPART; i++) {
+ if (mboot.parts[i].mbrp_typ != 0 &&
+ (mboot.parts[i].mbrp_start + mboot.parts[i].mbrp_size) >=
+ (dos_cylinders * dos_heads * dos_sectors)) {
+ mbs->flags |= BFL_EXTINT13;
+ break;
+ }
+ }
+
if (!yesno("Update the bootselector?"))
bootsel_modified = 0;
}
diff -r d45a0da26682 -r 287ca72b3dd5 sbin/fdisk/mbr/mbr.8
--- a/sbin/fdisk/mbr/mbr.8 Wed Apr 28 23:24:42 1999 +0000
+++ b/sbin/fdisk/mbr/mbr.8 Wed Apr 28 23:27:01 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mbr.8,v 1.1 1999/04/15 22:35:19 fvdl Exp $
+.\" $NetBSD: mbr.8,v 1.2 1999/04/28 23:27:02 fvdl Exp $
.Dd April 13, 1999
.Dt MBR 8 i386
.Os
@@ -67,13 +67,13 @@
The following messages may be printed in case of an error condition,
(after which the user must restart the system):
.Bl -tag -width Er
-.It Error 1
+.It E1
Invalid partition table. The MBR has a partition table without an
active partition.
-.It Error 2
+.It E2
Read error. There was an error reading the bootsector for the
partition or drive selected.
-.It Error 3
+.It E3
No operating system. The bootsector was loaded successfully, but
it was not valid (i.e. the magic number check failed).
.El
diff -r d45a0da26682 -r 287ca72b3dd5 sbin/fdisk/mbr/mbr.S
--- a/sbin/fdisk/mbr/mbr.S Wed Apr 28 23:24:42 1999 +0000
+++ b/sbin/fdisk/mbr/mbr.S Wed Apr 28 23:27:01 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mbr.S,v 1.3 1999/02/08 21:52:43 ws Exp $ */
+/* $NetBSD: mbr.S,v 1.4 1999/04/28 23:27:02 fvdl Exp $ */
/*
* Copyright (C) 1998 Wolfgang Solfrank.
@@ -41,6 +41,40 @@
#define BOOTADDR 0x7c00
+/*
+ * XXX should be in an include file
+ */
+/*
+ * Register values used in the i386 instruction set
+ */
+#define AL 0
+#define BL 3
+#define CL 1
+#define DL 2
+#define AH 4
+#define BH 7
+#define CH 5
+#define DH 6
+
+#define AX 0
+#define BX 3
+#define CX 1
+#define DX 2
+#define SP 4
+#define BP 5
+#define SI 6
+#define DI 7
+
+#define SI_INDEX 4
+#define DI_INDEX 5
+#define BP_INDEX 6
+#define BX_INDEX 7
+
+#define cmpw_reg_iregoff(reg,ireg,off) \
+ .byte 0x39 ; .byte (0x40 + ireg) | (reg << 3) ; .byte off
+
+#define movb_ireg0_reg(ireg,reg) .byte 0x8a ; .byte (reg << 3) | ireg
+
.text
/*
* Move ourselves out of the way first
@@ -100,11 +134,44 @@
* Active partition pointed to by si.
* Read the first sector.
*
- * First determine whether we have int13-extensions.
+ * First:
+ * - see what the total number of sectors is that we can address through the
+ * normal CHS interface
+ * - if this partition needs more, determine whether we have int13-extensions.
+ *
+ * Why this extra check? Well, some BIOSes apparently report that they do
+ * int13 extensions, but fail if you actually use them (oh, great). So we
+ * try to avoid them unless really necessary.
*/
boot:
- addr32
- movb 0(%esi), %dl % get drive identifier
+ movb_ireg0_reg(SI_INDEX,DL)
+ 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) */
+ mul %ecx /* dx:ax = c * h * s */
+
+ cmpw_reg_iregoff(DX,SI_INDEX,10)
+ movb_ireg0_reg(SI_INDEX,DL)
+ jl noext
+ jne tryext
+ cmpw_reg_iregoff(AX,SI_INDEX,8)
+ jl noext /* total # chs sectors > part. start */
+
+tryext:
data32
push %esi
push %edx
diff -r d45a0da26682 -r 287ca72b3dd5 sbin/fdisk/mbr_bootsel/mbr_bootsel.S
--- a/sbin/fdisk/mbr_bootsel/mbr_bootsel.S Wed Apr 28 23:24:42 1999 +0000
+++ b/sbin/fdisk/mbr_bootsel/mbr_bootsel.S Wed Apr 28 23:27:01 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mbr_bootsel.S,v 1.2 1999/04/17 01:38:00 fvdl Exp $ */
+/* $NetBSD: mbr_bootsel.S,v 1.3 1999/04/28 23:27:02 fvdl Exp $ */
/*-
@@ -179,6 +179,7 @@
* or inactive. There may never be more because of space constraints.
*/
#define BFL_SELACTIVE 0x01
+#define BFL_EXT13 0x02
/*
* Scan values for the various keys we use, as returned by the BIOS
@@ -224,11 +225,8 @@
* do this and pass garbage.
*/
1:
- cmpb $MINDRV,%dl
- jb 2f
- cmpb $MAXDRV,%dl
- jbe 3f
-2:
+ testb $0x78,%dl
+ jz 3f
movb $0x80,%dl
3:
movb_reg_mem(DL,drvno)
@@ -288,7 +286,7 @@
subl %edi,%edx
movw_mem_ax(timeout)
cmpl %eax,%edx
- jb 3b
+ jl 3b
movb_mem_al(defkey)
jmp default
4:
@@ -306,21 +304,21 @@
*/
subb $SCAN_F1,%al
cmpb $9,%al
- ja 4b
+ jg 4b
cmpb $3,%al
- jbe 5f
+ jle 5f
/*
* F5-F10 -> boot disk 0-5. Check if the requested disk isn't above
* the number of disks actually in the system as stored in 0:0475 by
- * the BIOS.
+ * the BIOS. This is always sector 0, so never use int13 extensions.
*/
subb $4,%al
cmpb_mem_reg(0x0475,AL)
- jae 4b
+ jge 4b
movw_imm_reg(fakeent,SI)
addb $0x80,%al
movb %al,%dl
- jmp boot2
+ jmp16(noext)
5:
/*
* Check if the requested entry is actually active in the partition and
@@ -368,6 +366,10 @@
boot:
movb_mem_reg(drvno,DL)
boot2:
+ movb_mem_al(flags)
+ testb $BFL_EXT13,%al
+ jz noext
+
push %esi
push %edx
movw_imm_reg(0x55aa,BX)
@@ -469,7 +471,7 @@
prefix:
.asciz "F1: "
err:
- .asciz "Err "
+ .asciz "E"
/*
* Fake partition entry used to boot from other disks. First byte is
* overloaded, it's also used as storage for the drive number. We're
Home |
Main Index |
Thread Index |
Old Index