2 * Interrupt vectors emulation
4 * Copyright 1995 Alexandre Julliard
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.
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.
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
21 #include <sys/types.h>
23 #include "wine/winbase16.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(int);
31 static FARPROC16 INT_Vectors
[256];
32 static FARPROC48 INT_Vectors48
[256];
34 /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
35 #define FIRST_INTERRUPT 100
38 /**********************************************************************
41 * Return the protected mode interrupt vector for a given interrupt.
43 FARPROC16
INT_GetPMHandler( BYTE intnum
)
45 if (!INT_Vectors
[intnum
])
47 static HMODULE16 wprocs
;
50 if (((wprocs
= GetModuleHandle16( "wprocs" )) < 32) &&
51 ((wprocs
= LoadLibrary16( "wprocs" )) < 32))
53 ERR("could not load wprocs.dll\n");
57 if (!(INT_Vectors
[intnum
] = GetProcAddress16( wprocs
, (LPCSTR
)(FIRST_INTERRUPT
+ intnum
))))
59 WARN("int%x not implemented, returning dummy handler\n", intnum
);
60 INT_Vectors
[intnum
] = GetProcAddress16( wprocs
, (LPCSTR
)(FIRST_INTERRUPT
+ 256) );
63 return INT_Vectors
[intnum
];
67 /**********************************************************************
70 * Set the protected mode interrupt handler for a given interrupt.
72 void INT_SetPMHandler( BYTE intnum
, FARPROC16 handler
)
74 TRACE("Set protected mode interrupt vector %02x <- %04x:%04x\n",
75 intnum
, HIWORD(handler
), LOWORD(handler
) );
76 INT_Vectors
[intnum
] = handler
;
80 /**********************************************************************
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.
86 FARPROC48
INT_GetPMHandler48( BYTE intnum
)
88 if (!INT_Vectors48
[intnum
].selector
)
90 INT_Vectors48
[intnum
].selector
= DOSMEM_dpmi_segments
.int48_sel
;
91 INT_Vectors48
[intnum
].offset
= 4 * intnum
;
93 return INT_Vectors48
[intnum
];
97 /**********************************************************************
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.
103 void INT_SetPMHandler48( BYTE intnum
, FARPROC48 handler
)
105 TRACE("Set 32-bit protected mode interrupt vector %02x <- %04x:%08lx\n",
106 intnum
, handler
.selector
, handler
.offset
);
107 INT_Vectors48
[intnum
] = handler
;
111 /**********************************************************************
112 * INT_DefaultHandler (WPROCS.356)
114 * Default interrupt handler.
116 void WINAPI
INT_DefaultHandler( CONTEXT86
*context
)