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)
37 ERR("could not load wprocs.dll\n");
41 INT_Vectors[intnum] = NE_GetEntryPoint( wprocs, FIRST_INTERRUPT + intnum );
43 return INT_Vectors[intnum];
47 /**********************************************************************
50 * Set the protected mode interrupt handler for a given interrupt.
52 void INT_SetPMHandler( BYTE intnum, FARPROC16 handler )
54 TRACE("Set protected mode interrupt vector %02x <- %04x:%04x\n",
55 intnum, HIWORD(handler), LOWORD(handler) );
56 INT_Vectors[intnum] = handler;
60 /**********************************************************************
63 * Return the real mode interrupt vector for a given interrupt.
65 FARPROC16 INT_GetRMHandler( BYTE intnum )
67 return ((FARPROC16*)DOSMEM_SystemBase())[intnum];
71 /**********************************************************************
74 * Set the real mode interrupt handler for a given interrupt.
76 void INT_SetRMHandler( BYTE intnum, FARPROC16 handler )
78 TRACE("Set real mode interrupt vector %02x <- %04x:%04x\n",
79 intnum, HIWORD(handler), LOWORD(handler) );
80 ((FARPROC16*)DOSMEM_SystemBase())[intnum] = handler;
84 /**********************************************************************
87 * Return the interrupt vector for a given interrupt.
89 FARPROC16 INT_CtxGetHandler( CONTEXT86 *context, BYTE intnum )
92 return INT_GetRMHandler(intnum);
94 return INT_GetPMHandler(intnum);
98 /**********************************************************************
101 * Set the interrupt handler for a given interrupt.
103 void INT_CtxSetHandler( CONTEXT86 *context, BYTE intnum, FARPROC16 handler )
106 INT_SetRMHandler(intnum, handler);
108 INT_SetPMHandler(intnum, handler);
112 /**********************************************************************
113 * INT_RealModeInterrupt
115 * Handle real mode interrupts
117 int INT_RealModeInterrupt( BYTE intnum, CONTEXT86 *context )
119 /* we should really map to if1632/wprocs.spec, but not all
120 * interrupt handlers are adapted to support real mode yet */
123 INT_Int09Handler(context);
126 INT_Int10Handler(context);
129 INT_Int11Handler(context);
132 INT_Int12Handler(context);
135 INT_Int13Handler(context);
138 INT_Int15Handler(context);
141 INT_Int16Handler(context);
144 INT_Int17Handler(context);
147 INT_Int1aHandler(context);
150 INT_Int20Handler(context);
156 INT_Int25Handler(context);
159 INT_Int29Handler(context);
162 INT_Int2aHandler(context);
165 INT_Int2fHandler(context);
168 INT_Int31Handler(context);
171 INT_Int33Handler(context);
174 FIXME("Unknown Interrupt in DOS mode: 0x%x\n", intnum);