Release 950606
[wine] / miscemu / interrupts.c
1 /*
2  * Interrupt vectors emulation
3  *
4  * Copyright 1995 Alexandre Julliard
5  */
6
7 #include "windows.h"
8 #include "miscemu.h"
9 #include "module.h"
10 #include "stddebug.h"
11 #include "debug.h"
12
13 static SEGPTR INT_Vectors[256];
14
15   /* Ordinal number for interrupt 0 handler in WINPROCS.DLL */
16 #define FIRST_INTERRUPT_ORDINAL 100
17
18
19 /**********************************************************************
20  *          INT_Init
21  */
22 BOOL INT_Init(void)
23 {
24     SEGPTR addr, dummyHandler;
25     WORD vector;
26     HMODULE hModule = GetModuleHandle( "WINPROCS" );
27
28     dummyHandler = MODULE_GetEntryPoint( hModule, FIRST_INTERRUPT_ORDINAL+256);
29     for (vector = 0; vector < 256; vector++)
30     {
31         addr = MODULE_GetEntryPoint( hModule, FIRST_INTERRUPT_ORDINAL+vector );
32         INT_Vectors[vector] = addr ? addr : dummyHandler;
33     }
34     return TRUE;
35 }
36
37
38 /**********************************************************************
39  *          INT_GetHandler
40  *
41  * Return the interrupt vector for a given interrupt.
42  */
43 SEGPTR INT_GetHandler( BYTE intnum )
44 {
45     dprintf_int( stddeb, "Get interrupt vector %02x -> %04x:%04x\n",
46                  intnum, HIWORD(INT_Vectors[intnum]),
47                  LOWORD(INT_Vectors[intnum]) );
48     return INT_Vectors[intnum];
49 }
50
51
52 /**********************************************************************
53  *          INT_SetHandler
54  *
55  * Set the interrupt handler for a given interrupt.
56  */
57 void INT_SetHandler( BYTE intnum, SEGPTR handler )
58 {
59     dprintf_int( stddeb, "Set interrupt vector %02x <- %04x:%04x\n",
60                  intnum, HIWORD(handler), LOWORD(handler) );
61     INT_Vectors[intnum] = handler;
62 }
63
64
65 /**********************************************************************
66  *          INT_DummyHandler
67  */
68 void INT_DummyHandler( struct sigcontext_struct context )
69 {
70     dprintf_int( stddeb, "Dummy handler called!\n" );
71 }
72
73 /**********************************************************************
74  *          INT_Int10Handler
75  */
76 void INT_Int10Handler( struct sigcontext_struct context )
77 {
78     dprintf_int( stddeb, "int 10 called indirectly through handler!\n" );
79     do_int10( &context );
80 }
81
82
83 /**********************************************************************
84  *          INT_Int13Handler
85  */
86 void INT_Int13Handler( struct sigcontext_struct context )
87 {
88     dprintf_int( stddeb, "int 13 called indirectly through handler!\n" );
89     do_int13( &context );
90 }
91
92
93 /**********************************************************************
94  *          INT_Int15Handler
95  */
96 void INT_Int15Handler( struct sigcontext_struct context )
97 {
98     dprintf_int( stddeb, "int 15 called indirectly through handler!\n" );
99     do_int15( &context );
100 }
101
102
103 /**********************************************************************
104  *          INT_Int16Handler
105  */
106 void INT_Int16Handler( struct sigcontext_struct context )
107 {
108     dprintf_int( stddeb, "int 16 called indirectly through handler!\n" );
109     do_int16( &context );
110 }
111
112
113 /**********************************************************************
114  *          INT_Int1aHandler
115  */
116 void INT_Int1aHandler( struct sigcontext_struct context )
117 {
118     dprintf_int( stddeb, "int 1a called indirectly through handler!\n" );
119     do_int1a( &context );
120 }
121
122
123 /**********************************************************************
124  *          INT_Int21Handler
125  */
126 void INT_Int21Handler( struct sigcontext_struct context )
127 {
128     dprintf_int( stddeb, "int 21 called indirectly through handler!\n" );
129     do_int21( &context );
130 }
131
132
133 /**********************************************************************
134  *          INT_Int25Handler
135  */
136 void INT_Int25Handler( struct sigcontext_struct context )
137 {
138     dprintf_int( stddeb, "int 25 called indirectly through handler!\n" );
139     do_int25( &context );
140 }
141
142
143 /**********************************************************************
144  *          INT_Int26Handler
145  */
146 void INT_Int26Handler( struct sigcontext_struct context )
147 {
148     dprintf_int( stddeb, "int 26 called indirectly through handler!\n" );
149     do_int26( &context );
150 }
151
152
153 /**********************************************************************
154  *          INT_Int2aHandler
155  */
156 void INT_Int2aHandler( struct sigcontext_struct context )
157 {
158     dprintf_int( stddeb, "int 2a called indirectly through handler!\n" );
159     do_int2a( &context );
160 }
161
162
163 /**********************************************************************
164  *          INT_Int2fHandler
165  */
166 void INT_Int2fHandler( struct sigcontext_struct context )
167 {
168     dprintf_int( stddeb, "int 2f called indirectly through handler!\n" );
169     do_int2f( &context );
170 }
171
172
173 /**********************************************************************
174  *          INT_Int31Handler
175  */
176 void INT_Int31Handler( struct sigcontext_struct context )
177 {
178     dprintf_int( stddeb, "int 31 called indirectly through handler!\n" );
179     do_int31( &context );
180 }
181
182
183 /**********************************************************************
184  *          INT_Int5cHandler
185  */
186 void INT_Int5cHandler( struct sigcontext_struct context )
187 {
188     dprintf_int( stddeb, "int 5c called indirectly through handler!\n" );
189     do_int5c( &context );
190 }