final int21 move (9/11)

György 'Nog' Jeney nog at sdf.lonestar.org
Wed Nov 27 13:35:18 CST 2002


ChangeLog:
 * dlls/winedos/int21.c
 * dlls/winedos/dosexe.h
 * dlls/winedos/winedos.spec
 * msdos/int21.c
 * msdos/dpmi.c
 * include/callback.h
 * include/drive.h
 * files/drive.c
   Move ioctl functions to winedos

nog.

-------------- next part --------------
--- ../readwritewine/include/callback.h	2002-11-21 09:37:00.000000000 +0200
+++ include/callback.h	2002-11-27 16:23:55.000000000 +0200
@@ -34,7 +34,6 @@
     unsigned (WINAPI *GetTimer)( void );
     BOOL (WINAPI *inport)( int port, int size, DWORD *res );
     BOOL (WINAPI *outport)( int port, int size, DWORD val );
-    void (WINAPI *ASPIHandler)( CONTEXT86 *context );
 } DOSVM_TABLE;
 
 extern DOSVM_TABLE Dosvm;
--- ../readwritewine/include/drive.h	2002-08-27 03:13:59.000000000 +0200
+++ include/drive.h	2002-11-27 16:22:25.000000000 +0200
@@ -54,8 +54,6 @@
 extern int DRIVE_Enable( int drive  );
 extern int DRIVE_SetLogicalMapping ( int existing_drive, int new_drive );
 extern int DRIVE_OpenDevice( int drive, int flags );
-extern int DRIVE_RawRead(BYTE drive, DWORD begin, DWORD length, BYTE *dataptr, BOOL fake_success );
-extern int DRIVE_RawWrite(BYTE drive, DWORD begin, DWORD length, BYTE *dataptr, BOOL fake_success );
 extern char *DRIVE_BuildEnv(void);
 
 #endif  /* __WINE_DRIVE_H */
--- ../readwritewine/files/drive.c	2002-10-25 05:32:11.000000000 +0200
+++ files/drive.c	2002-11-27 16:23:11.000000000 +0200
@@ -1225,62 +1225,6 @@
     return open( DOSDrives[drive].device, flags );
 }
 
-
-/***********************************************************************
- *           DRIVE_RawRead
- *
- * Read raw sectors from a device
- */
-int DRIVE_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)
-        {
-	    if (begin == 0 && nr_sect > 1) *(dataptr + 512) = 0xf8;
-	    if (begin == 1) *dataptr = 0xf8;
-	}
-	else
-	    return 0;
-    }
-    return 1;
-}
-
-
-/***********************************************************************
- *           DRIVE_RawWrite
- *
- * Write raw sectors to a device
- */
-int DRIVE_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 0;
-
-    return 1;
-}
-
-
 /***********************************************************************
  *           DRIVE_GetFreeSpace
  */
--- ../readwritewine/dlls/winedos/winedos.spec	2002-11-17 09:47:59.000000000 +0200
+++ dlls/winedos/winedos.spec	2002-11-27 16:23:21.000000000 +0200
@@ -14,4 +14,3 @@
 @ stdcall GetTimer() DOSVM_GetTimer
 @ stdcall inport(long long ptr) DOSVM_inport
 @ stdcall outport(long long long) DOSVM_outport
-@ stdcall ASPIHandler(ptr) DOSVM_ASPIHandler
--- ../readwritewine/msdos/dpmi.c	2002-11-25 08:58:13.000000000 +0200
+++ msdos/dpmi.c	2002-11-27 16:23:36.000000000 +0200
@@ -49,7 +49,6 @@
     GET_ADDR(GetTimer);
     GET_ADDR(inport);
     GET_ADDR(outport);
-    GET_ADDR(ASPIHandler);
     GET_ADDR(EmulateInterruptPM);
     GET_ADDR(CallBuiltinHandler);
 #undef GET_ADDR
--- msdos/int21.c.8	2002-11-27 16:10:44.000000000 +0200
+++ msdos/int21.c	2002-11-27 16:31:38.000000000 +0200
@@ -76,182 +76,6 @@
 
 extern char TempDirectory[];
 
