Release 941017
[wine/gsoc-2012-control.git] / miscemu / int31.c
blob6bdef308e8ce81f277e633690d32c6ee1660b73f
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "registers.h"
4 #include "wine.h"
5 #include "stddebug.h"
6 /* #define DEBUG_INT */
7 /* #undef DEBUG_INT */
8 #include "debug.h"
10 typedef struct {
11 WORD accessed : 1;
12 WORD read_write : 1;
13 WORD conf_exp : 1;
14 WORD code : 1;
15 WORD xsystem : 1;
16 WORD dpl : 2;
17 WORD present : 1;
18 WORD dummy : 8;
19 } ACCESS;
20 typedef ACCESS *LPACCESS;
22 typedef struct {
23 WORD Limit;
24 WORD addr_lo;
25 BYTE addr_hi;
26 ACCESS access;
27 WORD reserved;
28 } DESCRIPTOR;
29 typedef DESCRIPTOR *LPDESCRIPTOR;
31 HANDLE DPMI_GetNewSelector(WORD selcount);
32 BOOL DPMI_FreeSelector(HANDLE pmSel);
33 BOOL DPMI_SetDescriptor(HANDLE pmSel, LPDESCRIPTOR lpDesc);
35 /*************************************************************************/
37 int do_int31(struct sigcontext_struct *context)
39 LPDESCRIPTOR lpDesc;
40 dprintf_int(stddeb,"do_int31 // context->sc_eax=%04X\n",
41 context->sc_eax);
42 switch(context->sc_eax)
44 case 0x0000:
45 context->sc_eax = DPMI_GetNewSelector(context->sc_ecx);
46 break;
47 case 0x0001:
48 context->sc_eax = DPMI_FreeSelector(context->sc_ebx);
49 break;
50 case 0x000C:
51 lpDesc = MAKELONG(context->sc_edi, context->sc_es);
52 context->sc_eax = DPMI_SetDescriptor(context->sc_ebx, lpDesc);
53 break;
54 default:
55 IntBarf(0x31, context);
57 return 1;
61 /*************************************************************************/
64 HANDLE DPMI_GetNewSelector(WORD selcount)
66 LPSTR ptr;
67 HANDLE pmSel;
68 dprintf_int(stddeb,"DPMI_GetNewSelector(%d); !\n", selcount);
69 pmSel = GlobalAlloc(GMEM_FIXED, 4096);
70 ptr = GlobalLock(pmSel);
71 dprintf_int(stddeb,"DPMI_GetNewSelector() return %04X !\n", pmSel);
72 return pmSel;
76 BOOL DPMI_FreeSelector(HANDLE pmSel)
78 dprintf_int(stddeb,"DPMI_FreeSelector(%04X); !\n", pmSel);
79 GlobalFree(pmSel);
80 return 0;
83 BOOL DPMI_SetDescriptor(HANDLE pmSel, LPDESCRIPTOR lpDesc)
85 dprintf_int(stdnimp,"DPMI_SetDescriptor(%04X, %08X); !\n",
86 pmSel, lpDesc);
87 dprintf_int(stdnimp,"DPMI lpDesc->Limit=%u \n", lpDesc->Limit);
88 dprintf_int(stdnimp,"DPMI lpDesc->addr_lo=%04X \n", lpDesc->addr_lo);
89 dprintf_int(stdnimp,"DPMI lpDesc->addr_hi=%02X \n", lpDesc->addr_hi);
90 dprintf_int(stdnimp,"DPMI lpDesc->access.accessed=%u \n",
91 lpDesc->access.accessed);
92 dprintf_int(stdnimp,"DPMI lpDesc->access.read_write=%u \n",
93 lpDesc->access.read_write);
94 dprintf_int(stdnimp,"DPMI lpDesc->access.conf_exp=%u \n",
95 lpDesc->access.conf_exp);
96 dprintf_int(stdnimp,"DPMI lpDesc->access.code=%u \n",
97 lpDesc->access.code);
98 dprintf_int(stdnimp,"DPMI lpDesc->access.xsystem=%u \n",
99 lpDesc->access.xsystem);
100 dprintf_int(stdnimp,"DPMI lpDesc->access.dpl=%u \n",
101 lpDesc->access.dpl);
102 dprintf_int(stdnimp,"DPMI lpDesc->access.present=%u \n",
103 lpDesc->access.present);
104 dprintf_int(stdnimp,"DPMI lpDesc->reserved=%04X \n", lpDesc->reserved);
105 return FALSE;