Release 950727
[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 "dos_fs.h"
10 #include "module.h"
11 #include "registers.h"
12 #include "stackframe.h"
13 #include "stddebug.h"
14 #include "debug.h"
15
16 static SEGPTR INT_Vectors[256];
17
18   /* Ordinal number for interrupt 0 handler in WINPROCS.DLL */
19 #define FIRST_INTERRUPT_ORDINAL 100
20
21
22 /**********************************************************************
23  *          INT_Init
24  */
25 BOOL INT_Init(void)
26 {
27     WORD vector;
28     HMODULE hModule = GetModuleHandle( "WINPROCS" );
29
30     for (vector = 0; vector < 256; vector++)
31     {
32         if (!(INT_Vectors[vector] = MODULE_GetEntryPoint( hModule,
33                                              FIRST_INTERRUPT_ORDINAL+vector )))
34         {
35             fprintf(stderr,"Internal error: no vector for int %02x\n",vector);
36             return FALSE;
37         }
38     }
39     return TRUE;
40 }
41
42
43 /**********************************************************************
44  *          INT_GetHandler
45  *
46  * Return the interrupt vector for a given interrupt.
47  */
48 SEGPTR INT_GetHandler( BYTE intnum )
49 {
50     return INT_Vectors[intnum];
51 }
52
53
54 /**********************************************************************
55  *          INT_SetHandler
56  *
57  * Set the interrupt handler for a given interrupt.
58  */
59 void INT_SetHandler( BYTE intnum, SEGPTR handler )
60 {
61     dprintf_int( stddeb, "Set interrupt vector %02x <- %04x:%04x\n",
62                  intnum, HIWORD(handler), LOWORD(handler) );
63     INT_Vectors[intnum] = handler;
64 }
65
66
67 /**********************************************************************
68  *          INT_DummyHandler
69  */
70 void INT_DummyHandler( struct sigcontext_struct sigcontext )
71 {
72 #define context (&sigcontext)
73     INT_BARF( CURRENT_STACK16->ordinal_number - FIRST_INTERRUPT_ORDINAL );
74 #undef context
75 }
76
77
78 /**********************************************************************
79  *          INT_Int11Handler
80  *
81  * Handler for int 11h (get equipment list).
82  */
83 void INT_Int11Handler( struct sigcontext_struct sigcontext )
84 {
85 #define context (&sigcontext)
86     AX = DOS_GetEquipment();
87 #undef context
88 }
89
90
91 /**********************************************************************
92  *          INT_Int12Handler
93  *
94  * Handler for int 12h (get memory size).
95  */
96 void INT_Int12Handler( struct sigcontext_struct sigcontext )
97 {
98 #define context (&sigcontext)
99     AX = 640;
100 #undef context
101 }
102
103
104 /**********************************************************************
105  *          INT_Int15Handler
106  *
107  * Handler for int 15h.
108  */
109 void INT_Int15Handler( struct sigcontext_struct sigcontext )
110 {
111 #define context (&sigcontext)
112     INT_BARF( 0x15 );
113 #undef context
114 }
115
116
117 /**********************************************************************
118  *          INT_Int16Handler
119  *
120  * Handler for int 16h (keyboard).
121  */
122 void INT_Int16Handler( struct sigcontext_struct sigcontext )
123 {
124 #define context (&sigcontext)
125     INT_BARF( 0x16 );
126 #undef context
127 }