-void CreateBPB(int drive, BYTE *data, BOOL16 limited)
-/* limited == TRUE is used with INT 0x21/0x440d */
-{
-	if (drive > 1) {
-		setword(data, 512);
-		data[2] = 2;
-		setword(&data[3], 0);
-		data[5] = 2;
-		setword(&data[6], 240);
-		setword(&data[8], 64000);
-		data[0x0a] = 0xf8;
-		setword(&data[0x0b], 40);
-		setword(&data[0x0d], 56);
-		setword(&data[0x0f], 2);
-		setword(&data[0x11], 0);
-		if (!limited) {
-		    setword(&data[0x1f], 800);
-		    data[0x21] = 5;
-		    setword(&data[0x22], 1);
-		}
-	} else { /* 1.44mb */
-		setword(data, 512);
-		data[2] = 2;
-		setword(&data[3], 0);
-		data[5] = 2;
-		setword(&data[6], 240);
-		setword(&data[8], 2880);
-		data[0x0a] = 0xf8;
-		setword(&data[0x0b], 6);
-		setword(&data[0x0d], 18);
-		setword(&data[0x0f], 2);
-		setword(&data[0x11], 0);
-		if (!limited) {
-		    setword(&data[0x1f], 80);
-		    data[0x21] = 7;
-		    setword(&data[0x22], 2);
-		}
-	}
-}
-
-static void ioctlGetDeviceInfo( CONTEXT86 *context )
-{
-    int curr_drive;
-    const DOS_DEVICE *dev;
-
-    TRACE("(%d)\n", BX_reg(context));
-
-    RESET_CFLAG(context);
-
-    /* DOS device ? */
-    if ((dev = DOSFS_GetDeviceByHandle( DosFileHandleToWin32Handle(BX_reg(context)) )))
-    {
-        SET_DX( context, dev->flags );
-        return;
-    }
-
-    /* it seems to be a file */
-    curr_drive = DRIVE_GetCurrentDrive();
-    SET_DX( context, 0x0140 + curr_drive + ((curr_drive > 1) ? 0x0800 : 0) );
-    /* no floppy */
-    /* bits 0-5 are current drive
-     * bit 6 - file has NOT been written..FIXME: correct?
-     * bit 8 - generate int24 if no diskspace on write/ read past end of file
-     * bit 11 - media not removable
-     * bit 14 - don't set file date/time on closing
-     * bit 15 - file is remote
-     */
-}
-
-static BOOL ioctlGenericBlkDevReq( CONTEXT86 *context )
-{
-	BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
-	int drive = DOS_GET_DRIVE( BL_reg(context) );
-
-	if (!DRIVE_IsValid(drive))
-        {
-            SetLastError( ERROR_FILE_NOT_FOUND );
-            return TRUE;
-	}
-
-	if (CH_reg(context) != 0x08)
-        {
-            INT_BARF( context, 0x21 );
-            return FALSE;
-	}
-
-	switch (CL_reg(context))
-	{
-		case 0x4a: /* lock logical volume */
-			TRACE("lock logical volume (%d) level %d mode %d\n",drive,BH_reg(context),DX_reg(context));
-			break;
-
-		case 0x60: /* get device parameters */
-			   /* used by w4wgrp's winfile */
-			memset(dataptr, 0, 0x20); /* DOS 6.22 uses 0x20 bytes */
-			dataptr[0] = 0x04;
-			dataptr[6] = 0; /* media type */
-			if (drive > 1)
-			{
-				dataptr[1] = 0x05; /* fixed disk */
-				setword(&dataptr[2], 0x01); /* non removable */
-				setword(&dataptr[4], 0x300); /* # of cylinders */
-			}
-			else
-			{
-				dataptr[1] = 0x07; /* block dev, floppy */
-				setword(&dataptr[2], 0x02); /* removable */
-				setword(&dataptr[4], 80); /* # of cylinders */
-			}
-			CreateBPB(drive, &dataptr[7], TRUE);
-			RESET_CFLAG(context);
-			break;
-
-		case 0x41: /* write logical device track */
-		case 0x61: /* read logical device track */
-			{
-				BYTE drive = BL_reg(context) ?
-						BL_reg(context) : DRIVE_GetCurrentDrive();
-				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;
-				int (*raw_func)(BYTE, DWORD, DWORD, BYTE *, BOOL);
-
-				raw_func = (CL_reg(context) == 0x41) ?
-								DRIVE_RawWrite : DRIVE_RawRead;
-
-				if (raw_func(drive, head*cyl*sect, nrsect, data, FALSE))
-					RESET_CFLAG(context);
-				else
-				{
-					SET_AX( context, 0x1e ); /* read fault */
-					SET_CFLAG(context);
-				}
-			}
-			break;
-		case 0x66:/*  get disk serial number */
-			{
-				char	label[12],fsname[9],path[4];
-				DWORD	serial;
-
-				strcpy(path,"x:\\");path[0]=drive+'A';
-				GetVolumeInformationA(
-					path,label,12,&serial,NULL,NULL,fsname,9
-				);
-				*(WORD*)dataptr		= 0;
-				memcpy(dataptr+2,&serial,4);
-				memcpy(dataptr+6,label	,11);
-				memcpy(dataptr+17,fsname,8);
-			}
-			break;
-
-		case 0x6a:
-			TRACE("logical volume %d unlocked.\n",drive);
-			break;
-
-		case 0x6f:
-			memset(dataptr+1, '\0', dataptr[0]-1);
-			dataptr[1] = dataptr[0];
-			dataptr[2] = 0x07; /* protected mode driver; no eject; no notification */
-			dataptr[3] = 0xFF; /* no physical drive */
-			break;
-
-		case 0x72:
-			/* Trail on error implementation */
-			SET_AX( context, GetDriveType16(BL_reg(context)) == DRIVE_UNKNOWN ? 0x0f : 0x01 );
-			SET_CFLAG(context);	/* Seems to be set all the time */
-			break;
-
-		default:
-                        INT_BARF( context, 0x21 );
-	}
-	return FALSE;
-}
-
 /* Many calls translate a drive argument like this:
    drive number (00h = default, 01h = A:, etc)
    */
