diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec index b0d351596cf..e9dd6cf59e5 100644 --- a/dlls/kernel/kernel32.spec +++ b/dlls/kernel/kernel32.spec @@ -1053,8 +1053,7 @@ @ cdecl DOSMEM_GetBlock(long ptr) DOSMEM_GetBlock @ cdecl DOSMEM_GetDPMISegments() DOSMEM_GetDPMISegments @ cdecl DOSMEM_Init(long) DOSMEM_Init -@ stdcall INT_Int25Handler(ptr) INT_Int25Handler -@ stdcall INT_Int26Handler(ptr) INT_Int26Handler +@ cdecl DRIVE_OpenDevice(long long) DRIVE_OpenDevice @ cdecl LOCAL_Alloc(long long long) LOCAL_Alloc @ cdecl LOCAL_Compact(long long long) LOCAL_Compact @ cdecl LOCAL_CountFree(long) LOCAL_CountFree diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index e09aca068ab..c469f5674cb 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -51,8 +51,6 @@ C_SRCS = \ $(TOPOBJDIR)/msdos/dosmem.c \ $(TOPOBJDIR)/msdos/dpmi.c \ $(TOPOBJDIR)/msdos/int21.c \ - $(TOPOBJDIR)/msdos/int25.c \ - $(TOPOBJDIR)/msdos/int26.c \ $(TOPOBJDIR)/msdos/ioports.c \ $(TOPOBJDIR)/msdos/ppdev.c \ $(TOPOBJDIR)/msdos/vxd.c \ diff --git a/dlls/winedos/Makefile.in b/dlls/winedos/Makefile.in index 350e50fd8b7..b6a5ccd7707 100644 --- a/dlls/winedos/Makefile.in +++ b/dlls/winedos/Makefile.in @@ -28,6 +28,8 @@ C_SRCS = \ int1a.c \ int20.c \ int21.c \ + int25.c \ + int26.c \ int29.c \ int2a.c \ int2f.c \ diff --git a/dlls/winedos/dosexe.h b/dlls/winedos/dosexe.h index 306e725053d..f3978d26486 100644 --- a/dlls/winedos/dosexe.h +++ b/dlls/winedos/dosexe.h @@ -148,6 +148,14 @@ extern void WINAPI DOSVM_Int20Handler(CONTEXT86*); /* int21.c */ extern void WINAPI DOSVM_Int21Handler(CONTEXT86*); +/* int25.c */ +BOOL DOSVM_RawRead( BYTE, DWORD, DWORD, BYTE *, BOOL ); +void WINAPI DOSVM_Int25Handler( CONTEXT86 * ); + +/* int26.c */ +BOOL DOSVM_RawWrite( BYTE, DWORD, DWORD, BYTE *, BOOL ); +void WINAPI DOSVM_Int26Handler( CONTEXT86 * ); + /* int29.c */ extern void WINAPI DOSVM_Int29Handler(CONTEXT86*); diff --git a/dlls/winedos/int25.c b/dlls/winedos/int25.c new file mode 100644 index 00000000000..0bcff1dd29b --- /dev/null +++ b/dlls/winedos/int25.c @@ -0,0 +1,112 @@ +/* + * DOS interrupt 25h handler + * + * Copyright 1997 Andreas Mohr + * + * 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 +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include "msdos.h" +#include "miscemu.h" +#include "drive.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(int); + + +/*********************************************************************** + * DOSVM_RawRead + * + * Read raw sectors from a device. + */ +BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success) +{ + int fd; + + if ((fd = DRIVE_OpenDevice( drive, O_RDONLY )) != -1) + { + lseek( fd, begin * 512, SEEK_SET ); + /* FIXME: check errors */ + read( fd, dataptr, nr_sect * 512 ); + close( fd ); + } + else + { + memset( dataptr, 0, nr_sect * 512 ); + if (fake_success) + { + /* FIXME: explain what happens here */ + if (begin == 0 && nr_sect > 1) *(dataptr + 512) = 0xf8; + if (begin == 1) *dataptr = 0xf8; + } + else + return FALSE; + } + + return TRUE; +} + + +/********************************************************************** + * DOSVM_Int25Handler (WINEDOS16.137) + * + * Handler for int 25h (absolute disk read). + */ +void WINAPI DOSVM_Int25Handler( CONTEXT86 *context ) +{ + WCHAR drivespec[4] = {'A', ':', '\\', 0}; + BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx ); + DWORD begin; + DWORD length; + + drivespec[0] += AL_reg( context ); + + if (GetDriveTypeW( drivespec ) == DRIVE_NO_ROOT_DIR || + GetDriveTypeW( drivespec ) == DRIVE_UNKNOWN) + { + SET_CFLAG( context ); + SET_AX( context, 0x0201 ); /* unknown unit */ + return; + } + + if (CX_reg( context ) == 0xffff) + { + begin = *(DWORD *)dataptr; + length = *(WORD *)(dataptr + 4); + dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context, + *(WORD *)(dataptr + 8), + *(DWORD *)(dataptr + 6) ); + } + else + { + begin = DX_reg( context ); + length = CX_reg( context ); + } + + TRACE( "abs diskread, drive %d, sector %ld, " + "count %ld, buffer %p\n", + AL_reg( context ), begin, length, dataptr ); + + DOSVM_RawRead( AL_reg( context ), begin, length, dataptr, TRUE ); + RESET_CFLAG( context ); +} diff --git a/dlls/winedos/int26.c b/dlls/winedos/int26.c new file mode 100644 index 00000000000..4709680d16a --- /dev/null +++ b/dlls/winedos/int26.c @@ -0,0 +1,101 @@ +/* + * DOS interrupt 26h handler + * + * Copyright 1997 Andreas Mohr + * + * 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 +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include "msdos.h" +#include "miscemu.h" +#include "drive.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(int); + + +/*********************************************************************** + * DOSVM_RawWrite + * + * Write raw sectors to a device. + */ +BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success) +{ + int fd; + + if ((fd = DRIVE_OpenDevice( drive, O_RDONLY )) != -1) + { + lseek( fd, begin * 512, SEEK_SET ); + /* FIXME: check errors */ + write( fd, dataptr, nr_sect * 512 ); + close( fd ); + } + else if (!fake_success) + return FALSE; + + return TRUE; +} + + +/********************************************************************** + * DOSVM_Int26Handler (WINEDOS16.138) + * + * Handler for int 26h (absolute disk read). + */ +void WINAPI DOSVM_Int26Handler( CONTEXT86 *context ) +{ + WCHAR drivespec[4] = {'A', ':', '\\', 0}; + BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx ); + DWORD begin; + DWORD length; + + drivespec[0] += AL_reg( context ); + + if (GetDriveTypeW( drivespec ) == DRIVE_NO_ROOT_DIR || + GetDriveTypeW( drivespec ) == DRIVE_UNKNOWN) + { + SET_CFLAG( context ); + SET_AX( context, 0x0201 ); /* unknown unit */ + return; + } + + if (CX_reg( context ) == 0xffff) + { + begin = *(DWORD *)dataptr; + length = *(WORD *)(dataptr + 4); + dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context, + *(WORD *)(dataptr + 8), + *(DWORD *)(dataptr + 6) ); + } + else + { + begin = DX_reg( context ); + length = CX_reg( context ); + } + + TRACE( "abs diskwrite, drive %d, sector %ld, " + "count %ld, buffer %p\n", + AL_reg( context ), begin, length, dataptr ); + + DOSVM_RawWrite( AL_reg( context ), begin, length, dataptr, TRUE ); + RESET_CFLAG( context ); +} diff --git a/dlls/winedos/interrupts.c b/dlls/winedos/interrupts.c index 1706ee4e9c3..8013f0f2dd4 100644 --- a/dlls/winedos/interrupts.c +++ b/dlls/winedos/interrupts.c @@ -24,17 +24,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(int); -/*********************************************************************** - * DOSVM_Int25Handler (WINEDOS16.137) - * DOSVM_Int26Handler (WINEDOS16.138) - * - * FIXME: Interrupt handlers for interrupts implemented in other DLLs. - * These functions should be removed when the interrupt handlers have - * been moved to winedos. - */ -void WINAPI DOSVM_Int25Handler( CONTEXT86 *context ) { INT_Int25Handler(context); } -void WINAPI DOSVM_Int26Handler( CONTEXT86 *context ) { INT_Int26Handler(context); } - static FARPROC16 DOSVM_Vectors16[256]; static FARPROC48 DOSVM_Vectors48[256]; static const INTPROC DOSVM_VectorsBuiltin[] = diff --git a/include/miscemu.h b/include/miscemu.h index 107894710fd..2ebf7af68a6 100644 --- a/include/miscemu.h +++ b/include/miscemu.h @@ -175,6 +175,7 @@ struct DPMI_segments WORD int48_sel; }; +/* msdos/dosmem.c */ extern struct DPMI_segments DOSMEM_dpmi_segments; extern const struct DPMI_segments *DOSMEM_GetDPMISegments(void); @@ -196,17 +197,10 @@ extern BOOL INSTR_EmulateInstruction( CONTEXT86 *context ); extern DWORD IO_inport( int port, int count ); extern void IO_outport( int port, int count, DWORD value ); -/* msdos/int25.c */ -extern void WINAPI INT_Int25Handler(CONTEXT86*); - -/* msdos/int26.c */ -extern void WINAPI INT_Int26Handler(CONTEXT86*); - /* msdos/dpmi.c */ extern BOOL DPMI_LoadDosSystem(void); /* misc/ppdev.c */ - extern BOOL IO_pp_outp(int port, DWORD* res); extern int IO_pp_inp(int port, DWORD* res); extern char IO_pp_init(void); diff --git a/msdos/int25.c b/msdos/int25.c deleted file mode 100644 index 3f83eefc621..00000000000 --- a/msdos/int25.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * DOS interrupt 25h handler - * - * Copyright 1997 Andreas Mohr - * - * 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 -#include -#include -#ifdef HAVE_UNISTD_H -# include -#endif -#include "msdos.h" -#include "miscemu.h" -#include "drive.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(int); - - -/********************************************************************** - * INT_Int25Handler (WPROCS.137) - * - * Handler for int 25h (absolute disk read). - */ -void WINAPI INT_Int25Handler( CONTEXT86 *context ) -{ - BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx ); - DWORD begin, length; - - if (!DRIVE_IsValid(LOBYTE(context->Eax))) - { - SET_CFLAG(context); - SET_AX( context, 0x0201 ); /* unknown unit */ - return; - } - - if (LOWORD(context->Ecx) == 0xffff) - { - begin = *(DWORD *)dataptr; - length = *(WORD *)(dataptr + 4); - dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context, - *(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) ); - } - else - { - begin = LOWORD(context->Edx); - length = LOWORD(context->Ecx); - } - TRACE("int25: abs diskread, drive %d, sector %ld, " - "count %ld, buffer %p\n", - LOBYTE(context->Eax), begin, length, dataptr); - - DRIVE_RawRead(LOBYTE(context->Eax), begin, length, dataptr, TRUE); - RESET_CFLAG(context); -} diff --git a/msdos/int26.c b/msdos/int26.c deleted file mode 100644 index a6b92d6fd89..00000000000 --- a/msdos/int26.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * DOS interrupt 26h handler - * - * Copyright 1997 Andreas Mohr - * - * 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 -#include -#ifdef HAVE_UNISTD_H -# include -#endif -#include "msdos.h" -#include "miscemu.h" -#include "drive.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(int); - -/********************************************************************** - * INT_Int26Handler (WPROCS.138) - * - * Handler for int 26h (absolute disk read). - */ -void WINAPI INT_Int26Handler( CONTEXT86 *context ) -{ - BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx ); - DWORD begin, length; - - if (!DRIVE_IsValid(LOBYTE(context->Eax))) - { - SET_CFLAG(context); - SET_AX( context, 0x0201 ); /* unknown unit */ - return; - } - - if (LOWORD(context->Ecx) == 0xffff) - { - begin = *(DWORD *)dataptr; - length = *(WORD *)(dataptr + 4); - dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context, - *(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) ); - } - else - { - begin = LOWORD(context->Edx); - length = LOWORD(context->Ecx); - } - - TRACE("int26: abs diskwrite, drive %d, sector %ld, " - "count %ld, buffer %p\n", - AL_reg(context), begin, length, dataptr ); - - DRIVE_RawWrite(LOBYTE(context->Eax), begin, length, dataptr, TRUE); - RESET_CFLAG(context); -}