home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / DASD / OS2ASPI / ASPISTR1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  6.5 KB  |  169 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. /*static char *SCCSID = "src/dev/dasd/os2aspi/aspistr1.c, aspi, r206 93/03/20";*/
  13. /**************************************************************************
  14.  *
  15.  * SOURCE FILE NAME = ASPISTR1.C
  16.  *
  17.  * DESCRIPTIVE NAME = OS2ASPI.DMD - OS/2 ASPI Device Manager
  18.  *                    ASPI Device Manager - Strategy 1 EP
  19.  *
  20.  *
  21.  * VERSION = V2.0
  22.  *
  23.  * DATE
  24.  *
  25.  * DESCRIPTION Initialization packet and handles ASPI requests
  26.  *
  27.  *
  28. */
  29. #define VDDENTRY _pascal _far _loadds
  30. typedef unsigned short (VDDENTRY *FPFNVDD)(unsigned long, unsigned long, unsigned long);   /* fpfnvdd */
  31. #define INCL_NOBASEAPI
  32. #define INCL_NOPMAPI
  33. #include <os2.h>
  34.  
  35.  
  36. #include <devcmd.h>                                                  /*@V99999*/
  37. #include <devclass.h>
  38.  
  39. #include <strat2.h>
  40. #include <reqpkt.h>
  41. #include <dskinit.h>
  42. #include <scb.h>
  43.  
  44. #include <iorb.h>
  45. #include <addcalls.h>
  46. #include <scsi.h>
  47. #include <aspi.h>
  48. #include <aspicons.h>
  49. #include <aspitype.h>
  50. #include <aspipro.h>
  51.  
  52. extern USHORT InitComplete;
  53. extern FPFNVDD VDDProc;
  54.  
  55. #pragma optimize("cegl",off)        /* Disable optimization switches that    */
  56.                                     /* are illegal for routines that contain */
  57.                                     /* inline assembly code                  */
  58.  
  59. /*********************************************************
  60. *                                                        *
  61. *   Procedure Name : ASPIEntry                           *
  62. *                                                        *
  63. *   Description : This is the entry point for all ASPI   *
  64. *   requests from other drivers. It follows the ASPI     *
  65. *   specification for OS/2, and expects all SRBs to be   *
  66. *   passed on the stack and NOT as part of a standard    *
  67. *   device driver request packet.                        *
  68. *                                                        *
  69. *   Since this is an IDC entry point a request packet    *
  70. *   is NOT required. We will verify the command type     *
  71. *   to make sure that the request packet is valid.       *
  72. *   All necessary information is contained in the SRB.   *
  73. *                                                        *
  74. *   Input :                                              *
  75. *         ASPIDataSegment - The data selector for this   *
  76. *            driver, obtained via DDAttach               *
  77. *         pSRB - A pointer to the new SRB                *
  78. *                                                        *
  79. *   Output :                                             *
  80. *                                                        *
  81. *********************************************************/
  82. VOID FAR ASPIEntry (USHORT ASPIDataSegment,PASPI_SRB_HEADER pSRB)
  83.  
  84.    {
  85.    int segmentES;
  86.  
  87.    /* Save ES in a local variable. Don't PUSH on stack because */
  88.    /* MSC 6.0 generates     code                               */
  89.  
  90.    _asm mov word ptr segmentES, es
  91.    _asm pusha
  92.  
  93.    /* Handle the ASPI Request */
  94.       ASPISRBEntr(pSRB,0);
  95.  
  96.    _asm popa
  97.    /* Restore ES */
  98.    _asm mov es, word ptr segmentES
  99.    }
  100.  
  101. /*********************************************************
  102. *                                                        *
  103. *   Procedure Name : ASPIStr1                            *
  104. *                                                        *
  105. *   Description : This is the entry point for request    *
  106. *   packets sent by the system and device drivers.       *
  107. *   This entry point should only be used during system   *
  108. *   initialization. All real ASPI requests must use      *
  109. *   use ASPIEntry to conform to the specification.       *
  110. *                                                        *
  111. *                                                        *
  112. *   Input :                                              *
  113. *                                                        *
  114. *   Output :                                             *
  115. *                                                        *
  116. *********************************************************/
  117. VOID FAR ASPIStr1(VOID)
  118.  
  119.    {
  120.  
  121.    PRPH   pRPH;
  122.  
  123.    /* Setup a pointer to the driver request packet */
  124.    _asm
  125.    {
  126.    mov word ptr pRPH[0], bx
  127.    mov word ptr pRPH[2], es
  128.    }
  129.  
  130.    /* Verify that the command is acceptable */
  131.  
  132.    if ((pRPH->Cmd == CMDInitBase) && !InitComplete)
  133.       pRPH->Status = ASPIInit((PRPINITIN) pRPH);
  134.    else
  135.       {
  136.       if (pRPH->Cmd == CMDGenIOCTL)
  137.          {
  138.          ASPISRBEntr((PASPI_SRB_HEADER) ((PRP_GENIOCTL)pRPH)->ParmPacket,0);
  139.          pRPH->Status |= STDON;
  140.          }
  141.       else
  142.          StatusError(pRPH,0x8103);
  143.       }
  144.  
  145.    }
  146.  
  147. #pragma optimize("cegl",on)         /* Enable optimization switches again */
  148.  
  149. /*********************************************************
  150. *                                                        *
  151. *   Procedure Name : StatusError                         *
  152. *                                                        *
  153. *   Description : This procedure updates the status      *
  154. *   byte with any error information that is returned.    *
  155. *                                                        *
  156. *   Input :                                              *
  157. *         pRPH - A pointer to the request packet         *
  158. *         errorCode - The error that was returned        *
  159. *                                                        *
  160. *   Output :                                             *
  161. *                                                        *
  162. *********************************************************/
  163. VOID NEAR StatusError(PRPH pRPH, USHORT ErrorCode )
  164.  
  165.    {
  166.    pRPH->Status |= ErrorCode;
  167.    pRPH->Status |= STATUS_DONE;
  168.    }
  169.