[USETUP]
authorEric Kohl <eric.kohl@reactos.org>
Sat, 7 Jun 2014 20:02:26 +0000 (20:02 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 7 Jun 2014 20:02:26 +0000 (20:02 +0000)
Implement scolling through the list of logical partitions. Multiple disks are not supported yet.

svn path=/trunk/; revision=63547

reactos/base/setup/usetup/interface/usetup.c
reactos/base/setup/usetup/partlist.c
reactos/base/setup/usetup/partlist.h

index e2c394c..7bc2564 100644 (file)
@@ -1581,12 +1581,14 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
                  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN))  /* DOWN */
         {
         else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
                  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN))  /* DOWN */
         {
-            ScrollDownPartitionList(PartitionList);
+            if (ScrollDownPartitionList(PartitionList))
+                DrawPartitionList(PartitionList);
         }
         else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
                  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP))  /* UP */
         {
         }
         else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
                  (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP))  /* UP */
         {
-            ScrollUpPartitionList(PartitionList);
+            if (ScrollUpPartitionList(PartitionList))
+                DrawPartitionList(PartitionList);
         }
         else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN)  /* ENTER */
         {
         }
         else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN)  /* ENTER */
         {
index 61b93a2..b8aad4a 100644 (file)
@@ -1174,6 +1174,29 @@ AddDiskToList(
         DumpPartitionTable(DiskEntry);
 #endif
 
         DumpPartitionTable(DiskEntry);
 #endif
 
+        if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart != 0 &&
+            DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionLength.QuadPart != 0 &&
+            DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionType != 0)
+        {
+            if ((DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector) % DiskEntry->SectorsPerTrack == 0)
+            {
+                DPRINT1("Use %lu Sector alignment!\n", DiskEntry->SectorsPerTrack);
+            }
+            else if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart % 1048756 == 0)
+            {
+                DPRINT1("Use megabyte (%lu Sectors) alignment!\n", 1048756 / DiskEntry->BytesPerSector);
+            }
+            else
+            {
+                DPRINT1("No matching aligment found! Partiton 1 starts at %I64u\n", DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart);
+            }
+        }
+        else
+        {
+            DPRINT1("No valid partiton table found! Use megabyte (%lu Sectors) alignment!\n", 1048756 / DiskEntry->BytesPerSector);
+        }
+
+
         if (DiskEntry->LayoutBuffer->PartitionCount == 0)
         {
             DiskEntry->NewDisk = TRUE;
         if (DiskEntry->LayoutBuffer->PartitionCount == 0)
         {
             DiskEntry->NewDisk = TRUE;
@@ -1986,33 +2009,80 @@ SelectPartition(
 }
 
 
 }
 
 
-VOID
+BOOL
 ScrollDownPartitionList(
     PPARTLIST List)
 {
 //    PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 ScrollDownPartitionList(
     PPARTLIST List)
 {
 //    PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
-//    PLIST_ENTRY Entry1;
-    PLIST_ENTRY Entry2;
+    PLIST_ENTRY Entry;
 
     /* Check for empty disks */
     if (IsListEmpty(&List->DiskListHead))
 
     /* Check for empty disks */
     if (IsListEmpty(&List->DiskListHead))
-        return;
+        return FALSE;
+
 
     /* Check for next usable entry on current disk */
     if (List->CurrentPartition != NULL)
     {
 
     /* Check for next usable entry on current disk */
     if (List->CurrentPartition != NULL)
     {
-        Entry2 = List->CurrentPartition->ListEntry.Flink;
-        if (Entry2 != &List->CurrentDisk->PrimaryPartListHead)
+        if (List->CurrentPartition->LogicalPartition)
         {
         {
-            PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
+            /* Logical partition */
 
 
-            List->CurrentPartition = PartEntry;
-            DrawPartitionList(List);
-            return;
+            Entry = List->CurrentPartition->ListEntry.Flink;
+            if (Entry != &List->CurrentDisk->LogicalPartListHead)
+            {
+                /* Next logical partition */
+                PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+
+                List->CurrentPartition = PartEntry;
+                return TRUE;
+            }
+            else
+            {
+                Entry = List->CurrentDisk->ExtendedPartition->ListEntry.Flink;
+                if (Entry != &List->CurrentDisk->PrimaryPartListHead)
+                {
+                    PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+
+                    List->CurrentPartition = PartEntry;
+                    return TRUE;
+                }
+            }
+        }
+        else
+        {
+            /* Primary or extended partition */
+
+            if (IsContainerPartition(List->CurrentPartition->PartitionType))
+            {
+                /* First logical partition */
+                Entry = List->CurrentDisk->LogicalPartListHead.Flink;
+                if (Entry != &List->CurrentDisk->LogicalPartListHead)
+                {
+                    PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+
+                    List->CurrentPartition = PartEntry;
+                    return TRUE;
+                }
+            }
+            else
+            {
+                /* Next primary partition */
+                Entry = List->CurrentPartition->ListEntry.Flink;
+                if (Entry != &List->CurrentDisk->PrimaryPartListHead)
+                {
+                    PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+
+                    List->CurrentPartition = PartEntry;
+                    return TRUE;
+                }
+            }
         }
     }
 
         }
     }
 
+    DPRINT1("TODO: Check the next drive!\n");
+
 #if 0
     /* Check for first usable entry on next disk */
     if (List->CurrentDisk != NULL)
 #if 0
     /* Check for first usable entry on next disk */
     if (List->CurrentDisk != NULL)
@@ -2037,38 +2107,68 @@ ScrollDownPartitionList(
         }
     }
 #endif
         }
     }
 #endif
