4 * Copyright 1995 Alexandre Julliard
12 #include "registers.h"
16 /* #define DEBUG_INT */
20 /**********************************************************************
23 * Handler for int 31h (DPMI).
25 void INT_Int31Handler( struct sigcontext_struct context
)
30 RESET_CFLAG(&context
);
31 switch(AX_reg(&context
))
33 case 0x0000: /* Allocate LDT descriptors */
34 if (!(AX_reg(&context
) = AllocSelectorArray( CX_reg(&context
) )))
36 AX_reg(&context
) = 0x8011; /* descriptor unavailable */
41 case 0x0001: /* Free LDT descriptor */
42 if (FreeSelector( BX_reg(&context
) ))
44 AX_reg(&context
) = 0x8022; /* invalid selector */
49 case 0x0003: /* Get next selector increment */
50 AX_reg(&context
) = __AHINCR
;
53 case 0x0004: /* Lock selector (not supported) */
54 AX_reg(&context
) = 0; /* FIXME: is this a correct return value? */
57 case 0x0005: /* Unlock selector (not supported) */
58 AX_reg(&context
) = 0; /* FIXME: is this a correct return value? */
61 case 0x0006: /* Get selector base address */
62 if (!(dw
= GetSelectorBase( BX_reg(&context
) )))
64 AX_reg(&context
) = 0x8022; /* invalid selector */
69 CX_reg(&context
) = HIWORD(dw
);
70 DX_reg(&context
) = LOWORD(dw
);
74 case 0x0007: /* Set selector base address */
75 SetSelectorBase( BX_reg(&context
),
76 MAKELONG( DX_reg(&context
), CX_reg(&context
) ) );
79 case 0x0008: /* Set selector limit */
80 SetSelectorLimit( BX_reg(&context
),
81 MAKELONG( DX_reg(&context
), CX_reg(&context
) ) );
84 case 0x0009: /* Set selector access rights */
85 SelectorAccessRights( BX_reg(&context
), 1, CX_reg(&context
) );
87 case 0x000a: /* Allocate selector alias */
88 if (!(AX_reg(&context
) = AllocCStoDSAlias( BX_reg(&context
) )))
90 AX_reg(&context
) = 0x8011; /* descriptor unavailable */
95 case 0x000b: /* Get descriptor */
98 LDT_GetEntry( SELECTOR_TO_ENTRY( BX_reg(&context
) ), &entry
);
99 /* FIXME: should use ES:EDI for 32-bit clients */
100 LDT_EntryToBytes( PTR_SEG_OFF_TO_LIN( ES_reg(&context
),
101 DI_reg(&context
) ), &entry
);
105 case 0x000c: /* Set descriptor */
108 LDT_BytesToEntry( PTR_SEG_OFF_TO_LIN( ES_reg(&context
),
109 DI_reg(&context
) ), &entry
);
110 LDT_GetEntry( SELECTOR_TO_ENTRY( BX_reg(&context
) ), &entry
);
114 case 0x000d: /* Allocate specific LDT descriptor */
115 AX_reg(&context
) = 0x8011; /* descriptor unavailable */
119 case 0x0204: /* Get protected mode interrupt vector */
120 dw
= (DWORD
)INT_GetHandler( BL_reg(&context
) );
121 CX_reg(&context
) = HIWORD(dw
);
122 DX_reg(&context
) = LOWORD(dw
);
125 case 0x0205: /* Set protected mode interrupt vector */
126 INT_SetHandler( BL_reg(&context
),
127 (SEGPTR
)MAKELONG( DX_reg(&context
), CX_reg(&context
) ));
130 case 0x0400: /* Get DPMI version */
131 AX_reg(&context
) = 0x005a; /* DPMI version 0.90 */
132 BX_reg(&context
) = 0x0005; /* Flags: 32-bit, virtual memory */
133 CL_reg(&context
) = 3; /* CPU type: 386 */
134 DX_reg(&context
) = 0x0102; /* Master/slave interrupt controller base*/
137 case 0x0500: /* Get free memory information */
138 ptr
= (BYTE
*)PTR_SEG_OFF_TO_LIN( ES_reg(&context
), DI_reg(&context
) );
139 *(DWORD
*)ptr
= 0x00ff0000; /* Largest block available */
140 memset( ptr
+ 4, 0xff, 0x2c ); /* No other information supported */
143 case 0x0501: /* Allocate memory block */
144 if (!(ptr
= (BYTE
*)malloc( MAKELONG( CX_reg(&context
),
145 BX_reg(&context
) ) )))
147 AX_reg(&context
) = 0x8012; /* linear memory not available */
152 BX_reg(&context
) = SI_reg(&context
) = HIWORD(ptr
);
153 CX_reg(&context
) = DI_reg(&context
) = LOWORD(ptr
);
157 case 0x0502: /* Free memory block */
158 free( (void *)MAKELONG( DI_reg(&context
), SI_reg(&context
) ) );
161 case 0x0503: /* Resize memory block */
162 if (!(ptr
= (BYTE
*)realloc( (void *)MAKELONG(DI_reg(&context
),SI_reg(&context
)),
163 MAKELONG(CX_reg(&context
),BX_reg(&context
)))))
165 AX_reg(&context
) = 0x8012; /* linear memory not available */
170 BX_reg(&context
) = SI_reg(&context
) = HIWORD(ptr
);
171 CX_reg(&context
) = DI_reg(&context
) = LOWORD(ptr
);
175 case 0x0600: /* Lock linear region */
176 break; /* Just ignore it */
178 case 0x0601: /* Unlock linear region */
179 break; /* Just ignore it */
182 INT_BARF( &context
, 0x31 );
183 AX_reg(&context
) = 0x8001; /* unsupported function */