Fixed bit 2 value and set bit 1 too.
[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 static FARPROC48 INT_Vectors48[256];
33
34 /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
35 #define FIRST_INTERRUPT 100
36
37
38 /**********************************************************************
39  *          INT_GetPMHandler
40  *
41  * Return the protected mode interrupt vector for a given interrupt.
42  */
43 FARPROC16 INT_GetPMHandler( BYTE intnum )
44 {
45     if (!INT_Vectors[intnum])
46     {
47         static HMODULE16 wprocs;
48         if (!wprocs)
49         {
50             if (((wprocs = GetModuleHandle16( "wprocs" )) < 32) &&
51                 ((wprocs = LoadLibrary16( "wprocs" )) < 32))
52             {
53                 ERR("could not load wprocs.dll\n");
54                 return 0;
55             }
56         }
57         if (!(INT_Vectors[intnum] = GetProcAddress16( wprocs, (LPCSTR)(FIRST_INTERRUPT + intnum))))
58         {
59             WARN("int%x not implemented, returning dummy handler\n", intnum );
60             INT_Vectors[intnum] = GetProcAddress16( wprocs, (LPCSTR)(FIRST_INTERRUPT + 256) );
61         }
62     }
63     return INT_Vectors[intnum];
64 }
65
66
67 /**********************************************************************
68  *          INT_SetPMHandler
69  *
70  * Set the protected mode interrupt handler for a given interrupt.
71  */
72 void INT_SetPMHandler( BYTE intnum, FARPROC16 handler )
73 {
74     TRACE("Set protected mode interrupt vector %02x <- %04x:%04x\n",
75                  intnum, HIWORD(handler), LOWORD(handler) );
76     INT_Vectors[intnum] = handler;
77 }
78
79
80 /**********************************************************************
81  *         INT_GetPMHandler48
82  *
83  * Return the protected mode interrupt vector for a given interrupt.
84  * Used to get 48-bit pointer for 32-bit interrupt handlers in DPMI32.
85  */
86 FARPROC48 INT_GetPMHandler48( BYTE intnum )
87 {
88     if (!INT_Vectors48[intnum].selector)
89     {
90         INT_Vectors48[intnum].selector = DOSMEM_dpmi_segments.int48_sel;
91         INT_Vectors48[intnum].offset = 4 * intnum;
92     }
93     return INT_Vectors48[intnum];
94 }
95
96
97 /**********************************************************************
98  *         INT_SetPMHandler48
99  *
100  * Set the protected mode interrupt handler for a given interrupt.
101  * Used to set 48-bit pointer for 32-bit interrupt handlers in DPMI32.
102  */
103 void INT_SetPMHandler48( BYTE intnum, FARPROC48 handler )
104 {
105     TRACE("Set 32-bit protected mode interrupt vector %02x <- %04x:%08lx\n",
106           intnum, handler.selector, handler.offset );
107     INT_Vectors48[intnum] = handler;
108 }
109
110
111 /**********************************************************************
112  *         INT_DefaultHandler (WPROCS.356)
113  *
114  * Default interrupt handler.
115  */
116 void WINAPI INT_DefaultHandler( CONTEXT86 *context )
117 {
118 }