Commit 6c3ef7e7 authored by Andreas Mohr's avatar Andreas Mohr Committed by Alexandre Julliard

- fix int21 block device read/write

- moved device block access log messages to inner function used by two different places - removed bogus CloseHandle()
parent d324ccfc
......@@ -2408,6 +2408,12 @@ static void CreateBPB(int drive, BYTE *data, BOOL16 limited)
}
}
inline DWORD INT21_Ioctl_CylHeadSect2Lin(DWORD cyl, WORD head, WORD sec, WORD cyl_cnt, WORD head_cnt, WORD sec_cnt)
{
DWORD res = (cyl * head_cnt*sec_cnt + head * sec_cnt + sec);
return res;
}
/***********************************************************************
* INT21_Ioctl_Block
*
......@@ -2462,7 +2468,7 @@ static void INT21_Ioctl_Block( CONTEXT86 *context )
break;
case 0x0d: /* GENERIC BLOCK DEVICE REQUEST */
/* Get pointer to IOCTL parameter block. */
/* Get pointer to IOCTL parameter block */
dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
switch (CX_reg(context))
......@@ -2471,13 +2477,31 @@ static void INT21_Ioctl_Block( CONTEXT86 *context )
TRACE( "GENERIC IOCTL - Write logical device track - %c:\n",
'A' + drive);
{
WORD head = *(WORD *)dataptr+1;
WORD cyl = *(WORD *)dataptr+3;
WORD sect = *(WORD *)dataptr+5;
WORD nrsect = *(WORD *)dataptr+7;
BYTE *data = (BYTE *)dataptr+9; /* FIXME: is this correct? */
WORD head = *(WORD *)(dataptr+1);
WORD cyl = *(WORD *)(dataptr+3);
WORD sect = *(WORD *)(dataptr+5);
WORD nrsect = *(WORD *)(dataptr+7);
BYTE *data = CTX_SEG_OFF_TO_LIN(context, *(WORD *)(dataptr+11), *(WORD *)(dataptr+9));
WORD cyl_cnt, head_cnt, sec_cnt;
/* FIXME: we're faking some values here */
if (drive > 1)
{
/* cyl_cnt = 0x300;
head_cnt = 16;
sec_cnt = 255; */
SET_AX( context, ERROR_WRITE_FAULT );
SET_CFLAG(context);
break;
}
else
{ /* floppy */
cyl_cnt = 80;
head_cnt = 2;
sec_cnt = 18;
}
if (!DOSVM_RawWrite(drive, head*cyl*sect, nrsect, data, FALSE))
if (!DOSVM_RawWrite(drive, INT21_Ioctl_CylHeadSect2Lin(cyl, head, sect, cyl_cnt, head_cnt, sec_cnt), nrsect, data, FALSE))
{
SET_AX( context, ERROR_WRITE_FAULT );
SET_CFLAG(context);
......@@ -2516,13 +2540,28 @@ static void INT21_Ioctl_Block( CONTEXT86 *context )
TRACE( "GENERIC IOCTL - Read logical device track - %c:\n",
'A' + drive);
{
WORD head = *(WORD *)dataptr+1;
WORD cyl = *(WORD *)dataptr+3;
WORD sect = *(WORD *)dataptr+5;
WORD nrsect = *(WORD *)dataptr+7;
BYTE *data = (BYTE *)dataptr+9; /* FIXME: is this correct? */
WORD head = *(WORD *)(dataptr+1);
WORD cyl = *(WORD *)(dataptr+3);
WORD sect = *(WORD *)(dataptr+5);
WORD nrsect = *(WORD *)(dataptr+7);
BYTE *data = CTX_SEG_OFF_TO_LIN(context, *(WORD *)(dataptr+11), *(WORD *)(dataptr+9));
WORD cyl_cnt, head_cnt, sec_cnt;
/* FIXME: we're faking some values here */
if (drive > 1)
{
cyl_cnt = 0x300;
head_cnt = 16;
sec_cnt = 255;
}
else
{ /* floppy */
cyl_cnt = 80;
head_cnt = 2;
sec_cnt = 18;
}
if (!DOSVM_RawRead(drive, head*cyl*sect, nrsect, data, FALSE))
if (!DOSVM_RawRead(drive, INT21_Ioctl_CylHeadSect2Lin(cyl, head, sect, cyl_cnt, head_cnt, sec_cnt), nrsect, data, FALSE))
{
SET_AX( context, ERROR_READ_FAULT );
SET_CFLAG(context);
......@@ -2557,7 +2596,7 @@ static void INT21_Ioctl_Block( CONTEXT86 *context )
break;
case 0x0872:
/* Trail on error implementation */
/* Trial and error implementation */
SET_AX( context, drivetype == DRIVE_UNKNOWN ? 0x0f : 0x01 );
SET_CFLAG(context); /* Seems to be set all the time */
break;
......
......@@ -43,6 +43,10 @@ BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL f
WCHAR root[] = {'\\','\\','.','\\','A',':',0};
HANDLE h;
TRACE( "abs diskread, drive %d, sector %ld, "
"count %ld, buffer %p\n",
drive, begin, nr_sect, dataptr );
root[4] += drive;
h = CreateFileW(root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
......@@ -55,7 +59,6 @@ BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL f
}
else
{
if (h != INVALID_HANDLE_VALUE) CloseHandle(h);
memset( dataptr, 0, nr_sect * 512 );
if (fake_success)
{
......@@ -107,10 +110,6 @@ void WINAPI DOSVM_Int25Handler( CONTEXT86 *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 );
}
......@@ -42,6 +42,10 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL
WCHAR root[] = {'\\','\\','.','\\','A',':',0};
HANDLE h;
TRACE( "abs diskwrite, drive %d, sector %ld, "
"count %ld, buffer %p\n",
drive, begin, nr_sect, dataptr );
root[4] += drive;
h = CreateFileW(root, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
0, NULL);
......@@ -62,7 +66,7 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL
/**********************************************************************
* DOSVM_Int26Handler (WINEDOS16.138)
*
* Handler for int 26h (absolute disk read).
* Handler for int 26h (absolute disk write).
*/
void WINAPI DOSVM_Int26Handler( CONTEXT86 *context )
{
......@@ -95,10 +99,6 @@ void WINAPI DOSVM_Int26Handler( CONTEXT86 *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 );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment