Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
* DPMI 0.9 emulation
*
* Copyright 1995 Alexandre Julliard
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windows.h"
#include "ldt.h"
#include "registers.h"
#include "wine.h"
#include "miscemu.h"
#include "stddebug.h"
/* #define DEBUG_INT */
#include "debug.h"
/**********************************************************************
* do_int31
*
* Handle the DPMI interrupt (int 31h).
*/
int do_int31( struct sigcontext_struct *context )
{
DWORD dw;
BYTE *ptr;
dprintf_int( stddeb, "int31 (DPMI): AX %04x, BX %04x, CX %04x, DX %04x, "
"SI %04x, DI %04x, DS %04x, ES %04x\n",
AX, BX, CX, DX, SI, DI, DS, ES );
ResetCflag;
switch(AX)
{
case 0x0000: /* Allocate LDT descriptors */
if (!(AX = AllocSelectorArray( CX )))
{
AX = 0x8011; /* descriptor unavailable */
SetCflag;
}
break;
case 0x0001: /* Free LDT descriptor */
if (FreeSelector( BX ))
{
AX = 0x8022; /* invalid selector */
SetCflag;
}
break;
case 0x0003: /* Get next selector increment */
AX = __AHINCR;
break;
case 0x0004: /* Lock selector (not supported) */
AX = 0; /* FIXME: is this a correct return value? */
break;
case 0x0005: /* Unlock selector (not supported) */
AX = 0; /* FIXME: is this a correct return value? */
break;
case 0x0006: /* Get selector base address */
if (!(dw = GetSelectorBase( BX )))
{
AX = 0x8022; /* invalid selector */
SetCflag;
}
else
{
CX = HIWORD(dw);
DX = LOWORD(dw);
}
break;
case 0x0007: /* Set selector base address */
SetSelectorBase( BX, MAKELONG( DX, CX ) );
break;
case 0x0008: /* Set selector limit */
SetSelectorLimit( BX, MAKELONG( DX, CX ) );
break;
case 0x0009: /* Set selector access rights */
SelectorAccessRights( BX, 1, CX );
case 0x000a: /* Allocate selector alias */
if (!(AX = AllocCStoDSAlias( BX )))
{
AX = 0x8011; /* descriptor unavailable */
SetCflag;
}
break;
case 0x000b: /* Get descriptor */
{
ldt_entry entry;
LDT_GetEntry( SELECTOR_TO_ENTRY(BX), &entry );
/* FIXME: should use ES:EDI for 32-bit clients */
LDT_EntryToBytes( PTR_SEG_OFF_TO_LIN( ES, DI ), &entry );
}
break;
case 0x000c: /* Set descriptor */
{
ldt_entry entry;
LDT_BytesToEntry( PTR_SEG_OFF_TO_LIN( ES, DI ), &entry );
LDT_GetEntry( SELECTOR_TO_ENTRY(BX), &entry );
}
break;
case 0x000d: /* Allocate specific LDT descriptor */
AX = 0x8011; /* descriptor unavailable */
SetCflag;
break;
case 0x0400: /* Get DPMI version */
AX = 0x0009; /* DPMI version 0.9 */
BX = 0x0005; /* Flags: 32-bit, virtual memory */
CL = 4; /* CPU type: 486 */
DX = 0x0102; /* Master and slave interrupt controller base */
break;
case 0x0500: /* Get free memory information */
memset( PTR_SEG_OFF_TO_LIN( ES, DI ),
0xff, 0x30 ); /* No information supported */
break;
case 0x0501: /* Allocate memory block */
if (!(ptr = (BYTE *)malloc( MAKELONG( CX, BX ) )))
{
AX = 0x8012; /* linear memory not available */
SetCflag;
}
else
{
BX = SI = HIWORD(ptr);
CX = DI = LOWORD(ptr);
}
break;
case 0x0502: /* Free memory block */
free( (void *)MAKELONG( DI, SI ) );
break;
case 0x0503: /* Resize memory block */
if (!(ptr = (BYTE *)realloc( (void *)MAKELONG(DI,SI),MAKELONG(CX,BX))))
{
AX = 0x8012; /* linear memory not available */
SetCflag;
}
else
{
BX = SI = HIWORD(ptr);
CX = DI = LOWORD(ptr);
}
break;
case 0x0600: /* Lock linear region */
break; /* Just ignore it */
case 0x0601: /* Unlock linear region */
break; /* Just ignore it */
default:
AX = 0x8001; /* unsupported function */
SetCflag;
break;
}
return 1;
}