1 /****************************************************************************
3 * SciTech OS Portability Manager Library
5 * ========================================================================
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
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.
17 * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 * The Initial Developer of the Original Code is SciTech Software, Inc.
20 * All Rights Reserved.
22 * ========================================================================
25 * Environment: Real mode and 16/32 bit Protected Mode
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:
38 * Mouse (0x33 callback)
40 * Keyboard (0x9 and 0x15)
41 * Control C/Break (0x23/0x1B)
42 * Critical Error (0x24)
44 ****************************************************************************/
49 /*--------------------------- Macros and Typedefs -------------------------*/
52 /* PC interrupts (Ensure consistent with pme.inc) */
54 #define PM_IRQ1 (PM_IRQ0+1)
55 #define PM_IRQ6 (PM_IRQ0+6)
56 #define PM_IRQ14 (PM_IRQ0+14)
59 /* Define the different types of interrupt handlers that we support */
61 typedef uint (PMAPIP PM_criticalHandler)(uint axValue,uint diValue);
62 typedef void (PMAPIP PM_breakHandler)(uint breakHit);
63 typedef short (PMAPIP PM_key15Handler)(short scanCode);
64 typedef void (PMAPIP PM_mouseHandler)(uint event, uint butstate,int x,int y,int mickeyX,int mickeyY);
66 /* Create a type for representing far pointers in both 16 and 32 bit
77 typedef void *PMFARPTR;
81 /*--------------------------- Function Prototypes -------------------------*/
84 extern "C" { /* Use "C" linkage when in C++ mode */
87 /* Routine to load save default data segment selector value into a code
88 * segment variable, and another to load the value into the DS register.
91 void PMAPI PM_loadDS(void);
92 void PMAPI PM_saveDS(void);
94 /* Routine to install a mouse interrupt handling routine. The
95 * mouse handler routine is a normal C function, and the PM library
96 * will take care of passing the correct parameters to the function,
97 * and switching to a local stack.
99 * Note that you _must_ lock the memory containing the mouse interrupt
100 * handler with the PM_lockPages() function otherwise you may encounter
101 * problems in virtual memory environments.
104 int PMAPI PM_setMouseHandler(int mask,PM_mouseHandler mh);
105 void PMAPI PM_restoreMouseHandler(void);
107 /* Routine to reset the mouse driver, and re-install the current
108 * mouse interrupt handler if one was currently installed (since the
109 * mouse reset will automatically remove this handler.
112 void PMAPI PM_resetMouseDriver(int hardReset);
114 /* Routine to reset the mouse driver, and re-install the current
115 * mouse interrupt handler if one was currently installed (since the
116 * mouse reset will automatically remove this handler.
119 void PMAPI PM_resetMouseDriver(int hardReset);
121 /* Routines to install and remove timer interrupt handlers.
123 * Note that you _must_ lock the memory containing the interrupt
124 * handlers with the PM_lockPages() function otherwise you may encounter
125 * problems in virtual memory environments.
128 void PMAPI PM_setTimerHandler(PM_intHandler ih);
129 void PMAPI PM_chainPrevTimer(void);
130 void PMAPI PM_restoreTimerHandler(void);
132 /* Routines to install and keyboard interrupt handlers.
134 * Note that you _must_ lock the memory containing the interrupt
135 * handlers with the PM_lockPages() function otherwise you may encounter
136 * problems in virtual memory environments.
139 void PMAPI PM_setKeyHandler(PM_intHandler ih);
140 void PMAPI PM_chainPrevKey(void);
141 void PMAPI PM_restoreKeyHandler(void);
143 /* Routines to hook and unhook the alternate Int 15h keyboard intercept
144 * callout routine. Your event handler will need to return the following:
146 * scanCode - Let the BIOS process scan code (chains to previous handler)
147 * 0 - You have processed the scan code so flush from BIOS
149 * Note that this is not available under all DOS extenders, but does
150 * work under real mode, DOS4GW and X32-VM. It does not work under the
151 * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know!
154 void PMAPI PM_setKey15Handler(PM_key15Handler ih);
155 void PMAPI PM_restoreKey15Handler(void);
157 /* Routines to install and remove the control c/break interrupt handlers.
158 * Interrupt handling is performed by the PM/Pro library, and you can call
159 * the supplied routines to test the status of the Ctrl-C and Ctrl-Break
160 * flags. If you pass the value TRUE for 'clearFlag' to these routines,
161 * the internal flags will be reset in order to catch another Ctrl-C or
162 * Ctrl-Break interrupt.
165 void PMAPI PM_installBreakHandler(void);
166 int PMAPI PM_ctrlCHit(int clearFlag);
167 int PMAPI PM_ctrlBreakHit(int clearFlag);
168 void PMAPI PM_restoreBreakHandler(void);
170 /* Routine to install an alternate break handler that will call your
171 * code directly. This is not available under all DOS extenders, but does
172 * work under real mode, DOS4GW and X32-VM. It does not work under the
173 * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know!
175 * Note that you should either install one or the other, but not both!
178 void PMAPI PM_installAltBreakHandler(PM_breakHandler bh);
180 /* Routines to install and remove the critical error handler. The interrupt
181 * is handled by the PM/Pro library, and the operation will always be failed.
182 * You can check the status of the critical error handler with the
183 * appropriate function. If you pass the value TRUE for 'clearFlag', the
184 * internal flag will be reset ready to catch another critical error.
187 void PMAPI PM_installCriticalHandler(void);
188 int PMAPI PM_criticalError(int *axValue, int *diValue, int clearFlag);
189 void PMAPI PM_restoreCriticalHandler(void);
191 /* Routine to install an alternate critical handler that will call your
192 * code directly. This is not available under all DOS extenders, but does
193 * work under real mode, DOS4GW and X32-VM. It does not work under the
194 * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know!
196 * Note that you should either install one or the other, but not both!
199 void PMAPI PM_installAltCriticalHandler(PM_criticalHandler);
201 /* Functions to manage protected mode only interrupt handlers */
203 void PMAPI PM_getPMvect(int intno, PMFARPTR *isr);
204 void PMAPI PM_setPMvect(int intno, PM_intHandler ih);
205 void PMAPI PM_restorePMvect(int intno, PMFARPTR isr);
208 } /* End of "C" linkage for C++ */
211 #endif /* __PMINT_H */