home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / PEN / PENTKT / PENBASE / STRAT.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  7KB  |  157 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. ;      /*                                                               */
  13. ;      /*                                                               */
  14. ;      /*****************************************************************/
  15. ;      /******************* START OF SPECIFICATIONS *********************/
  16. ;      /*                                                               */
  17. ;      /*  SOURCE FILE NAME: STRAT.ASM                                  */
  18. ;      /*                                                               */
  19. ;      /*  DESCRIPTIVE NAME: Strategy entry point                       */
  20. ;      /*                                                               */
  21. ;      /*                                                               */
  22. ;      /*  STATUS:  Version 1.0                                         */
  23. ;      /*                                                               */
  24. ;      /*  NOTES: This module contains the OS/2 device driver header    */
  25. ;      /*         and the strategy entry point. Minimal support is      */
  26. ;      /*         provided. Additional support can be acheived by       */
  27. ;      /*         replacing the entry point in the device driver        */
  28. ;      /*         header with a device dependent routine that does      */
  29. ;      /*         additional function then calls the provided routine   */
  30. ;      /*         for other functions.                                  */
  31. ;      /*                                                               */
  32. ;      /*         Routines are provided by the INIT.ASM module to       */
  33. ;      /*         change the device driver name in the device driver    */
  34. ;      /*         header and unit 0 header. Another routine is provided */
  35. ;      /*         to change the unit 0 device name.                     */
  36. ;      /*                                                               */
  37. ;      /*  ENTRY POINTS:                                                */
  38. ;      /*      See public statements                                    */
  39. ;      /*  EXTERNAL REFERENCES:                                         */
  40. ;      /*      See extrn statements                                     */
  41. ;      /*                                                               */
  42. ;      /******************* END  OF  SPECIFICATIONS *********************/
  43. .xlist
  44.   include pensegs.inc
  45.   include pen.inc
  46.   include devsym.inc
  47.   include struc.inc
  48. .list
  49.  
  50. .286p
  51.  
  52. ;------------------------------------------------------------------------------
  53. ; external routines
  54. ;------------------------------------------------------------------------------
  55.  
  56.   extrn GIO_Entry : near
  57.   extrn Init_Init : near
  58.   extrn Null_rtn_far :near
  59.  
  60. ;------------------------------------------------------------------------------
  61. ; external data
  62. ;------------------------------------------------------------------------------
  63.  
  64. ;------------------------------------------------------------------------------
  65. ; Global data declarations
  66. ;------------------------------------------------------------------------------
  67.  
  68. DSEG segment
  69. public DDHdr1
  70. DDHdr1   LABEL   WORD
  71.   DW       -1                    ; Device header pointer
  72.   DW       -1                    ; Device header pointer
  73.   DW       DEV_IOCTL+DEV_CHAR_DEV+DEVLEV_3 ; Device Driver attributes
  74.   DW       strat                 ; Strategy Routine Offset
  75.   DW       Null_rtn_far          ; IDC entry point
  76.   DB       'PENDD$  '            ; Device Name
  77.   DW       0                     ; Protect-mode CS Strategy Selector
  78.   DW       0                     ; Protect-mode DS selector
  79.   DW       0                     ; Real-mode CS Strategy Segment
  80.   DW       0                     ; Real-mode DS segment
  81.   DD       2                     ; Can handle > 16MB physical memory
  82.  
  83. installFlag db 0
  84. OpenCount   dw 0
  85.  
  86. DSEG ends
  87.  
  88.  
  89. CSEG     SEGMENT
  90.          ASSUME    CS:CSEG, SS:nothing, ES:nothing, DS:DSEG
  91. ;------------------------------------------------------------------------------
  92. ; This to catch branches to zero which are likely due to a blank in the DCB
  93. ;------------------------------------------------------------------------------
  94. public Call_To_Zero
  95. Call_To_Zero proc
  96.   PANIC PANIC_CALL0
  97.   ret
  98. Call_To_Zero endp
  99.  
  100. ;---- OS/2 STRATEGY ENTRY POINT -----------------------------------------------
  101. ; Handle OS/2 device driver interface commands
  102. ;  es:bx = request packet
  103. ;  si    = dcb
  104. ; note: called from device dependent stub in order to pass dcb for this device
  105. ;------------------------------------------------------------------------------
  106. public strat
  107. strat  proc far
  108. ; First check to see if we have been initialized.  If not then the only
  109. ; command that is allowed is an Init command.  If we have been de-installed
  110. ; then no commands are allowed.
  111.  
  112.   mov  es:[bx].PktStatus, 0
  113.   .if <installFlag ne 0>                          ; already installed
  114.      .if <es:[bx].PktCmd eq CMDDeInstall>
  115.         call deInstall                            ; go deinstall
  116.      .else
  117.         mov al, es:[bx].PktCmd
  118.         .if <al eq CMDGenIOCTL>
  119.            call GIO_Entry                 ; Generic IOCTL
  120.         .elseif <al eq CMDOpen>
  121.            inc  OpenCount        ; Keep track of how many opens
  122.         .elseif <al eq CMDClose>
  123.            dec  OpenCount        ; Keep track of how many opens
  124.         .else
  125.            mov  es:[bx].PktStatus, STDON+STERR+STECODE
  126.         .endif
  127.      .endif
  128.   .else                                   ; we have not installed
  129.      .if <es:[bx].PktCmd eq CMDInit>      ; if this is an Init command
  130.         call Init_Init                    ; call generic init command
  131.         mov  installFlag,1
  132.      .else                                ; else no other commands allowed
  133.         mov  es:[bx].PktStatus, STDON+STERR+STECODE ; set error condition
  134.      .endif
  135.   .endif
  136.   or   es:[bx].PktStatus, STDON           ; Set Blk Complete Flag
  137.   ret                                     ; return to system
  138. strat  endp
  139.  
  140.  
  141. ;------------------------------------------------------------------------------
  142. ; deinstall device (someday)
  143. ;  es:bx = request packet
  144. ;  si    = dcb
  145. ;------------------------------------------------------------------------------
  146. public deInstall
  147. deInstall  PROC  NEAR
  148.  
  149.   mov  installFlag,0
  150.  
  151.   ret
  152. deInstall  ENDP
  153.  
  154.  
  155. CSEG ENDS
  156. END
  157.