Release 940815
[wine/gsoc-2012-control.git] / miscemu / int31.c
blobd738772f205d6475ddaa63a10a99f06b153cdff4
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "registers.h"
4 #include "wine.h"
6 typedef struct {
7 WORD accessed : 1;
8 WORD read_write : 1;
9 WORD conf_exp : 1;
10 WORD code : 1;
11 WORD xsystem : 1;
12 WORD dpl : 2;
13 WORD present : 1;
14 WORD dummy : 8;
15 } ACCESS;
16 typedef ACCESS *LPACCESS;
18 typedef struct {
19 WORD Limit;
20 WORD addr_lo;
21 BYTE addr_hi;
22 ACCESS access;
23 WORD reserved;
24 } DESCRIPTOR;
25 typedef DESCRIPTOR *LPDESCRIPTOR;
27 HANDLE DPMI_GetNewSelector(WORD selcount);
28 BOOL DPMI_FreeSelector(HANDLE pmSel);
29 BOOL DPMI_SetDescriptor(HANDLE pmSel, LPDESCRIPTOR lpDesc);
31 /*************************************************************************/
33 int do_int31(struct sigcontext_struct *context)
35 LPDESCRIPTOR lpDesc;
36 printf("do_int31 // context->sc_eax=%04X\n", context->sc_eax);
37 switch(context->sc_eax)
39 case 0x0000:
40 context->sc_eax = DPMI_GetNewSelector(context->sc_ecx);
41 break;
42 case 0x0001:
43 context->sc_eax = DPMI_FreeSelector(context->sc_ebx);
44 break;
45 case 0x000C:
46 lpDesc = MAKELONG(context->sc_edi, context->sc_es);
47 context->sc_eax = DPMI_SetDescriptor(context->sc_ebx, lpDesc);
48 break;
49 default:
50 IntBarf(0x31, context);
52 return 1;
56 /*************************************************************************/
59 HANDLE DPMI_GetNewSelector(WORD selcount)
61 LPSTR ptr;
62 HANDLE pmSel;
63 printf("DPMI_GetNewSelector(%d); !\n", selcount);
64 pmSel = GlobalAlloc(GMEM_FIXED, 4096);
65 ptr = GlobalLock(pmSel);
66 printf("DPMI_GetNewSelector() return %04X !\n", pmSel);
67 return pmSel;
71 BOOL DPMI_FreeSelector(HANDLE pmSel)
73 printf("DPMI_FreeSelector(%04X); !\n", pmSel);
74 GlobalFree(pmSel);
75 return 0;
78 BOOL DPMI_SetDescriptor(HANDLE pmSel, LPDESCRIPTOR lpDesc)
80 printf("DPMI_SetDescriptor(%04X, %08X); !\n", pmSel, lpDesc);
81 printf("DPMI lpDesc->Limit=%u \n", lpDesc->Limit);
82 printf("DPMI lpDesc->addr_lo=%04X \n", lpDesc->addr_lo);
83 printf("DPMI lpDesc->addr_hi=%02X \n", lpDesc->addr_hi);
84 printf("DPMI lpDesc->access.accessed=%u \n", lpDesc->access.accessed);
85 printf("DPMI lpDesc->access.read_write=%u \n", lpDesc->access.read_write);
86 printf("DPMI lpDesc->access.conf_exp=%u \n", lpDesc->access.conf_exp);
87 printf("DPMI lpDesc->access.code=%u \n", lpDesc->access.code);
88 printf("DPMI lpDesc->access.xsystem=%u \n", lpDesc->access.xsystem);
89 printf("DPMI lpDesc->access.dpl=%u \n", lpDesc->access.dpl);
90 printf("DPMI lpDesc->access.present=%u \n", lpDesc->access.present);
91 printf("DPMI lpDesc->reserved=%04X \n", lpDesc->reserved);
92 return FALSE;