From 429528f37622115d826269a6c937be34b178891b Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Mar 2017 21:34:14 +0000 Subject: [PATCH] loader: biosdisk should report IO error from INT13 We should be more verbose about read errors from biosdisk, except filter out the floppy controller errors, which apparently are resulting from read attempt from device without the media present. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D10032 --- sys/boot/i386/libi386/biosdisk.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index ffebb187e9ff..fc3e962235df 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -559,7 +559,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, { struct disk_devdesc *dev = (struct disk_devdesc *)devdata; uint64_t disk_blocks; - int blks; + int blks, rc; #ifdef BD_SUPPORT_FRAGS /* XXX: sector size */ char fragbuf[BIOSDISK_SECSIZE]; size_t fragsize; @@ -616,8 +616,12 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, case F_READ: DEBUG("read %d from %lld to %p", blks, dblk, buf); - if (blks && bd_read(dev, dblk, blks, buf)) { - DEBUG("read error"); + if (blks && (rc = bd_read(dev, dblk, blks, buf))) { + /* Filter out floppy controller errors */ + if (BD(dev).bd_flags != BD_FLOPPY || rc != 0x20) { + printf("read %d from %lld to %p, error: 0x%x", blks, dblk, + buf, rc); + } return (EIO); } #ifdef BD_SUPPORT_FRAGS /* XXX: sector size */ @@ -676,7 +680,9 @@ bd_edd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, v86.ds = VTOPSEG(&packet); v86.esi = VTOPOFF(&packet); v86int(); - return (V86_CY(v86.efl)); + if (V86_CY(v86.efl)) + return (v86.eax >> 8); + return (0); } static int @@ -710,7 +716,9 @@ bd_chs_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, v86.es = VTOPSEG(dest); v86.ebx = VTOPOFF(dest); v86int(); - return (V86_CY(v86.efl)); + if (V86_CY(v86.efl)) + return (v86.eax >> 8); + return (0); } static int @@ -797,7 +805,7 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, int write) DEBUG("Read %d sector(s) from %lld to %p (0x%x) %s", x, dblk, p, VTOP(p), result ? "failed" : "ok"); if (result) { - return(-1); + return (result); } if (!write && bbuf != NULL) bcopy(bbuf, p, x * BD(dev).bd_sectorsize);