VOID SortedUartHandle ( IN EFI_HANDLE *Handles, IN UINTN NoHandles ) /*++ Routine Description: Sort Uart handles array with Acpi->UID from low to high Arguments: Handles - EFI_SERIAL_IO_PROTOCOL handle buffer NoHandles - EFI_SERIAL_IO_PROTOCOL handle count Returns: None --*/ { UINTN Index1; UINTN Index2; UINTN Position; UINT32 AcpiUid1; UINT32 AcpiUid2; UINT32 TempAcpiUid; EFI_HANDLE TempHandle; for (Index1 = 0; Index1 < NoHandles-1; Index1++) { if (!RetrieveUartUid (Handles[Index1], &AcpiUid1)) { continue; } TempHandle = Handles[Index1]; Position = Index1; TempAcpiUid = AcpiUid1; for (Index2 = Index1+1; Index2 < NoHandles; Index2++) { if (!RetrieveUartUid (Handles[Index2], &AcpiUid2)) { continue; } if (AcpiUid2 < TempAcpiUid) { TempAcpiUid = AcpiUid2; TempHandle = Handles[Index2]; Position = Index2; } } Handles[Position] = Handles[Index1]; Handles[Index1] = TempHandle; } }
/** Sort Uart handles array with Acpi->UID from low to high. @param Handles EFI_SERIAL_IO_PROTOCOL handle buffer @param NoHandles EFI_SERIAL_IO_PROTOCOL handle count **/ VOID SortedUartHandle ( IN EFI_HANDLE *Handles, IN UINTN NoHandles ) { UINTN Index1; UINTN Index2; UINTN Position; UINT32 AcpiUid1; UINT32 AcpiUid2; UINT32 TempAcpiUid; EFI_HANDLE TempHandle; for (Index1 = 0; Index1 < NoHandles-1; Index1++) { if (!RetrieveUartUid (Handles[Index1], &AcpiUid1)) { continue; } TempHandle = Handles[Index1]; Position = Index1; TempAcpiUid = AcpiUid1; for (Index2 = Index1+1; Index2 < NoHandles; Index2++) { if (!RetrieveUartUid (Handles[Index2], &AcpiUid2)) { continue; } if (AcpiUid2 < TempAcpiUid) { TempAcpiUid = AcpiUid2; TempHandle = Handles[Index2]; Position = Index2; } } Handles[Position] = Handles[Index1]; Handles[Index1] = TempHandle; } }