diff --git a/dlls/kernel/Makefile.in b/dlls/kernel/Makefile.in index cb5eceaedda..a32b1fe1d04 100644 --- a/dlls/kernel/Makefile.in +++ b/dlls/kernel/Makefile.in @@ -25,7 +25,6 @@ C_SRCS = \ $(TOPOBJDIR)/files/smb.c \ $(TOPOBJDIR)/misc/options.c \ $(TOPOBJDIR)/misc/registry.c \ - $(TOPOBJDIR)/msdos/dpmi.c \ atom.c \ change.c \ comm.c \ @@ -99,7 +98,6 @@ SUBDIRS = tests EXTRASUBDIRS = \ $(TOPOBJDIR)/files \ $(TOPOBJDIR)/misc \ - $(TOPOBJDIR)/msdos \ messages \ nls diff --git a/dlls/kernel/device.c b/dlls/kernel/device.c index 58d0b561566..93129cacb61 100644 --- a/dlls/kernel/device.c +++ b/dlls/kernel/device.c @@ -42,7 +42,6 @@ #include "winioctl.h" #include "winnt.h" #include "msdos.h" -#include "miscemu.h" #include "kernel_private.h" #include "wine/server.h" #include "wine/debug.h" @@ -509,15 +508,9 @@ static BOOL DeviceIo_IFSMgr(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbI win32apieq_2_CONTEXT(pIn,&cxt); if(dwIoControlCode==IFS_IOCTL_21) - { - if(Dosvm.CallBuiltinHandler || DPMI_LoadDosSystem()) - Dosvm.CallBuiltinHandler( &cxt, 0x21 ); - } - else - { - if(Dosvm.CallBuiltinHandler || DPMI_LoadDosSystem()) - Dosvm.CallBuiltinHandler( &cxt, 0x2f ); - } + INSTR_CallBuiltinHandler( &cxt, 0x21 ); + else + INSTR_CallBuiltinHandler( &cxt, 0x2f ); CONTEXT_2_win32apieq(&cxt,pOut); @@ -676,9 +669,7 @@ static BOOL DeviceIo_VWin32(DWORD dwIoControlCode, break; } - if(Dosvm.CallBuiltinHandler || DPMI_LoadDosSystem()) - Dosvm.CallBuiltinHandler( &cxt, intnum ); - + INSTR_CallBuiltinHandler( &cxt, intnum ); CONTEXT_2_DIOCRegs( &cxt, pOut ); } break; diff --git a/dlls/kernel/instr.c b/dlls/kernel/instr.c index 6bfcad53b1f..e3c8a8a97c8 100644 --- a/dlls/kernel/instr.c +++ b/dlls/kernel/instr.c @@ -37,8 +37,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(int); WINE_DECLARE_DEBUG_CHANNEL(io); -#ifdef __i386__ - /* macros to set parts of a DWORD */ #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val)) #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val)) @@ -67,6 +65,33 @@ inline static void *get_stack( CONTEXT86 *context ) } +static void (WINAPI *DOS_EmulateInterruptPM)( CONTEXT86 *context, BYTE intnum ); +static void (WINAPI *DOS_CallBuiltinHandler)( CONTEXT86 *context, BYTE intnum ); +static DWORD (WINAPI *DOS_inport)( int port, int size ); +static void (WINAPI *DOS_outport)( int port, int size, DWORD val ); + + +static void init_winedos(void) +{ + static HMODULE module; + + if (module) return; + module = LoadLibraryA( "winedos.dll" ); + if (!module) + { + ERR("could not load winedos.dll, DOS subsystem unavailable\n"); + module = (HMODULE)1; /* don't try again */ + return; + } +#define GET_ADDR(func) DOS_##func = (void *)GetProcAddress(module, #func); + GET_ADDR(inport); + GET_ADDR(outport); + GET_ADDR(EmulateInterruptPM); + GET_ADDR(CallBuiltinHandler); +#undef GET_ADDR +} + + /*********************************************************************** * INSTR_ReplaceSelector * @@ -339,7 +364,8 @@ static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context ) { DWORD res = ~0U; - if (Dosvm.inport || DPMI_LoadDosSystem()) res = Dosvm.inport( port, size ); + if (!DOS_inport) init_winedos(); + if (DOS_inport) res = DOS_inport( port, size ); if (TRACE_ON(io)) { @@ -370,7 +396,8 @@ static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context ) */ static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context ) { - if (Dosvm.outport || DPMI_LoadDosSystem()) Dosvm.outport( port, size, val ); + if (!DOS_outport) init_winedos(); + if (DOS_outport) DOS_outport( port, size, val ); if (TRACE_ON(io)) { @@ -689,14 +716,11 @@ DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context ) case 0xcd: /* int */ if (IS_SELECTOR_SYSTEM(context->SegCs)) break; /* don't emulate it in 32-bit code */ - if (!Dosvm.EmulateInterruptPM && !DPMI_LoadDosSystem()) - { - ERR("could not initialize interrupt handling\n"); - } - else + if (!DOS_EmulateInterruptPM) init_winedos(); + if (DOS_EmulateInterruptPM) { context->Eip += prefixlen + 2; - Dosvm.EmulateInterruptPM( context, instr[1] ); + DOS_EmulateInterruptPM( context, instr[1] ); return ExceptionContinueExecution; } break; /* Unable to emulate it */ @@ -786,4 +810,40 @@ DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context ) return ExceptionContinueSearch; /* Unable to emulate it */ } -#endif /* __i386__ */ + +/*********************************************************************** + * INSTR_CallBuiltinHandler + */ +void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum ) +{ + if (!DOS_CallBuiltinHandler) init_winedos(); + if (DOS_CallBuiltinHandler) DOS_CallBuiltinHandler( context, intnum ); +} + + +/*********************************************************************** + * DOS3Call (KERNEL.102) + */ +void WINAPI DOS3Call( CONTEXT86 *context ) +{ + INSTR_CallBuiltinHandler( context, 0x21 ); +} + + +/*********************************************************************** + * NetBIOSCall (KERNEL.103) + */ +void WINAPI NetBIOSCall16( CONTEXT86 *context ) +{ + INSTR_CallBuiltinHandler( context, 0x5c ); +} + + +/*********************************************************************** + * GetSetKernelDOSProc (KERNEL.311) + */ +FARPROC16 WINAPI GetSetKernelDOSProc16( FARPROC16 DosProc ) +{ + FIXME("(DosProc=0x%08x): stub\n", (UINT)DosProc); + return NULL; +} diff --git a/dlls/kernel/kernel_private.h b/dlls/kernel/kernel_private.h index a38c384cd1b..c53274e228a 100644 --- a/dlls/kernel/kernel_private.h +++ b/dlls/kernel/kernel_private.h @@ -53,17 +53,8 @@ extern BOOL WOWTHUNK_Init(void); extern VOID SYSLEVEL_CheckNotLevel( INT level ); -typedef struct -{ - void (WINAPI *EmulateInterruptPM)( CONTEXT86 *context, BYTE intnum ); - void (WINAPI *CallBuiltinHandler)( CONTEXT86 *context, BYTE intnum ); - - /* I/O functions */ - DWORD (WINAPI *inport)( int port, int size ); - void (WINAPI *outport)( int port, int size, DWORD val ); -} DOSVM_TABLE; - -extern DOSVM_TABLE Dosvm; +extern DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context ); +extern void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum ); /* this structure is always located at offset 0 of the DGROUP segment */ #include "pshpack1.h" diff --git a/dlls/kernel/vxd.c b/dlls/kernel/vxd.c index bb86ab605a7..a760e93233c 100644 --- a/dlls/kernel/vxd.c +++ b/dlls/kernel/vxd.c @@ -1087,8 +1087,7 @@ static DWORD VxDCall_VWin32( DWORD service, CONTEXT86 *context ) SET_AX( context, callnum ); SET_CX( context, parm ); - if(Dosvm.CallBuiltinHandler || DPMI_LoadDosSystem()) - Dosvm.CallBuiltinHandler( context, 0x31 ); + INSTR_CallBuiltinHandler( context, 0x31 ); return LOWORD(context->Eax); } diff --git a/include/miscemu.h b/include/miscemu.h index d11e0a14e94..4c14e653ba7 100644 --- a/include/miscemu.h +++ b/include/miscemu.h @@ -104,12 +104,6 @@ extern LPVOID DOSMEM_MapRealToLinear(DWORD); /* real-mode to linear */ extern LPVOID DOSMEM_MapDosToLinear(UINT); /* linear DOS to Wine */ extern UINT DOSMEM_MapLinearToDos(LPVOID); /* linear Wine to DOS */ -/* memory/instr.c */ -extern DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context ); - -/* msdos/dpmi.c */ -extern BOOL DPMI_LoadDosSystem(void); - #define PTR_REAL_TO_LIN(seg,off) \ ((void*)(((unsigned int)(seg) << 4) + LOWORD(off))) diff --git a/msdos/dpmi.c b/msdos/dpmi.c deleted file mode 100644 index d1693a95f24..00000000000 --- a/msdos/dpmi.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * DPMI 0.9 emulation - * - * Copyright 1995 Alexandre Julliard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" -#include "wine/port.h" - -#include - -#include "windef.h" -#include "winbase.h" -#include "kernel_private.h" -#include "wine/debug.h" -#include "wine/windef16.h" - -WINE_DEFAULT_DEBUG_CHANNEL(int31); - -DOSVM_TABLE Dosvm = { NULL, }; - -static HMODULE DosModule; - -/********************************************************************** - * DPMI_LoadDosSystem - */ -BOOL DPMI_LoadDosSystem(void) -{ - if (DosModule) return TRUE; - DosModule = LoadLibraryA( "winedos.dll" ); - if (!DosModule) { - ERR("could not load winedos.dll, DOS subsystem unavailable\n"); - return FALSE; - } -#define GET_ADDR(func) Dosvm.func = (void *)GetProcAddress(DosModule, #func); - - GET_ADDR(inport); - GET_ADDR(outport); - GET_ADDR(EmulateInterruptPM); - GET_ADDR(CallBuiltinHandler); -#undef GET_ADDR - return TRUE; -} - - -/*********************************************************************** - * NetBIOSCall (KERNEL.103) - * - */ -void WINAPI NetBIOSCall16( CONTEXT86 *context ) -{ - if (Dosvm.CallBuiltinHandler || DPMI_LoadDosSystem()) - Dosvm.CallBuiltinHandler( context, 0x5c ); -} - - -/*********************************************************************** - * DOS3Call (KERNEL.102) - */ -void WINAPI DOS3Call( CONTEXT86 *context ) -{ - if (Dosvm.CallBuiltinHandler || DPMI_LoadDosSystem()) - Dosvm.CallBuiltinHandler( context, 0x21 ); -} - - -/*********************************************************************** - * GetSetKernelDOSProc (KERNEL.311) - */ -FARPROC16 WINAPI GetSetKernelDOSProc16( FARPROC16 DosProc ) -{ - FIXME("(DosProc=0x%08x): stub\n", (UINT)DosProc); - return NULL; -}