Add LanguageGroup/GeoID enumeration fns.
[wine/hacks.git] / dlls / kernel / instr.c
blobdf52b44bb3c54466dee423d50db93dc254aef010
1 /*
2 * Emulation of privileged instructions
4 * Copyright 1995 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <stdarg.h>
23 #include "ntstatus.h"
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "wine/winuser16.h"
28 #include "excpt.h"
29 #include "module.h"
30 #include "miscemu.h"
31 #include "selectors.h"
32 #include "wine/debug.h"
33 #include "callback.h"
34 #include "thread.h"
35 #include "wine/exception.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(int);
38 WINE_DECLARE_DEBUG_CHANNEL(io);
40 #ifdef __i386__
42 /* macros to set parts of a DWORD */
43 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
44 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
45 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
47 inline static void add_stack( CONTEXT86 *context, int offset )
49 if (ISV86(context) || !IS_SELECTOR_32BIT(context->SegSs))
50 ADD_LOWORD( context->Esp, offset );
51 else
52 context->Esp += offset;
55 inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
57 if (ISV86(context)) return PTR_REAL_TO_LIN( seg, off );
58 if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
59 if (!long_addr) off = LOWORD(off);
60 return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
63 inline static void *get_stack( CONTEXT86 *context )
65 if (ISV86(context)) return PTR_REAL_TO_LIN( context->SegSs, context->Esp );
66 return wine_ldt_get_ptr( context->SegSs, context->Esp );
70 /***********************************************************************
71 * INSTR_ReplaceSelector
73 * Try to replace an invalid selector by a valid one.
74 * The only selector where it is allowed to do "mov ax,40;mov es,ax"
75 * is the so called 'bimodal' selector 0x40, which points to the BIOS
76 * data segment. Used by (at least) Borland products (and programs compiled
77 * using Borland products).
79 * See Undocumented Windows, Chapter 5, __0040.
81 static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
83 if (*sel == 0x40)
85 static WORD sys_timer = 0;
86 if (!sys_timer)
87 sys_timer = CreateSystemTimer( 55, DOSMEM_Tick );
88 *sel = DOSMEM_BiosDataSeg;
89 return TRUE;
91 return FALSE; /* Can't replace selector, crashdump */
95 /***********************************************************************
96 * INSTR_GetOperandAddr
98 * Return the address of an instruction operand (from the mod/rm byte).
100 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
101 int long_addr, int segprefix, int *len )
103 int mod, rm, base, index = 0, ss = 0, seg = 0, off;
104 LDT_ENTRY entry;
106 #define GET_VAL(val,type) \
107 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
109 *len = 0;
110 GET_VAL( &mod, BYTE );
111 rm = mod & 7;
112 mod >>= 6;
114 if (mod == 3)
116 switch(rm)
118 case 0: return (BYTE *)&context->Eax;
119 case 1: return (BYTE *)&context->Ecx;
120 case 2: return (BYTE *)&context->Edx;
121 case 3: return (BYTE *)&context->Ebx;
122 case 4: return (BYTE *)&context->Esp;
123 case 5: return (BYTE *)&context->Ebp;
124 case 6: return (BYTE *)&context->Esi;
125 case 7: return (BYTE *)&context->Edi;
129 if (long_addr)
131 if (rm == 4)
133 BYTE sib;
134 GET_VAL( &sib, BYTE );
135 rm = sib & 7;
136 ss = sib >> 6;
137 switch(sib >> 3)
139 case 0: index = context->Eax; break;
140 case 1: index = context->Ecx; break;
141 case 2: index = context->Edx; break;
142 case 3: index = context->Ebx; break;
143 case 4: index = 0; break;
144 case 5: index = context->Ebp; break;
145 case 6: index = context->Esi; break;
146 case 7: index = context->Edi; break;
150 switch(rm)
152 case 0: base = context->Eax; seg = context->SegDs; break;
153 case 1: base = context->Ecx; seg = context->SegDs; break;
154 case 2: base = context->Edx; seg = context->SegDs; break;
155 case 3: base = context->Ebx; seg = context->SegDs; break;
156 case 4: base = context->Esp; seg = context->SegSs; break;
157 case 5: base = context->Ebp; seg = context->SegSs; break;
158 case 6: base = context->Esi; seg = context->SegDs; break;
159 case 7: base = context->Edi; seg = context->SegDs; break;
161 switch (mod)
163 case 0:
164 if (rm == 5) /* special case: ds:(disp32) */
166 GET_VAL( &base, DWORD );
167 seg = context->SegDs;
169 break;
171 case 1: /* 8-bit disp */
172 GET_VAL( &off, BYTE );
173 base += (signed char)off;
174 break;
176 case 2: /* 32-bit disp */
177 GET_VAL( &off, DWORD );
178 base += (signed long)off;
179 break;
182 else /* short address */
184 switch(rm)
186 case 0: /* ds:(bx,si) */
187 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
188 seg = context->SegDs;
189 break;
190 case 1: /* ds:(bx,di) */
191 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
192 seg = context->SegDs;
193 break;
194 case 2: /* ss:(bp,si) */
195 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
196 seg = context->SegSs;
197 break;
198 case 3: /* ss:(bp,di) */
199 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
200 seg = context->SegSs;
201 break;
202 case 4: /* ds:(si) */
203 base = LOWORD(context->Esi);
204 seg = context->SegDs;
205 break;
206 case 5: /* ds:(di) */
207 base = LOWORD(context->Edi);
208 seg = context->SegDs;
209 break;
210 case 6: /* ss:(bp) */
211 base = LOWORD(context->Ebp);
212 seg = context->SegSs;
213 break;
214 case 7: /* ds:(bx) */
215 base = LOWORD(context->Ebx);
216 seg = context->SegDs;
217 break;
220 switch(mod)
222 case 0:
223 if (rm == 6) /* special case: ds:(disp16) */
225 GET_VAL( &base, WORD );
226 seg = context->SegDs;
228 break;
230 case 1: /* 8-bit disp */
231 GET_VAL( &off, BYTE );
232 base += (signed char)off;
233 break;
235 case 2: /* 16-bit disp */
236 GET_VAL( &off, WORD );
237 base += (signed short)off;
238 break;
240 base &= 0xffff;
242 if (segprefix != -1) seg = segprefix;
244 /* Make sure the segment and offset are valid */
245 if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
246 if ((seg & 7) != 7) return NULL;
247 wine_ldt_get_entry( seg, &entry );
248 if (wine_ldt_is_empty( &entry )) return NULL;
249 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
250 return (char *)wine_ldt_get_base(&entry) + base + (index << ss);
251 #undef GET_VAL
255 /***********************************************************************
256 * INSTR_EmulateLDS
258 * Emulate the LDS (and LES,LFS,etc.) instruction.
260 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
261 int long_addr, int segprefix, int *len )
263 WORD seg;
264 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
265 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
266 long_addr, segprefix, len );
267 if (!addr)
268 return FALSE; /* Unable to emulate it */
269 seg = *(WORD *)(addr + (long_op ? 4 : 2));
271 if (!INSTR_ReplaceSelector( context, &seg ))
272 return FALSE; /* Unable to emulate it */
274 /* Now store the offset in the correct register */
276 switch((*regmodrm >> 3) & 7)
278 case 0:
279 if (long_op) context->Eax = *(DWORD *)addr;
280 else SET_LOWORD(context->Eax,*(WORD *)addr);
281 break;
282 case 1:
283 if (long_op) context->Ecx = *(DWORD *)addr;
284 else SET_LOWORD(context->Ecx,*(WORD *)addr);
285 break;
286 case 2:
287 if (long_op) context->Edx = *(DWORD *)addr;
288 else SET_LOWORD(context->Edx,*(WORD *)addr);
289 break;
290 case 3:
291 if (long_op) context->Ebx = *(DWORD *)addr;
292 else SET_LOWORD(context->Ebx,*(WORD *)addr);
293 break;
294 case 4:
295 if (long_op) context->Esp = *(DWORD *)addr;
296 else SET_LOWORD(context->Esp,*(WORD *)addr);
297 break;
298 case 5:
299 if (long_op) context->Ebp = *(DWORD *)addr;
300 else SET_LOWORD(context->Ebp,*(WORD *)addr);
301 break;
302 case 6:
303 if (long_op) context->Esi = *(DWORD *)addr;
304 else SET_LOWORD(context->Esi,*(WORD *)addr);
305 break;
306 case 7:
307 if (long_op) context->Edi = *(DWORD *)addr;
308 else SET_LOWORD(context->Edi,*(WORD *)addr);
309 break;
312 /* Store the correct segment in the segment register */
314 switch(*instr)
316 case 0xc4: context->SegEs = seg; break; /* les */
317 case 0xc5: context->SegDs = seg; break; /* lds */
318 case 0x0f: switch(instr[1])
320 case 0xb2: context->SegSs = seg; break; /* lss */
321 case 0xb4: context->SegFs = seg; break; /* lfs */
322 case 0xb5: context->SegGs = seg; break; /* lgs */
324 break;
327 /* Add the opcode size to the total length */
329 *len += 1 + (*instr == 0x0f);
330 return TRUE;
333 /***********************************************************************
334 * INSTR_inport
336 * input on a I/O port
338 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
340 DWORD res = ~0U;
342 if (Dosvm.inport || DPMI_LoadDosSystem()) res = Dosvm.inport( port, size );
344 if (TRACE_ON(io))
346 switch(size)
348 case 1:
349 DPRINTF( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
350 (WORD)context->SegCs, LOWORD(context->Eip));
351 break;
352 case 2:
353 DPRINTF( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
354 (WORD)context->SegCs, LOWORD(context->Eip));
355 break;
356 case 4:
357 DPRINTF( "0x%x < %08lx @ %04x:%04x\n", port, res,
358 (WORD)context->SegCs, LOWORD(context->Eip));
359 break;
362 return res;
366 /***********************************************************************
367 * INSTR_outport
369 * output on a I/O port
371 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
373 if (Dosvm.outport || DPMI_LoadDosSystem()) Dosvm.outport( port, size, val );
375 if (TRACE_ON(io))
377 switch(size)
379 case 1:
380 DPRINTF("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
381 (WORD)context->SegCs, LOWORD(context->Eip));
382 break;
383 case 2:
384 DPRINTF("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
385 (WORD)context->SegCs, LOWORD(context->Eip));
386 break;
387 case 4:
388 DPRINTF("0x%x > %08lx @ %04x:%04x\n", port, val,
389 (WORD)context->SegCs, LOWORD(context->Eip));
390 break;
396 /***********************************************************************
397 * INSTR_EmulateInstruction
399 * Emulate a privileged instruction.
400 * Returns exception continuation status.
402 DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
404 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
405 BYTE *instr;
407 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
408 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
409 if (!instr) return ExceptionContinueSearch;
411 /* First handle any possible prefix */
413 segprefix = -1; /* no prefix */
414 prefix = 1;
415 repX = 0;
416 prefixlen = 0;
417 while(prefix)
419 switch(*instr)
421 case 0x2e:
422 segprefix = context->SegCs;
423 break;
424 case 0x36:
425 segprefix = context->SegSs;
426 break;
427 case 0x3e:
428 segprefix = context->SegDs;
429 break;
430 case 0x26:
431 segprefix = context->SegEs;
432 break;
433 case 0x64:
434 segprefix = context->SegFs;
435 break;
436 case 0x65:
437 segprefix = context->SegGs;
438 break;
439 case 0x66:
440 long_op = !long_op; /* opcode size prefix */
441 break;
442 case 0x67:
443 long_addr = !long_addr; /* addr size prefix */
444 break;
445 case 0xf0: /* lock */
446 break;
447 case 0xf2: /* repne */
448 repX = 1;
449 break;
450 case 0xf3: /* repe */
451 repX = 2;
452 break;
453 default:
454 prefix = 0; /* no more prefixes */
455 break;
457 if (prefix)
459 instr++;
460 prefixlen++;
464 /* Now look at the actual instruction */
466 switch(*instr)
468 case 0x07: /* pop es */
469 case 0x17: /* pop ss */
470 case 0x1f: /* pop ds */
472 WORD seg = *(WORD *)get_stack( context );
473 if (INSTR_ReplaceSelector( context, &seg ))
475 switch(*instr)
477 case 0x07: context->SegEs = seg; break;
478 case 0x17: context->SegSs = seg; break;
479 case 0x1f: context->SegDs = seg; break;
481 add_stack(context, long_op ? 4 : 2);
482 context->Eip += prefixlen + 1;
483 return ExceptionContinueExecution;
486 break; /* Unable to emulate it */
488 case 0x0f: /* extended instruction */
489 switch(instr[1])
491 case 0x22: /* mov eax, crX */
492 switch (instr[2])
494 case 0xc0:
495 ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
496 context->Eip,context->Eax );
497 context->Eip += prefixlen+3;
498 return ExceptionContinueExecution;
499 default:
500 break; /*fallthrough to bad instruction handling */
502 break; /*fallthrough to bad instruction handling */
503 case 0x20: /* mov crX, eax */
504 switch (instr[2])
506 case 0xe0: /* mov cr4, eax */
507 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
508 * bit 0: VME Virtual Mode Exception ?
509 * bit 1: PVI Protected mode Virtual Interrupt
510 * bit 2: TSD Timestamp disable
511 * bit 3: DE Debugging extensions
512 * bit 4: PSE Page size extensions
513 * bit 5: PAE Physical address extension
514 * bit 6: MCE Machine check enable
515 * bit 7: PGE Enable global pages
516 * bit 8: PCE Enable performance counters at IPL3
518 ERR("mov cr4,eax at 0x%08lx\n",context->Eip);
519 context->Eax = 0;
520 context->Eip += prefixlen+3;
521 return ExceptionContinueExecution;
522 case 0xc0: /* mov cr0, eax */
523 ERR("mov cr0,eax at 0x%08lx\n",context->Eip);
524 context->Eax = 0x10; /* FIXME: set more bits ? */
525 context->Eip += prefixlen+3;
526 return ExceptionContinueExecution;
527 default: /* fallthrough to illegal instruction */
528 break;
530 /* fallthrough to illegal instruction */
531 break;
532 case 0xa1: /* pop fs */
534 WORD seg = *(WORD *)get_stack( context );
535 if (INSTR_ReplaceSelector( context, &seg ))
537 context->SegFs = seg;
538 add_stack(context, long_op ? 4 : 2);
539 context->Eip += prefixlen + 2;
540 return ExceptionContinueExecution;
543 break;
544 case 0xa9: /* pop gs */
546 WORD seg = *(WORD *)get_stack( context );
547 if (INSTR_ReplaceSelector( context, &seg ))
549 context->SegGs = seg;
550 add_stack(context, long_op ? 4 : 2);
551 context->Eip += prefixlen + 2;
552 return ExceptionContinueExecution;
555 break;
556 case 0xb2: /* lss addr,reg */
557 case 0xb4: /* lfs addr,reg */
558 case 0xb5: /* lgs addr,reg */
559 if (INSTR_EmulateLDS( context, instr, long_op,
560 long_addr, segprefix, &len ))
562 context->Eip += prefixlen + len;
563 return ExceptionContinueExecution;
565 break;
567 break; /* Unable to emulate it */
569 case 0x6c: /* insb */
570 case 0x6d: /* insw/d */
571 case 0x6e: /* outsb */
572 case 0x6f: /* outsw/d */
574 int typ = *instr; /* Just in case it's overwritten. */
575 int outp = (typ >= 0x6e);
576 unsigned long count = repX ?
577 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
578 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
579 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
580 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
582 if (outp)
583 /* FIXME: Check segment readable. */
584 (void)0;
585 else
586 /* FIXME: Check segment writeable. */
587 (void)0;
589 if (repX)
591 if (long_addr) context->Ecx = 0;
592 else SET_LOWORD(context->Ecx,0);
595 while (count-- > 0)
597 void *data;
598 WORD dx = LOWORD(context->Edx);
599 if (outp)
601 data = make_ptr( context, seg, context->Esi, long_addr );
602 if (long_addr) context->Esi += step;
603 else ADD_LOWORD(context->Esi,step);
605 else
607 data = make_ptr( context, seg, context->Edi, long_addr );
608 if (long_addr) context->Edi += step;
609 else ADD_LOWORD(context->Edi,step);
612 switch (typ)
614 case 0x6c:
615 *(BYTE *)data = INSTR_inport( dx, 1, context );
616 break;
617 case 0x6d:
618 if (long_op)
619 *(DWORD *)data = INSTR_inport( dx, 4, context );
620 else
621 *(WORD *)data = INSTR_inport( dx, 2, context );
622 break;
623 case 0x6e:
624 INSTR_outport( dx, 1, *(BYTE *)data, context );
625 break;
626 case 0x6f:
627 if (long_op)
628 INSTR_outport( dx, 4, *(DWORD *)data, context );
629 else
630 INSTR_outport( dx, 2, *(WORD *)data, context );
631 break;
634 context->Eip += prefixlen + 1;
636 return ExceptionContinueExecution;
638 case 0x8e: /* mov XX,segment_reg */
640 WORD seg;
641 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
642 long_addr, segprefix, &len );
643 if (!addr)
644 break; /* Unable to emulate it */
645 seg = *(WORD *)addr;
646 if (!INSTR_ReplaceSelector( context, &seg ))
647 break; /* Unable to emulate it */
649 switch((instr[1] >> 3) & 7)
651 case 0:
652 context->SegEs = seg;
653 context->Eip += prefixlen + len + 1;
654 return ExceptionContinueExecution;
655 case 1: /* cs */
656 break;
657 case 2:
658 context->SegSs = seg;
659 context->Eip += prefixlen + len + 1;
660 return ExceptionContinueExecution;
661 case 3:
662 context->SegDs = seg;
663 context->Eip += prefixlen + len + 1;
664 return ExceptionContinueExecution;
665 case 4:
666 context->SegFs = seg;
667 context->Eip += prefixlen + len + 1;
668 return ExceptionContinueExecution;
669 case 5:
670 context->SegGs = seg;
671 context->Eip += prefixlen + len + 1;
672 return ExceptionContinueExecution;
673 case 6: /* unused */
674 case 7: /* unused */
675 break;
678 break; /* Unable to emulate it */
680 case 0xc4: /* les addr,reg */
681 case 0xc5: /* lds addr,reg */
682 if (INSTR_EmulateLDS( context, instr, long_op,
683 long_addr, segprefix, &len ))
685 context->Eip += prefixlen + len;
686 return ExceptionContinueExecution;
688 break; /* Unable to emulate it */
690 case 0xcd: /* int <XX> */
691 if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
693 ERR("could not initialize interrupt handling\n");
695 else
697 context->Eip += prefixlen + 2;
698 Dosvm.EmulateInterruptPM( context, instr[1] );
699 return ExceptionContinueExecution;
701 break; /* Unable to emulate it */
703 case 0xcf: /* iret */
704 if (long_op)
706 DWORD *stack = get_stack( context );
707 context->Eip = *stack++;
708 context->SegCs = *stack++;
709 context->EFlags = *stack;
710 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
712 else
714 WORD *stack = get_stack( context );
715 context->Eip = *stack++;
716 context->SegCs = *stack++;
717 SET_LOWORD(context->EFlags,*stack);
718 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
720 return ExceptionContinueExecution;
722 case 0xe4: /* inb al,XX */
723 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
724 context->Eip += prefixlen + 2;
725 return ExceptionContinueExecution;
727 case 0xe5: /* in (e)ax,XX */
728 if (long_op)
729 context->Eax = INSTR_inport( instr[1], 4, context );
730 else
731 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
732 context->Eip += prefixlen + 2;
733 return ExceptionContinueExecution;
735 case 0xe6: /* outb XX,al */
736 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
737 context->Eip += prefixlen + 2;
738 return ExceptionContinueExecution;
740 case 0xe7: /* out XX,(e)ax */
741 if (long_op)
742 INSTR_outport( instr[1], 4, context->Eax, context );
743 else
744 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
745 context->Eip += prefixlen + 2;
746 return ExceptionContinueExecution;
748 case 0xec: /* inb al,dx */
749 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
750 context->Eip += prefixlen + 1;
751 return ExceptionContinueExecution;
753 case 0xed: /* in (e)ax,dx */
754 if (long_op)
755 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
756 else
757 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
758 context->Eip += prefixlen + 1;
759 return ExceptionContinueExecution;
761 case 0xee: /* outb dx,al */
762 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
763 context->Eip += prefixlen + 1;
764 return ExceptionContinueExecution;
766 case 0xef: /* out dx,(e)ax */
767 if (long_op)
768 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
769 else
770 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
771 context->Eip += prefixlen + 1;
772 return ExceptionContinueExecution;
774 case 0xfa: /* cli */
775 NtCurrentTeb()->dpmi_vif = 0;
776 context->Eip += prefixlen + 1;
777 return ExceptionContinueExecution;
779 case 0xfb: /* sti */
780 NtCurrentTeb()->dpmi_vif = 1;
781 context->Eip += prefixlen + 1;
782 if (NtCurrentTeb()->vm86_pending)
784 NtCurrentTeb()->vm86_pending = 0;
785 rec->ExceptionCode = EXCEPTION_VM86_STI;
786 return ExceptionContinueSearch;
788 return ExceptionContinueExecution;
790 return ExceptionContinueSearch; /* Unable to emulate it */
793 #endif /* __i386__ */