home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / INC / DEVHLP.INC < prev    next >
Text File  |  1995-04-14  |  13KB  |  274 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12. ;       SCCSID = @(#)devhlp.inc 6.10 91/11/13
  13. ; ****************************************************************************
  14. ; *                                                                          *
  15. ; *                                                                          *
  16. ; *                                                                          *
  17. ; ****************************************************************************
  18.  
  19. SUBTTL  DevHlp - Definitions for device driver helper functions
  20.  
  21.  
  22. DevHlp_SchedClock       EQU      0      ;  0    Called each timer tick
  23. DevHlp_DevDone          EQU      1      ;  1    Device I/O complete
  24. DevHlp_Yield            EQU      2      ;  2    yield CPU if resched set
  25. DevHlp_TCYield          EQU      3      ;  3    yield to time critical task
  26.  
  27. DevHlp_ProcBlock        EQU      4      ;  4    Block on event
  28. DevHlp_ProcRun          EQU      5      ;  5    Unblock process
  29.  
  30. DevHlp_SemRequest       EQU      6      ;  6    claim a semaphore
  31. DevHlp_SemClear         EQU      7      ;  7    release a semaphore
  32. DevHlp_SemHandle        EQU      8      ;  8    obtain a semaphore handle
  33.  
  34. DevHlp_PushRequest      EQU      9      ;  9    Push the request
  35. DevHlp_PullRequest      EQU     10      ;  A    Pull next request from Q
  36. DevHlp_PullParticular   EQU     11      ;  B    Pull a specific request
  37. DevHlp_SortRequest      EQU     12      ;  C    Push request in sorted order
  38.  
  39. DevHlp_AllocReqPacket   EQU     13      ;  D    allocate request packet
  40. DevHlp_FreeReqPacket    EQU     14      ;  E    free request packet
  41.  
  42. DevHlp_QueueInit        EQU     15      ;  F    Init/Clear char queue
  43. DevHlp_QueueFlush       EQU     16      ; 10    flush queue
  44. DevHlp_QueueWrite       EQU     17      ; 11    Put a char in the queue
  45. DevHlp_QueueRead        EQU     18      ; 12    Get a char from the queue
  46.  
  47. DevHlp_Lock             EQU     19      ; 13    Lock segment
  48. DevHlp_Unlock           EQU     20      ; 14    Unlock segment
  49.  
  50. DevHlp_PhysToVirt       EQU     21      ; 15    convert physical address to virtual
  51. DevHlp_VirtToPhys       EQU     22      ; 16    convert virtual address to physical
  52. DevHlp_PhysToUVirt      EQU     23      ; 17    convert physical to LDT
  53.  
  54. DevHlp_AllocPhys        EQU     24      ; 18    allocate physical memory
  55. DevHlp_FreePhys         EQU     25      ; 19    free physical memory
  56.  
  57. DevHlp_SetROMVector     EQU     26      ; 1A    set a ROM service routine vector
  58. DevHlp_SetIRQ           EQU     27      ; 1B    set an IRQ interrupt
  59. DevHlp_UnSetIRQ         EQU     28      ; 1C    unset an IRQ interrupt
  60.  
  61. DevHlp_SetTimer         EQU     29      ; 1D    set timer request handler
  62. DevHlp_ResetTimer       EQU     30      ; 1E    unset timer request handler
  63.  
  64. DevHlp_MonitorCreate    EQU     31      ; 1F    create a monitor
  65. DevHlp_Register         EQU     32      ; 20    install a monitor
  66. DevHlp_DeRegister       EQU     33      ; 21    remove a monitor
  67. DevHlp_MonWrite         EQU     34      ; 22    pass data records to monitor
  68. DevHlp_MonFlush         EQU     35      ; 23    remove all data from stream
  69.  
  70. DevHlp_GetDOSVar        EQU     36      ; 24    Return pointer to DOS variable
  71.  
  72. ; Dos variable indexes used in DevHlp_GetDOSVar
  73. DHGETDOSV_SYSINFOSEG    EQU     1
  74. DHGETDOSV_LOCINFOSEG    EQU     2
  75. DHGETDOSV_VECTORSDF     EQU     4
  76. DHGETDOSV_VECTORREBOOT  EQU     5
  77. DHGETDOSV_VECTORMSATS   EQU     6
  78. DHGETDOSV_INTERRUPTLEV  EQU     13      ; Interrupt level
  79. DHGETDOSV_DEVICECLASSTABLE EQU     14   ; Device Class Table
  80. DHGETDOSV_DMQSSEL       EQU     15      ; DMQS selector
  81.  
  82. DevHlp_SendEvent        EQU     37      ; 25    an event occurred
  83. DevHlp_ROMCritSection   EQU     38      ; 26    ROM Critical Section
  84. DevHlp_VerifyAccess     EQU     39      ; 27    Verify access to memory
  85. DevHlp_RAS              EQU     40      ; 28    Put info in RAS trace buffer
  86.  
  87. DevHlp_ABIOSGetParms    EQU     41      ; 29    Get ABIOS Calling Parms
  88. DevHlp_AttachDD         EQU     42      ; 2A    Attach to a device driver
  89. DevHlp_InternalError    EQU     43      ; 2B    Signal an internal error
  90. DevHlp_ModifyPriority   EQU     44      ; 2C    Undocumented (used by PM)
  91. DevHlp_AllocGDTSelector EQU     45      ; 2D    Allocate GDT Selectors
  92. DevHlp_PhysToGDTSelector EQU    46      ; 2E    Convert phys addr to GDT sel
  93. DevHlp_RealToProt       EQU     47      ; 2F    Change from real to protected mode
  94. DevHlp_ProtToReal       EQU     48      ; 30    Change from protected to real mode
  95.  
  96. DevHlp_EOI              EQU     49      ; 31    Send EOI to PIC
  97. DevHlp_UnPhysToVirt     EQU     50      ; 32    mark completion of PhysToVirt
  98. DevHlp_TickCount        EQU     51      ; 33    modify timer
  99.  
  100. DevHlp_GetLIDEntry      EQU     52      ; 34    Obtain Logical ID
  101. DevHlp_FreeLIDEntry     EQU     53      ; 35    Release Logical ID
  102. DevHlp_ABIOSCall        EQU     54      ; 36    Call ABIOS
  103. DevHlp_ABIOSCommonEntry EQU     55      ; 37    Invoke Common Entry Point
  104. DevHlp_GetDeviceBlock   EQU     56      ; 38    Get ABIOS Device Block
  105.                                         ; 39    Reserved for Profiling Kernel
  106. DevHlp_RegisterStackUsage EQU   58      ; 3A    Register for stack usage
  107. DevHlp_LogEntry         EQU     59      ; 3B    Place data in log buffer
  108.  
  109. DevHlp_VideoPause       EQU     60      ; 3C Video pause on/off      - D607
  110.  
  111. DevHlp_Save_Message     EQU     61      ; 3D    Save msg in SysInit Message Table
  112.  
  113. DevHlp_SegRealloc       EQU     62      ; 3E    Realloc DD protect mode segment
  114. DevHlp_PutWaitingQueue  EQU     63      ; 3F    Put I/O request on waiting queue
  115. DevHlp_GetWaitingQueue  EQU     64      ; 40    Get I/O request from waiting queue
  116. ;DevHlp_PhysToSys        EQU     65      ; 41    Address conversion for the AOX
  117. ;DevHlp_PhysToSysHook    EQU     66      ; 42    Address conversion for the AOX
  118. DevHlp_RegisterDeviceClass EQU     67      ; 43    Register DC entry point
  119. ;
  120. ; 32-Bit DevHelps start at 80 (50h)
  121. ;
  122. DevHlp_RegisterPDD      EQU     80      ; 50    Register PDD entry point with
  123.                                         ;       VDM manager for later PDD-VDD
  124.                                         ;       communication
  125. DevHlp_RegisterBeep     EQU     81      ; 51    register PTD beep service
  126.                                         ;       entry point with kernel
  127. DevHlp_Beep             EQU     82      ; 52    preempt beep service via PTD
  128.  
  129. DevHlp_FreeGDTSelector  EQU     83      ; 53    Free allocated GDT selector
  130.  
  131. DevHlp_PhysToGDTSel     EQU     84      ; 54    Convert Phys Addr to GDT sel
  132.                                         ;       with given access
  133.                                         ;   BUGBUG: TEMPORARY!!!
  134.  
  135. DevHlp_VMLock           EQU     85      ; 55    Lock linear address range
  136.  
  137. DevHlp_VMUnlock         EQU     86      ; 56    Unlock address range
  138.  
  139. DevHlp_VMAlloc          EQU     87      ; 56    Allocate memory
  140.  
  141. DevHlp_VMFree           EQU     88      ; 58    Free memory or mapping
  142.  
  143. DevHlp_VMProcessToGlobal EQU    89      ; 59    Create global mapping to process
  144.                                         ;       memory
  145.  
  146. DevHlp_VMGlobalToProcess EQU    90      ; 5A    Create process mapping to global
  147.                                         ;       memory
  148.  
  149. DevHlp_VirtToLin        EQU     91      ; 5B Convert virtual address to linear
  150.  
  151. DevHlp_LinToGDTSelector EQU     92      ; 5C Convert linear address to virtual
  152.  
  153. DevHlp_GetDescInfo      EQU     93      ; 5D Return descriptor information
  154.  
  155. DevHlp_LinToPageList    EQU     94      ; 5E build pagelist array from lin addr
  156.  
  157. DevHlp_PageListToLin    EQU     95      ; 5F map page list array to lin addr
  158.  
  159. DevHlp_PageListToGDTSelector EQU    96  ; 60 map page list array to GDT sel.
  160.  
  161. DevHlp_RegisterTmrDD    EQU     97      ; 61 Register TMR Device Driver.
  162.  
  163. DevHlp_RegisterPerfCtrs EQU     98      ; 62 Register device driver perf. ctrs (PVW).
  164.  
  165. DevHlp_AllocateCtxHook  EQU     99      ; 63 Allocate a context hook
  166.  
  167. DevHlp_FreeCtxHook      EQU     100     ; 64 Free a context hook
  168.  
  169. DevHlp_ArmCtxHook       EQU     101     ; 65 Arm a context hook
  170.  
  171. DevHlp_VMSetMem         EQU     102     ; 66H commit/decommit memory
  172.  
  173. DevHlp_OpenEventSem     EQU     103     ; 67H open an event semaphore
  174.  
  175. DevHlp_CloseEventSem    EQU     104     ; 68H close an event semaphore
  176.  
  177. DevHlp_PostEventSem     EQU     105     ; 69H post an event semaphore
  178.  
  179. DevHlp_ResetEventSem    EQU     106     ; 6AH reset an event semaphore
  180.  
  181. DevHlp_RegisterFreq     EQU     107     ; 6BH   register PTD freq service
  182.                                         ;       entry point with kernel
  183.  
  184. DevHlp_DynamicAPI       EQU     108     ; 6CH add a dynamic API
  185. ;
  186. ; Request bit definitions used in DevHlp_DynamicAPI
  187. DHDYNAM_16B_CALLGATE    EQU     1       ; 1 = 16 bit callgate, 0 = 32 bit
  188. DHDYNAM_16B_APIRTN      EQU     2       ; 1 = 16 bit API rtn,  0 = 32 rtn
  189.  
  190. DevHlp_ProcRun2         EQU     109     ; 6DH  Unblock process via procrun2
  191. ;
  192. DevHlp_CreateInt13VDM   EQU     110 ;6EH Create Int13 VDM (Internal Only) OEMINT13
  193.  
  194. event_SM_Mou            equ     0       ; event was Session Manager-mouse@@
  195.     event_MUF           equ     0       ; (OBSOLETE) event was muf key
  196. event_CtrlBrk           equ     1       ; event was Ctrl-Break
  197. event_CtrlC             equ     2       ; event was Ctrl-C
  198. event_CtrlScrLk         equ     3       ; event was Ctrl-ScrollLock
  199. event_CtrlPrtSc         equ     4       ; event was Ctrl-PrtSc
  200. event_ShftPrtSc         equ     5       ; event was Shift-PrtSc
  201. event_SM_Kbd            equ     6       ; event was Session Manager -keyboard@@
  202. event_SM_CAD            equ     7       ; event was Ctl-Alt-Del
  203. event_HOT_PLUG          equ     8       ; Keyboard Hot Plug/Reset   DCR1187
  204. event_POWER             equ     9       ; Power suspend event #26087
  205. event_count             equ     10      ; @@ Number of possible events DCR1187
  206.  
  207. ;       Character Queue structure
  208. ;
  209. ;       QueueInit must be called before any other queue manipulation
  210. ;       subroutine.  The Qsize field must be initialized before
  211. ;       calling QueueInit.
  212.  
  213. CharQueue STRUC
  214.         Qsize   DW      ?               ; Size of queue in bytes
  215.         Qchrout DW      ?               ; Index of next char out
  216.         Qcount  DW      ?               ; Count of characters in the queue
  217.         Qbase   DB      ?               ; Queue buffer
  218. CharQueue ENDS
  219.  
  220. RASrouter struc
  221.         pretrace_addr   dw      0
  222.         preminor        dw      0
  223.         posttrace_addr  dw      0
  224.         postminor       dw      0
  225. RASrouter ends
  226.  
  227.  
  228. ; Following are constants used in conversion of LDT pseudo-tiled addresses
  229.  
  230. SEL_FLATMASK    equ     01fff0000h
  231. SEL_FLAT_SHIFT  equ     0dh
  232. SEL_LDT_RPL3    equ     07h
  233.  
  234.  
  235. SelToFlat  MACRO        ;; Converts LDTsel:offset to Flat linear address
  236. ;;
  237. ;;      This macro converts given LDT selector:offset pair to Flat linear
  238. ;;  address. No verification is done on parameters. It is the invoker's
  239. ;;  responsibility to assure that the selector is valid, not a call gate,
  240. ;;  and given offset is within descriptor's limit.
  241. ;;
  242. ;;      ENTRY   (AX) = selector
  243. ;;              (BX) = offset
  244. ;;      EXIT   (EAX) = Flat address
  245.  
  246.         shl     eax, SEL_FLAT_SHIFT
  247.         and     eax, SEL_FLATMASK
  248.         mov     ax, bx
  249. ENDM
  250.  
  251.  
  252.  
  253. FlatToSel  MACRO        ;; Convert flat linear address to LDTsel:offset pair
  254. ;;
  255. ;;      This macro converts given flat address to selector:offset pair. No
  256. ;;  verification is done on the parameters. It is the invoker's responsibility
  257. ;;  to ensure that the flat address is in the LDT pseudo-tiled compatibility
  258. ;;  region, and that the selector returned is valid.
  259. ;;      Linear addresses < 20000000h (512 Meg) fall into the LDT compatibility
  260. ;;  region. All memory allocated in this region with selector mapping request
  261. ;;  will have valid selectors.
  262. ;;  WARNING: The returned selector will have RPL level 3. Selectors
  263. ;;  corresponding to IOPL segments should have their lowest bit turned off.
  264. ;;
  265. ;;      ENTRY  (EAX) = Flat address
  266. ;;      EXIT    (AX) = selector
  267. ;;              (BX) = offset
  268.  
  269.         mov     bx, ax
  270.         shr     eax, SEL_FLAT_SHIFT
  271.         or      ax, SEL_LDT_RPL3
  272.  
  273. ENDM
  274.