home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / odtlktv4.zip / ODTLKT / TOOLKIT / INC / DEVHLP.INC < prev    next >
Text File  |  1995-11-22  |  13KB  |  271 lines

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