Fixed some handle type mismatches and added a few casts in prevision
[wine] / msdos / interrupts.c
1 /*
2  * Interrupt vectors emulation
3  *
4  * Copyright 1995 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <sys/types.h>
22 #include "windef.h"
23 #include "wine/winbase16.h"
24 #include "miscemu.h"
25 #include "msdos.h"
26 #include "module.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(int);
30
31 static FARPROC16 INT_Vectors[256];
32
33 /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
34 #define FIRST_INTERRUPT 100
35
36
37 /**********************************************************************
38  *          INT_GetPMHandler
39  *
40  * Return the protected mode interrupt vector for a given interrupt.
41  */
42 FARPROC16 INT_GetPMHandler( BYTE intnum )
43 {
44     if (!INT_Vectors[intnum])
45     {
46         static HMODULE16 wprocs;
47         if (!wprocs)
48         {
49             if (((wprocs = GetModuleHandle16( "wprocs" )) < 32) &&
50                 ((wprocs = LoadLibrary16( "wprocs" )) < 32))
51             {
52                 ERR("could not load wprocs.dll\n");
53                 return 0;
54             }
55         }
56         if (!(INT_Vectors[intnum] = GetProcAddress16( wprocs, (LPCSTR)(FIRST_INTERRUPT + intnum))))
57         {
58             WARN("int%x not implemented, returning dummy handler\n", intnum );
59             INT_Vectors[intnum] = GetProcAddress16( wprocs, (LPCSTR)(FIRST_INTERRUPT + 256) );
60         }
61     }
62     return INT_Vectors[intnum];
63 }
64
65
66 /**********************************************************************
67  *          INT_SetPMHandler
68  *
69  * Set the protected mode interrupt handler for a given interrupt.
70  */
71 void INT_SetPMHandler( BYTE intnum, FARPROC16 handler )
72 {
73     TRACE("Set protected mode interrupt vector %02x <- %04x:%04x\n",
74                  intnum, HIWORD(handler), LOWORD(handler) );
75     INT_Vectors[intnum] = handler;
76 }
77
78
79 /**********************************************************************
80  *         INT_DefaultHandler (WPROCS.356)
81  *
82  * Default interrupt handler.
83  */
84 void WINAPI INT_DefaultHandler( CONTEXT86 *context )
85 {
86 }