home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / inc / devhlp.inc < prev    next >
Text File  |  1999-03-15  |  16KB  |  345 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. ; * 19th Sep 97 RJM RAS SDD trace enhncements F180062                        *
  11. ; ****************************************************************************
  12.  
  13. SUBTTL  DevHlp - Definitions for device driver helper functions
  14.  
  15.  
  16. DevHlp_SchedClock       EQU      0      ;  0    Called each timer tick
  17. DevHlp_DevDone          EQU      1      ;  1    Device I/O complete
  18. DevHlp_Yield            EQU      2      ;  2    yield CPU if resched set
  19. DevHlp_TCYield          EQU      3      ;  3    yield to time critical task
  20.  
  21. DevHlp_ProcBlock        EQU      4      ;  4    Block on event
  22. DevHlp_ProcRun          EQU      5      ;  5    Unblock process
  23.  
  24. DevHlp_SemRequest       EQU      6      ;  6    claim a semaphore
  25. DevHlp_SemClear         EQU      7      ;  7    release a semaphore
  26. DevHlp_SemHandle        EQU      8      ;  8    obtain a semaphore handle
  27.  
  28. DevHlp_PushRequest      EQU      9      ;  9    Push the request
  29. DevHlp_PullRequest      EQU     10      ;  A    Pull next request from Q
  30. DevHlp_PullParticular   EQU     11      ;  B    Pull a specific request
  31. DevHlp_SortRequest      EQU     12      ;  C    Push request in sorted order
  32.  
  33. DevHlp_AllocReqPacket   EQU     13      ;  D    allocate request packet
  34. DevHlp_FreeReqPacket    EQU     14      ;  E    free request packet
  35.  
  36. DevHlp_QueueInit        EQU     15      ;  F    Init/Clear char queue
  37. DevHlp_QueueFlush       EQU     16      ; 10    flush queue
  38. DevHlp_QueueWrite       EQU     17      ; 11    Put a char in the queue
  39. DevHlp_QueueRead        EQU     18      ; 12    Get a char from the queue
  40.  
  41. DevHlp_Lock             EQU     19      ; 13    Lock segment
  42. DevHlp_Unlock           EQU     20      ; 14    Unlock segment
  43.  
  44. DevHlp_PhysToVirt       EQU     21      ; 15    convert physical address to virtual
  45. DevHlp_VirtToPhys       EQU     22      ; 16    convert virtual address to physical
  46. DevHlp_PhysToUVirt      EQU     23      ; 17    convert physical to LDT
  47.  
  48. DevHlp_AllocPhys        EQU     24      ; 18    allocate physical memory
  49. DevHlp_FreePhys         EQU     25      ; 19    free physical memory
  50.  
  51. DevHlp_SetROMVector     EQU     26      ; 1A    set a ROM service routine vector
  52. DevHlp_SetIRQ           EQU     27      ; 1B    set an IRQ interrupt
  53. DevHlp_UnSetIRQ         EQU     28      ; 1C    unset an IRQ interrupt
  54.  
  55. DevHlp_SetTimer         EQU     29      ; 1D    set timer request handler
  56. DevHlp_ResetTimer       EQU     30      ; 1E    unset timer request handler
  57.  
  58. DevHlp_MonitorCreate    EQU     31      ; 1F    create a monitor
  59. DevHlp_Register         EQU     32      ; 20    install a monitor
  60. DevHlp_DeRegister       EQU     33      ; 21    remove a monitor
  61. DevHlp_MonWrite         EQU     34      ; 22    pass data records to monitor
  62. DevHlp_MonFlush         EQU     35      ; 23    remove all data from stream
  63.  
  64. DevHlp_GetDOSVar        EQU     36      ; 24    Return pointer to DOS variable
  65.  
  66. ; Dos variable indexes used in DevHlp_GetDOSVar
  67. DHGETDOSV_SYSINFOSEG    EQU     1
  68. DHGETDOSV_LOCINFOSEG    EQU     2
  69. DHGETDOSV_VECTORSDF     EQU     4
  70. DHGETDOSV_VECTORREBOOT  EQU     5
  71. DHGETDOSV_VECTORMSATS   EQU     6
  72. DHGETDOSV_INTERRUPTLEV  EQU     13      ; Interrupt level
  73. DHGETDOSV_DEVICECLASSTABLE EQU     14   ; Device Class Table
  74. DHGETDOSV_DMQSSEL       EQU     15      ; DMQS selector
  75. DHGETDOSV_APMINFO       EQU     16      ; Query APM BIOS presence, establish connection
  76. DHGETDOSV_APM11INFO     EQU     17      ; APM 1.1 information
  77. DHGETDOSV_CPUMODE       EQU     18      ; 0 = uniprocessor, 1=multiprocessor
  78. DHGETDOSV_PSDFLAGS      EQU     19      ; Get the PSD's flags
  79. DHGETDOSV_TOTALCPUS     EQU     20      ; Number of processors online
  80.  
  81. DevHlp_SendEvent        EQU     37      ; 25    an event occurred
  82. DevHlp_ROMCritSection   EQU     38      ; 26    ROM Critical Section
  83. DevHlp_VerifyAccess     EQU     39      ; 27    Verify access to memory
  84. DevHlp_RAS              EQU     40      ; 28    Put info in RAS trace buffer
  85. DevHlp_SysTrace         EQU     40      ; 28    Synonym for DevHlp_RAS   f180062
  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. DevHlp_PerfSysTrace     EQU     69      ; 45    Software Trace DD entry point; 153279
  120. ;
  121. ; 32-Bit DevHelps start at 80 (50h)
  122. ;
  123. DevHlp_RegisterPDD      EQU     80      ; 50    Register PDD entry point with
  124.                                         ;       VDM manager for later PDD-VDD
  125.                                         ;       communication
  126. DevHlp_RegisterBeep     EQU     81      ; 51    register PTD beep service
  127.                                         ;       entry point with kernel
  128. DevHlp_Beep             EQU     82      ; 52    preempt beep service via PTD
  129.  
  130. DevHlp_FreeGDTSelector  EQU     83      ; 53    Free allocated GDT selector
  131.  
  132. DevHlp_PhysToGDTSel     EQU     84      ; 54    Convert Phys Addr to GDT sel
  133.                                         ;       with given access
  134.                                         ;   BUGBUG: TEMPORARY!!!
  135.  
  136. DevHlp_VMLock           EQU     85      ; 55    Lock linear address range
  137.  
  138. DevHlp_VMUnlock         EQU     86      ; 56    Unlock address range
  139.  
  140. DevHlp_VMAlloc          EQU     87      ; 56    Allocate memory
  141.  
  142. DevHlp_VMFree           EQU     88      ; 58    Free memory or mapping
  143.  
  144. DevHlp_VMProcessToGlobal EQU    89      ; 59    Create global mapping to process
  145.                                         ;       memory
  146.  
  147. DevHlp_VMGlobalToProcess EQU    90      ; 5A    Create process mapping to global
  148.                                         ;       memory
  149.  
  150. DevHlp_VirtToLin        EQU     91      ; 5B Convert virtual address to linear
  151.  
  152. DevHlp_LinToGDTSelector EQU     92      ; 5C Convert linear address to virtual
  153.  
  154. DevHlp_GetDescInfo      EQU     93      ; 5D Return descriptor information
  155.  
  156. DevHlp_LinToPageList    EQU     94      ; 5E build pagelist array from lin addr
  157.  
  158. DevHlp_PageListToLin    EQU     95      ; 5F map page list array to lin addr
  159.  
  160. DevHlp_PageListToGDTSelector EQU    96  ; 60 map page list array to GDT sel.
  161.  
  162. DevHlp_RegisterTmrDD    EQU     97      ; 61 Register TMR Device Driver.
  163.  
  164. DevHlp_RegisterPerfCtrs EQU     98      ; 62 Register device driver perf. ctrs (PVW).
  165.  
  166. DevHlp_AllocateCtxHook  EQU     99      ; 63 Allocate a context hook
  167.  
  168. DevHlp_FreeCtxHook      EQU     100     ; 64 Free a context hook
  169.  
  170. DevHlp_ArmCtxHook       EQU     101     ; 65 Arm a context hook
  171.  
  172. DevHlp_VMSetMem         EQU     102     ; 66H commit/decommit memory
  173.  
  174. DevHlp_OpenEventSem     EQU     103     ; 67H open an event semaphore
  175.  
  176. DevHlp_CloseEventSem    EQU     104     ; 68H close an event semaphore
  177.  
  178. DevHlp_PostEventSem     EQU     105     ; 69H post an event semaphore
  179.  
  180. DevHlp_ResetEventSem    EQU     106     ; 6AH reset an event semaphore
  181.  
  182. DevHlp_RegisterFreq     EQU     107     ; 6BH   register PTD freq service
  183.                                         ;       entry point with kernel
  184.  
  185. DevHlp_DynamicAPI       EQU     108     ; 6CH add a dynamic API
  186. ;
  187. ; Request bit definitions used in DevHlp_DynamicAPI
  188. DHDYNAM_16B_CALLGATE    EQU     1       ; 1 = 16 bit callgate, 0 = 32 bit
  189. DHDYNAM_16B_APIRTN      EQU     2       ; 1 = 16 bit API rtn,  0 = 32 rtn
  190.  
  191. DevHlp_ProcRun2         EQU     109     ; 6DH  Unblock process via procrun2
  192. ;
  193. DevHlp_CreateInt13VDM   EQU     110 ;6EH Create Int13 VDM (Internal Only) OEMINT13
  194. ;
  195. DevHlp_RegisterKrnlExit EQU     111 ;6FH Used to capture Kernel Exits   F78693
  196. DevHlp_PMPostEventSem   EQU     112     ; 70h  PM Post Event Semaphore
  197.  
  198. ; DevHlp's 70-7C used by other OS/2 versions                              ;@SEC
  199.  
  200. ;ifdef SMP
  201. DevHlp_AcquireSpinLock  EQU     113     ; 71H acquire Spin Lock
  202. DevHlp_ReleaseSpinLock  EQU     114     ; 72H release Spin Lock
  203. DevHlp_InitIntMouseCursorData  EQU 115  ; 73H Initialize Mouse/Cursor Data
  204. DevHlp_StartIntMouseCursor  EQU 116     ; 74H Start Int Time Mouse/Cursor
  205. DevHlp_EndIntMouseCursor    EQU 117     ; 75H End Int Time Mouse/Cursor
  206. DevHlp_Port_IO          EQU     118     ; 76H Port I/O
  207. DevHlp_SetIRQMask       EQU     119     ; 77H Set/Unset an IRQ Mask
  208. DevHlp_GetIRQMask       EQU     120     ; 78H Retrieve an IRQ Mask state
  209. DevHlp_CreateSpinLock   EQU     121     ; 79H create Spin Lock
  210. DevHlp_FreeSpinLock     EQU     122     ; 7AH free Spin Lock
  211. ;endif
  212.  
  213. DevHlp_KillProc         EQU     125 ;7DH Kill Proc                        ;@SEC
  214. DevHlp_QSysState        EQU     126 ;7EH Query System State               ;@SEC
  215.  
  216. event_SM_Mou            equ     0       ; event was Session Manager-mouse@@
  217.     event_MUF           equ     0       ; (OBSOLETE) event was muf key
  218. event_CtrlBrk           equ     1       ; event was Ctrl-Break
  219. event_CtrlC             equ     2       ; event was Ctrl-C
  220. event_CtrlScrLk         equ     3       ; event was Ctrl-ScrollLock
  221. event_CtrlPrtSc         equ     4       ; event was Ctrl-PrtSc
  222. event_ShftPrtSc         equ     5       ; event was Shift-PrtSc
  223. event_SM_Kbd            equ     6       ; event was Session Manager -keyboard@@
  224. event_SM_CAD            equ     7       ; event was Ctl-Alt-Del
  225. event_HOT_PLUG          equ     8       ; Keyboard Hot Plug/Reset   DCR1187
  226. event_POWER             equ     9       ; Power suspend event #26087
  227. event_POWEROFF          equ     10      ; Power off event           ;d153441
  228. event_count             equ     11      ; Number of possible events ;d153441
  229. ;
  230. ; file system devhelps (2/19/96) SRD
  231. DevHlp_OpenFile         EQU     127     ; 7FH  Ring-0 File system Write
  232. DevHlp_CloseFile        EQU     128     ; 80H  Ring-0 File system Seek
  233. DevHlp_ReadFile         EQU     129     ; 81H  Ring-0 File system Read
  234. DevHlp_ReadFileAt       EQU     130     ; 82H  File system Read at (seek)
  235.  
  236. ; 182896 start
  237. ; Kernel Debug Driver devhlp/strucs/flags
  238.  
  239. DevHlp_RegisterKDD      EQU     131     ; 83H Register Driver with kernel debugger
  240.  
  241. KDD_REGISTER_COMM       EQU     1       ; Register driver for kernel debugger
  242.                                         ;  communication
  243. KDDC STRUC
  244.         KDDC_flags      DD      ?       ; Flags
  245.         KDDC_IRQ        DD      ?       ; IRQ Number
  246.         KDDC_pfnRouter  DD      ?       ; Address of router function
  247.         KDDC_pStatus    DD      ?       ; Address of status flags
  248. KDDC ENDS
  249.  
  250. ; KDDC_Flags value
  251.  
  252. KDDC_fTEST              EQU     00000001H ; Test if KDDC is possible
  253. KDDC_fFLAT              EQU     00000010H ; Addresses are 0:32
  254. KDDC_fREBOOT            EQU     00000020H ; Reboot if not KDD debugable
  255. KDDC_fDUMP              EQU     00000040H ; Dump if not KDD debugable
  256. KDDC_fVALID_MASK        EQU     00000060H ; Valid flag Mask
  257.  
  258. ; Router commands
  259.  
  260. KDDC_rcSEND             EQU     00000001H ; Send character
  261. KDDC_rcRECV             EQU     00000002H ; Receive character
  262. KDDC_rcFLUSH            EQU     00000003H ; Flush buffer
  263.  
  264. ; Router command modifier
  265.  
  266. KDDC_rmRECV_WAIT        EQU     00000001H ; Wait for character
  267.  
  268. KDDC_rmFLUSH_SEND       EQU     00000001H ; Flush send buffer
  269. KDDC_rmFLUSH_RECV       EQU     00000002H ; Flush recv buffer
  270.  
  271. ; Status flags
  272.  
  273. KDDC_sfACTIVE           EQU     00000001H ; KDD Comm Active
  274. KDDC_sfKDB_ACTIVE       EQU     00000002H ; KDB Active
  275.  
  276. ; 182896 ends
  277.  
  278. ;       Character Queue structure
  279. ;
  280. ;       QueueInit must be called before any other queue manipulation
  281. ;       subroutine.  The Qsize field must be initialized before
  282. ;       calling QueueInit.
  283.  
  284. CharQueue STRUC
  285.         Qsize   DW      ?               ; Size of queue in bytes
  286.         Qchrout DW      ?               ; Index of next char out
  287.         Qcount  DW      ?               ; Count of characters in the queue
  288.         Qbase   DB      ?               ; Queue buffer
  289. CharQueue ENDS
  290.  
  291. RASrouter struc
  292.         pretrace_addr   dw      0
  293.         preminor        dw      0
  294.         posttrace_addr  dw      0
  295.         postminor       dw      0
  296. RASrouter ends
  297.  
  298.  
  299. ; Following are constants used in conversion of LDT pseudo-tiled addresses
  300.  
  301. SEL_FLATMASK    equ     01fff0000h
  302. SEL_FLAT_SHIFT  equ     0dh
  303. SEL_LDT_RPL3    equ     07h
  304.  
  305.  
  306. SelToFlat  MACRO        ;; Converts LDTsel:offset to Flat linear address
  307. ;;
  308. ;;      This macro converts given LDT selector:offset pair to Flat linear
  309. ;;  address. No verification is done on parameters. It is the invoker's
  310. ;;  responsibility to assure that the selector is valid, not a call gate,
  311. ;;  and given offset is within descriptor's limit.
  312. ;;
  313. ;;      ENTRY   (AX) = selector
  314. ;;              (BX) = offset
  315. ;;      EXIT   (EAX) = Flat address
  316.  
  317.         shl     eax, SEL_FLAT_SHIFT
  318.         and     eax, SEL_FLATMASK
  319.         mov     ax, bx
  320. ENDM
  321.  
  322.  
  323.  
  324. FlatToSel  MACRO        ;; Convert flat linear address to LDTsel:offset pair
  325. ;;
  326. ;;      This macro converts given flat address to selector:offset pair. No
  327. ;;  verification is done on the parameters. It is the invoker's responsibility
  328. ;;  to ensure that the flat address is in the LDT pseudo-tiled compatibility
  329. ;;  region, and that the selector returned is valid.
  330. ;;      Linear addresses < 20000000h (512 Meg) fall into the LDT compatibility
  331. ;;  region. All memory allocated in this region with selector mapping request
  332. ;;  will have valid selectors.
  333. ;;  WARNING: The returned selector will have RPL level 3. Selectors
  334. ;;  corresponding to IOPL segments should have their lowest bit turned off.
  335. ;;
  336. ;;      ENTRY  (EAX) = Flat address
  337. ;;      EXIT    (AX) = selector
  338. ;;              (BX) = offset
  339.  
  340.         mov     bx, ax
  341.         shr     eax, SEL_FLAT_SHIFT
  342.         or      ax, SEL_LDT_RPL3
  343.  
  344. ENDM
  345.