From be3b2569c7e36787548f58632e1d6f5692173e1f Mon Sep 17 00:00:00 2001 From: Jukka Heinonen Date: Mon, 25 Aug 2003 01:01:01 +0000 Subject: [PATCH] Make all users of DOSVM_Enter explicitly set V86 flag. Fix mouse relay stack usage in protected mode. Raw mode switch now handles interrupt flag correctly. --- dlls/winedos/devices.c | 1 + dlls/winedos/dosaspi.c | 2 ++ dlls/winedos/dosexe.h | 7 +++++++ dlls/winedos/dosvm.c | 9 +++------ dlls/winedos/int31.c | 13 ++++++++++++- dlls/winedos/int33.c | 6 ++++++ dlls/winedos/interrupts.c | 13 ------------- dlls/winedos/module.c | 2 +- 8 files changed, 32 insertions(+), 21 deletions(-) diff --git a/dlls/winedos/devices.c b/dlls/winedos/devices.c index dda04809cb9..fe58d6d940b 100644 --- a/dlls/winedos/devices.c +++ b/dlls/winedos/devices.c @@ -547,6 +547,7 @@ static void DOSDEV_DoReq(void*req, DWORD dev) /* prepare to call device driver */ memset(&ctx, 0, sizeof(ctx)); + ctx.EFlags |= V86_FLAG; /* ES:BX points to request for strategy routine */ ctx.SegEs = HIWORD(DOS_LOLSeg); diff --git a/dlls/winedos/dosaspi.c b/dlls/winedos/dosaspi.c index 7ccd2b18255..88ab4c629ab 100644 --- a/dlls/winedos/dosaspi.c +++ b/dlls/winedos/dosaspi.c @@ -82,6 +82,8 @@ DOSASPI_PostProc( SRB_ExecSCSICmd *lpPRB ) /* Zero everything */ memset(&ctx, 0, sizeof(ctx)); + ctx.EFlags |= V86_FLAG; + /* CS:IP is routine to call */ ctx.SegCs = SELECTOROF(lpSRB16->cmd.SRB_PostProc); ctx.Eip = OFFSETOF(lpSRB16->cmd.SRB_PostProc); diff --git a/dlls/winedos/dosexe.h b/dlls/winedos/dosexe.h index b17d00ba06f..f0027ef2a7b 100644 --- a/dlls/winedos/dosexe.h +++ b/dlls/winedos/dosexe.h @@ -88,7 +88,14 @@ extern struct DPMI_segments *DOSVM_dpmi_segments; # define MZ_SUPPORTED #endif /* linux-i386 */ +/* + * Declare some CONTEXT86.EFlags bits. + * IF_MASK is only pushed into real mode stack. + */ #define V86_FLAG 0x00020000 +#define IF_MASK 0x00000200 +#define VIF_MASK 0x00080000 +#define VIP_MASK 0x00100000 #define BIOS_DATA ((void *)0x400) diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c index 0ca05650b5f..6ebf6e5f521 100644 --- a/dlls/winedos/dosvm.c +++ b/dlls/winedos/dosvm.c @@ -61,9 +61,6 @@ WINE_DECLARE_DEBUG_CHANNEL(relay); WORD DOSVM_psp = 0; WORD DOSVM_retval = 0; -#ifdef HAVE_SYS_VM86_H -# include -#endif #ifdef HAVE_SYS_MMAN_H # include #endif @@ -416,7 +413,7 @@ void WINAPI DOSVM_Wait( CONTEXT86 *waitctx ) */ if (!ISV86(&context)) { - context.EFlags |= 0x00020000; + context.EFlags |= V86_FLAG; context.SegSs = 0xffff; context.Esp = 0; } @@ -580,8 +577,8 @@ static WINE_EXCEPTION_FILTER(exception_handler) int WINAPI DOSVM_Enter( CONTEXT86 *context ) { - /* Some callers forget to turn V86_FLAG on. */ - context->EFlags |= V86_FLAG; + if (!ISV86(context)) + ERR( "Called with protected mode context!\n" ); __TRY { diff --git a/dlls/winedos/int31.c b/dlls/winedos/int31.c index 71259038295..7b952dc6f86 100644 --- a/dlls/winedos/int31.c +++ b/dlls/winedos/int31.c @@ -696,7 +696,12 @@ void WINAPI DOSVM_RawModeSwitchHandler( CONTEXT86 *context ) rm_ctx.Ebp = context->Ebp; rm_ctx.SegFs = 0; rm_ctx.SegGs = 0; - rm_ctx.EFlags = context->EFlags; /* at least we need the IF flag */ + + /* Copy interrupt state. */ + if (NtCurrentTeb()->dpmi_vif) + rm_ctx.EFlags = V86_FLAG | VIF_MASK; + else + rm_ctx.EFlags = V86_FLAG; /* enter real mode again */ TRACE("re-entering real mode at %04lx:%04lx\n",rm_ctx.SegCs,rm_ctx.Eip); @@ -721,6 +726,12 @@ void WINAPI DOSVM_RawModeSwitchHandler( CONTEXT86 *context ) context->SegFs = 0; context->SegGs = 0; + /* Copy interrupt state. */ + if (rm_ctx.EFlags & VIF_MASK) + NtCurrentTeb()->dpmi_vif = 1; + else + NtCurrentTeb()->dpmi_vif = 0; + /* Return to new address and hope that we didn't mess up */ TRACE("re-entering protected mode at %04lx:%08lx\n", context->SegCs, context->Eip); diff --git a/dlls/winedos/int33.c b/dlls/winedos/int33.c index 41d36d72f2f..32c436607b6 100644 --- a/dlls/winedos/int33.c +++ b/dlls/winedos/int33.c @@ -139,6 +139,12 @@ static void MouseRelay(CONTEXT86 *context,void *mdata) MCALLDATA *data = (MCALLDATA *)mdata; CONTEXT86 ctx = *context; + if (!ISV86(&ctx)) + { + ctx.EFlags |= V86_FLAG; + ctx.SegSs = 0; /* Allocate new stack. */ + } + ctx.Eax = data->mask; ctx.Ebx = data->but; ctx.Ecx = data->x; diff --git a/dlls/winedos/interrupts.c b/dlls/winedos/interrupts.c index 941417bfa85..f981c6d51f7 100644 --- a/dlls/winedos/interrupts.c +++ b/dlls/winedos/interrupts.c @@ -26,19 +26,6 @@ #include "thread.h" -#ifdef HAVE_SYS_VM86_H -# include -#endif - -#ifndef IF_MASK -#define IF_MASK 0x00000200 -#endif - -#ifndef VIF_MASK -#define VIF_MASK 0x00080000 -#endif - - WINE_DEFAULT_DEBUG_CHANNEL(int); WINE_DECLARE_DEBUG_CHANNEL(relay); diff --git a/dlls/winedos/module.c b/dlls/winedos/module.c index 0ed2584d9a0..cce91a145d6 100644 --- a/dlls/winedos/module.c +++ b/dlls/winedos/module.c @@ -574,7 +574,7 @@ static DWORD WINAPI MZ_DOSVM( LPVOID lpExtra ) context.Esp = init_sp; context.SegDs = DOSVM_psp; context.SegEs = DOSVM_psp; - context.EFlags = 0x00080000; /* virtual interrupt flag */ + context.EFlags = V86_FLAG | VIF_MASK; DOSVM_SetTimer(0x10000); ret = DOSVM_Enter( &context ); -- 2.11.4.GIT