1 /* 2 * Copyright (c) 2001 Joerg Wunsch 3 * 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #include <sys/types.h> 30 #include <sys/fdcio.h> 31 32 #include <stdio.h> 33 #include <string.h> 34 35 #include <dev/ic/nec765.h> 36 37 #include "fdutil.h" 38 39 void 40 printstatus(struct fdc_status *fdcsp, int terse) 41 { 42 char msgbuf[100]; 43 44 if (!terse) 45 fprintf(stderr, 46 "\nFDC status ST0=%#x ST1=%#x ST2=%#x C=%u H=%u R=%u N=%u:\n", 47 fdcsp->status[0] & 0xff, 48 fdcsp->status[1] & 0xff, 49 fdcsp->status[2] & 0xff, 50 fdcsp->status[3] & 0xff, 51 fdcsp->status[4] & 0xff, 52 fdcsp->status[5] & 0xff, 53 fdcsp->status[6] & 0xff); 54 55 if ((fdcsp->status[0] & NE7_ST0_IC_RC) != NE7_ST0_IC_AT) { 56 sprintf(msgbuf, "unexcpted interrupt code %#x", 57 fdcsp->status[0] & NE7_ST0_IC_RC); 58 } else { 59 strcpy(msgbuf, "unexpected error code in ST1/ST2"); 60 61 if (fdcsp->status[1] & NE7_ST1_EN) 62 strcpy(msgbuf, "end of cylinder (wrong format)"); 63 else if (fdcsp->status[1] & NE7_ST1_DE) { 64 if (fdcsp->status[2] & NE7_ST2_DD) 65 strcpy(msgbuf, "CRC error in data field"); 66 else 67 strcpy(msgbuf, "CRC error in ID field"); 68 } else if (fdcsp->status[1] & NE7_ST1_MA) { 69 if (fdcsp->status[2] & NE7_ST2_MD) 70 strcpy(msgbuf, "no address mark in data field"); 71 else 72 strcpy(msgbuf, "no address mark in ID field"); 73 } else if (fdcsp->status[2] & NE7_ST2_WC) 74 strcpy(msgbuf, "wrong cylinder (format mismatch)"); 75 else if (fdcsp->status[1] & NE7_ST1_ND) 76 strcpy(msgbuf, "no data (sector not found)"); 77 } 78 fputs(msgbuf, stderr); 79 } 80 81