home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / vdl020d.zip / HM.DOC < prev    next >
Text File  |  1993-04-14  |  39KB  |  911 lines

  1. (*
  2.   ====================  H A C   M A N A G E R   U N I T ====================
  3.   =                                                                        =
  4.   =  Version 1.0.0                06/03/92                     Jon Taylor  =
  5.   =                                                                        =
  6.   ==========================================================================
  7.   =                                                                        =
  8.   =  Hac Manager library for TP V:6.0                                      =
  9.   =                                                                        =
  10.   =  Written By Jonathan Robert Taylor                                     =
  11.   =                                                                        =
  12.   =  This code is the property of Columbia Data Products, Inc.             =
  13.   =  It may be distributed and used outside CDP so long as this header     =
  14.   =  remains intact and unmodified, and as long as it is used with a       =
  15.   =  licensed Columbia Data Products, Inc.  product.                       =
  16.   =                                                                        =
  17.   =  Copyright 1991,1992 Columbia Data Products                            =
  18.   =  ALL RIGHTS RESERVED                                                   =
  19.   =                                                                        =
  20.   ==========================================================================
  21.   =                                                                        =
  22.   =  Revision History        Procedures changed; overall purpose of change.=
  23.   =                          Procedure specific revision notes below.      =
  24.   =                          Reverse chronological order.                  =
  25.   = ---------------------------------------------------------------------- =
  26.   =   date    initials   change description                                =
  27.   = ---------------------------------------------------------------------- =
  28.   =                                                                        =
  29.   = 11-19-92    jrt     Modified HM_ExecSCSI to poll locally instead       =
  30.   =                     of making HAC poll.                                =
  31.   =                                                                        =
  32.   = 06-03-92    jrt     Tested.  Modified to use Hac Manager 0.5.0         =
  33.   =                                                                        =
  34.   = 05-18-92    jrt     Added code to turn interrupts off before executing =
  35.   =                     critical or non-reentrant code.                    =
  36.   =                                                                        =
  37.   = 05-13-92    jrt     All code written, no testing yet.                  =
  38.   =                                                                        =
  39.   = 05-05-92    jrt     Started                                            =
  40.   =                                                                        =
  41.   ==========================================================================
  42.   =                                                                        =
  43.   =  Caveats                                                               =
  44.   = ---------------------------------------------------------------------- =
  45.   =   date   initals     description                                       =
  46.   = ---------------------------------------------------------------------- =
  47.   =                                                                        =
  48.   = 06-03-92    jrt     May need to pass actual CDB to HM_ExecSCSI instead =
  49.   =                     of a pointer, so that the memory for the CDB       =
  50.   =                     doesn't have to exist in two places (packet&Heap)  =
  51.   =                                                                        =
  52.   =                     Need to clean up HM_ExecSCSI usage of physical IOS =
  53.   =                     /virtual IOS/auto addressing                       =
  54.   =                                                                        =
  55.   =                     We currently create the CAPS data locally, as      =
  56.   =                     the HAC manager does not yet return all the        =
  57.   =                     necessary information (version, OSDP size, etc)    =
  58.   =                                                                        =
  59.   =                     HM_PacketAbort and HM_ReqSenseBroadcast are not    =
  60.   =                     yet completed, as they are not properly            =
  61.   =                     implemented in the HAC manager.                    =
  62.   =                                                                        =
  63.   =                     The internal function CallHacManager makes         =
  64.   =                     provisions for the HAC manager returning a         =
  65.   =                     value in AX.  The Hac manager does not return a    =
  66.   =                     value in AX, so the value returned by              =
  67.   =                     CallHacManager is hardcoded to 0.                  =
  68.   =                                                                        =
  69.   ==========================================================================
  70. *)
  71.  
  72.  
  73. Unit HM;
  74.  
  75.  
  76.  
  77.  
  78.  
  79. Uses
  80.  
  81.   DOS;
  82.  
  83.  
  84.  
  85. Const
  86.  
  87.   eInit_NoHacManager         = $01;
  88.   eIOSAdd_IOSFull            = $01;
  89.  
  90.   eExecSCSI_CantAlloc        = $FFFF;
  91.  
  92.   eXS_CantAlloc              = $FFFF;
  93.   eXS_OK                     = $8100;
  94.  
  95.   {----------------------}
  96.   { HAC Manager Commands }
  97.   {----------------------}
  98.  
  99.   HCMD_ExecCDB       = $00;
  100.   HCMD_HacInit       = $01;
  101.   HCMD_ResetBus      = $02;
  102.   HCMD_ResetDev      = $03;
  103.   HCMD_Raw           = $04;
  104.   HCMD_Abort         = $05;
  105.   HCMD_VtoP          = $F5;
  106.   HCMD_ClearVtoP     = $F5;
  107.   HCMD_AEN_Sense     = $F7;
  108.   HCMD_RemoveHac     = $F8;
  109.   HCMD_RemoveClient  = $F9;
  110.   HCMD_GetClient_ID  = $FA;
  111.   HCMD_AddClient     = $FB;
  112.   HCMD_SetHDT        = $FC;
  113.   HCMD_GetHDT        = $FD;
  114.   HCMD_GetNum_Hacs   = $FE;
  115.   HCMD_AddHAC        = $FF;
  116.  
  117.   {------------------}
  118.   { Hac Packet Flags }
  119.   {------------------}
  120.  
  121.   HFLG_Poll          = $0001;     { Dont return until HAC CMD is done }
  122.   HFLG_Write         = $0002;     { SCSI Write operation              }
  123.   HFLG_Read          = $0000;     { SCSI Read  operation              }
  124.   HFLG_NoBusyRetry   = $0004;     { No retries on busy                }
  125.   HFLG_AutoDir       = $0008;     { Do Auto direction determination   }
  126.   HFLG_AutoAddr      = $0010;     { Do auto address conversion        }
  127.   HFLG_StopOnLinkErr = $0040;     { Stop linked commands on an error  }
  128.   HFLG_PascalPost    = $0080;     { Post with pascal stack frame      }
  129.   HFLG_VtoPClear     = $8000;     { Clear the Virt to Phys convert    }
  130.  
  131.   HSTAT_NotDone      = $00;       { Command In Progress               }
  132.   HSTAT_Success      = $01;       { Command Compleate With No Error   }
  133.   HSTAT_ScsiError    = $02;       { Cmd Compleate With SCSI Error     }
  134.   HSTAT_HacFailed    = $03;       { General Hac Failure               }
  135.   HSTAT_IRQCnflct    = $04;       { Interrupt Line Conflict           }
  136.   HSTAT_CmdTimeOut   = $05;       { Command Timeout                   }
  137.   HSTAT_Busy         = $06;       { HAC Is Busy                       }
  138.   HSTAT_DevNotResp   = $07;       { Selection Timeout                 }
  139.   HSTAT_BusReset     = $08;       { SCSI Bus Was Reset                }
  140.   HSTAT_HMTD         = $09;       { Host Has More Data Than Trg Wants }
  141.   HSTAT_HLTD         = $0A;       { Host Sent Less Data Than Trg Wants}
  142.   HSTAT_TMHD         = $0B;       { Trg Has More Data Than Host Wants }
  143.   HSTAT_TLHD         = $0C;       { Trg Sent Less Data Than Host Wants}
  144.   HSTAT_BadSense     = $0D;       { Failed To Get sense Data          }
  145.   HSTAT_BadCmd       = $0E;       { Bad Hac Command Code Sent         }
  146.   HSTAT_BadPhase     = $0F;       { Bad Bus Phase Detected            }
  147.   HSTAT_CmdAbrted    = $10;       { HAC Command Aborted               }
  148.   HSTAT_NoAutoDir    = $11;       { No Auto Direction Allowed         }
  149.   HSTAT_HDTCnflct    = $12;       { HAC Rejected Due To HDT Conflict  }
  150.   HSTAT_HACMgrFull   = $13;       { Maximum Number Of HACs Reached    }
  151.   HSTAT_BadHac       = $14;       { Bad HAC Number Specified          }
  152.   HSTAT_BadSubChnl   = $15;       { Bad SubChannel Specified          }
  153.   HSTAT_NoHACMgr     = $16;       { No HAC Manager Installed          }
  154.   HSTAT_BadAddr      = $17;       { Bad Address Passed                }
  155.   HSTAT_BadClient    = $18;       { Bad Client Number Specified       }
  156.   HSTAT_CrdNotResp   = $19;       { Host Adapter Not Responding       }
  157.   HSTAT_BadHACRp     = $1A;       { Invalid Field In HAC Request Pkt  }
  158.   HSTAT_MaxClients   = $1B;       { Max Client Reached, Client Reject }
  159.   HSTAT_VtoPFailed   = $1C;       { Virtual To Physical Failed        }
  160.   HSTAT_VtoPClrFail  = $1D;       { Virtual To Physical Clear Failed  }
  161.   HSTAT_NoTermPower  = $1E;       { No Termination Power On SCSI Bus  }
  162.   HSTAT_HDTModify    = $1F;       { HDT Was Modified To Cards Values  }
  163.   HSTAT_BadFirmware  = $20;       { Unsupported Firmware              }
  164.   HSTAT_DEVST_VALID  = $21;       { Device status Is Valid            }
  165.  
  166.  
  167.   {--------------------------}
  168.   { IOS Allocation Constants }
  169.   {--------------------------}
  170.  
  171.  
  172.   IOS_AllocPhys      = $01;       { Alloc a Physical IOS              }
  173.   IOS_AllocVirt      = $02;       { Alloc a Virtual IOS               }
  174.   IOS_AllocDefault   = $04;       { Alloc with default # of entries   }
  175.  
  176.  
  177.   {----------------------------}
  178.   { HM_ExecSCSI Flag Constants }
  179.   {----------------------------}
  180.  
  181.   ES_Poll            = $0001;
  182.   ES_Write           = $0002;
  183.   ES_Read            = $0000;
  184.   ES_NoBusyRetry     = $0004;
  185.   ES_AutoDir         = $0008;
  186.   ES_PascalPost      = $0080;
  187.   ES_CPost           = $0000;
  188.   ES_UseIOSH         = $8000;
  189.  
  190.  
  191.   {-----------------------------------}
  192.   { ESDefaultPostInfo Structure Flags }
  193.   {-----------------------------------}
  194.  
  195.   ESDP_Complete      = $01;
  196.  
  197.  
  198.  
  199. Type
  200.  
  201.   T4Byte = Array[0..3] of BYTE;
  202.  
  203.  
  204.   TError        = WORD;
  205.   TAENHandle    = WORD;
  206.  
  207.  
  208.   {-----}
  209.   { CDB }
  210.   {-----}
  211.  
  212.   TCDB = Array[1..16] of BYTE;
  213.   PCDB = ^TCDB;
  214.  
  215.   {---------------}
  216.   { Data Buffer   }
  217.   {---------------}
  218.  
  219.   TData = Array[0..0] of BYTE;
  220.   PData = ^TData;
  221.  
  222.  
  223.   {--------------------}
  224.   { Hac I/O Structure  }
  225.   {--------------------}
  226.  
  227.   TIOSEntry = Record
  228.  
  229.     Addr     : Pointer;
  230.     Size     : LONGINT;
  231.  
  232.   END;
  233.  
  234.   PIOSEntry = ^TIOSEntry;
  235.  
  236.   TIOS = Array[1..128] of TIOSEntry;
  237.  
  238.   PIOS  = ^TIOS;
  239.   PPIOS = ^PIOS;
  240.  
  241.   TIOSHeader = RECORD
  242.  
  243.     Avail      : WORD;
  244.     Used       : WORD;
  245.     IOS        : PIOS;
  246.  
  247.   END;
  248.  
  249.   PIOSHeader = ^TIOSHeader;
  250.  
  251.   {--------------------}
  252.   { Hac Command Packet }
  253.   {--------------------}
  254.  
  255.   PHacPacket = ^THacPacket;
  256.  
  257.   THacPacket = RECORD
  258.  
  259.     Command         : BYTE;
  260.     flagw           : WORD;
  261.     Target          : BYTE;
  262.     LUN             : BYTE;
  263.     Channel         : BYTE;
  264.     SubChannel      : BYTE;
  265.     DevStatus       : BYTE;
  266.     HacStatus       : BYTE;
  267.     CDBSize         : BYTE;
  268.     CDB             : TCDB;
  269.     SenseBuff       : Pointer;
  270.     SenseBuffSize   : WORD;
  271.     VueStatus       : Pointer;
  272.     IOSize          : LONGINT;
  273.     PhysElements    : WORD;
  274.     PhysIOS         : PIOS;
  275.     VirtElements    : WORD;
  276.     VirtIOS         : PIOS;
  277.     PostRoutine     : Pointer;
  278.     PostDataSeg     : WORD;
  279.     Next            : PHacPacket;
  280.  
  281.     RealPost        : POINTER;
  282.     RealPostDS      : WORD;
  283.  
  284.     OSDepLength     : BYTE;
  285.  
  286.  
  287.     DPT             : Pointer;
  288.     OSDPData        : Array[1..180] of BYTE;
  289.  
  290.     OSDPMyDSeg      : WORD;
  291.     OSDPMyPost      : Pointer;
  292.     OSDPMyIdata     : Pointer;
  293.     OSDPMyAll       : Pointer;
  294.  
  295.   END;
  296.  
  297.   PPHacPacket = ^PHacPacket;
  298.  
  299.  
  300.   TDefHacPacket = THacPacket;
  301.  
  302.   PDefHacPacket = ^TDefHacPacket;
  303.  
  304.   {-----------------------}
  305.   { Post Procedure Syntax }
  306.   {-----------------------}
  307.  
  308.   THMPostProc = Procedure( Packet : PHacPacket );
  309.  
  310.   TExecSCSIPostProc = Procedure( HacError : WORD;
  311.                                  DevError : WORD;
  312.                                  IData    : Pointer );
  313.  
  314.  
  315.   {----------------------}
  316.   { Add Client Structure }
  317.   {----------------------}
  318.  
  319.   TAddClientStructure = RECORD
  320.  
  321.     AENProc           : POINTER;       { Seg:Ofs of clients AEN procedure }
  322.     AENAttr           : WORD;          { AEN types that client wants 2 C  }
  323.     TypeID            : WORD;          { Client type ID (int13,aspi,etc)  }
  324.     DSeg              : WORD;          { DataSeg value for AENProc call   }
  325.  
  326.   END;
  327.  
  328.  
  329.  
  330.   {-----------------------------}
  331.   { ESDefaultPostInfo Structure }
  332.   {-----------------------------}
  333.  
  334.   TESDefaultPostInfo = RECORD
  335.  
  336.     flagw           : WORD;
  337.     HacError        : WORD;
  338.     DevError        : WORD;
  339.     Reserved        : WORD;
  340.  
  341.   END;
  342.  
  343.   PESDefaultPostInfo = ^TESDefaultPostInfo;
  344.  
  345.  
  346.   {--------------------------}
  347.   { HAC Manager Capabilities }
  348.   {--------------------------}
  349.  
  350.  
  351.   THMCaps = RECORD
  352.  
  353.     Present       : BOOLEAN;
  354.  
  355.     MajorVer      : BYTE;
  356.     MinorVer      : BYTE;
  357.     MaintVer      : BYTE;
  358.     CheckLevel    : WORD;
  359.  
  360.     LibMajorVer   : BYTE;
  361.     LibMinorVer   : BYTE;
  362.     LibMaintVer   : BYTE;
  363.     LibCheckLevel : BYTE;
  364.  
  365.     NumHacs       : BYTE;
  366.  
  367.     MinHPSize     : WORD;
  368.  
  369.   END;
  370.  
  371.   PHMCaps = ^THMCaps;
  372.  
  373.  
  374.   {------------}
  375.   { All Record }
  376.   {------------}
  377.  
  378.   TAll = RECORD
  379.  
  380.     HP          : PHacPacket;
  381.     VirtIOSH    : PIOSHeader;
  382.     PhysIOSH    : PIOSHeader;
  383.     Data        : Pointer;
  384.     Sense       : Pointer;
  385.     flagw       : WORD;
  386.     VIOSHE      : WORD;
  387.     PIOSHE      : WORD;
  388.     DataSize    : LONGINT;
  389.     SenseSize   : LONGINT;
  390.  
  391.   END;
  392.  
  393.   PAll = ^TAll;
  394.  
  395.  
  396. {---------------------------------------------------------------------------}
  397.  
  398. {--------------------------------------------}
  399. { HAC Manager APP library specific functions }
  400. {--------------------------------------------}
  401.  
  402. Function HM_LibInit : TError;
  403.  
  404.   { MUST BE CALLED BEFORE USING ANY OF THESE FUNCTIONS! }
  405.  
  406.  
  407. Procedure HM_GetCaps(               HMCaps      : PHMCaps    );
  408.  
  409.   { Will return capability information on the HAC manager, including }
  410.   { version, checklevel, number of hacs, etc. etc.                   }
  411.   {                                                                  }
  412.   { HMCAPS              Pointer to an THMCaps structure.             }
  413.  
  414.  
  415.  
  416. {-----------------------}
  417. { Hac Manager Functions }
  418. {-----------------------}
  419.  
  420. Function  HM_NewAEN(                AENMask     : WORD;
  421.                                     AENProc     : POINTER    ): TAENHandle;
  422.  
  423.  
  424.   { Informs the HAC manager to accept a new AEN to its internal list }
  425.   { of AENs.  Any time an asyncronous event occurs, the hac mgr      }
  426.   { will see if it is a type of event that this routine wants        }
  427.   { to see by checking the AEN type against the AENMask value. If it }
  428.   { passes the AENMask, the hac mgr will call the specified AENProc. }
  429.   {                                                                  }
  430.   { This function returns a  TAENHandle which must be used to        }
  431.   { dispose of the AEN before the AEN procedure can "Go away"        }
  432.   { (IE: Be unloaded from system memory)                             }
  433.   {                                                                  }
  434.   { AENFlags            Flags and mask of events this AEN proc wants }
  435.   {                     to see.                                      }
  436.   {                                                                  }
  437.   { AENProc             Pointer to the AEN procedure.                }
  438.   {                                                                  }
  439.   { [RETURNS]           TAENHandle, an AEN handle.                   }
  440.  
  441.  
  442.  
  443.  
  444.  
  445. Procedure HM_DisposeAEN(             AENHandle  : TAENHandle );
  446.  
  447.   { Tells the HAC manager to unload an AEN procedure.                }
  448.   {                                                                  }
  449.   { TAENHandle          An AEN Handle.                               }
  450.  
  451.  
  452.  
  453. {---}
  454.  
  455.  
  456. Function  HM_ExecPacket(            HMPacket    : PHacPacket  ): TError;
  457.  
  458.   { Executes any HAC Manager packet                                  }
  459.   {                                                                  }
  460.   { HMPacket            Pointer to a Hac Manger Packet.              }
  461.   {                                                                  }
  462.   { [RETURNS]           Status/Error.                                }
  463.   {                       0 if successfull.                          }
  464.  
  465.  
  466. {---}
  467.  
  468.  
  469.  
  470. Function  HM_HACReset(              HAC         : BYTE        ): TError;
  471.  
  472.   { Resets and Re-initializes the specified Host Adapter Channel     }
  473.   {                                                                  }
  474.   { HAC                 HAC to reset/Re-init                         }
  475.   {                                                                  }
  476.   { [RETURNS]           Status/Error.                                }
  477.   {                       0 if successfull.                          }
  478.  
  479.  
  480. {---}
  481.  
  482.  
  483.  
  484. Function  HM_BusReset(              HAC         : BYTE;
  485.                                     SCSIBus     : BYTE        ): TError;
  486.  
  487.  
  488.   { Resets all SCSI devices on the specified specified SCSI bus of   }
  489.   { the specified HAC.                                               }
  490.   {                                                                  }
  491.   { HAC                 HAC SCSI Bus resides on                      }
  492.   { SCSIBus             SCSI Bus to reset                            }
  493.   {                                                                  }
  494.   { [RETURNS]           Status/Error.                                }
  495.   {                       0 if successfull.                          }
  496.  
  497.  
  498. {---}
  499.  
  500.  
  501.  
  502. Function  HM_DeviceReset(           HAC         : BYTE;
  503.                                     SCSIBus     : BYTE;
  504.                                     Target      : BYTE        ): TError;
  505.  
  506.   { Resets a SCSI device on the specified SCSI Bus of the            }
  507.   { specified HAC.                                                   }
  508.   {                                                                  }
  509.   { HAC                 HAC SCSI Bus resides on                      }
  510.   { SCSIBus             SCSI Bus device resides on                   }
  511.   { Target              Target ID of the SCSI device to reset        }
  512.   {                                                                  }
  513.   { [RETURNS]           Status/Error.                                }
  514.   {                       0 if successfull.                          }
  515.  
  516. {---}
  517.  
  518. Function  HM_PacketAbort(           Packet      : PHacPacket  ): TError;
  519.  
  520.   { Aborts the specified HAC Manager packet.                         }
  521.   {                                                                  }
  522.   { Packet              A Hac Manager packet which was previously    }
  523.   {                     transmitted to the HAC manager and has not   }
  524.   {                     yet been executed.                           }
  525.   {                                                                  }
  526.   {                                                                  }
  527.   { [RETURNS]           Status/Error.                                }
  528.   {                       0 if successfull.                          }
  529.  
  530.  
  531. {---}
  532.  
  533. Function  HM_HDTGet(                HAC         : BYTE;
  534.                                     HDT         : Pointer     ): TError;
  535.  
  536.   { Gets the HAC Descriptor Table (HDT) of the specified HAC         }
  537.   {                                                                  }
  538.   { HAC                 HAC to get HDt from.                         }
  539.   {                                                                  }
  540.   { HDT                 Pointer to buffer to receive a copy of the   }
  541.   {                     HDT.                                         }
  542.   {                                                                  }
  543.   { [RETURNS]           Status/Error.                                }
  544.   {                       0 if successfull.                          }
  545.  
  546. {---}
  547.  
  548. Function  HM_HDTSet(                HAC         : BYTE;
  549.                                     HDT         : Pointer     ): TError;
  550.  
  551.   { Sets the HAC Descriptor Table (HDT) of the specified HAC         }
  552.   {                                                                  }
  553.   { HAC                 HAC to receive new HDT.                      }
  554.   {                                                                  }
  555.   { HDT                 Pointer to a HDT to be copied to the HACs    }
  556.   {                     HDT.                                         }
  557.   {                                                                  }
  558.   { [RETURNS]           Status/Error.                                }
  559.   {                       0 if successfull.                          }
  560.  
  561.  
  562. {---}
  563.  
  564. Function  HM_ReqSenseBroadcast(     HAC         : BYTE;
  565.                                     SCSIBus     : BYTE;
  566.                                     Target      : BYTE;
  567.                                     Lun         : BYTE;
  568.                                     ReqSense    : Pointer;
  569.                                     ReqSenSize  : WORD        ): TError;
  570.  
  571.   { Broadcast Request Sense Data to all HAC Manager AEN clients      }
  572.   {                                                                  }
  573.   { HAC                 HAC request sense data came from.            }
  574.   { SCSIBus             SCSIBus request sense data came from.        }
  575.   { TARGET              Target request sense data came from.         }
  576.   { Lun                 Logical Unit Number Request Sense came from. }
  577.   {                                                                  }
  578.   { ReqSense            Pointer to request sense data.               }
  579.   { ReqSenSize          Size of request sense data                   }
  580.   {                                                                  }
  581.   { [RETURNS]           Status/Error.                                }
  582.   {                       0 if successfull.                          }
  583.  
  584.  
  585.  
  586.  
  587. {-----------------------}
  588. { Execute SCSI Function }
  589. {-----------------------}
  590.  
  591. Function  HM_ExecSCSI(              flagw       : WORD;
  592.                                     Target      : BYTE;
  593.                                     Lun         : BYTE;
  594.                                     Channel     : BYTE;
  595.                                     SubChannel  : BYTE;
  596.                                     CDB         : PCDB;
  597.                                     CDBSize     : BYTE;
  598.                                     IOBuff      : Pointer;
  599.                                     IOSize      : LONGINT;
  600.                                     PostAddr    : Pointer;
  601.                                     PostDSeg    : WORD;
  602.                                     PostIData   : Pointer   ): TError;
  603.  
  604.  
  605.   { Will dynamically allocate the HAC packet and all other objects  }
  606.   { required to execute the SCSI command.  These objects will then  }
  607.   { be filled in as specified, and the SCSI command executed.       }
  608.   { If not posting, all dynamically allocated objects will be freed }
  609.   { prior to returning.  If posting, this function will deflect     }
  610.   { the post to its own routine, which will free the dynamically    }
  611.   { allocated objects and call the specified POST                   }
  612.   { routine which should expect only to get the ERROR and PostIData }
  613.   { values on the stack (as opposed to a PHacPacket).               }
  614.   {                                                                 }
  615.   { It should be noted that this command does not support auto      }
  616.   { request sense or linked commmands.                              }
  617.   {                                                                 }
  618.   { flagw                                                           }
  619.   {                                                                 }
  620.   {   ES_Write          For SCSI Write operation (Host-->Devices)   }
  621.   {   ES_Read           For SCSI Read  operation (Devices<--Host)   }
  622.   {                                                                 }
  623.   {   ES_AutoDIr        For SCSI Read/Write direction automatic     }
  624.   {                     determination.  If this flag                }
  625.   {                     is set, the caller need not specify ES_Read }
  626.   {                     or ES_Write.                                }
  627.   {                                                                 }
  628.   {   ES_UseIOSH        Indicates that IOBuff points to an IOS hdr  }
  629.   {                     and not directly to an IO buffer.           }
  630.   {                     An IOS is like a scatter/gather list.       }
  631.   {                                                                 }
  632.   {   ES_CPost          To call post routine with 'C' calling       }
  633.   {                     convention.                                 }
  634.   {                                                                 }
  635.   {   ES_PascalPost     To call post routine with PASCAL calling    }
  636.   {                     convention.                                 }
  637.   {                                                                 }
  638.   { Channel             Host Adapter Channel (HAC) to use.          }
  639.   { SubChannel          HAC SCSI SubChannel to use.                 }
  640.   { Target              SCSI Target to use.                         }
  641.   { Lun                 SCSI Targets LUN to use.                    }
  642.   {                                                                 }
  643.   { CDB                 Pointer to the CDB to execute.              }
  644.   { CDBSize             Length of the CDB, in bytes.                }
  645.   {                                                                 }
  646.   { IOBuff              Pointer to an I/O buffer or to an IOS       }
  647.   {                     is the ES_UseIOSH flag is set.              }
  648.   {                                                                 }
  649.   { IOSize              Number of bytes to I/O.                     }
  650.   {                                                                 }
  651.   { PostAddr            Pointer to a Exec SCSI Post Routine,        }
  652.   {                                                                 }
  653.   {                       set to 0 if not using a post routine,     }
  654.   {                       set to ESDefaultPost to use the default   }
  655.   {                       post routine.  (Described later)          }
  656.   {                                                                 }
  657.   { PostDSeg            Value that should be loaded into the 80x86  }
  658.   {                     Data Segment register (DS) prior to         }
  659.   {                     calling the post routine,                   }
  660.   {                                                                 }
  661.   {                       set to 0 if you don't care,               }
  662.   {                       set to ESDefaultPostDS when using the     }
  663.   {                       default post routine.                     }
  664.   {                                                                 }
  665.   { PostIData           4 bytes of post instance data.  This value  }
  666.   {                     will be passed on the stack as a paramater  }
  667.   {                     to the post routine.  It can be used by     }
  668.   {                     post routines that are specified in         }
  669.   {                     multiple HM_ExecSCSI calls to identify      }
  670.   {                     which request is being posted.              }
  671.   {                                                                 }
  672.   {                     For the ESDefaultPost routine, this value   }
  673.   {                     should point to a an ESDefaultPostInfo      }
  674.   {                     structure which will be filled in by the    }
  675.   {                     ESDefaultPost routine during posting.       }
  676.   {                     Programs who wish to poll for HM_ExecSCSI   }
  677.   {                     completion can poll the specified           }
  678.   {                     ESDefaultPostInfo structure.                }
  679.   {                                                                 }
  680.   {                     If this value is set to 0, the              }
  681.   {                     ESDefaultPost routine will not fill out an  }
  682.   {                     ESDefaultPostInfo structure during posting. }
  683.  
  684.  
  685.  
  686.  
  687. {------------------------------------------}
  688. { HAC Manager Object Construction Funtions }
  689. {------------------------------------------}
  690.  
  691. Function  HM_HacPacketAlloc(        flagw       : WORD       ): PHacPacket;
  692.  
  693.   { Will allocate a HAC packet.  All fields will be zero.           }
  694.   { This function will allocate a HAC packet plus the required      }
  695.   { number of operating system dependent bytes at the end of the    }
  696.   { packet.
  697.   {                                                                 }
  698.   { flagw               are not currently used.                     }
  699.   {                                                                 }
  700.   { [RETURNS]           Pointer to a HAC packet,                    }
  701.   {                     0/NIL if a packet could not be allocated.   }
  702.  
  703.  
  704.  
  705.  
  706. Procedure HM_HacPacketFree(         HacPacket   : PHacPacket );
  707.  
  708.   { Will free a HAC packet.                                         }
  709.   {                                                                 }
  710.   { HacPacket           Pointer to a HAC packet.                    }
  711.  
  712.  
  713.  
  714. {---}
  715.  
  716.  
  717.  
  718. Function  HM_IOSHeaderAlloc(        flagw       : WORD;
  719.                                     NumEntries  : WORD       ): PIOSHeader;
  720.  
  721.    { Will dynamically allocate an IOS of the default amount of IOS }
  722.    { entries.  Will also set all IOS fields to 0                   }
  723.    {                                                               }
  724.    { flagw                                                         }
  725.    {                                                               }
  726.    {   IOS_AllocVirt    To allocate a virtual IOS.                 }
  727.    {   IOS_AllocPhys    To allocate a physical IOS.                }
  728.    {                                                               }
  729.    { NumEntries         Number of IOS entries to allocated in the  }
  730.    {                    IOS,                                       }
  731.    {                                                               }
  732.    {                      set to IOS_DefaultLen to allocate the    }
  733.    {                      default number of IOS entries for the    }
  734.    {                      specified IOS type.                      }
  735.    {                                                               }
  736.    { [RETURNS]          Pointer to an IOS, or 0/nil if an IOS      }
  737.    {                    could not be allocated.                    }
  738.  
  739.  
  740.  
  741.  
  742.  
  743. Function  HM_IOSAddBuff(            IOSH        : PIOSHeader;
  744.                                     BuffAddr    : POINTER;
  745.                                     BuffSize    : LONGINT    ): TError;
  746.  
  747.    { Will add a buffer to the IOS allocated above.                 }
  748.    {                                                               }
  749.    { BuffAddr           Pointer to the region/buffer to add.       }
  750.    { BuffSize           Size of the region/buffer, in bytes.       }
  751.    {                                                               }
  752.    { [RETURNS]          0 if no error,                             }
  753.    {                       (error codes here)                      }
  754.  
  755.  
  756.  
  757.  
  758.  
  759. Function  HM_IOSGetUsedCount(       IOSH        : PIOSHeader ): WORD;
  760.  
  761.   { Will return the number of entries in the IOS that are used.    }
  762.   {                                                                }
  763.   { IOS                 Pointer to an IOS.                         }
  764.   {                                                                }
  765.   { [RETURNS]           Number of used IOS entries.                }
  766.  
  767.  
  768.  
  769.  
  770.  
  771. Function  HM_IOSGetByteCount(       IOSH        : PIOSHeader ): LONGINT;
  772.  
  773.    { Will return the combined length of all the buffers in the IOS }
  774.    {                                                               }
  775.    { IOS                Pointer to an IOS.                         }
  776.    {                                                               }
  777.    { [RETURNS]          Total IOS byte count.                      }
  778.  
  779.  
  780.  
  781. Function  HM_IOSGetPointer(         IOSH        : PIOSHeader ): Pios;
  782.  
  783.  
  784.  
  785.  
  786. Procedure HM_IOSClear(              IOSH        : PIOSHeader );
  787.  
  788.    { Will clear all the buffer entries out of an IOS.              }
  789.    {                                                               }
  790.    { IOS                Pointer to an IOS.                         }
  791.  
  792.  
  793.  
  794.  
  795. Procedure HM_IOSHeaderFree(         IOSH        : PIOSHeader );
  796.  
  797.    { Will dynamically free the IOS header.                         }
  798.    {                                                               }
  799.    { IOS                Pointer to an IOS header.                  }
  800.  
  801.  
  802.  
  803.  
  804. {---}
  805.  
  806. Function  HM_AllAlloc(              flagw       : WORD;
  807.                                     VirtIOSLen  : WORD;
  808.                                     PhysIOSLen  : WORD;
  809.                                     DataLen     : LONGINT;
  810.                                     SenseLen    : WORD       ): PAll;
  811.  
  812.   { Dynamically allocates a HAC packet, Physical IOS, Virutal IOS      }
  813.   { and a sense buffer.   The PhysIOS, VirtIOS, Databuff and SenseBuff }
  814.   { fields in the hac packet will point to the newly allocated         }
  815.   { structures,  As will the fields in the root of the ALL record.     }
  816.   {                                                                    }
  817.   { flagw               are not currently used.                        }
  818.   {                                                                    }
  819.   { VirtIOSLen          Number of IOS entries to allocate in the       }
  820.   {                     virtual IOS,                                   }
  821.   {                                                                    }
  822.   {                       set to IOS_DefaultLen to allocate default #  }
  823.   {                       set to 0 to not allocate a virtual IOS.      }
  824.   {                                                                    }
  825.   { PhysIOSLen          Number of IOS entries to allocate in the       }
  826.   {                     physical IOS,                                  }
  827.   {                                                                    }
  828.   {                       set to IOS_DefaultLen to allocate default #  }
  829.   {                       set to 0 to not allocate a physical IOS.     }
  830.   {                                                                    }
  831.   { DataLen             Size of the data buffer to allocate,           }
  832.   {                       set to 0 to not allocate a data buffer.      }
  833.   {                                                                    }
  834.   { SenseLen            Size of the sense buffer to allocate,          }
  835.   {                       set to 0 to not allocat a sense buffer.      }
  836.   {                                                                    }
  837.   { [RETURNS]           Pointer to a new Tall structure,               }
  838.   {                       or 0 if one could not be allocated.          }
  839.  
  840.  
  841.  
  842. Procedure HM_AllFree(               All         : PAll       );
  843.  
  844.   { Gives back everything allocated with HM_AllAlloc, above            }
  845.   {                                                                    }
  846.   { Tall                Pointer to a Tall structure.                   }
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854. {---------------------------------------------}
  855. { HAC Manager Packet Loading Helper Functions }
  856. {---------------------------------------------}
  857.  
  858.  
  859.  
  860. Procedure HM_CDB6Load(              CDB         : PCDB;
  861.                                     b1          : BYTE;
  862.                                     b2          : BYTE;
  863.                                     b3          : BYTE;
  864.                                     b4          : BYTE;
  865.                                     b5          : BYTE;
  866.                                     b6          : BYTE          );
  867.  
  868.  
  869. Procedure HM_CDB10Load(             CDB         : PCDB;
  870.                                     b1          : BYTE;
  871.                                     b2          : BYTE;
  872.                                     b3          : BYTE;
  873.                                     b4          : BYTE;
  874.                                     b5          : BYTE;
  875.                                     b6          : BYTE;
  876.                                     b7          : BYTE;
  877.                                     b8          : BYTE;
  878.                                     b9          : BYTE;
  879.                                     b10         : BYTE          );
  880.  
  881.  
  882.  
  883.  
  884. Procedure HM_LoadHacPacket(         HacPacket   : PHacPacket;
  885.                                     Command     : BYTE;
  886.                                     flagw       : BYTE;
  887.                                     Target      : BYTE;
  888.                                     LUN         : BYTE;
  889.                                     Channel     : BYTE;
  890.                                     SubChannel  : BYTE;
  891.                                     DevStatus   : BYTE;
  892.                                     HacStatus   : BYTE;
  893.                                     CDBSize     : BYTE;
  894.                                     CDB         : PCDB;
  895.                                     SenseBuff   : Pointer;
  896.                                     SenseBuffLen: WORD;
  897.                                     VueStatus   : Pointer;
  898.                                     IOSize      : LONGINT;
  899.                                     PhysElements: WORD;
  900.                                     PhysIOS     : Pointer;
  901.                                     VirtElements: WORD;
  902.                                     VirtIOS     : Pointer;
  903.                                     PostRoutine : Pointer;
  904.                                     PostDSeg    : WORD;
  905.                                     Next        : PHacPacket    );
  906.  
  907.  
  908.  
  909.  
  910.  
  911.