home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / pc / windows / qtw_201 / setup / samples / mmio_dh / dispatch.asm < prev    next >
Encoding:
Assembly Source File  |  1994-12-19  |  6.4 KB  |  229 lines

  1. ; Copyright:    (c) 1988-1994 Apple Computer, Inc. All Rights Reserved.
  2. ;
  3. ; Project:      QuickTime for Windows
  4. ;
  5. ; Component:    Data Handler
  6. ;
  7. ; Description:  Function dispatcher
  8. ;
  9. ; ---------------------------------------------------------------------
  10. INCLUDE  QTMACROS.INC
  11. INCLUDE     dhlrsel.inc
  12.  
  13. DGROUP   GROUP   _DATA
  14. _DATA    SEGMENT PARA PUBLIC 'DATA'
  15. _DATA    ENDS
  16.  
  17. CODESEG  SEGMENT PARA USE16 PUBLIC 'CODE'
  18.          OPTION LANGUAGE:C
  19.         .386
  20.          ASSUME  DS:DGROUP
  21.  
  22. ; ***************************************************************
  23. ; * THESE JUMP TABLES MUST BE IN THE CORRECT ORDER, I.E. THE
  24. ; * SAME ORDER AS THE COMPONENT FUNCTION SELECTOR IDS.  IF A
  25. ; * CALL IS NOT SUPPORTED, PUT A '0' (ZERO) IN THE TABLE ENTRY
  26. ; ***************************************************************
  27.  
  28. ; jump table for selectors < 0 (standard component manger calls)
  29. ; NOTE that these are in reverse order, i.e. they are in the
  30. ; order of their call selectors, but negated.
  31. DataHJumpTableUnder0:
  32.     EXTERN C DataHOpen:NEAR
  33.     EXTERN C DataHClose:NEAR
  34.     EXTERN C DataHCanDo:NEAR
  35.     EXTERN C DataHVersion:NEAR
  36.  
  37.     DW DataHOpen                ; -1
  38.     DW DataHClose                ; -2
  39.     DW DataHCanDo                ; -3
  40.     DW DataHVersion                ; -4
  41.     DW 0                        ; -5, Register
  42.     DW 0                        ; -6, Target
  43.     DW 0                        ; -7, Unregister
  44.     
  45. ; jump table for selectors 1-255
  46. DataHJumpTableUnder256:
  47.     EXTERN C DataHCanUseDataRef:NEAR
  48.     EXTERN C DataHGetVolumeList:NEAR
  49.     EXTERN C DataHGetDeviceIndex:NEAR
  50.     EXTERN C DataHSetDataRef:NEAR
  51.     EXTERN C DataHGetDataRef:NEAR
  52.     EXTERN C DataHCompareDataRef:NEAR
  53.     EXTERN C DataHResolveDataRef:NEAR
  54.     EXTERN C DataHOpenForRead:NEAR
  55.     EXTERN C DataHCloseForRead:NEAR
  56.     EXTERN C DataHOpenForWrite:NEAR
  57.     EXTERN C DataHCloseForWrite:NEAR
  58.     EXTERN C DataHGetData:NEAR
  59.     EXTERN C DataHPutData:NEAR
  60.     EXTERN C DataHScheduleData:NEAR
  61.     EXTERN C DataHFinishData:NEAR
  62.     EXTERN C DataHTask:NEAR
  63.     EXTERN C DataHFlushCache:NEAR
  64.     EXTERN C DataHFlushData:NEAR
  65.     EXTERN C DataHGetFileSize:NEAR
  66.     EXTERN C DataHSetFileSize:NEAR
  67.     EXTERN C DataHCreateFile:NEAR
  68.     EXTERN C DataHGetPreferredBlockSize:NEAR
  69.     EXTERN C DataHGetFreeSpace:NEAR
  70.     EXTERN C DataHPreextend:NEAR
  71.     EXTERN C DataHWrite:NEAR
  72.     EXTERN C DataHGetScheduleAheadTime:NEAR
  73.     EXTERN C DataHPlaybackHints:NEAR
  74.     EXTERN C DataHSetOSFileReference:NEAR
  75.     EXTERN C DataHGetOSFileReference:NEAR
  76.  
  77.     DW 0                                ; 1
  78.     DW DataHGetData                        ; 2
  79.     DW DataHPutData                        ; 3
  80.     DW DataHFlushData                    ; 4
  81.     DW DataHOpenForWrite                ; 5
  82.     DW DataHCloseForWrite                ; 6
  83.     DW 0                                ; 7
  84.     DW DataHOpenForRead                    ; 8
  85.     DW DataHCloseForRead                ; 9
  86.     DW DataHSetDataRef                    ; 10
  87.     DW DataHGetDataRef                    ; 11
  88.     DW DataHCompareDataRef                ; 12
  89.     DW DataHTask                        ; 13
  90.     DW DataHScheduleData                ; 14
  91.     DW DataHFinishData                    ; 15
  92.     DW DataHFlushCache                    ; 16
  93.     DW DataHResolveDataRef                ; 17
  94.     DW DataHGetFileSize                    ; 18
  95.     DW DataHCanUseDataRef                ; 19
  96.     DW DataHGetVolumeList                ; 20
  97.     DW DataHWrite                        ; 21
  98.     DW DataHPreextend                    ; 22
  99.     DW DataHSetFileSize                    ; 23
  100.     DW DataHGetFreeSpace                ; 24
  101.     DW DataHCreateFile                    ; 25
  102.     DW DataHGetPreferredBlockSize        ; 26
  103.     DW DataHGetDeviceIndex                ; 27
  104.     DW 0                                ; 28
  105.     DW 0                                ; 29
  106.     DW DataHGetScheduleAheadTime        ; 30
  107.         
  108. ; selector codes in the 0x100 range
  109. DataHJumpTableOver256:
  110.     DW 0                                ; 0x100 + 1
  111.     DW 0                                ; 0x100 + 2
  112.     DW DataHPlaybackHints                ; 0x100 + 3
  113.     
  114. ; selector codes in the 0x200 range
  115. DataHJumpTableOver512:
  116.     DW 0                                ; 0x200 + 1
  117.     DW 0                                ; 0x200 + 2
  118.     DW 0                                ; 0x200 + 3
  119.     DW DataHSetOSFileReference            ; 0x200 + 4
  120.     DW DataHGetOSFileReference            ; 0x200 + 5
  121.     
  122. ; **********************************************************************
  123. ; * 
  124. ; * Name:    DataHEntry
  125. ; *
  126. ; * Description:
  127. ; *
  128. ; *        This is the entry point for dispatching of component manger
  129. ; *        calls.
  130. ; *
  131. ; **********************************************************************
  132.     PUBLIC C DataHEntry
  133. DataHEntry PROC FAR
  134.         cmp        bx,0
  135.         je        BadSelector            ; no selector 0
  136.         
  137.         ; check for a negative selector id (standard component
  138.         ; manager call)
  139.         jl        NegativeSelector    ; skip if selector is negative
  140.         
  141.         ; check each section in the order of highest range to lowest
  142.         ; range
  143.         
  144.         ; check for an out of range selector (beyond the 0x200 group)
  145.         cmp        bx,0200h+kDataHFunctionGroup512Count
  146.         jge        BadSelector
  147.         
  148.         ; check for a call in the 0x200 group
  149.         cmp        bx,0200h
  150.         jge        CheckSelector512
  151.         
  152.         ; check for a call in the 0x100 group
  153.         cmp        bx,0100h
  154.         jge        CheckSelector256
  155.         
  156.         ; it is a call selector less than 256, convert to zero-based
  157.         ; index and double to make a word index
  158.         dec        bx
  159.         add        bx,bx
  160.         
  161.         ; make sure the function pointer is non-zero
  162.         mov        ax,WORD PTR DataHJumpTableUnder256[bx]
  163.         or        ax,ax                ; zero?
  164.         je        BadSelector            ; yes, unsupported call
  165.         
  166.         ; dispatch the call
  167.         MOV        AX, DGROUP            ; Set DS for this DLL
  168.         MOV        DS, AX
  169.         jmp        WORD PTR cs:DataHJumpTableUnder256[bx];
  170.  
  171. CheckSelector256:
  172.         ; strip high byte to make less than 256, convert to zero-based
  173.         ; index and double to make a word index
  174.         and        bx,0ffh
  175.         cmp        bx,kDataHFunctionGroup256Count    ; insure it's within range
  176.         jg        BadSelector            
  177.         dec        bx
  178.         add        bx,bx
  179.         
  180.         ; make sure the function pointer is non-zero
  181.         mov        ax,WORD PTR DataHJumpTableOver256[bx]
  182.         or        ax,ax                ; zero?
  183.         je        BadSelector            ; yes, unsupported call
  184.         
  185.         ; dispatch the call
  186.         MOV        AX, DGROUP            ; Set DS for this DLL
  187.         MOV        DS, AX
  188.         jmp        WORD PTR cs:DataHJumpTableOver256[bx];
  189.  
  190.         
  191. CheckSelector512:
  192.         ; strip high byte to make less than 512, convert to zero-based
  193.         ; index and double to make a word index
  194.         and        bx,0ffh
  195.         cmp        bx,kDataHFunctionGroup512Count    ; insure it's within range
  196.         jg        BadSelector            
  197.         dec        bx
  198.         add        bx,bx
  199.         
  200.         ; make sure the function pointer is non-zero
  201.         mov        ax,WORD PTR DataHJumpTableOver512[bx]
  202.         or        ax,ax                ; zero?
  203.         je        BadSelector            ; yes, unsupported call
  204.         
  205.         ; dispatch the call
  206.         MOV        AX, DGROUP            ; Set DS for this DLL
  207.         MOV        DS, AX
  208.         jmp        WORD PTR cs:DataHJumpTableOver512[bx];
  209.  
  210. NegativeSelector:
  211.         NEG        BX                    ; Make positive
  212.         cmp        bx,kDataHFunctionGroupNegativeCount    ; insure it's within range
  213.         jge        BadSelector            
  214.         DEC        BX                    ; One relative to zero relative
  215.         ADD        BX, BX                ; WORD offset to byte offset
  216.         MOV        AX, DGROUP            ; Set DS for this DLL
  217.         MOV        DS, AX
  218.         JMP        WORD PTR cs:DataHJumpTableUnder0[BX]
  219.  
  220. BadSelector:
  221.         MOV        DX,8000h            ; Load special error return
  222.         MOV        AX,8002h            ; badComponentSelector
  223.         RET
  224.  
  225. DataHEntry ENDP
  226.  
  227. CODESEG    ENDS
  228.         END
  229.