Moved instruction emulation to dlls/kernel.
This commit is contained in:
parent
1084a8ba93
commit
1479aebda3
|
@ -31,6 +31,7 @@ C_SRCS = \
|
||||||
file16.c \
|
file16.c \
|
||||||
format_msg.c \
|
format_msg.c \
|
||||||
heap.c \
|
heap.c \
|
||||||
|
instr.c \
|
||||||
kernel_main.c \
|
kernel_main.c \
|
||||||
lcformat.c \
|
lcformat.c \
|
||||||
local16.c \
|
local16.c \
|
||||||
|
@ -48,6 +49,7 @@ C_SRCS = \
|
||||||
stress.c \
|
stress.c \
|
||||||
string.c \
|
string.c \
|
||||||
sync.c \
|
sync.c \
|
||||||
|
system.c \
|
||||||
tape.c \
|
tape.c \
|
||||||
task.c \
|
task.c \
|
||||||
thread.c \
|
thread.c \
|
||||||
|
@ -61,8 +63,7 @@ C_SRCS = \
|
||||||
|
|
||||||
C_SRCS16 = \
|
C_SRCS16 = \
|
||||||
error16.c \
|
error16.c \
|
||||||
registry16.c \
|
registry16.c
|
||||||
system.c
|
|
||||||
|
|
||||||
ASM_SRCS = relay16asm.s
|
ASM_SRCS = relay16asm.s
|
||||||
|
|
||||||
|
|
|
@ -66,19 +66,6 @@ inline static void *get_stack( CONTEXT86 *context )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* timer_thread
|
|
||||||
*/
|
|
||||||
static DWORD CALLBACK timer_thread( void *dummy )
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
Sleep(55);
|
|
||||||
DOSMEM_Tick( 0 );
|
|
||||||
}
|
|
||||||
return 0; /* unreached */
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* INSTR_ReplaceSelector
|
* INSTR_ReplaceSelector
|
||||||
*
|
*
|
||||||
|
@ -94,13 +81,9 @@ static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
|
||||||
{
|
{
|
||||||
if (*sel == 0x40)
|
if (*sel == 0x40)
|
||||||
{
|
{
|
||||||
#if 0 /* hack until this is moved to kernel */
|
|
||||||
static WORD sys_timer = 0;
|
static WORD sys_timer = 0;
|
||||||
if (!sys_timer)
|
if (!sys_timer)
|
||||||
sys_timer = CreateSystemTimer( 55, DOSMEM_Tick );
|
sys_timer = CreateSystemTimer( 55, DOSMEM_Tick );
|
||||||
#endif
|
|
||||||
static HANDLE sys_thread;
|
|
||||||
if (!sys_thread) sys_thread = CreateThread( NULL, 0, timer_thread, NULL, 0, NULL );
|
|
||||||
*sel = DOSMEM_BiosDataSeg;
|
*sel = DOSMEM_BiosDataSeg;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -502,7 +485,8 @@ DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
|
||||||
switch(instr[1])
|
switch(instr[1])
|
||||||
{
|
{
|
||||||
case 0x22: /* mov eax, crX */
|
case 0x22: /* mov eax, crX */
|
||||||
switch (instr[2]) {
|
switch (instr[2])
|
||||||
|
{
|
||||||
case 0xc0:
|
case 0xc0:
|
||||||
ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
|
ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
|
||||||
context->Eip,context->Eax );
|
context->Eip,context->Eax );
|
||||||
|
@ -513,7 +497,8 @@ DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
|
||||||
}
|
}
|
||||||
break; /*fallthrough to bad instruction handling */
|
break; /*fallthrough to bad instruction handling */
|
||||||
case 0x20: /* mov crX, eax */
|
case 0x20: /* mov crX, eax */
|
||||||
switch (instr[2]) {
|
switch (instr[2])
|
||||||
|
{
|
||||||
case 0xe0: /* mov cr4, eax */
|
case 0xe0: /* mov cr4, eax */
|
||||||
/* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
|
/* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
|
||||||
* bit 0: VME Virtual Mode Exception ?
|
* bit 0: VME Virtual Mode Exception ?
|
||||||
|
@ -699,13 +684,7 @@ DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
|
||||||
break; /* Unable to emulate it */
|
break; /* Unable to emulate it */
|
||||||
|
|
||||||
case 0xcd: /* int <XX> */
|
case 0xcd: /* int <XX> */
|
||||||
if (IS_SELECTOR_SYSTEM(context->SegCs))
|
if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
|
||||||
{
|
|
||||||
/* Win32 applications cannot use interrupts */
|
|
||||||
ret = EXCEPTION_ACCESS_VIOLATION;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
|
|
||||||
{
|
{
|
||||||
ERR("could not initialize interrupt handling\n");
|
ERR("could not initialize interrupt handling\n");
|
||||||
}
|
}
|
|
@ -170,16 +170,21 @@ static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RE
|
||||||
NtCurrentTeb()->cur_stack = frame32->frame16;
|
NtCurrentTeb()->cur_stack = frame32->frame16;
|
||||||
_LeaveWin16Lock();
|
_LeaveWin16Lock();
|
||||||
}
|
}
|
||||||
else
|
else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
|
||||||
|
record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION)
|
||||||
{
|
{
|
||||||
if (IS_SELECTOR_SYSTEM(context->SegCs))
|
if (IS_SELECTOR_SYSTEM(context->SegCs))
|
||||||
{
|
{
|
||||||
if (fix_selector( context )) return ExceptionContinueExecution;
|
if (fix_selector( context )) return ExceptionContinueExecution;
|
||||||
}
|
}
|
||||||
else /* check for Win16 __GP handler */
|
else
|
||||||
{
|
{
|
||||||
SEGPTR gpHandler = HasGPHandler16( MAKESEGPTR( context->SegCs, context->Eip ) );
|
SEGPTR gpHandler;
|
||||||
if (gpHandler)
|
|
||||||
|
if (!INSTR_EmulateInstruction( context )) return ExceptionContinueExecution;
|
||||||
|
|
||||||
|
/* check for Win16 __GP handler */
|
||||||
|
if ((gpHandler = HasGPHandler16( MAKESEGPTR( context->SegCs, context->Eip ) )))
|
||||||
{
|
{
|
||||||
WORD *stack = wine_ldt_get_ptr( context->SegSs, context->Esp );
|
WORD *stack = wine_ldt_get_ptr( context->SegSs, context->Esp );
|
||||||
*--stack = context->SegCs;
|
*--stack = context->SegCs;
|
||||||
|
|
|
@ -21,7 +21,6 @@ C_SRCS = \
|
||||||
$(TOPOBJDIR)/memory/environ.c \
|
$(TOPOBJDIR)/memory/environ.c \
|
||||||
$(TOPOBJDIR)/memory/global.c \
|
$(TOPOBJDIR)/memory/global.c \
|
||||||
$(TOPOBJDIR)/memory/heap.c \
|
$(TOPOBJDIR)/memory/heap.c \
|
||||||
$(TOPOBJDIR)/memory/instr.c \
|
|
||||||
$(TOPOBJDIR)/memory/selector.c \
|
$(TOPOBJDIR)/memory/selector.c \
|
||||||
$(TOPOBJDIR)/memory/string.c \
|
$(TOPOBJDIR)/memory/string.c \
|
||||||
$(TOPOBJDIR)/memory/virtual.c \
|
$(TOPOBJDIR)/memory/virtual.c \
|
||||||
|
|
|
@ -407,7 +407,6 @@ typedef struct
|
||||||
|
|
||||||
#include "wine/exception.h"
|
#include "wine/exception.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "miscemu.h"
|
|
||||||
#include "syslevel.h"
|
#include "syslevel.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
|
@ -748,13 +747,6 @@ static inline DWORD get_fpu_code( const CONTEXT *context )
|
||||||
static void do_segv( CONTEXT *context, int trap_code, void *cr2, int err_code )
|
static void do_segv( CONTEXT *context, int trap_code, void *cr2, int err_code )
|
||||||
{
|
{
|
||||||
EXCEPTION_RECORD rec;
|
EXCEPTION_RECORD rec;
|
||||||
DWORD page_fault_code = EXCEPTION_ACCESS_VIOLATION;
|
|
||||||
|
|
||||||
#ifdef FAULT_ADDRESS
|
|
||||||
/* we want the page-fault case to be fast */
|
|
||||||
if (trap_code == T_PAGEFLT)
|
|
||||||
if (!(page_fault_code = VIRTUAL_HandleFault( cr2 ))) return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rec.ExceptionRecord = NULL;
|
rec.ExceptionRecord = NULL;
|
||||||
rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
|
rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
|
||||||
|
@ -778,15 +770,17 @@ static void do_segv( CONTEXT *context, int trap_code, void *cr2, int err_code )
|
||||||
case T_SEGNPFLT: /* Segment not present exception */
|
case T_SEGNPFLT: /* Segment not present exception */
|
||||||
case T_PROTFLT: /* General protection fault */
|
case T_PROTFLT: /* General protection fault */
|
||||||
case T_UNKNOWN: /* Unknown fault code */
|
case T_UNKNOWN: /* Unknown fault code */
|
||||||
if (!(rec.ExceptionCode = INSTR_EmulateInstruction( context ))) return;
|
rec.ExceptionCode = err_code ? EXCEPTION_ACCESS_VIOLATION : EXCEPTION_PRIV_INSTRUCTION;
|
||||||
break;
|
break;
|
||||||
case T_PAGEFLT: /* Page fault */
|
case T_PAGEFLT: /* Page fault */
|
||||||
#ifdef FAULT_ADDRESS
|
#ifdef FAULT_ADDRESS
|
||||||
|
if (!(rec.ExceptionCode = VIRTUAL_HandleFault( cr2 ))) return;
|
||||||
rec.NumberParameters = 2;
|
rec.NumberParameters = 2;
|
||||||
rec.ExceptionInformation[0] = (err_code & 2) != 0;
|
rec.ExceptionInformation[0] = (err_code & 2) != 0;
|
||||||
rec.ExceptionInformation[1] = (DWORD)cr2;
|
rec.ExceptionInformation[1] = (DWORD)cr2;
|
||||||
|
#else
|
||||||
|
rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
|
||||||
#endif
|
#endif
|
||||||
rec.ExceptionCode = page_fault_code;
|
|
||||||
break;
|
break;
|
||||||
case T_ALIGNFLT: /* Alignment check exception */
|
case T_ALIGNFLT: /* Alignment check exception */
|
||||||
/* FIXME: pass through exception handler first? */
|
/* FIXME: pass through exception handler first? */
|
||||||
|
|
Loading…
Reference in New Issue