@@ -338,17 +162,6 @@
      }
 }
 
-
-static void ASPI_DOS_HandleInt( CONTEXT86 *context )
-{
-    if (!Dosvm.ASPIHandler && !DPMI_LoadDosSystem())
-    {
-        ERR("could not setup ASPI handler\n");
-        return;
-    }
-    Dosvm.ASPIHandler( context );
-}
-
 /***********************************************************************
  *           DOS3Call         (KERNEL.102)
  *           INT_Int21Handler (WPROCS.133)
@@ -384,91 +197,6 @@
     case 0x44: /* IOCTL */
         switch (AL_reg(context))
         {
-        case 0x00:
-            ioctlGetDeviceInfo(context);
-            break;
-
-        case 0x01:
-            break;
-        case 0x02:{
-            const DOS_DEVICE *dev;
-            static const WCHAR scsimgrW[] = {'S','C','S','I','M','G','R','$',0};
-            if ((dev = DOSFS_GetDeviceByHandle( DosFileHandleToWin32Handle(BX_reg(context)) )) &&
-                !strcmpiW( dev->name, scsimgrW ))
-            {
-                ASPI_DOS_HandleInt(context);
-            }
-            break;
-       }
-	case 0x05:{	/* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */
-	    /*BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);*/
-	    int	drive = DOS_GET_DRIVE(BL_reg(context));
-
-	    FIXME("program tried to write to block device control channel of drive %d:\n",drive);
-	    /* for (i=0;i<CX_reg(context);i++)
-	    	fprintf(stdnimp,"%02x ",dataptr[i]);
-	    fprintf(stdnimp,"\n");*/
-	    SET_AX( context, context->Ecx );
-	    break;
-	}
-        case 0x08:   /* Check if drive is removable. */
-            TRACE("IOCTL - CHECK IF BLOCK DEVICE REMOVABLE for drive %s\n",
-		 INT21_DriveName( BL_reg(context)));
-            switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
-            {
-            case DRIVE_UNKNOWN:
-                SetLastError( ERROR_INVALID_DRIVE );
-                SET_AX( context, ERROR_INVALID_DRIVE );
-                SET_CFLAG(context);
-                break;
-            case DRIVE_REMOVABLE:
-                SET_AX( context, 0 );      /* removable */
-                break;
-            default:
-                SET_AX( context, 1 );   /* not removable */
-                break;
-            }
-            break;
-
-        case 0x09:   /* CHECK IF BLOCK DEVICE REMOTE */
-            TRACE("IOCTL - CHECK IF BLOCK DEVICE REMOTE for drive %s\n",
-		 INT21_DriveName( BL_reg(context)));
-            switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
-            {
-            case DRIVE_UNKNOWN:
-                SetLastError( ERROR_INVALID_DRIVE );
-                SET_AX( context, ERROR_INVALID_DRIVE );
-                SET_CFLAG(context);
-                break;
-            case DRIVE_REMOTE:
-                SET_DX( context, (1<<9) | (1<<12) );  /* remote */
-                break;
-            default:
-                SET_DX( context, 0 );  /* FIXME: use driver attr here */
-                break;
-            }
-            break;
-
-        case 0x0a: /* check if handle (BX) is remote */
-            TRACE("IOCTL - CHECK IF HANDLE %d IS REMOTE\n",BX_reg(context));
-            /* returns DX, bit 15 set if remote, bit 14 set if date/time
-             * not set on close
-             */
-            SET_DX( context, 0 );
-            break;
-
-        case 0x0d:
-            TRACE("IOCTL - GENERIC BLOCK DEVICE REQUEST %s\n",
-		  INT21_DriveName( BL_reg(context)));
-            bSetDOSExtendedError = ioctlGenericBlkDevReq(context);
-            break;
-
-	case 0x0e: /* get logical drive mapping */
-            TRACE("IOCTL - GET LOGICAL DRIVE MAP for drive %s\n",
-		  INT21_DriveName( BL_reg(context)));
-	    SET_AL( context, 0 ); /* drive has no mapping - FIXME: may be wrong*/
-	    break;
-
         case 0x0F:   /* Set logical drive mapping */
 	    {
 	    int drive;
@@ -483,20 +211,6 @@
             break;
 	    }
 
-        case 0xe0:  /* Sun PC-NFS API */
-            /* not installed */
-            break;
-
-	case 0x52:  /* DR-DOS version */
-            /* This is not DR-DOS */
-
-            TRACE("GET DR-DOS VERSION requested\n");
-
-            SET_AX( context, 0x0001 ); /* Invalid function */
-            SET_CFLAG(context);       /* Error */
-            SetLastError( ERROR_INVALID_FUNCTION );
-            break;
-
         default:
             INT_BARF( context, 0x21 );
             break;
--- dlls/winedos/int21.c.8	2002-11-27 16:10:54.000000000 +0200
+++ dlls/winedos/int21.c	2002-11-27 16:30:39.000000000 +0200
@@ -1008,36 +1008,340 @@
     return 1;
 }
 
