int25.c 2.09 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2
/*
 * DOS interrupt 25h handler
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * 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
Alexandre Julliard's avatar
Alexandre Julliard committed
19 20
 */

21 22
#include "config.h"

Alexandre Julliard's avatar
Alexandre Julliard committed
23
#include <stdlib.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
24
#include <string.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
25
#include <fcntl.h>
26 27 28
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
29
#include "msdos.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
30
#include "miscemu.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
31
#include "drive.h"
32
#include "wine/debug.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
33

34
WINE_DEFAULT_DEBUG_CHANNEL(int);
35

36

Alexandre Julliard's avatar
Alexandre Julliard committed
37
/**********************************************************************
38
 *	    INT_Int25Handler (WPROCS.137)
Alexandre Julliard's avatar
Alexandre Julliard committed
39 40 41
 *
 * Handler for int 25h (absolute disk read).
 */
42
void WINAPI INT_Int25Handler( CONTEXT86 *context )
Alexandre Julliard's avatar
Alexandre Julliard committed
43
{
44
    BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
Alexandre Julliard's avatar
Alexandre Julliard committed
45
    DWORD begin, length;
Alexandre Julliard's avatar
Alexandre Julliard committed
46

47
    if (!DRIVE_IsValid(LOBYTE(context->Eax)))
Alexandre Julliard's avatar
Alexandre Julliard committed
48
    {
Alexandre Julliard's avatar
Alexandre Julliard committed
49
        SET_CFLAG(context);
50
        SET_AX( context, 0x0201 );        /* unknown unit */
Alexandre Julliard's avatar
Alexandre Julliard committed
51 52
        return;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
53

54
    if (LOWORD(context->Ecx) == 0xffff)
Alexandre Julliard's avatar
Alexandre Julliard committed
55
    {
Alexandre Julliard's avatar
Alexandre Julliard committed
56 57
        begin   = *(DWORD *)dataptr;
        length  = *(WORD *)(dataptr + 4);
58
        dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
59
					*(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
Alexandre Julliard's avatar
Alexandre Julliard committed
60 61 62
    }
    else
    {
63 64
        begin  = LOWORD(context->Edx);
        length = LOWORD(context->Ecx);
Alexandre Julliard's avatar
Alexandre Julliard committed
65
    }
66
    TRACE("int25: abs diskread, drive %d, sector %ld, "
67
                 "count %ld, buffer %p\n",
68
          LOBYTE(context->Eax), begin, length, dataptr);
Alexandre Julliard's avatar
Alexandre Julliard committed
69

70
    DRIVE_RawRead(LOBYTE(context->Eax), begin, length, dataptr, TRUE);
Alexandre Julliard's avatar
Alexandre Julliard committed
71
    RESET_CFLAG(context);
Alexandre Julliard's avatar
Alexandre Julliard committed
72
}