From c8a7691f703d0d60bdde045610989dd3ef67ee27 Mon Sep 17 00:00:00 2001 From: weingart Date: Fri, 18 Apr 1997 06:54:40 +0000 Subject: [PATCH] Clean up error handling a little. There is a small problem with marginal disks. This code does not like them at all. I'm too frazzled right now to figure this out. This should give better error messages... --- sys/arch/i386/stand/libsa/biosdev.c | 27 +++++++++++++-------------- sys/arch/i386/stand/libsa/biosdev.h | 3 ++- sys/arch/i386/stand/libsa/biosdisk.S | 23 ++++++++++++++++++++++- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c index ce0862184f4..d7600c3dcf9 100644 --- a/sys/arch/i386/stand/libsa/biosdev.c +++ b/sys/arch/i386/stand/libsa/biosdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.c,v 1.10 1997/04/18 04:23:51 mickey Exp $ */ +/* $OpenBSD: biosdev.c,v 1.11 1997/04/18 06:54:40 weingart Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -307,10 +307,12 @@ biosstrategy(void *devdata, int rw, if (debug) printf(" (%d,%d,%d,%d)@%p", cyl, hd, sect, n, bb); #endif - for (error = 1, j = 5; error && j--;) { - error = (rw == F_READ)? - biosread (bd->biosdev, cyl, hd, sect, n, bb) - : bioswrite(bd->biosdev, cyl, hd, sect, n, bb); + /* Try to do operation up to 5 times */ + for (error = 1, j = 5; error && (j > 0); j--) { + if(rw == F_READ) + error = biosread(bd->biosdev, cyl, hd, sect, n, bb); + else + error = bioswrite(bd->biosdev, cyl, hd, sect, n, bb); switch (error) { case 0x00: /* No errors */ @@ -318,15 +320,12 @@ biosstrategy(void *devdata, int rw, error = 0; break; - default: -#ifdef BIOS_DEBUG - if (debug) { - for (p = bd_errors; p < &bd_errors[bd_nents] && - p->bd_id != error; p++); - printf("\nBIOS error %x (%s)\n", p->bd_id, p->msg); - } -#endif - continue; + default: /* All other errors */ + for (p = bd_errors; p < &bd_errors[bd_nents] && + p->bd_id != error; p++); + printf("\nBIOS error %x (%s)\n", p->bd_id, p->msg); + biosdreset(); + break; } } diff --git a/sys/arch/i386/stand/libsa/biosdev.h b/sys/arch/i386/stand/libsa/biosdev.h index 198003f118a..c20004f32d8 100644 --- a/sys/arch/i386/stand/libsa/biosdev.h +++ b/sys/arch/i386/stand/libsa/biosdev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.h,v 1.4 1997/04/09 08:39:17 mickey Exp $ */ +/* $OpenBSD: biosdev.h,v 1.5 1997/04/18 06:54:42 weingart Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -50,6 +50,7 @@ int biosioctl __P((struct open_file *, u_long, void *)); /* biosdisk.S */ u_int16_t biosdinfo __P((int dev)); +int biosdreset __P((void)); int biosread __P((int dev, int cyl, int hd, int sect, int nsect, void *)); int bioswrite __P((int dev, int cyl, int hd, int sect, int nsect, void *)); diff --git a/sys/arch/i386/stand/libsa/biosdisk.S b/sys/arch/i386/stand/libsa/biosdisk.S index bd9e0c670ad..06890298926 100644 --- a/sys/arch/i386/stand/libsa/biosdisk.S +++ b/sys/arch/i386/stand/libsa/biosdisk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdisk.S,v 1.5 1997/04/09 08:39:20 mickey Exp $ */ +/* $OpenBSD: biosdisk.S,v 1.6 1997/04/18 06:54:43 weingart Exp $ */ /* * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 @@ -141,3 +141,24 @@ ENTRY(biosdinfo) popl %ebp ret + +/* +# +# biosdreset(): reset disk system +# +*/ + +ENTRY(biosdreset) + pushl %ebp + movl %esp, %ebp + pushl %ebx + pushl %ecx + + movb $0x00, %ah # ask for disk info + BIOSINT(0x13) + + popl %ecx + popl %ebx + popl %ebp + ret + -- 2.20.1