home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / runnable / mmos2 / mmtoolkt / samples / audiodd / startup.asm < prev   
Encoding:
Assembly Source File  |  1992-05-06  |  5.0 KB  |  142 lines

  1.         PAGE    80,132
  2.  
  3.         TITLE  Audio OS/2 Device Driver
  4.         .seq                                      ; Use segments in order listed
  5.         .286p                                     ; Allow priviledged instruct
  6.  
  7. ;********************** START OF SPECIFICATIONS *********************
  8. ;*
  9. ;* SOURCE FILE NAME:  STARTUP.ASM
  10. ;*
  11. ;* DESCRIPTIVE NAME:  Audio device driver PDD 'ASM' startup module for 'C'.
  12. ;*
  13. ;* FUNCTION: Provides the user's "main" routine with the address of
  14. ;*           the request packet.
  15. ;*
  16. ;*           Satisfies the C EXTRN for __acrtused, which prevents the startup
  17. ;*           logic from being included from the standard C library.
  18. ;*
  19. ;*********************** END OF SPECIFICATIONS **********************
  20.  
  21. ;******************************************************************************
  22. ;                            S E G M E N T S
  23. ;******************************************************************************
  24.  
  25. _DATA   SEGMENT WORD PUBLIC 'DATA'
  26. _DATA   ENDS
  27.  
  28. _BSS    SEGMENT WORD PUBLIC 'BSS'
  29. _BSS    ENDS
  30.  
  31. CONST   SEGMENT WORD PUBLIC 'CONST'
  32. CONST   ENDS
  33.  
  34. _ENDDATA   SEGMENT WORD PUBLIC 'ENDDATA'
  35. _ENDDATA   ENDS
  36.  
  37. _TEXT   SEGMENT WORD PUBLIC 'CODE'
  38.         EXTRN  _Strategy_c:NEAR
  39.         EXTRN  _DDCmdInternalEntryPoint:far
  40.         PUBLIC  __acrtused
  41.         PUBLIC _Strategy
  42.         PUBLIC _DDCMDEntryPoint
  43. _TEXT   ENDS
  44.  
  45. _ENDTEXT SEGMENT WORD PUBLIC 'ENDCODE'
  46. _ENDTEXT   ENDS
  47.  
  48.  
  49. DGROUP  GROUP   CONST, _BSS, _DATA, _ENDDATA
  50. CGRP    GROUP   _TEXT, _ENDTEXT
  51.  
  52. ;******************************************************************************
  53. ;  C O D E   S E G M E N T
  54. ;******************************************************************************
  55. _TEXT   SEGMENT WORD PUBLIC 'CODE'
  56. ;;        ASSUME cs:_TEXT, ds:DGROUP, es:NOTHING, ss:NOTHING
  57.         ASSUME ds:DGROUP, es:NOTHING, ss:NOTHING        ; MASM 6.00
  58.  
  59.  
  60.  
  61. ;********************** START OF SPECIFICATIONS *********************
  62. ;*
  63. ;* SUBROUTINE NAME: Strategy
  64. ;*
  65. ;* DESCRIPTIVE NAME: Audio PDD Strategy Routine
  66. ;*
  67. ;* ENTRY POINTS:  Strategy
  68. ;*
  69. ;* INPUT:  DS    = DD Data Segment
  70. ;*         ES:BX -> Pointer to the Request Packet
  71. ;*
  72. ;*            The Request Packet:
  73. ;*            ------------------
  74. ;*            HEADER:                 ; Request Header
  75. ;*              BYTE    .PktLen       ;   length of request packet
  76. ;*              BYTE                  ;   Block Device unit code (unused)
  77. ;*              BYTE    .PktCmd       ;   command code
  78. ;*              WORD    .PktStatus    ;   return status
  79. ;*              DWORD   .PktDevLink   ;   ReqPkt queue linkage
  80. ;*                                    ;
  81. ;*            DATA:                   ;
  82. ;*              ????                  ; Depends on function requested
  83. ;*
  84. ;* EXIT-NORMAL: .PktStatus  = 0100h ( No Error              )
  85. ;*                            0300h ( Device Busy, No Error )
  86. ;*
  87. ;* EXIT-ERROR:  .PktStatus  = 8101h ( Unknown Unit          )
  88. ;*                            8102h ( Device Not Ready      )
  89. ;*                            8103h ( Unknown command       )
  90. ;*                            810Ch ( General Failure       )
  91. ;*                            8111h ( Char_Call_Interrupted )
  92. ;*                            8112h ( No Monitor Support    )
  93. ;*                            8113h ( Invalid Parameter     )
  94. ;*
  95. ;*********************** END OF SPECIFICATIONS **********************
  96. _Strategy proc far
  97. __acrtused label byte                           ; Label for linker, eliminates
  98.                                                 ; inclusion of C runtime startup
  99.         push    es                              ; Push address of request
  100.         push    bx                              ; packet (parm to C routine)
  101.         call    _Strategy_c
  102.         pop     bx                              ; Restore stack frame and
  103.         pop     es                              ; restore pointer to request
  104.                                                 ; packet.
  105.         mov     WORD PTR es:[bx+3],ax           ; plug in status word
  106.         ret                                     ; Return to kernel
  107. _Strategy endp
  108.  
  109.  
  110. ;***************************************
  111. ; DDCMDEntryPoint - Enables Audio stream
  112. ; handler to communicate with Audio PDD
  113. ;***************************************
  114.  
  115. _DDCMDEntryPoint proc far
  116.  
  117.         push   bp                               ; Save stack pointer
  118.         mov    bp, sp
  119.  
  120.         push   ds                               ; Create own data segment
  121.         mov    ax, DGROUP
  122.         mov    ds, ax
  123.  
  124.  
  125.         push   [bp+8]                           ; high address
  126.         push   [bp+6]                           ; low address
  127.                                                 ; +4[bp] has old CS register
  128.  
  129.         call   _DDCmdInternalEntryPoint         ; C routine to process DDCMDs
  130.  
  131.         add    sp, 4                            ; toss calling address
  132.  
  133.         pop    ds                               ; restore registers ds, bp
  134.         pop    bp
  135.         ret
  136.  
  137. _DDCMDEntryPoint endp
  138.  
  139.  
  140. _TEXT   ENDS
  141.         END
  142.