-void WINAPI DOSVM_Int21Handler_Ioctl( CONTEXT86 *context )
+/***********************************************************************
+ *                     CreateBPB [internal]
+ *
+ * Haven't fealt like figuring out what this actually does...
+ *
+ * PARAMS:
+ *   drive [?]: ???
+ *   data [?]: ???
+ *   limited [I]: ???
+ *
+ * RETURNS:
+ *   Nothing.
+ */
+void CreateBPB(int drive, BYTE *data, BOOL16 limited)
+/* limited == TRUE is used with INT 0x21/0x440d */
 {
-  static const WCHAR emmxxxx0W[] = {'E','M','M','X','X','X','X','0',0};
-  const DOS_DEVICE *dev = DOSFS_GetDeviceByHandle(
-      DosFileHandleToWin32Handle(BX_reg(context)) );
-
-  if (dev && !strcmpiW( dev->name, emmxxxx0W )) {
-    EMS_Ioctl_Handler(context);
-    return;
-  }
-
-  switch (AL_reg(context))
-  {
-  case 0x0b: /* SET SHARING RETRY COUNT */
-      TRACE("IOCTL - SET SHARING RETRY COUNT pause %d retries %d\n",
-           CX_reg(context), DX_reg(context));
-      if (!CX_reg(context))
-      {
-         SET_AX( context, 1 );
-         SET_CFLAG(context);
+    if(drive > 1) {
+        setword(data, 512);
+        data[2] = 2;
+        setword(&data[3], 0);
+        data[5] = 2;
+        setword(&data[6], 240);
+        setword(&data[8], 64000);
+        data[0x0a] = 0xf8;
+        setword(&data[0x0b], 40);
+        setword(&data[0x0d], 56);
+        setword(&data[0x0f], 2);
+        setword(&data[0x11], 0);
+        if(!limited) {
+            setword(&data[0x1f], 800);
+            data[0x21] = 5;
+            setword(&data[0x22], 1);
+        }
+    } else { /* 1.44mb */
+        setword(data, 512);
+        data[2] = 2;
+        setword(&data[3], 0);
+        data[5] = 2;
+        setword(&data[6], 240);
+        setword(&data[8], 2880);
+        data[0x0a] = 0xf8;
+        setword(&data[0x0b], 6);
+        setword(&data[0x0d], 18);
+        setword(&data[0x0f], 2);
+        setword(&data[0x11], 0);
+        if(!limited) {
+            setword(&data[0x1f], 80);
+            data[0x21] = 7;
+           setword(&data[0x22], 2);
+        }
+    }
+}
+
+/***********************************************************************
+ *                     DOSVM_Int21Handle_Ioctl [internal]
+ *
+ * Handles dos ioctl requests.
+ *
+ * PARAMS:
+ *   context [I]: Pointer to structure holding registers.
+ *
+ * RETURNS:
+ *   Nothing.
+ *
+ * NOTES:
+ *   There is only one place that DOSFS_GetDeviceByHandle is called but it is
+ *   a the center of most ioctls.  I didn't find a windows funciton to get the
+ *   name of a device. How can we implement this properly?
+ */
+void WINAPI DOSVM_Int21Handler_Ioctl(CONTEXT86 *context)
+{
+    static const WCHAR emmxxxx0W[] = {'E','M','M','X','X','X','X','0',0};
+    const DOS_DEVICE *dev = DOSFS_GetDeviceByHandle(
+                                   DosFileHandleToWin32Handle(BX_reg(context)));    int curr_drive;
+
+    if(dev && !strcmpiW(dev->name, emmxxxx0W)) {
+        EMS_Ioctl_Handler(context);
+        return;
+    }
+
+    switch (AL_reg(context)) {
+    case 0x00: /* GET DEVICE INFO */
+        TRACE("IOCTL - GET DEVICE INFO handle: %d\n", BX_reg(context));
+
+        /* DOS device ? */
+        if(dev) {
+            SET_DX(context, dev->flags);
+            return;
+        }
+
+        /* it seems to be a file */
+        curr_drive = GetDosDrive(0);
+        SET_DX(context, 0x0140 + curr_drive + ((curr_drive > 1) ? 0x0800 : 0));
+         /* no floppy */
+         /* bits 0-5 are current drive
+          * bit 6 - file has NOT been written..FIXME: correct?
+          * bit 8- generate int24 if no diskspace on write/read past end of file          * bit 11 - media not removable
+          * bit 14 - don't set file date/time on closing
+          * bit 15 - file is remote
+          */
          break;
-      }
-      DOSMEM_LOL()->sharing_retry_delay = CX_reg(context);
-      if (!DX_reg(context))
-         DOSMEM_LOL()->sharing_retry_count = DX_reg(context);
-      RESET_CFLAG(context);
-      break;
-  default:
-      DOS3Call( context );
-  }
+
+    case 0x01: /* SET DEVICE INFORMATION */
+        FIXME("IOCTL - SET DEVICE INFORMATION\n");
+        break;
+
+    case 0x02: /* READ FROM CHARACTER DEVICE */
+        TRACE("IOCTL - READ FROM CHARACTER DEVICE\n");
+        {
+            static const WCHAR scsimgrW[] = {'S','C','S','I','M','G','R','$',0};            if(dev && !strcmpiW(dev->name, scsimgrW)) {
+                DOSVM_ASPIHandler(context);
+            } else
+                FIXME("IOCTL - Reading from char device: %s not implemented\n",
+                      debugstr_w(dev->name));
+        }
+        break;
+
+    case 0x05: /* WRITE TO BLOCK DEVICE CONTROL CHANNEL */
+        {
+            /*BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs,
+                                                 context->Edx);*/
+            FIXME("IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL drive: %d\n",
+                  BX_reg(context));
+            /* for (i=0;i<CX_reg(context);i++)
+                fprintf(stdnimp,"%02x ",dataptr[i]);
+            fprintf(stdnimp,"\n");*/
+            SET_AX(context, context->Ecx);
+            break;
+        }
+
+    case 0x08: /* Check if drive is removable. */
+        {
+            char driveA[] = "A:\\";
+            TRACE("IOCTL - CHECK IF BLOCK DEVICE REMOVABLE for drive %s\n",
+                  INT21_DriveName(BL_reg(context)));
+            *driveA += GetDosDrive(BL_reg(context));
+
+            switch(GetDriveTypeA(driveA)) {
+            case DRIVE_UNKNOWN:
+                SetLastError(ERROR_INVALID_DRIVE);
+                SET_AX(context, ERROR_INVALID_DRIVE);
+                SET_CFLAG(context);
+                break;
+            case DRIVE_REMOVABLE:
+                SET_AX(context, 0); /* removable */
+                break;
+            default:
+                SET_AX(context, 1); /* not removable */
+                break;
+            }
+        }
+        break;
+
+    case 0x09: /* CHECK IF BLOCK DEVICE REMOTE */
+        {
+            char driveA[] = "A:\\";
+            TRACE("IOCTL - CHECK IF BLOCK DEVICE REMOTE for drive %s\n",
+                 INT21_DriveName( BL_reg(context)));
+
+            *driveA += GetDosDrive(BL_reg(context));
+            switch(GetDriveTypeA(driveA)) {
+            case DRIVE_UNKNOWN:
+                SetLastError(ERROR_INVALID_DRIVE);
+                SET_AX(context, ERROR_INVALID_DRIVE);
+                SET_CFLAG(context);
+                break;
+            case DRIVE_REMOTE:
+                SET_DX(context, (1 << 9) | (1 << 12));  /* remote */
+                break;
+            default:
+                SET_DX(context, 0); /* FIXME: use driver attr here */
+                break;
+            }
+        }
+        break;
+
+    case 0x0a: /* check if handle (BX) is remote */
+        TRACE("IOCTL - CHECK IF HANDLE %d IS REMOTE\n",BX_reg(context));
+        /* returns DX, bit 15 set if remote, bit 14 set if date/time
+         * not set on close
+         */
+        SET_DX(context, 0);
+        break;
+
+    case 0x0b: /* SET SHARING RETRY COUNT */
+        TRACE("IOCTL - SET SHARING RETRY COUNT pause %d retries %d\n",
+             CX_reg(context), DX_reg(context));
+        if(!CX_reg(context)) {
+            SET_AX(context, 1);
+            SET_CFLAG(context);
+            break;
+        }
+        DOSMEM_LOL()->sharing_retry_delay = CX_reg(context);
+        if(!DX_reg(context))
+            DOSMEM_LOL()->sharing_retry_count = DX_reg(context);
+        RESET_CFLAG(context);
+        break;
+
+    case 0x0d: /* GENERIC BLOCK DEVICE REQUEST */
+        TRACE("IOCTL - GENERIC BLOCK DEVICE REQUEST %s\n",
+              INT21_DriveName(BL_reg(context)));
+        {
+            BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs,
+                                               context->Edx);
+            int drive = GetDosDrive(BL_reg(context));
+
+            if(!IsDriveValid(drive)) {
+                SetLastError(ERROR_FILE_NOT_FOUND);
+                break;
+            }
+
+            if(CH_reg(context) != 0x08) {
+                INT_BARF(context, 0x21);
+                break;
+            }
+
+            switch (CL_reg(context)) {
+            case 0x4a: /* lock logical volume */
+                /* We could open the device and send a FSCTL_LOCK_VOLUME ictl
+                 * but the problem is that we would have to keep the device
+                 * open till it needs to be unlocked.  If we close the device
+                 * then it will become unlocked...*/
+                FIXME("lock logical volume (%d) level %d mode %d\n", drive,
+                      BH_reg(context), DX_reg(context));
+                break;
+
+            case 0x60: /* get device parameters */
+                       /* used by w4wgrp's winfile */
+                memset(dataptr, 0, 0x20); /* DOS 6.22 uses 0x20 bytes */
+                dataptr[0] = 0x04;
+                dataptr[6] = 0; /* media type */
+                if(drive > 1) {
+                    dataptr[1] = 0x05; /* fixed disk */
+                    setword(&dataptr[2], 0x01); /* non removable */
+                    setword(&dataptr[4], 0x300); /* # of cylinders */
+                } else {
+                    dataptr[1] = 0x07; /* block dev, floppy */
+                    setword(&dataptr[2], 0x02); /* removable */
+                    setword(&dataptr[4], 80); /* # of cylinders */
+                }
+                CreateBPB(drive, &dataptr[7], TRUE);
+                RESET_CFLAG(context);
+                break;
+
+            case 0x41: /* write logical device track */
+            case 0x61: /* read logical device track */
+                TRACE("%s logical device track\n", (CL_reg(context) == 0x41) ?
+                      "Write" : "Read");
+                {
+                    BYTE drive = GetDosDrive(BL_reg(context));
+                    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;
+                    int (*raw_func)(BYTE, DWORD, DWORD, BYTE *, BOOL);
+
+                    raw_func = (CL_reg(context) == 0x41) ? DOSVM_RawWrite :
+                                                                  DOSVM_RawRead;
+                    if(raw_func(drive, head*cyl*sect, nrsect, data, FALSE))
+                        RESET_CFLAG(context);
+                    else {
+                        SET_AX(context, 0x1e); /* read fault */
+                        SET_CFLAG(context);
+                    }
+                }
+                break;
+
+            case 0x66: /* get disk serial number */
+                {
+                    char label[12], fsname[9], path[4];
+                    DWORD serial;
+
+                    TRACE("Get disk serial number\n");
+
+                    strcpy(path, "x:\\");
+                    path[0] = drive + 'A';
+                    GetVolumeInformationA(path, label, 12, &serial, NULL, NULL,
+                                          fsname, 9);
+                    *(WORD*)dataptr = 0;
+                    memcpy(dataptr + 2, &serial, 4);
+                    memcpy(dataptr + 6, label, 11);
+                    memcpy(dataptr + 17, fsname, 8);
+                }
+                break;
+
+            case 0x6a:
+                /* We could use the FSCTL_UNLOCK_VOLUME ioctl. See the comment
+                 * in Lock logical volume */
+                FIXME("Unlock logical volume %d\n", drive);
+                break;
+
+            case 0x6f:
+                memset(dataptr+1, '\0', dataptr[0]-1);
+                dataptr[1] = dataptr[0];
+                dataptr[2] = 0x07; /* protected mode driver; no eject; no notification */
+                dataptr[3] = 0xFF; /* no physical drive */
+                break;
+
+            case 0x72:
+                {
+                    char driveA[] = "A:\\";
+                    /* Trail on error implementation */
+                    *driveA += GetDosDrive(BL_reg(context));
+                    SET_AX(context, GetDriveTypeA(driveA) == DRIVE_UNKNOWN ?
+                                                                   0x0f : 0x01);                    SET_CFLAG(context); /* Seems to be set all the time */
+                }
+                break;
+
+            default:
+                INT_BARF( context, 0x21 );
+            }
+        }
+
+    case 0x0e: /* get logical drive mapping */
+        TRACE("IOCTL - GET LOGICAL DRIVE MAP for drive %s\n",
+              INT21_DriveName( BL_reg(context)));
+        SET_AL(context, 0); /* drive has no mapping - FIXME: may be wrong */
+        break;
+
+    case 0x52:  /* DR-DOS version */
+        /* This is not DR-DOS */
+
+        TRACE("GET DR-DOS VERSION requested\n");
+
+        SET_AX(context, 0x0001); /* Invalid function */
+        SET_CFLAG(context); /* Error */
+        SetLastError(ERROR_INVALID_FUNCTION);
+        break;
+
+    default:
+        DOS3Call(context);
+        break;
+    }
 }
 
 /***********************************************************************
--- dlls/winedos/dosexe.h.0	2002-11-27 18:18:54.000000000 +0200
+++ dlls/winedos/dosexe.h	2002-11-27 18:21:08.000000000 +0200
@@ -79,6 +79,9 @@
 extern UINT WINAPI DOSVM_GetTimer( void );
 extern void DOSVM_RealModeInterrupt( BYTE intnum, CONTEXT86 *context );
 
+/* dosaspi.c */
+extern void WINAPI DOSVM_ASPIHandler( CONTEXT86 *context );
+
 /* dosconf.c */
 extern DOSCONF *DOSCONF_GetConfig();
 



More information about the wine-patches mailing list