+
+    return FALSE;
 }
 
 
 }
 
 
-VOID
+BOOL
 ScrollUpPartitionList(
     PPARTLIST List)
 {
 //    PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 ScrollUpPartitionList(
     PPARTLIST List)
 {
 //    PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
-//    PLIST_ENTRY Entry1;
-    PLIST_ENTRY Entry2;
+    PLIST_ENTRY Entry;
 
     /* Check for empty disks */
     if (IsListEmpty(&List->DiskListHead))
 
     /* Check for empty disks */
     if (IsListEmpty(&List->DiskListHead))
-        return;
+        return FALSE;
 
 
-    /* check for previous usable entry on current disk */
+    /* Check for previous usable entry on current disk */
     if (List->CurrentPartition != NULL)
     {
     if (List->CurrentPartition != NULL)
     {
-        Entry2 = List->CurrentPartition->ListEntry.Blink;
-        if (Entry2 != &List->CurrentDisk->PrimaryPartListHead)
+        if (List->CurrentPartition->LogicalPartition)
         {
         {
-            PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
+            /* Logical partition */
+            Entry = List->CurrentPartition->ListEntry.Blink;
+            if (Entry != &List->CurrentDisk->LogicalPartListHead)
+            {
+                /* Previous logical partition */
+                PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+            }
+            else
+            {
+                /* Extended partition*/
+                PartEntry = List->CurrentDisk->ExtendedPartition;
+            }
 
             List->CurrentPartition = PartEntry;
 
             List->CurrentPartition = PartEntry;
+            return TRUE;
+        }
+        else
+        {
+            /* Primary or extended partition */
+
+            Entry = List->CurrentPartition->ListEntry.Blink;
+            if (Entry != &List->CurrentDisk->PrimaryPartListHead)
+            {
+                PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+
+                if (IsContainerPartition(PartEntry->PartitionType))
+                {
+                    Entry = List->CurrentDisk->LogicalPartListHead.Blink;
+                    PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+                }
+
+                List->CurrentPartition = PartEntry;
+                return TRUE;
+            }
 
 
-            /* Draw partition list and return */
-            DrawPartitionList(List);
-            return;
         }
     }
 
         }
     }
 
+    DPRINT1("TODO: Check the previous drive!\n");
+
 #if 0
     /* check for last usable entry on previous disk */
     if (List->CurrentDisk != NULL)
 #if 0
     /* check for last usable entry on previous disk */
     if (List->CurrentDisk != NULL)
@@ -2095,6 +2195,8 @@ ScrollUpPartitionList(
         }
     }
 #endif
         }
     }
 #endif
+
+    return FALSE;
 }
 
 
 }
 
 
index b276ef3..3423fe6 100644 (file)
@@ -211,11 +211,11 @@ BOOL
 SetMountedDeviceValues(
     PPARTLIST List);
 
 SetMountedDeviceValues(
     PPARTLIST List);
 
-VOID
+BOOL
 ScrollDownPartitionList(
     PPARTLIST List);
 
 ScrollDownPartitionList(
     PPARTLIST List);
 
-VOID
+BOOL
 ScrollUpPartitionList(
     PPARTLIST List);
 
 ScrollUpPartitionList(
     PPARTLIST List);