Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / memory / instr.c
blobada93efa1cefba1c0ae739e31c62c31e76f95b2a
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 "module.h"
29 #include "miscemu.h"
30 #include "selectors.h"
31 #include "wine/debug.h"
32 #include "callback.h"
33 #include "thread.h"
34 #include "wine/exception.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(int);
37 WINE_DECLARE_DEBUG_CHANNEL(io);
39 #ifdef __i386__
41 /* macros to set parts of a DWORD */
42 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
43 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
44 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
46 inline static void add_stack( CONTEXT86 *context, int offset )
48 if (ISV86(context) || !IS_SELECTOR_32BIT(context->SegSs))
49 ADD_LOWORD( context->Esp, offset );
50 else
51 context->Esp += offset;
54 inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
56 if (ISV86(context)) return PTR_REAL_TO_LIN( seg, off );
57 if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
58 if (!long_addr) off = LOWORD(off);
59 return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
62 inline static void *get_stack( CONTEXT86 *context )
64 if (ISV86(context)) return PTR_REAL_TO_LIN( context->SegSs, context->Esp );
65 return wine_ldt_get_ptr( context->SegSs, context->Esp );
69 /***********************************************************************
70 * timer_thread
72 static DWORD CALLBACK timer_thread( void *dummy )
74 for (;;)
76 Sleep(55);
77 DOSMEM_Tick( 0 );
81 /***********************************************************************
82 * INSTR_ReplaceSelector
84 * Try to replace an invalid selector by a valid one.
85 * The only selector where it is allowed to do "mov ax,40;mov es,ax"
86 * is the so called 'bimodal' selector 0x40, which points to the BIOS
87 * data segment. Used by (at least) Borland products (and programs compiled
88 * using Borland products).
90 * See Undocumented Windows, Chapter 5, __0040.
92 static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
94 if (*sel == 0x40)
96 #if 0 /* hack until this is moved to kernel */
97 static WORD sys_timer = 0;
98 if (!sys_timer)
99 sys_timer = CreateSystemTimer( 55, DOSMEM_Tick );
100 #endif
101 static HANDLE sys_thread;
102 if (!sys_thread) sys_thread = CreateThread( NULL, 0, timer_thread, NULL, 0, NULL );
103 *sel = DOSMEM_BiosDataSeg;
104 return TRUE;
106 return FALSE; /* Can't replace selector, crashdump */
110 /***********************************************************************
111 * INSTR_GetOperandAddr
113 * Return the address of an instruction operand (from the mod/rm byte).
115 static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
116 int long_addr, int segprefix, int *len )
118 int mod, rm, base, index = 0, ss = 0, seg = 0, off;
119 LDT_ENTRY entry;
121 #define GET_VAL(val,type) \
122 { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); }
124 *len = 0;
125 GET_VAL( &mod, BYTE );
126 rm = mod & 7;
127 mod >>= 6;
129 if (mod == 3)
131 switch(rm)
133 case 0: return (BYTE *)&context->Eax;
134 case 1: return (BYTE *)&context->Ecx;
135 case 2: return (BYTE *)&context->Edx;
136 case 3: return (BYTE *)&context->Ebx;
137 case 4: return (BYTE *)&context->Esp;
138 case 5: return (BYTE *)&context->Ebp;
139 case 6: return (BYTE *)&context->Esi;
140 case 7: return (BYTE *)&context->Edi;
144 if (long_addr)
146 if (rm == 4)
148 BYTE sib;
149 GET_VAL( &sib, BYTE );
150 rm = sib & 7;
151 ss = sib >> 6;
152 switch(sib >> 3)
154 case 0: index = context->Eax; break;
155 case 1: index = context->Ecx; break;
156 case 2: index = context->Edx; break;
157 case 3: index = context->Ebx; break;
158 case 4: index = 0; break;
159 case 5: index = context->Ebp; break;
160 case 6: index = context->Esi; break;
161 case 7: index = context->Edi; break;
165 switch(rm)
167 case 0: base = context->Eax; seg = context->SegDs; break;
168 case 1: base = context->Ecx; seg = context->SegDs; break;
169 case 2: base = context->Edx; seg = context->SegDs; break;
170 case 3: base = context->Ebx; seg = context->SegDs; break;
171 case 4: base = context->Esp; seg = context->SegSs; break;
172 case 5: base = context->Ebp; seg = context->SegSs; break;
173 case 6: base = context->Esi; seg = context->SegDs; break;
174 case 7: base = context->Edi; seg = context->SegDs; break;
176 switch (mod)
178 case 0:
179 if (rm == 5) /* special case: ds:(disp32) */
181 GET_VAL( &base, DWORD );
182 seg = context->SegDs;
184 break;
186 case 1: /* 8-bit disp */
187 GET_VAL( &off, BYTE );
188 base += (signed char)off;
189 break;
191 case 2: /* 32-bit disp */
192 GET_VAL( &off, DWORD );
193 base += (signed long)off;
194 break;
197 else /* short address */
199 switch(rm)
201 case 0: /* ds:(bx,si) */
202 base = LOWORD(context->Ebx) + LOWORD(context->Esi);
203 seg = context->SegDs;
204 break;
205 case 1: /* ds:(bx,di) */
206 base = LOWORD(context->Ebx) + LOWORD(context->Edi);
207 seg = context->SegDs;
208 break;
209 case 2: /* ss:(bp,si) */
210 base = LOWORD(context->Ebp) + LOWORD(context->Esi);
211 seg = context->SegSs;
212 break;
213 case 3: /* ss:(bp,di) */
214 base = LOWORD(context->Ebp) + LOWORD(context->Edi);
215 seg = context->SegSs;
216 break;
217 case 4: /* ds:(si) */
218 base = LOWORD(context->Esi);
219 seg = context->SegDs;
220 break;
221 case 5: /* ds:(di) */
222 base = LOWORD(context->Edi);
223 seg = context->SegDs;
224 break;
225 case 6: /* ss:(bp) */
226 base = LOWORD(context->Ebp);
227 seg = context->SegSs;
228 break;
229 case 7: /* ds:(bx) */
230 base = LOWORD(context->Ebx);
231 seg = context->SegDs;
232 break;
235 switch(mod)
237 case 0:
238 if (rm == 6) /* special case: ds:(disp16) */
240 GET_VAL( &base, WORD );
241 seg = context->SegDs;
243 break;
245 case 1: /* 8-bit disp */
246 GET_VAL( &off, BYTE );
247 base += (signed char)off;
248 break;
250 case 2: /* 16-bit disp */
251 GET_VAL( &off, WORD );
252 base += (signed short)off;
253 break;
255 base &= 0xffff;
257 if (segprefix != -1) seg = segprefix;
259 /* Make sure the segment and offset are valid */
260 if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
261 if ((seg & 7) != 7) return NULL;
262 wine_ldt_get_entry( seg, &entry );
263 if (wine_ldt_is_empty( &entry )) return NULL;
264 if (wine_ldt_get_limit(&entry) < (base + (index << ss))) return NULL;
265 return (char *)wine_ldt_get_base(&entry) + base + (index << ss);
266 #undef GET_VAL
270 /***********************************************************************
271 * INSTR_EmulateLDS
273 * Emulate the LDS (and LES,LFS,etc.) instruction.
275 static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
276 int long_addr, int segprefix, int *len )
278 WORD seg;
279 BYTE *regmodrm = instr + 1 + (*instr == 0x0f);
280 BYTE *addr = INSTR_GetOperandAddr( context, regmodrm,
281 long_addr, segprefix, len );
282 if (!addr)
283 return FALSE; /* Unable to emulate it */
284 seg = *(WORD *)(addr + (long_op ? 4 : 2));
286 if (!INSTR_ReplaceSelector( context, &seg ))
287 return FALSE; /* Unable to emulate it */
289 /* Now store the offset in the correct register */
291 switch((*regmodrm >> 3) & 7)
293 case 0:
294 if (long_op) context->Eax = *(DWORD *)addr;
295 else SET_LOWORD(context->Eax,*(WORD *)addr);
296 break;
297 case 1:
298 if (long_op) context->Ecx = *(DWORD *)addr;
299 else SET_LOWORD(context->Ecx,*(WORD *)addr);
300 break;
301 case 2:
302 if (long_op) context->Edx = *(DWORD *)addr;
303 else SET_LOWORD(context->Edx,*(WORD *)addr);
304 break;
305 case 3:
306 if (long_op) context->Ebx = *(DWORD *)addr;
307 else SET_LOWORD(context->Ebx,*(WORD *)addr);
308 break;
309 case 4:
310 if (long_op) context->Esp = *(DWORD *)addr;
311 else SET_LOWORD(context->Esp,*(WORD *)addr);
312 break;
313 case 5:
314 if (long_op) context->Ebp = *(DWORD *)addr;
315 else SET_LOWORD(context->Ebp,*(WORD *)addr);
316 break;
317 case 6:
318 if (long_op) context->Esi = *(DWORD *)addr;
319 else SET_LOWORD(context->Esi,*(WORD *)addr);
320 break;
321 case 7:
322 if (long_op) context->Edi = *(DWORD *)addr;
323 else SET_LOWORD(context->Edi,*(WORD *)addr);
324 break;
327 /* Store the correct segment in the segment register */
329 switch(*instr)
331 case 0xc4: context->SegEs = seg; break; /* les */
332 case 0xc5: context->SegDs = seg; break; /* lds */
333 case 0x0f: switch(instr[1])
335 case 0xb2: context->SegSs = seg; break; /* lss */
336 case 0xb4: context->SegFs = seg; break; /* lfs */
337 case 0xb5: context->SegGs = seg; break; /* lgs */
339 break;
342 /* Add the opcode size to the total length */
344 *len += 1 + (*instr == 0x0f);
345 return TRUE;
348 /***********************************************************************
349 * INSTR_inport
351 * input on a I/O port
353 static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
355 DWORD res = IO_inport( port, size );
356 if (TRACE_ON(io))
358 switch(size)
360 case 1:
361 DPRINTF( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
362 (WORD)context->SegCs, LOWORD(context->Eip));
363 break;
364 case 2:
365 DPRINTF( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
366 (WORD)context->SegCs, LOWORD(context->Eip));
367 break;
368 case 4:
369 DPRINTF( "0x%x < %08lx @ %04x:%04x\n", port, res,
370 (WORD)context->SegCs, LOWORD(context->Eip));
371 break;
374 return res;
378 /***********************************************************************
379 * INSTR_outport
381 * output on a I/O port
383 static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
385 IO_outport( port, size, val );
386 if (TRACE_ON(io))
388 switch(size)
390 case 1:
391 DPRINTF("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
392 (WORD)context->SegCs, LOWORD(context->Eip));
393 break;
394 case 2:
395 DPRINTF("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
396 (WORD)context->SegCs, LOWORD(context->Eip));
397 break;
398 case 4:
399 DPRINTF("0x%x > %08lx @ %04x:%04x\n", port, val,
400 (WORD)context->SegCs, LOWORD(context->Eip));
401 break;
407 /***********************************************************************
408 * INSTR_EmulateInstruction
410 * Emulate a privileged instruction.
411 * Returns exception code, or 0 if emulation successful.
413 DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
415 int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
416 BYTE *instr;
417 DWORD ret = EXCEPTION_PRIV_INSTRUCTION;
419 long_op = long_addr = (!ISV86(context) && IS_SELECTOR_32BIT(context->SegCs));
420 instr = make_ptr( context, context->SegCs, context->Eip, TRUE );
421 if (!instr) return ret;
423 /* First handle any possible prefix */
425 segprefix = -1; /* no prefix */
426 prefix = 1;
427 repX = 0;
428 prefixlen = 0;
429 while(prefix)
431 switch(*instr)
433 case 0x2e:
434 segprefix = context->SegCs;
435 break;
436 case 0x36:
437 segprefix = context->SegSs;
438 break;
439 case 0x3e:
440 segprefix = context->SegDs;
441 break;
442 case 0x26:
443 segprefix = context->SegEs;
444 break;
445 case 0x64:
446 segprefix = context->SegFs;
447 break;
448 case 0x65:
449 segprefix = context->SegGs;
450 break;
451 case 0x66:
452 long_op = !long_op; /* opcode size prefix */
453 break;
454 case 0x67:
455 long_addr = !long_addr; /* addr size prefix */
456 break;
457 case 0xf0: /* lock */
458 break;
459 case 0xf2: /* repne */
460 repX = 1;
461 break;
462 case 0xf3: /* repe */
463 repX = 2;
464 break;
465 default:
466 prefix = 0; /* no more prefixes */
467 break;
469 if (prefix)
471 instr++;
472 prefixlen++;
476 /* Now look at the actual instruction */
478 switch(*instr)
480 case 0x07: /* pop es */
481 case 0x17: /* pop ss */
482 case 0x1f: /* pop ds */
484 WORD seg = *(WORD *)get_stack( context );
485 if (INSTR_ReplaceSelector( context, &seg ))
487 switch(*instr)
489 case 0x07: context->SegEs = seg; break;
490 case 0x17: context->SegSs = seg; break;
491 case 0x1f: context->SegDs = seg; break;
493 add_stack(context, long_op ? 4 : 2);
494 context->Eip += prefixlen + 1;
495 return 0;
498 break; /* Unable to emulate it */
500 case 0x0f: /* extended instruction */
501 switch(instr[1])
503 case 0x22: /* mov eax, crX */
504 switch (instr[2]) {
505 case 0xc0:
506 ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
507 context->Eip,context->Eax );
508 context->Eip += prefixlen+3;
509 return 0;
510 default:
511 break; /*fallthrough to bad instruction handling */
513 break; /*fallthrough to bad instruction handling */
514 case 0x20: /* mov crX, eax */
515 switch (instr[2]) {
516 case 0xe0: /* mov cr4, eax */
517 /* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
518 * bit 0: VME Virtual Mode Exception ?
519 * bit 1: PVI Protected mode Virtual Interrupt
520 * bit 2: TSD Timestamp disable
521 * bit 3: DE Debugging extensions
522 * bit 4: PSE Page size extensions
523 * bit 5: PAE Physical address extension
524 * bit 6: MCE Machine check enable
525 * bit 7: PGE Enable global pages
526 * bit 8: PCE Enable performance counters at IPL3
528 ERR("mov cr4,eax at 0x%08lx\n",context->Eip);
529 context->Eax = 0;
530 context->Eip += prefixlen+3;
531 return 0;
532 case 0xc0: /* mov cr0, eax */
533 ERR("mov cr0,eax at 0x%08lx\n",context->Eip);
534 context->Eax = 0x10; /* FIXME: set more bits ? */
535 context->Eip += prefixlen+3;
536 return 0;
537 default: /* fallthrough to illegal instruction */
538 break;
540 /* fallthrough to illegal instruction */
541 break;
542 case 0xa1: /* pop fs */
544 WORD seg = *(WORD *)get_stack( context );
545 if (INSTR_ReplaceSelector( context, &seg ))
547 context->SegFs = seg;
548 add_stack(context, long_op ? 4 : 2);
549 context->Eip += prefixlen + 2;
550 return 0;
553 break;
554 case 0xa9: /* pop gs */
556 WORD seg = *(WORD *)get_stack( context );
557 if (INSTR_ReplaceSelector( context, &seg ))
559 context->SegGs = seg;
560 add_stack(context, long_op ? 4 : 2);
561 context->Eip += prefixlen + 2;
562 return 0;
565 break;
566 case 0xb2: /* lss addr,reg */
567 case 0xb4: /* lfs addr,reg */
568 case 0xb5: /* lgs addr,reg */
569 if (INSTR_EmulateLDS( context, instr, long_op,
570 long_addr, segprefix, &len ))
572 context->Eip += prefixlen + len;
573 return 0;
575 break;
577 break; /* Unable to emulate it */
579 case 0x6c: /* insb */
580 case 0x6d: /* insw/d */
581 case 0x6e: /* outsb */
582 case 0x6f: /* outsw/d */
584 int typ = *instr; /* Just in case it's overwritten. */
585 int outp = (typ >= 0x6e);
586 unsigned long count = repX ?
587 (long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
588 int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
589 int step = (context->EFlags & 0x400) ? -opsize : +opsize;
590 int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
592 if (outp)
593 /* FIXME: Check segment readable. */
594 (void)0;
595 else
596 /* FIXME: Check segment writeable. */
597 (void)0;
599 if (repX)
601 if (long_addr) context->Ecx = 0;
602 else SET_LOWORD(context->Ecx,0);
605 while (count-- > 0)
607 void *data;
608 WORD dx = LOWORD(context->Edx);
609 if (outp)
611 data = make_ptr( context, seg, context->Esi, long_addr );
612 if (long_addr) context->Esi += step;
613 else ADD_LOWORD(context->Esi,step);
615 else
617 data = make_ptr( context, seg, context->Edi, long_addr );
618 if (long_addr) context->Edi += step;
619 else ADD_LOWORD(context->Edi,step);
622 switch (typ)
624 case 0x6c:
625 *(BYTE *)data = INSTR_inport( dx, 1, context );
626 break;
627 case 0x6d:
628 if (long_op)
629 *(DWORD *)data = INSTR_inport( dx, 4, context );
630 else
631 *(WORD *)data = INSTR_inport( dx, 2, context );
632 break;
633 case 0x6e:
634 INSTR_outport( dx, 1, *(BYTE *)data, context );
635 break;
636 case 0x6f:
637 if (long_op)
638 INSTR_outport( dx, 4, *(DWORD *)data, context );
639 else
640 INSTR_outport( dx, 2, *(WORD *)data, context );
641 break;
644 context->Eip += prefixlen + 1;
646 return 0;
648 case 0x8e: /* mov XX,segment_reg */
650 WORD seg;
651 BYTE *addr = INSTR_GetOperandAddr(context, instr + 1,
652 long_addr, segprefix, &len );
653 if (!addr)
654 break; /* Unable to emulate it */
655 seg = *(WORD *)addr;
656 if (!INSTR_ReplaceSelector( context, &seg ))
657 break; /* Unable to emulate it */
659 switch((instr[1] >> 3) & 7)
661 case 0:
662 context->SegEs = seg;
663 context->Eip += prefixlen + len + 1;
664 return 0;
665 case 1: /* cs */
666 break;
667 case 2:
668 context->SegSs = seg;
669 context->Eip += prefixlen + len + 1;
670 return 0;
671 case 3:
672 context->SegDs = seg;
673 context->Eip += prefixlen + len + 1;
674 return 0;
675 case 4:
676 context->SegFs = seg;
677 context->Eip += prefixlen + len + 1;
678 return 0;
679 case 5:
680 context->SegGs = seg;
681 context->Eip += prefixlen + len + 1;
682 return 0;
683 case 6: /* unused */
684 case 7: /* unused */
685 break;
688 break; /* Unable to emulate it */
690 case 0xc4: /* les addr,reg */
691 case 0xc5: /* lds addr,reg */
692 if (INSTR_EmulateLDS( context, instr, long_op,
693 long_addr, segprefix, &len ))
695 context->Eip += prefixlen + len;
696 return 0;
698 break; /* Unable to emulate it */
700 case 0xcd: /* int <XX> */
701 if (IS_SELECTOR_SYSTEM(context->SegCs))
703 /* Win32 applications cannot use interrupts */
704 ret = EXCEPTION_ACCESS_VIOLATION;
705 break;
707 else if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
709 ERR("could not initialize interrupt handling\n");
711 else
713 context->Eip += prefixlen + 2;
714 Dosvm.EmulateInterruptPM( context, instr[1] );
715 return 0;
717 break; /* Unable to emulate it */
719 case 0xcf: /* iret */
720 if (long_op)
722 DWORD *stack = get_stack( context );
723 context->Eip = *stack++;
724 context->SegCs = *stack++;
725 context->EFlags = *stack;
726 add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
728 else
730 WORD *stack = get_stack( context );
731 context->Eip = *stack++;
732 context->SegCs = *stack++;
733 SET_LOWORD(context->EFlags,*stack);
734 add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
736 return 0;
738 case 0xe4: /* inb al,XX */
739 SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
740 context->Eip += prefixlen + 2;
741 return 0;
743 case 0xe5: /* in (e)ax,XX */
744 if (long_op)
745 context->Eax = INSTR_inport( instr[1], 4, context );
746 else
747 SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
748 context->Eip += prefixlen + 2;
749 return 0;
751 case 0xe6: /* outb XX,al */
752 INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
753 context->Eip += prefixlen + 2;
754 return 0;
756 case 0xe7: /* out XX,(e)ax */
757 if (long_op)
758 INSTR_outport( instr[1], 4, context->Eax, context );
759 else
760 INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
761 context->Eip += prefixlen + 2;
762 return 0;
764 case 0xec: /* inb al,dx */
765 SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
766 context->Eip += prefixlen + 1;
767 return 0;
769 case 0xed: /* in (e)ax,dx */
770 if (long_op)
771 context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
772 else
773 SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
774 context->Eip += prefixlen + 1;
775 return 0;
777 case 0xee: /* outb dx,al */
778 INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
779 context->Eip += prefixlen + 1;
780 return 0;
782 case 0xef: /* out dx,(e)ax */
783 if (long_op)
784 INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
785 else
786 INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
787 context->Eip += prefixlen + 1;
788 return 0;
790 case 0xfa: /* cli */
791 NtCurrentTeb()->dpmi_vif = 0;
792 context->Eip += prefixlen + 1;
793 return 0;
795 case 0xfb: /* sti */
796 NtCurrentTeb()->dpmi_vif = 1;
797 context->Eip += prefixlen + 1;
798 if (NtCurrentTeb()->vm86_pending)
800 NtCurrentTeb()->vm86_pending = 0;
801 return EXCEPTION_VM86_STI;
803 return 0;
805 return ret; /* Unable to emulate it */
808 #endif /* __i386__ */