home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / AHDI / TTFHDX / ERROR.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-09  |  1.2 KB  |  56 lines

  1. /*
  2.  *    ERROR.C
  3.  *
  4.  *    26-May-1988    ml.    Started this.
  5.  *    18-Jul-1990    ml.    Modified for FHDX.
  6.  *
  7.  */
  8.  
  9. #include <osbind.h>
  10. #include <obdefs.h>
  11. #include "define.h"
  12. #include "addr.h"
  13. #include "fhdx.h"
  14.  
  15. /*
  16.  *  Errcode()
  17.  *    Find error code for previous instruction which returned Check
  18.  *  Condition Status.
  19.  *
  20.  *  Input:
  21.  *    pdev - the physical device number.
  22.  *
  23.  */
  24. errcode(pdev)
  25. int pdev;
  26. {
  27.     char data[16];
  28.     extern int rqsense(), pcode;
  29.     int len;
  30.     long ostack;
  31.     UWORD error;
  32.  
  33.     if (pcode == 0x80)    /* if ST-506 drives */
  34.         len = 4;    /* non-extended Request Sense */
  35.     else        /* else SCSI drives */
  36.         len = 16;    /* extended Request Sense */
  37.         
  38.     ostack = Super(NULL);
  39.     error = rqsense(pdev, len, data);
  40.     delay();
  41.     Super(ostack);
  42.     
  43.     if (error != 0)
  44.         return err("[1][Cannot get error code!][  OK  ]");
  45.         
  46.     if (len == 4)    /* if non-extended Request Sense */
  47.         error = (UWORD)(data[0] & 0x7f);    /* error code at byte 0 */
  48.     else        /* if extended Request Sense */
  49.         error = (UWORD)data[12];        /* error code at byte 12 */
  50.         
  51.     itoa(error, data);
  52.     strcpy(errnum[ERRNO].ob_spec, data);
  53.     errnum[ERROK].ob_state = NORMAL;
  54.     execform(errnum, 0);
  55. }
  56.