Implement scolling through the list of logical partitions. Multiple disks are not supported yet.

svn path=/trunk/; revision=63547
This commit is contained in:
Eric Kohl 2014-06-07 20:02:26 +00:00
parent a06ec7042e
commit 39465487a9
3 changed files with 129 additions and 25 deletions

View file

@ -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 */
{

View file

@ -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;
}

View file

@ -211,11 +211,11 @@ BOOL
SetMountedDeviceValues(
PPARTLIST List);
VOID
BOOL
ScrollDownPartitionList(
PPARTLIST List);
VOID
BOOL
ScrollUpPartitionList(
PPARTLIST List);