2 * Interrupt vectors emulation
4 * Copyright 1995 Alexandre Julliard
9 #include "wine/winbase16.h"
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(int);
17 static FARPROC16 INT_Vectors
[256];
19 /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
20 #define FIRST_INTERRUPT 100
23 /**********************************************************************
26 * Return the protected mode interrupt vector for a given interrupt.
28 FARPROC16
INT_GetPMHandler( BYTE intnum
)
30 if (!INT_Vectors
[intnum
])
32 static HMODULE16 wprocs
;
35 if (((wprocs
= GetModuleHandle16( "wprocs" )) < 32) &&
36 ((wprocs
= LoadLibrary16( "wprocs" )) < 32))
38 ERR("could not load wprocs.dll\n");
42 if (!(INT_Vectors
[intnum
] = GetProcAddress16( wprocs
, (LPCSTR
)(FIRST_INTERRUPT
+ intnum
))))
44 WARN("int%x not implemented, returning dummy handler\n", intnum
);
45 INT_Vectors
[intnum
] = GetProcAddress16( wprocs
, (LPCSTR
)(FIRST_INTERRUPT
+ 256) );
48 return INT_Vectors
[intnum
];
52 /**********************************************************************
55 * Set the protected mode interrupt handler for a given interrupt.
57 void INT_SetPMHandler( BYTE intnum
, FARPROC16 handler
)
59 TRACE("Set protected mode interrupt vector %02x <- %04x:%04x\n",
60 intnum
, HIWORD(handler
), LOWORD(handler
) );
61 INT_Vectors
[intnum
] = handler
;
65 /**********************************************************************
68 * Return the real mode interrupt vector for a given interrupt.
70 FARPROC16
INT_GetRMHandler( BYTE intnum
)
72 return ((FARPROC16
*)DOSMEM_SystemBase())[intnum
];
76 /**********************************************************************
79 * Set the real mode interrupt handler for a given interrupt.
81 void INT_SetRMHandler( BYTE intnum
, FARPROC16 handler
)
83 TRACE("Set real mode interrupt vector %02x <- %04x:%04x\n",
84 intnum
, HIWORD(handler
), LOWORD(handler
) );
85 ((FARPROC16
*)DOSMEM_SystemBase())[intnum
] = handler
;
89 /**********************************************************************
92 * Return the interrupt vector for a given interrupt.
94 FARPROC16
INT_CtxGetHandler( CONTEXT86
*context
, BYTE intnum
)
97 return INT_GetRMHandler(intnum
);
99 return INT_GetPMHandler(intnum
);
103 /**********************************************************************
106 * Set the interrupt handler for a given interrupt.
108 void INT_CtxSetHandler( CONTEXT86
*context
, BYTE intnum
, FARPROC16 handler
)
111 INT_SetRMHandler(intnum
, handler
);
113 INT_SetPMHandler(intnum
, handler
);
117 /**********************************************************************
118 * INT_RealModeInterrupt
120 * Handle real mode interrupts
122 int INT_RealModeInterrupt( BYTE intnum
, CONTEXT86
*context
)
124 /* we should really map to if1632/wprocs.spec, but not all
125 * interrupt handlers are adapted to support real mode yet */
128 INT_Int09Handler(context
);
131 INT_Int10Handler(context
);
134 INT_Int11Handler(context
);
137 INT_Int12Handler(context
);
140 INT_Int13Handler(context
);
143 INT_Int15Handler(context
);
146 INT_Int16Handler(context
);
149 INT_Int17Handler(context
);
152 INT_Int1aHandler(context
);
155 INT_Int20Handler(context
);
161 INT_Int25Handler(context
);
164 INT_Int29Handler(context
);
167 INT_Int2aHandler(context
);
170 INT_Int2fHandler(context
);
173 INT_Int31Handler(context
);
176 INT_Int33Handler(context
);
179 FIXME("Unknown Interrupt in DOS mode: 0x%x\n", intnum
);
186 /**********************************************************************
189 * Default interrupt handler.
191 void WINAPI
INT_DefaultHandler( CONTEXT86
*context
)