Separated the MZ loader and core DOS VM into dlls/winedos.
[wine] / dlls / winedos / dosvm.c
1 /*
2  * DOS Virtual Machine
3  *
4  * Copyright 1998 Ove Kåven
5  *
6  * This code hasn't been completely cleaned up yet.
7  */
8
9 #include "config.h"
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <fcntl.h>
16 #include <signal.h>
17 #include <unistd.h>
18 #include <sys/time.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21
22 #include "wine/winbase16.h"
23 #include "wine/exception.h"
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "winnt.h"
29 #include "wincon.h"
30
31 #include "callback.h"
32 #include "msdos.h"
33 #include "file.h"
34 #include "miscemu.h"
35 #include "dosexe.h"
36 #include "../../loader/dos/dosmod.h"
37 #include "stackframe.h"
38 #include "debugtools.h"
39
40 DECLARE_DEBUG_CHANNEL(int);
41 DECLARE_DEBUG_CHANNEL(module);
42 DECLARE_DEBUG_CHANNEL(relay);
43
44 #ifdef MZ_SUPPORTED
45
46 #ifdef HAVE_SYS_VM86_H
47 # include <sys/vm86.h>
48 #endif
49 #ifdef HAVE_SYS_MMAN_H
50 # include <sys/mman.h>
51 #endif
52
53 #define IF_CLR(ctx)     ((ctx)->EFlags &= ~VIF_MASK)
54 #define IF_SET(ctx)     ((ctx)->EFlags |= VIF_MASK)
55 #define IF_ENABLED(ctx) ((ctx)->EFlags & VIF_MASK)
56 #define SET_PEND(ctx)   ((ctx)->EFlags |= VIP_MASK)
57 #define CLR_PEND(ctx)   ((ctx)->EFlags &= ~VIP_MASK)
58 #define IS_PEND(ctx)    ((ctx)->EFlags & VIP_MASK)
59
60 #undef TRY_PICRETURN
61
62 typedef struct _DOSEVENT {
63   int irq,priority;
64   void (*relay)(CONTEXT86*,void*);
65   void *data;
66   struct _DOSEVENT *next;
67 } DOSEVENT, *LPDOSEVENT;
68
69 static struct _DOSEVENT *pending_event, *current_event;
70 static int sig_sent, entered;
71
72 /* from module.c */
73 extern int read_pipe, write_pipe;
74 extern HANDLE hReadPipe;
75 extern pid_t dosmod_pid;
76
77 static void do_exception( int signal, CONTEXT86 *context )
78 {
79     EXCEPTION_RECORD rec;
80     if ((signal == SIGTRAP) || (signal == SIGHUP))
81     {
82         rec.ExceptionCode  = EXCEPTION_BREAKPOINT;
83         rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
84     }
85     else
86     {
87         rec.ExceptionCode  = EXCEPTION_ILLEGAL_INSTRUCTION;  /* generic error */
88         rec.ExceptionFlags = EH_NONCONTINUABLE;
89     }
90     rec.ExceptionRecord  = NULL;
91     rec.ExceptionAddress = (LPVOID)context->Eip;
92     rec.NumberParameters = 0;
93     EXC_RtlRaiseException( &rec, context );
94 }
95
96 static void DOSVM_Dump( int fn, int sig, struct vm86plus_struct*VM86 )
97 {
98  BYTE*inst;
99  int x;
100
101  switch (VM86_TYPE(fn)) {
102   case VM86_SIGNAL:
103    printf("Trapped signal %d\n",sig); break;
104   case VM86_UNKNOWN:
105    printf("Trapped unhandled GPF\n"); break;
106   case VM86_INTx:
107    printf("Trapped INT %02x\n",VM86_ARG(fn)); break;
108   case VM86_STI:
109    printf("Trapped STI\n"); break;
110   case VM86_PICRETURN:
111    printf("Trapped due to pending PIC request\n"); break;
112   case VM86_TRAP:
113    printf("Trapped debug request\n"); break;
114   default:
115    printf("Trapped unknown VM86 type %d arg %d\n",VM86_TYPE(fn),VM86_ARG(fn)); break;
116  }
117 #define REGS VM86->regs
118  fprintf(stderr,"AX=%04lX CX=%04lX DX=%04lX BX=%04lX\n",REGS.eax,REGS.ecx,REGS.edx,REGS.ebx);
119  fprintf(stderr,"SI=%04lX DI=%04lX SP=%04lX BP=%04lX\n",REGS.esi,REGS.edi,REGS.esp,REGS.ebp);
120  fprintf(stderr,"CS=%04X DS=%04X ES=%04X SS=%04X\n",REGS.cs,REGS.ds,REGS.es,REGS.ss);
121  fprintf(stderr,"IP=%04lX EFLAGS=%08lX\n",REGS.eip,REGS.eflags);
122
123  inst = PTR_REAL_TO_LIN( REGS.cs, REGS.eip );
124 #undef REGS
125  printf("Opcodes:");
126  for (x=0; x<8; x++) printf(" %02x",inst[x]);
127  printf("\n");
128 }
129
130 static int DOSVM_SimulateInt( int vect, CONTEXT86 *context, BOOL inwine )
131 {
132   FARPROC16 handler=INT_GetRMHandler(vect);
133
134   /* check for our real-mode hooks */
135   if (vect==0x31) {
136     if (context->SegCs==DOSMEM_wrap_seg) {
137       /* exit from real-mode wrapper */
138       return -1;
139     }
140     /* we could probably move some other dodgy stuff here too from dpmi.c */
141   }
142   /* check if the call is from our fake BIOS interrupt stubs */
143   if ((context->SegCs==0xf000) && !inwine) {
144     if (vect != (context->Eip/4)) {
145       TRACE_(int)("something fishy going on here (interrupt stub is %02lx)\n", context->Eip/4);
146     }
147     TRACE_(int)("builtin interrupt %02x has been branched to\n", vect);
148     INT_RealModeInterrupt(vect, context);
149   }
150   /* check if the call goes to an unhooked interrupt */
151   else if (SELECTOROF(handler)==0xf000) {
152     /* if so, call it directly */
153     TRACE_(int)("builtin interrupt %02x has been invoked (through vector %02x)\n", OFFSETOF(handler)/4, vect);
154     INT_RealModeInterrupt(OFFSETOF(handler)/4, context);
155   }
156   /* the interrupt is hooked, simulate interrupt in DOS space */
157   else {
158     WORD*stack= PTR_REAL_TO_LIN( context->SegSs, context->Esp );
159     WORD flag=LOWORD(context->EFlags);
160
161     if (IF_ENABLED(context)) flag|=IF_MASK;
162     else flag&=~IF_MASK;
163
164     *(--stack)=flag;
165     *(--stack)=context->SegCs;
166     *(--stack)=LOWORD(context->Eip);
167     context->Esp-=6;
168     context->SegCs=SELECTOROF(handler);
169     context->Eip=OFFSETOF(handler);
170     IF_CLR(context);
171   }
172   return 0;
173 }
174
175 #define SHOULD_PEND(x) \
176   (x && ((!current_event) || (x->priority < current_event->priority)))
177
178 static void DOSVM_SendQueuedEvent(CONTEXT86 *context)
179 {
180   LPDOSEVENT event = pending_event;
181
182   if (SHOULD_PEND(event)) {
183     /* remove from "pending" list */
184     pending_event = event->next;
185     /* process event */
186     if (event->irq>=0) {
187       /* it's an IRQ, move it to "current" list */
188       event->next = current_event;
189       current_event = event;
190       TRACE_(int)("dispatching IRQ %d\n",event->irq);
191       /* note that if DOSVM_SimulateInt calls an internal interrupt directly,
192        * current_event might be cleared (and event freed) in this very call! */
193       DOSVM_SimulateInt((event->irq<8)?(event->irq+8):(event->irq-8+0x70),context,TRUE);
194     } else {
195       /* callback event */
196       TRACE_(int)("dispatching callback event\n");
197       (*event->relay)(context,event->data);
198       free(event);
199     }
200   }
201   if (!SHOULD_PEND(pending_event)) {
202     TRACE_(int)("clearing Pending flag\n");
203     CLR_PEND(context);
204   }
205 }
206
207 static void DOSVM_SendQueuedEvents(CONTEXT86 *context)
208 {
209   /* we will send all queued events as long as interrupts are enabled,
210    * but IRQ events will disable interrupts again */
211   while (IS_PEND(context) && IF_ENABLED(context))
212     DOSVM_SendQueuedEvent(context);
213 }
214
215 void WINAPI DOSVM_QueueEvent( int irq, int priority, void (*relay)(CONTEXT86*,void*), void *data)
216 {
217   LPDOSEVENT event, cur, prev;
218
219   if (entered) {
220     event = malloc(sizeof(DOSEVENT));
221     if (!event) {
222       ERR_(int)("out of memory allocating event entry\n");
223       return;
224     }
225     event->irq = irq; event->priority = priority;
226     event->relay = relay; event->data = data;
227
228     /* insert event into linked list, in order *after*
229      * all earlier events of higher or equal priority */
230     cur = pending_event; prev = NULL;
231     while (cur && cur->priority<=priority) {
232       prev = cur;
233       cur = cur->next;
234     }
235     event->next = cur;
236     if (prev) prev->next = event;
237     else pending_event = event;
238     
239     /* get dosmod's attention to the new event, if necessary */
240     if (!sig_sent) {
241       TRACE_(int)("new event queued, signalling dosmod\n");
242       kill(dosmod_pid,SIGUSR2);
243       sig_sent++;
244     } else {
245       TRACE_(int)("new event queued\n");
246     }
247   } else {
248     /* DOS subsystem not running */
249     /* (this probably means that we're running a win16 app
250      *  which uses DPMI to thunk down to DOS services) */
251     if (irq<0) {
252       /* callback event, perform it with dummy context */
253       CONTEXT86 context;
254       memset(&context,0,sizeof(context));
255       (*relay)(&context,data);
256     } else {
257       ERR_(int)("IRQ without DOS task: should not happen");
258     }
259   }
260 }
261
262 #define CV do { CP(eax,Eax); CP(ecx,Ecx); CP(edx,Edx); CP(ebx,Ebx); \
263            CP(esi,Esi); CP(edi,Edi); CP(esp,Esp); CP(ebp,Ebp); \
264            CP(cs,SegCs); CP(ds,SegDs); CP(es,SegEs); \
265            CP(ss,SegSs); CP(fs,SegFs); CP(gs,SegGs); \
266            CP(eip,Eip); CP(eflags,EFlags); } while(0)
267
268 static int DOSVM_Process( int fn, int sig, struct vm86plus_struct*VM86 )
269 {
270  CONTEXT86 context;
271  int ret=0;
272
273 #define CP(x,y) context.y = VM86->regs.x
274   CV;
275 #undef CP
276  if (VM86_TYPE(fn)==VM86_UNKNOWN) {
277   ret=INSTR_EmulateInstruction(&context);
278 #define CP(x,y) VM86->regs.x = context.y
279   CV;
280 #undef CP
281   if (ret) return 0;
282   ret=0;
283  }
284 #ifdef TRY_PICRETURN
285  if (VM86->vm86plus.force_return_for_pic) {
286    SET_PEND(&context);
287  }
288 #else
289  /* linux doesn't preserve pending flag on return */
290  if (SHOULD_PEND(pending_event)) {
291    SET_PEND(&context);
292  }
293 #endif
294
295  switch (VM86_TYPE(fn)) {
296   case VM86_SIGNAL:
297    TRACE_(int)("DOS module caught signal %d\n",sig);
298    if ((sig==SIGALRM) || (sig==SIGUSR2)) {
299      if (sig==SIGALRM) {
300        sig_sent++;
301        DOSVM_QueueEvent(0,DOS_PRIORITY_REALTIME,NULL,NULL);
302      }
303      if (pending_event) {
304        TRACE_(int)("setting Pending flag, interrupts are currently %s\n",
305                  IF_ENABLED(&context) ? "enabled" : "disabled");
306        SET_PEND(&context);
307        DOSVM_SendQueuedEvents(&context);
308      } else {
309        TRACE_(int)("no events are pending, clearing Pending flag\n");
310        CLR_PEND(&context);
311      }
312      sig_sent--;
313    }
314    else if ((sig==SIGHUP) || (sig==SIGILL) || (sig==SIGSEGV)) {
315        do_exception( sig, &context );
316    } else {
317     DOSVM_Dump(fn,sig,VM86);
318     ret=-1;
319    }
320    break;
321   case VM86_UNKNOWN: /* unhandled GPF */
322    DOSVM_Dump(fn,sig,VM86);
323    do_exception( SIGSEGV, &context );
324    break;
325   case VM86_INTx:
326    if (TRACE_ON(relay))
327     DPRINTF("Call DOS int 0x%02x (EAX=%08lx) ret=%04lx:%04lx\n",VM86_ARG(fn),context.Eax,context.SegCs,context.Eip);
328    ret=DOSVM_SimulateInt(VM86_ARG(fn),&context,FALSE);
329    if (TRACE_ON(relay))
330     DPRINTF("Ret  DOS int 0x%02x (EAX=%08lx) ret=%04lx:%04lx\n",VM86_ARG(fn),context.Eax,context.SegCs,context.Eip);
331    break;
332   case VM86_STI:
333     IF_SET(&context);
334   /* case VM86_PICRETURN: */
335     TRACE_(int)("DOS task enabled interrupts %s events pending, sending events\n", IS_PEND(&context)?"with":"without");
336     DOSVM_SendQueuedEvents(&context);
337     break;
338   case VM86_TRAP:
339    do_exception( SIGTRAP, &context );
340    break;
341   default:
342    DOSVM_Dump(fn,sig,VM86);
343    ret=-1;
344  }
345
346 #define CP(x,y) VM86->regs.x = context.y
347  CV;
348 #undef CP
349 #ifdef TRY_PICRETURN
350  VM86->vm86plus.force_return_for_pic = IS_PEND(&context) ? 1 : 0;
351  CLR_PEND(&context);
352 #endif
353  return ret;
354 }
355
356 static void DOSVM_ProcessConsole(void)
357 {
358   INPUT_RECORD msg;
359   DWORD res;
360   BYTE scan;
361
362   if (ReadConsoleInputA(GetStdHandle(STD_INPUT_HANDLE),&msg,1,&res)) {
363     switch (msg.EventType) {
364     case KEY_EVENT:
365       scan = msg.Event.KeyEvent.wVirtualScanCode;
366       if (!msg.Event.KeyEvent.bKeyDown) scan |= 0x80;
367
368       /* check whether extended bit is set,
369        * and if so, queue the extension prefix */
370       if (msg.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY) {
371         INT_Int09SendScan(0xE0,0);
372       }
373       INT_Int09SendScan(scan,msg.Event.KeyEvent.uChar.AsciiChar);
374       break;
375     default:
376       FIXME_(int)("unhandled console event: %d\n", msg.EventType);
377     }
378   }
379 }
380
381 static void DOSVM_ProcessMessage(MSG *msg)
382 {
383   BYTE scan = 0;
384
385   TRACE_(int)("got message %04x, wparam=%08x, lparam=%08lx\n",msg->message,msg->wParam,msg->lParam);
386   if ((msg->message>=WM_MOUSEFIRST)&&
387       (msg->message<=WM_MOUSELAST)) {
388     INT_Int33Message(msg->message,msg->wParam,msg->lParam);
389   } else {
390     switch (msg->message) {
391     case WM_KEYUP:
392       scan = 0x80;
393     case WM_KEYDOWN:
394       scan |= (msg->lParam >> 16) & 0x7f;
395
396       /* check whether extended bit is set,
397        * and if so, queue the extension prefix */
398       if (msg->lParam & 0x1000000) {
399         /* FIXME: some keys (function keys) have
400          * extended bit set even when they shouldn't,
401          * should check for them */
402         INT_Int09SendScan(0xE0,0);
403       }
404       INT_Int09SendScan(scan,0);
405       break;
406     }
407   }
408 }
409
410 void WINAPI DOSVM_Wait( int read_pipe, HANDLE hObject )
411 {
412   MSG msg;
413   DWORD waitret;
414   HANDLE objs[2];
415   int objc;
416   BOOL got_msg = FALSE;
417
418   objs[0]=GetStdHandle(STD_INPUT_HANDLE);
419   objs[1]=hObject;
420   objc=hObject?2:1;
421   do {
422     /* check for messages (waste time before the response check below) */
423     if (Callout.PeekMessageA)
424     {
425         while (Callout.PeekMessageA(&msg,0,0,0,PM_REMOVE|PM_NOYIELD)) {
426             /* got a message */
427             DOSVM_ProcessMessage(&msg);
428             /* we don't need a TranslateMessage here */
429             Callout.DispatchMessageA(&msg);
430             got_msg = TRUE;
431         }
432     }
433     if (!got_msg) {
434       /* check for console input */
435       INPUT_RECORD msg;
436       DWORD num;
437       if (PeekConsoleInputA(objs[0],&msg,1,&num) && num) {
438         DOSVM_ProcessConsole();
439         got_msg = TRUE;
440       }
441     }
442     if (read_pipe == -1) {
443       if (got_msg) break;
444     } else {
445       fd_set readfds;
446       struct timeval timeout={0,0};
447       /* quick check for response from dosmod
448        * (faster than doing the full blocking wait, if data already available) */
449       FD_ZERO(&readfds); FD_SET(read_pipe,&readfds);
450       if (select(read_pipe+1,&readfds,NULL,NULL,&timeout)>0)
451         break;
452     }
453     /* nothing yet, block while waiting for something to do */
454     if (Callout.MsgWaitForMultipleObjects)
455         waitret = Callout.MsgWaitForMultipleObjects(objc,objs,FALSE,INFINITE,QS_ALLINPUT);
456     else
457         waitret = WaitForMultipleObjects(objc,objs,FALSE,INFINITE);
458
459     if (waitret==(DWORD)-1) {
460       ERR_(module)("dosvm wait error=%ld\n",GetLastError());
461     }
462     if ((read_pipe != -1) && hObject) {
463       if (waitret==(WAIT_OBJECT_0+1)) break;
464     }
465     if (waitret==WAIT_OBJECT_0) {
466       DOSVM_ProcessConsole();
467     }
468   } while (TRUE);
469 }
470
471 int WINAPI DOSVM_Enter( CONTEXT86 *context )
472 {
473  struct vm86plus_struct VM86;
474  int stat,len,sig;
475
476  memset(&VM86, 0, sizeof(VM86));
477 #define CP(x,y) VM86.regs.x = context->y
478   CV;
479 #undef CP
480   if (VM86.regs.eflags & IF_MASK)
481     VM86.regs.eflags |= VIF_MASK;
482
483  /* main exchange loop */
484  entered++;
485  do {
486   TRACE_(module)("thread is: %lx\n",GetCurrentThreadId());
487   stat = VM86_ENTER;
488   errno = 0;
489   /* transmit VM86 structure to dosmod task */
490   if (write(write_pipe,&stat,sizeof(stat))!=sizeof(stat)) {
491    ERR_(module)("dosmod sync lost, errno=%d, fd=%d, pid=%d\n",errno,write_pipe,getpid());
492    return -1;
493   }
494   if (write(write_pipe,&VM86,sizeof(VM86))!=sizeof(VM86)) {
495    ERR_(module)("dosmod sync lost, errno=%d\n",errno);
496    return -1;
497   }
498   /* wait for response, doing other things in the meantime */
499   DOSVM_Wait(read_pipe, hReadPipe);
500   /* read response */
501   while (1) {
502     if ((len=read(read_pipe,&stat,sizeof(stat)))==sizeof(stat)) break;
503     if (((errno==EINTR)||(errno==EAGAIN))&&(len<=0)) {
504      WARN_(module)("rereading dosmod return code due to errno=%d, result=%d\n",errno,len);
505      continue;
506     }
507     ERR_(module)("dosmod sync lost reading return code, errno=%d, result=%d\n",errno,len);
508     return -1;
509   }
510   TRACE_(module)("dosmod return code=%d\n",stat);
511   if (stat==DOSMOD_LEFTIDLE) {
512     continue;
513   }
514   while (1) {
515     if ((len=read(read_pipe,&VM86,sizeof(VM86)))==sizeof(VM86)) break;
516     if (((errno==EINTR)||(errno==EAGAIN))&&(len<=0)) {
517      WARN_(module)("rereading dosmod VM86 structure due to errno=%d, result=%d\n",errno,len);
518      continue;
519     }
520     ERR_(module)("dosmod sync lost reading VM86 structure, errno=%d, result=%d\n",errno,len);
521     return -1;
522   }
523   if ((stat&0xff)==DOSMOD_SIGNAL) {
524     while (1) {
525       if ((len=read(read_pipe,&sig,sizeof(sig)))==sizeof(sig)) break;
526       if (((errno==EINTR)||(errno==EAGAIN))&&(len<=0)) {
527         WARN_(module)("rereading dosmod signal due to errno=%d, result=%d\n",errno,len);
528         continue;
529       }
530       ERR_(module)("dosmod sync lost reading signal, errno=%d, result=%d\n",errno,len);
531       return -1;
532     } while (0);
533   } else sig=0;
534   /* got response */
535  } while (DOSVM_Process(stat,sig,&VM86)>=0);
536  entered--;
537
538 #define CP(x,y) context->y = VM86.regs.x
539   CV;
540 #undef CP
541  return 0;
542 }
543
544 void WINAPI DOSVM_PIC_ioport_out( WORD port, BYTE val)
545 {
546     LPDOSEVENT event;
547
548     if ((port==0x20) && (val==0x20)) {
549       if (current_event) {
550         /* EOI (End Of Interrupt) */
551         TRACE_(int)("received EOI for current IRQ, clearing\n");
552         event = current_event;
553         current_event = event->next;
554         if (event->relay)
555         (*event->relay)(NULL,event->data);
556         free(event);
557
558         if (pending_event &&
559             !sig_sent) {
560           /* another event is pending, which we should probably
561            * be able to process now, so tell dosmod about it */
562           TRACE_(int)("another event pending, signalling dosmod\n");
563           kill(dosmod_pid,SIGUSR2);
564           sig_sent++;
565         }
566       } else {
567         WARN_(int)("EOI without active IRQ\n");
568       }
569     } else {
570       FIXME_(int)("unrecognized PIC command %02x\n",val);
571     }
572 }
573
574 void WINAPI DOSVM_SetTimer( unsigned ticks )
575 {
576   int stat=DOSMOD_SET_TIMER;
577   struct timeval tim;
578
579   if (MZ_Current()) {
580     /* the PC clocks ticks at 1193180 Hz */
581     tim.tv_sec=0;
582     tim.tv_usec=MulDiv(ticks,1000000,1193180);
583     /* sanity check */
584     if (!tim.tv_usec) tim.tv_usec=1;
585
586     if (write(write_pipe,&stat,sizeof(stat))!=sizeof(stat)) {
587       ERR_(module)("dosmod sync lost, errno=%d\n",errno);
588       return;
589     }
590     if (write(write_pipe,&tim,sizeof(tim))!=sizeof(tim)) {
591       ERR_(module)("dosmod sync lost, errno=%d\n",errno);
592       return;
593     }
594     /* there's no return */
595   }
596 }
597
598 unsigned WINAPI DOSVM_GetTimer( void )
599 {
600   int stat=DOSMOD_GET_TIMER;
601   struct timeval tim;
602
603   if (MZ_Current()) {
604     if (write(write_pipe,&stat,sizeof(stat))!=sizeof(stat)) {
605       ERR_(module)("dosmod sync lost, errno=%d\n",errno);
606       return 0;
607     }
608     /* read response */
609     while (1) {
610       if (read(read_pipe,&tim,sizeof(tim))==sizeof(tim)) break;
611       if ((errno==EINTR)||(errno==EAGAIN)) continue;
612       ERR_(module)("dosmod sync lost, errno=%d\n",errno);
613       return 0;
614     }
615     return MulDiv(tim.tv_usec,1193180,1000000);
616   }
617   return 0;
618 }
619
620 #else /* !MZ_SUPPORTED */
621
622 int WINAPI DOSVM_Enter( CONTEXT86 *context )
623 {
624  ERR_(module)("DOS realmode not supported on this architecture!\n");
625  return -1;
626 }
627
628 void WINAPI DOSVM_Wait( int read_pipe, HANDLE hObject) {}
629 void WINAPI DOSVM_PIC_ioport_out( WORD port, BYTE val) {}
630 void WINAPI DOSVM_SetTimer( unsigned ticks ) {}
631 unsigned WINAPI DOSVM_GetTimer( void ) { return 0; }
632 void WINAPI DOSVM_QueueEvent( int irq, int priority, void (*relay)(CONTEXT86*,void*), void *data)
633 {
634   if (irq<0) {
635     /* callback event, perform it with dummy context */
636     CONTEXT86 context;
637     memset(&context,0,sizeof(context));
638     (*relay)(&context,data);
639   } else {
640     ERR_(int)("IRQ without DOS task: should not happen");
641   }
642 }
643
644 #endif