Fixed drive map in the shared user page.
authorEric Kohl <eric.kohl@reactos.org>
Fri, 26 Apr 2002 19:59:25 +0000 (19:59 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Fri, 26 Apr 2002 19:59:25 +0000 (19:59 +0000)
svn path=/trunk/; revision=2871

reactos/apps/tests/dump_shared_data/dump_shared_data.c
reactos/include/napi/shared_data.h
reactos/ntoskrnl/io/xhaldrv.c
reactos/ntoskrnl/ke/main.c

index fd12996..0b4a9e8 100644 (file)
@@ -3,6 +3,49 @@
 
 int main()
 {
+  int i;
+
   printf("TickCountLow: %x\n", 
         SharedUserData->TickCountLow);
+  printf("Drives: ");
+  for (i = 0; i < 26; i++)
+    {
+      printf("%c", (SharedUserData->DosDeviceMap & (1 << i))?'1':'0');
+    }
+  printf("\n");
+  for (i = 0; i < 26; i++)
+    {
+      if (SharedUserData->DosDeviceMap & (1 << i))
+       {
+         printf("%c: ", 'A'+i);
+         switch(SharedUserData->DosDeviceDriveType[i])
+           {
+             case DOSDEVICE_DRIVE_UNKNOWN:
+               printf("Unknown\n");
+               break;
+             case DOSDEVICE_DRIVE_CALCULATE:
+               printf("No root\n");
+               break;
+             case DOSDEVICE_DRIVE_REMOVABLE:
+               printf("Removable\n");
+               break;
+             case DOSDEVICE_DRIVE_FIXED:
+               printf("Fixed\n");
+               break;
+             case DOSDEVICE_DRIVE_REMOTE:
+               printf("Remote\n");
+               break;
+             case DOSDEVICE_DRIVE_CDROM:
+               printf("CD-ROM\n");
+               break;
+             case DOSDEVICE_DRIVE_RAMDISK:
+               printf("Ram disk\n");
+               break;
+             default:
+               printf("undefined type\n");
+               break;
+           }
+       }
+    }
+  printf("\n\n");
 }
index 8b601d2..2387273 100644 (file)
@@ -44,6 +44,16 @@ typedef struct _KUSER_SHARED_DATA
    BOOLEAN KdDebuggerEnabled;
 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
 
+/* Values for DosDeviceDriveType */
+#define DOSDEVICE_DRIVE_UNKNOWN                0
+#define DOSDEVICE_DRIVE_CALCULATE      1
+#define DOSDEVICE_DRIVE_REMOVABLE      2
+#define DOSDEVICE_DRIVE_FIXED          3
+#define DOSDEVICE_DRIVE_REMOTE         4
+#define DOSDEVICE_DRIVE_CDROM          5
+#define DOSDEVICE_DRIVE_RAMDISK                6
+
+
 #define KERNEL_SHARED_DATA     (0xFFDF0000)
 #define USER_SHARED_DATA       (0x7FFE0000)
 
index 2284645..4cbdd36 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xhaldrv.c,v 1.19 2002/04/17 18:26:53 ekohl Exp $
+/* $Id: xhaldrv.c,v 1.20 2002/04/26 19:58:48 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -241,64 +241,65 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
 
 static VOID
 HalpAssignDrive(IN PUNICODE_STRING PartitionName,
-               IN OUT PULONG DriveMap,
-               IN ULONG DriveNumber)
+               IN ULONG DriveNumber,
+               IN UCHAR DriveType)
 {
-   WCHAR DriveNameBuffer[8];
-   UNICODE_STRING DriveName;
-   ULONG i;
+  WCHAR DriveNameBuffer[8];
+  UNICODE_STRING DriveName;
+  ULONG i;
 
-   DPRINT("HalpAssignDrive()\n");
+  DPRINT("HalpAssignDrive()\n");
 
-   if ((DriveNumber != AUTO_DRIVE) && (DriveNumber < 24))
-     {
-       /* force assignment */
-       if ((*DriveMap & (1 << DriveNumber)) != 0)
-         {
-            DbgPrint("Drive letter already used!\n");
-            return;
-         }
-     }
-   else
-     {
-       /* automatic assignment */
-       DriveNumber = AUTO_DRIVE;
+  if ((DriveNumber != AUTO_DRIVE) && (DriveNumber < 24))
+    {
+      /* Force assignment */
+      if ((SharedUserData->DosDeviceMap & (1 << DriveNumber)) != 0)
+       {
+         DbgPrint("Drive letter already used!\n");
+         return;
+       }
+    }
+  else
+    {
+      /* Automatic assignment */
+      DriveNumber = AUTO_DRIVE;
 
-       for (i = 2; i < 24; i++)
-         {
-            if ((*DriveMap & (1 << i)) == 0)
-              {
-                 DriveNumber = i;
-                 break;
-              }
-         }
+      for (i = 2; i < 24; i++)
+       {
+         if ((SharedUserData->DosDeviceMap & (1 << i)) == 0)
+           {
+             DriveNumber = i;
+             break;
+           }
+       }
 
-       if (DriveNumber == AUTO_DRIVE)
-         {
-            DbgPrint("No drive letter available!\n");
-            return;
-         }
-     }
+      if (DriveNumber == AUTO_DRIVE)
+       {
+         DbgPrint("No drive letter available!\n");
+         return;
+       }
+    }
 
