Release 950606
[wine/multimedia.git] / miscemu / int31.c
blob7aa7dfde7fdeeb27282dee6684ea5cbe90abc4f3
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "registers.h"
4 #include "wine.h"
5 #include "miscemu.h"
6 #include "stddebug.h"
7 /* #define 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=%08lX\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 = (LPDESCRIPTOR) MAKELONG(context->sc_edi,
52 context->sc_es);
53 context->sc_eax = DPMI_SetDescriptor(context->sc_ebx, lpDesc);
54 break;
55 default:
56 IntBarf(0x31, context);
58 return 1;
62 /*************************************************************************/
65 HANDLE DPMI_GetNewSelector(WORD selcount)
67 LPSTR ptr;
68 HANDLE pmSel;
69 dprintf_int(stddeb,"DPMI_GetNewSelector(%d); !\n", selcount);
70 pmSel = GlobalAlloc(GMEM_FIXED, 4096);
71 ptr = GlobalLock(pmSel);
72 dprintf_int(stddeb,"DPMI_GetNewSelector() return %04X !\n", pmSel);
73 return pmSel;
77 BOOL DPMI_FreeSelector(HANDLE pmSel)
79 dprintf_int(stddeb,"DPMI_FreeSelector(%04X); !\n", pmSel);
80 GlobalFree(pmSel);
81 return 0;
84 BOOL DPMI_SetDescriptor(HANDLE pmSel, LPDESCRIPTOR lpDesc)
86 dprintf_int(stdnimp,"DPMI_SetDescriptor(%04X, %p); !\n",
87 pmSel, lpDesc);
88 dprintf_int(stdnimp,"DPMI lpDesc->Limit=%u \n", lpDesc->Limit);
89 dprintf_int(stdnimp,"DPMI lpDesc->addr_lo=%04X \n", lpDesc->addr_lo);
90 dprintf_int(stdnimp,"DPMI lpDesc->addr_hi=%02X \n", lpDesc->addr_hi);
91 dprintf_int(stdnimp,"DPMI lpDesc->access.accessed=%u \n",
92 lpDesc->access.accessed);
93 dprintf_int(stdnimp,"DPMI lpDesc->access.read_write=%u \n",
94 lpDesc->access.read_write);
95 dprintf_int(stdnimp,"DPMI lpDesc->access.conf_exp=%u \n",
96 lpDesc->access.conf_exp);
97 dprintf_int(stdnimp,"DPMI lpDesc->access.code=%u \n",
98 lpDesc->access.code);
99 dprintf_int(stdnimp,"DPMI lpDesc->access.xsystem=%u \n",
100 lpDesc->access.xsystem);
101 dprintf_int(stdnimp,"DPMI lpDesc->access.dpl=%u \n",
102 lpDesc->access.dpl);
103 dprintf_int(stdnimp,"DPMI lpDesc->access.present=%u \n",
104 lpDesc->access.present);
105 dprintf_int(stdnimp,"DPMI lpDesc->reserved=%04X \n", lpDesc->reserved);
106 return FALSE;