From: Eric Kohl Date: Sat, 7 Jun 2014 20:02:26 +0000 (+0000) Subject: [USETUP] X-Git-Tag: backups/0.3.17@66124~1044 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=39465487a968df3f0dcfc39ef35a4074ac54302f [USETUP] Implement scolling through the list of logical partitions. Multiple disks are not supported yet. svn path=/trunk/; revision=63547 --- diff --git a/reactos/base/setup/usetup/interface/usetup.c b/reactos/base/setup/usetup/interface/usetup.c index e2c394cf5ec..7bc25646673 100644 --- a/reactos/base/setup/usetup/interface/usetup.c +++ b/reactos/base/setup/usetup/interface/usetup.c @@ -1581,12 +1581,14 @@ SelectPartitionPage(PINPUT_RECORD Ir) 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 */ { - ScrollUpPartitionList(PartitionList); + if (ScrollUpPartitionList(PartitionList)) + DrawPartitionList(PartitionList); } else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ { diff --git a/reactos/base/setup/usetup/partlist.c b/reactos/base/setup/usetup/partlist.c index 61b93a2582f..b8aad4ad9ae 100644 --- a/reactos/base/setup/usetup/partlist.c +++ b/reactos/base/setup/usetup/partlist.c @@ -1174,6 +1174,29 @@ AddDiskToList( 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; @@ -1986,33 +2009,80 @@ SelectPartition( } -VOID +BOOL ScrollDownPartitionList( PPARTLIST List) { // PDISKENTRY DiskEntry; PPARTENTRY PartEntry; -// PLIST_ENTRY Entry1; - PLIST_ENTRY Entry2; + PLIST_ENTRY Entry; /* Check for empty disks */ if (IsListEmpty(&List->DiskListHead)) - return; + return FALSE; + /* 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) @@ -2037,38 +2107,68 @@ ScrollDownPartitionList( } } #endif + + return FALSE; } -VOID +BOOL ScrollUpPartitionList( PPARTLIST List) { // PDISKENTRY DiskEntry; PPARTENTRY PartEntry; -// PLIST_ENTRY Entry1; - PLIST_ENTRY Entry2; + PLIST_ENTRY Entry; /* 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) { - 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; + 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) @@ -2095,6 +2195,8 @@ ScrollUpPartitionList( } } #endif + + return FALSE; } diff --git a/reactos/base/setup/usetup/partlist.h b/reactos/base/setup/usetup/partlist.h index b276ef3ec81..3423fe65120 100644 --- a/reactos/base/setup/usetup/partlist.h +++ b/reactos/base/setup/usetup/partlist.h @@ -211,11 +211,11 @@ BOOL SetMountedDeviceValues( PPARTLIST List); -VOID +BOOL ScrollDownPartitionList( PPARTLIST List); -VOID +BOOL ScrollUpPartitionList( PPARTLIST List);