pmint.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /****************************************************************************
  2. *
  3. * SciTech OS Portability Manager Library
  4. *
  5. * ========================================================================
  6. *
  7. * The contents of this file are subject to the SciTech MGL Public
  8. * License Version 1.0 (the "License"); you may not use this file
  9. * except in compliance with the License. You may obtain a copy of
  10. * the License at http://www.scitechsoft.com/mgl-license.txt
  11. *
  12. * Software distributed under the License is distributed on an
  13. * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  14. * implied. See the License for the specific language governing
  15. * rights and limitations under the License.
  16. *
  17. * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
  18. *
  19. * The Initial Developer of the Original Code is SciTech Software, Inc.
  20. * All Rights Reserved.
  21. *
  22. * ========================================================================
  23. *
  24. * Language: ANSI C
  25. * Environment: Real mode and 16/32 bit Protected Mode
  26. *
  27. * Description: Header file for the interrupt handling extensions to the OS
  28. * Portability Manager Library. These extensions includes
  29. * simplified interrupt handling, allowing all common interrupt
  30. * handlers to be hooked and handled directly with normal C
  31. * functions, both in 16 bit and 32 bit modes. Note however that
  32. * simplified handling does not mean slow performance! All low
  33. * level interrupt handling is done efficiently in assembler
  34. * for speed (well actually necessary to insulate the
  35. * application from the lack of far pointers in 32 bit PM). The
  36. * interrupt handlers currently supported are:
  37. *
  38. * Mouse (0x33 callback)
  39. * Timer Tick (0x8)
  40. * Keyboard (0x9 and 0x15)
  41. * Control C/Break (0x23/0x1B)
  42. * Critical Error (0x24)
  43. *
  44. ****************************************************************************/
  45. #ifndef __PMINT_H
  46. #define __PMINT_H
  47. /*--------------------------- Macros and Typedefs -------------------------*/
  48. #ifdef __SMX32__
  49. /* PC interrupts (Ensure consistent with pme.inc) */
  50. #define PM_IRQ0 0x40
  51. #define PM_IRQ1 (PM_IRQ0+1)
  52. #define PM_IRQ6 (PM_IRQ0+6)
  53. #define PM_IRQ14 (PM_IRQ0+14)
  54. #endif
  55. /* Define the different types of interrupt handlers that we support */
  56. typedef uint (PMAPIP PM_criticalHandler)(uint axValue,uint diValue);
  57. typedef void (PMAPIP PM_breakHandler)(uint breakHit);
  58. typedef short (PMAPIP PM_key15Handler)(short scanCode);
  59. typedef void (PMAPIP PM_mouseHandler)(uint event, uint butstate,int x,int y,int mickeyX,int mickeyY);
  60. /* Create a type for representing far pointers in both 16 and 32 bit
  61. * protected mode.
  62. */
  63. #ifdef PM386
  64. typedef struct {
  65. long off;
  66. short sel;
  67. } PMFARPTR;
  68. #define PMNULL {0,0}
  69. #else
  70. typedef void *PMFARPTR;
  71. #define PMNULL NULL
  72. #endif
  73. /*--------------------------- Function Prototypes -------------------------*/
  74. #ifdef __cplusplus
  75. extern "C" { /* Use "C" linkage when in C++ mode */
  76. #endif
  77. /* Routine to load save default data segment selector value into a code
  78. * segment variable, and another to load the value into the DS register.
  79. */
  80. void PMAPI PM_loadDS(void);
  81. void PMAPI PM_saveDS(void);
  82. /* Routine to install a mouse interrupt handling routine. The
  83. * mouse handler routine is a normal C function, and the PM library
  84. * will take care of passing the correct parameters to the function,
  85. * and switching to a local stack.
  86. *
  87. * Note that you _must_ lock the memory containing the mouse interrupt
  88. * handler with the PM_lockPages() function otherwise you may encounter
  89. * problems in virtual memory environments.
  90. */
  91. int PMAPI PM_setMouseHandler(int mask,PM_mouseHandler mh);
  92. void PMAPI PM_restoreMouseHandler(void);
  93. /* Routine to reset the mouse driver, and re-install the current
  94. * mouse interrupt handler if one was currently installed (since the
  95. * mouse reset will automatically remove this handler.
  96. */
  97. void PMAPI PM_resetMouseDriver(int hardReset);
  98. /* Routine to reset the mouse driver, and re-install the current
  99. * mouse interrupt handler if one was currently installed (since the
  100. * mouse reset will automatically remove this handler.
  101. */
  102. void PMAPI PM_resetMouseDriver(int hardReset);
  103. /* Routines to install and remove timer interrupt handlers.
  104. *
  105. * Note that you _must_ lock the memory containing the interrupt
  106. * handlers with the PM_lockPages() function otherwise you may encounter
  107. * problems in virtual memory environments.
  108. */
  109. void PMAPI PM_setTimerHandler(PM_intHandler ih);
  110. void PMAPI PM_chainPrevTimer(void);
  111. void PMAPI PM_restoreTimerHandler(void);
  112. /* Routines to install and keyboard interrupt handlers.
  113. *
  114. * Note that you _must_ lock the memory containing the interrupt
  115. * handlers with the PM_lockPages() function otherwise you may encounter
  116. * problems in virtual memory environments.
  117. */
  118. void PMAPI PM_setKeyHandler(PM_intHandler ih);
  119. void PMAPI PM_chainPrevKey(void);
  120. void PMAPI PM_restoreKeyHandler(void);
  121. /* Routines to hook and unhook the alternate Int 15h keyboard intercept
  122. * callout routine. Your event handler will need to return the following:
  123. *
  124. * scanCode - Let the BIOS process scan code (chains to previous handler)
  125. * 0 - You have processed the scan code so flush from BIOS
  126. *
  127. * Note that this is not available under all DOS extenders, but does
  128. * work under real mode, DOS4GW and X32-VM. It does not work under the
  129. * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know!
  130. */
  131. void PMAPI PM_setKey15Handler(PM_key15Handler ih);
  132. void PMAPI PM_restoreKey15Handler(void);
  133. /* Routines to install and remove the control c/break interrupt handlers.
  134. * Interrupt handling is performed by the PM/Pro library, and you can call
  135. * the supplied routines to test the status of the Ctrl-C and Ctrl-Break
  136. * flags. If you pass the value TRUE for 'clearFlag' to these routines,
  137. * the internal flags will be reset in order to catch another Ctrl-C or
  138. * Ctrl-Break interrupt.
  139. */
  140. void PMAPI PM_installBreakHandler(void);
  141. int PMAPI PM_ctrlCHit(int clearFlag);
  142. int PMAPI PM_ctrlBreakHit(int clearFlag);
  143. void PMAPI PM_restoreBreakHandler(void);
  144. /* Routine to install an alternate break handler that will call your
  145. * code directly. This is not available under all DOS extenders, but does
  146. * work under real mode, DOS4GW and X32-VM. It does not work under the
  147. * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know!
  148. *
  149. * Note that you should either install one or the other, but not both!
  150. */
  151. void PMAPI PM_installAltBreakHandler(PM_breakHandler bh);
  152. /* Routines to install and remove the critical error handler. The interrupt
  153. * is handled by the PM/Pro library, and the operation will always be failed.
  154. * You can check the status of the critical error handler with the
  155. * appropriate function. If you pass the value TRUE for 'clearFlag', the
  156. * internal flag will be reset ready to catch another critical error.
  157. */
  158. void PMAPI PM_installCriticalHandler(void);
  159. int PMAPI PM_criticalError(int *axValue, int *diValue, int clearFlag);
  160. void PMAPI PM_restoreCriticalHandler(void);
  161. /* Routine to install an alternate critical handler that will call your
  162. * code directly. This is not available under all DOS extenders, but does
  163. * work under real mode, DOS4GW and X32-VM. It does not work under the
  164. * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know!
  165. *
  166. * Note that you should either install one or the other, but not both!
  167. */
  168. void PMAPI PM_installAltCriticalHandler(PM_criticalHandler);
  169. /* Functions to manage protected mode only interrupt handlers */
  170. void PMAPI PM_getPMvect(int intno, PMFARPTR *isr);
  171. void PMAPI PM_setPMvect(int intno, PM_intHandler ih);
  172. void PMAPI PM_restorePMvect(int intno, PMFARPTR isr);
  173. #ifdef __cplusplus
  174. } /* End of "C" linkage for C++ */
  175. #endif
  176. #endif /* __PMINT_H */