Moved instruction emulation to dlls/kernel.

This commit is contained in:
Alexandre Julliard 2003-09-17 04:34:31 +00:00
parent 1084a8ba93
commit 1479aebda3
5 changed files with 21 additions and 43 deletions

View File

@ -31,6 +31,7 @@ C_SRCS = \
file16.c \
format_msg.c \
heap.c \
instr.c \
kernel_main.c \
lcformat.c \
local16.c \
@ -48,6 +49,7 @@ C_SRCS = \
stress.c \
string.c \
sync.c \
system.c \
tape.c \
task.c \
thread.c \
@ -61,8 +63,7 @@ C_SRCS = \
C_SRCS16 = \
error16.c \
registry16.c \
system.c
registry16.c
ASM_SRCS = relay16asm.s

View File

@ -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
*
@ -94,13 +81,9 @@ static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
{
if (*sel == 0x40)
{
#if 0 /* hack until this is moved to kernel */
static WORD sys_timer = 0;
if (!sys_timer)
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;
return TRUE;
}
@ -502,7 +485,8 @@ DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
switch(instr[1])
{
case 0x22: /* mov eax, crX */
switch (instr[2]) {
switch (instr[2])
{
case 0xc0:
ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
context->Eip,context->Eax );
@ -513,7 +497,8 @@ DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
}
break; /*fallthrough to bad instruction handling */
case 0x20: /* mov crX, eax */
switch (instr[2]) {
switch (instr[2])
{
case 0xe0: /* mov cr4, eax */
/* CR4 register . See linux/arch/i386/mm/init.c, X86_CR4_ defs
* bit 0: VME Virtual Mode Exception ?
@ -699,13 +684,7 @@ DWORD INSTR_EmulateInstruction( CONTEXT86 *context )
break; /* Unable to emulate it */
case 0xcd: /* int <XX> */
if (IS_SELECTOR_SYSTEM(context->SegCs))
{
/* Win32 applications cannot use interrupts */
ret = EXCEPTION_ACCESS_VIOLATION;
break;
}
else if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem())
{
ERR("could not initialize interrupt handling\n");
}

View File

@ -170,16 +170,21 @@ static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RE
NtCurrentTeb()->cur_stack = frame32->frame16;
_LeaveWin16Lock();
}
else
else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION)
{
if (IS_SELECTOR_SYSTEM(context->SegCs))
{
if (fix_selector( context )) return ExceptionContinueExecution;
}
else /* check for Win16 __GP handler */
else
{
SEGPTR gpHandler = HasGPHandler16( MAKESEGPTR( context->SegCs, context->Eip ) );
if (gpHandler)
SEGPTR 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 );
*--stack = context->SegCs;

View File

@ -21,7 +21,6 @@ C_SRCS = \
$(TOPOBJDIR)/memory/environ.c \
$(TOPOBJDIR)/memory/global.c \
$(TOPOBJDIR)/memory/heap.c \
$(TOPOBJDIR)/memory/instr.c \
$(TOPOBJDIR)/memory/selector.c \
$(TOPOBJDIR)/memory/string.c \
$(TOPOBJDIR)/memory/virtual.c \

View File

@ -407,7 +407,6 @@ typedef struct
#include "wine/exception.h"
#include "global.h"
#include "miscemu.h"
#include "syslevel.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 )
{
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.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_PROTFLT: /* General protection fault */
case T_UNKNOWN: /* Unknown fault code */
if (!(rec.ExceptionCode = INSTR_EmulateInstruction( context ))) return;
rec.ExceptionCode = err_code ? EXCEPTION_ACCESS_VIOLATION : EXCEPTION_PRIV_INSTRUCTION;
break;
case T_PAGEFLT: /* Page fault */
#ifdef FAULT_ADDRESS
if (!(rec.ExceptionCode = VIRTUAL_HandleFault( cr2 ))) return;
rec.NumberParameters = 2;
rec.ExceptionInformation[0] = (err_code & 2) != 0;
rec.ExceptionInformation[1] = (DWORD)cr2;
#else
rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
#endif
rec.ExceptionCode = page_fault_code;
break;
case T_ALIGNFLT: /* Alignment check exception */
/* FIXME: pass through exception handler first? */