-   DPRINT("DriveNumber %d\n", DriveNumber);
+  DPRINT("DriveNumber %d\n", DriveNumber);
 
-   /* set bit in drive map */
-   *DriveMap = *DriveMap | (1 << DriveNumber);
+  /* Update the shared user page */
+  SharedUserData->DosDeviceMap |= (1 << DriveNumber);
+  SharedUserData->DosDeviceDriveType[DriveNumber] = DriveType;
 
-   /* build drive name */
-   swprintf(DriveNameBuffer,
-           L"\\??\\%C:",
-           'A' + DriveNumber);
-   RtlInitUnicodeString(&DriveName,
-                       DriveNameBuffer);
+  /* Build drive name */
+  swprintf(DriveNameBuffer,
+          L"\\??\\%C:",
+          'A' + DriveNumber);
+  RtlInitUnicodeString(&DriveName,
+                      DriveNameBuffer);
 
-   DPRINT("  %wZ ==> %wZ\n",
-         &DriveName,
-         PartitionName);
+  DPRINT("  %wZ ==> %wZ\n",
+        &DriveName,
+        PartitionName);
 
-   /* create symbolic link */
-   IoCreateSymbolicLink(&DriveName,
-                       PartitionName);
+  /* Create symbolic link */
+  IoCreateSymbolicLink(&DriveName,
+                      PartitionName);
 }
 
 
@@ -319,7 +320,6 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
    PWSTR Buffer2;
    ULONG i;
    NTSTATUS Status;
-   ULONG DriveMap = 0;
    ULONG j;
 
    DPRINT("xHalIoAssignDriveLetters()\n");
@@ -445,8 +445,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
 
                  /* assign it */
                  HalpAssignDrive(&UnicodeString2,
-                                 &DriveMap,
-                                 AUTO_DRIVE);
+                                 AUTO_DRIVE,
+                                 DOSDEVICE_DRIVE_FIXED);
               }
          }
      }
@@ -473,8 +473,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
                  DPRINT("  %wZ\n",
                         &UnicodeString2);
                  HalpAssignDrive(&UnicodeString2,
-                                 &DriveMap,
-                                 AUTO_DRIVE);
+                                 AUTO_DRIVE,
+                                 DOSDEVICE_DRIVE_FIXED);
               }
          }
      }
@@ -501,8 +501,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
                                  DPRINT("  %wZ\n",
                                         &UnicodeString2);
                                  HalpAssignDrive(&UnicodeString2,
-                                                 &DriveMap,
-                                                 AUTO_DRIVE);
+                                                 AUTO_DRIVE,
+                                                 DOSDEVICE_DRIVE_FIXED);
                               }
                          }
                }
@@ -528,8 +528,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
            DPRINT("  %wZ\n",
                   &UnicodeString2);
            HalpAssignDrive(&UnicodeString2,
-                           &DriveMap,
-                           AUTO_DRIVE);
+                           AUTO_DRIVE,
+                           DOSDEVICE_DRIVE_REMOVABLE);
          }
      }
 /* TEST END */
@@ -557,8 +557,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
        DPRINT("  %wZ\n",
               &UnicodeString1);
        HalpAssignDrive(&UnicodeString1,
-                       &DriveMap,
-                       (i < 2) ? i : AUTO_DRIVE);
+                       (i < 2) ? i : AUTO_DRIVE,
+                       DOSDEVICE_DRIVE_REMOVABLE);
      }
 
    /* Assign cdrom drives */
@@ -574,8 +574,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
        /* assign first free drive letter */
        DPRINT("  %wZ\n", &UnicodeString1);
        HalpAssignDrive(&UnicodeString1,
-                       &DriveMap,
-                       AUTO_DRIVE);
+                       AUTO_DRIVE,
+                       DOSDEVICE_DRIVE_CDROM);
      }
 
    /* Anything else ?? */
index d983be8..cd3a12d 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: main.c,v 1.118 2002/04/26 13:11:28 ekohl Exp $
+/* $Id: main.c,v 1.119 2002/04/26 19:57:11 ekohl Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/main.c
@@ -561,9 +561,6 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
          }
 
        NtClose (Handle);
-
-       /* set bit in dos drives bitmap (drive available) */
-       SharedUserData->DosDeviceMap |= (1<<i);
      }
 
    RtlFreeUnicodeString (&BootPath);