home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / hardware.swg / 0008_SCSICODE.PAS.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  3.7 KB  |  160 lines

  1. {
  2.  > I am trying to issue an SCSI START/StoP Unit via Adaptec's ASPI SCSI
  3.  > manager and an 1542B host adaptor.  This is For an application I am
  4.  > writing in BP.  Adaptec is of no help.  if anyone here has any
  5.  > comments
  6.  > or suggestions please respond in this Forum.
  7. }
  8.  
  9. Unit Aspi;
  10.  
  11. { I/O Error reporting:
  12.  
  13.   AspiSenseKey is the primary source of error inFormation.
  14.  
  15.     0:    I/O Complete.
  16.           Warnings (Filemark, Short block, etc) may be posted in Sense.
  17.  
  18.     1-E:  Error occured.
  19.           Examine SRBStat, HostStat, TargStat, Sense For details.
  20.  
  21.     F:    Severe error detected, no SCSI info available.
  22.  
  23.   -------------------------------------------------------------------- }
  24.  
  25. Interface
  26.  
  27. Const
  28.   SrbIn = $08;
  29.   SRBOut = $10;
  30.   SRBNone = $18;
  31.   AspiPtr:  Pointer = Nil;
  32.  
  33.  
  34. Type
  35.   AspiSrb = Record
  36.     SrbCmd:      Byte;
  37.     SrbStat:     Byte;
  38.     SrbHost:     Byte;
  39.     SrbReqFlags: Byte;
  40.     SrbHdrFill:  LongInt;
  41.     Case Integer of
  42.      2: (Srb2TargetID: Byte;
  43.          Srb2LUN:      Byte;
  44.          Srb2DataLen:  LongInt;
  45.          Srb2SenseLen: Byte;
  46.          Srb2DataPtr:  Pointer;
  47.          Srb2LinkPtr:  Pointer;
  48.          Srb2CDBLen:   Byte;
  49.          Srb2HAStat:   Byte;
  50.          Srb2TargStat: Byte;
  51.          Srb2PostAddr: Pointer;
  52.          Srb2Filler:   Array [1..34] of Byte;
  53.          { Sense data follows CDB }
  54.          Srb2CDB:      Array [0..50] of Byte);
  55.      1: (Srb1TargetID: Byte;
  56.          Srb1LUN:      Byte;
  57.          Srb1DevType:  Byte);
  58.      0: (Srb0Cnt:      Byte;
  59.          Srb0TargetID: Byte;
  60.          Srb0MgrID:    Array [1..16] of Char;
  61.          Srb0HostID:   Array [1..16] of Char;
  62.          Srb0HostParm: Array [1..16] of Char);
  63.     end;
  64.  
  65. Var
  66.   AspiSRBStat:      Byte;
  67.   AspiHostStat:     Byte;
  68.   AspiTargStat:     Byte;
  69.   AspiSenseKey:     Byte;
  70.   AspiSense:        Array [0..17] of Byte;
  71.   AspiSenseCode:    Word;
  72.  
  73. Function AspiOpen: Integer;
  74.  
  75. Procedure AspiCall (Var SRB: AspiSrb);
  76. { Call ASPI Handler With SRB }
  77. Inline ($FF/$1E/>AspiPtr/
  78.         $58/$58);
  79.  
  80. Procedure AspiWait (Var SRB: AspiSrb);
  81.  
  82. Function AspiClose: Integer;
  83.  
  84. Implementation
  85.  
  86. Uses Dos;
  87.  
  88. Procedure AspiWait (Var SRB: AspiSRB);
  89. { Call ASPI Handler With SRB and wait For Completion }
  90. begin
  91.   if AspiPtr = Nil
  92.     then begin
  93.       AspiSenseKey := $0F;
  94.       Exit;
  95.       end;
  96.   With Srb do begin
  97.     SrbStat := 0;
  98.     AspiCall (Srb);
  99.     While SrbStat = 0 do ;
  100.     AspiSrbStat   := SrbStat;
  101.     AspiHostStat  := Srb2HAStat;
  102.     AspiTargStat  := Srb2TargStat;
  103.     AspiSenseKey  := 0;
  104.     FillChar (AspiSense, Sizeof (AspiSense), #0);
  105.     Move (Srb2CDB [Srb2CDBLen], AspiSense, Sizeof (AspiSense));
  106.     AspiSenseKey := AspiSense[2] and $0F;
  107.     AspiSenseCode := (AspiSense [12] SHL 8) or AspiSense [13];
  108.     end;
  109.   end;
  110.  
  111. Function AspiOpen: Integer;
  112. Const
  113.   AspiName: Array [1..9] of Char = 'SCSIMGR$'#0;
  114. Var
  115.   R:       Registers;
  116.   AspiHan: Word;
  117. begin
  118.   With R do begin
  119.     { Assume failure }
  120.     AspiOpen := -1;
  121.     AspiPtr := Nil;
  122.  
  123.     { Open ASPI device driver }
  124.     AX := $3D00;
  125.     DS := Seg (AspiName[1]);
  126.     DX := ofs (AspiName[1]);
  127.     MSDos (R);
  128.     if odd (Flags)
  129.       then Exit;
  130.     AspiHan := AX;
  131.  
  132.     { Do IOCtl Read to get Pointer to ASPI handler }
  133.     AX := $4402;
  134.     BX := AspiHan;
  135.     CX := 4;
  136.     DS := Seg (AspiPtr);
  137.     DX := ofs (AspiPtr);
  138.     MSDos (R);
  139.     if Odd (flags)
  140.       then Exit;
  141.  
  142.     { Close device driver }
  143.     AX := $3E00;
  144.     BX := AspiHan;
  145.     MsDos (R);
  146.     if Odd (Flags)
  147.       then Exit;
  148.     end;
  149.  
  150.   { Indicate success  and Exit }
  151.   AspiOpen := 0;
  152.   end { AspiOpen };
  153.  
  154. Function AspiClose: Integer;
  155. begin
  156.   AspiClose := 0;
  157. end { AspiClose };
  158.  
  159. end.
  160.