at start we have only Volume->DeviceHandle
| 692 | |
| 693 | //at start we have only Volume->DeviceHandle |
| 694 | static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume) |
| 695 | { |
| 696 | EFI_STATUS Status; |
| 697 | EFI_DEVICE_PATH *DevicePath, *NextDevicePath; |
| 698 | EFI_DEVICE_PATH *DiskDevicePath, *RemainingDevicePath = NULL; |
| 699 | HARDDRIVE_DEVICE_PATH *HdPath = NULL; |
| 700 | EFI_HANDLE WholeDiskHandle; |
| 701 | UINTN PartialLength = 0; |
| 702 | UINTN DevicePathSize; |
| 703 | // UINTN BufferSize = 255; |
| 704 | EFI_FILE_SYSTEM_INFO *FileSystemInfoPtr; |
| 705 | EFI_FILE_INFO *RootInfo = NULL; |
| 706 | BOOLEAN Bootable; |
| 707 | // EFI_INPUT_KEY Key; |
| 708 | |
| 709 | // get device path |
| 710 | DiskDevicePath = DevicePathFromHandle(Volume->DeviceHandle); |
| 711 | //Volume->DevicePath = DuplicateDevicePath(DevicePathFromHandle(Volume->DeviceHandle)); |
| 712 | DevicePathSize = GetDevicePathSize (DiskDevicePath); |
| 713 | Volume->DevicePath = (__typeof__(Volume->DevicePath))AllocateAlignedPages(EFI_SIZE_TO_PAGES(DevicePathSize), 64); |
| 714 | CopyMem(Volume->DevicePath, DiskDevicePath, DevicePathSize); |
| 715 | Volume->DevicePathString = FileDevicePathToXStringW(Volume->DevicePath); |
| 716 | |
| 717 | #if REFIT_DEBUG > 0 |
| 718 | if (Volume->DevicePath != NULL) { |
| 719 | DBG(" %ls\n", FileDevicePathToXStringW(Volume->DevicePath).wc_str()); |
| 720 | //#if REFIT_DEBUG >= 2 |
| 721 | // DumpHex(1, 0, GetDevicePathSize(Volume->DevicePath), Volume->DevicePath); |
| 722 | //#endif |
| 723 | } |
| 724 | if ( Volume->ApfsFileSystemUUID.notEmpty() ) { |
| 725 | DBG(" apfsFileSystemUUID=%s\n", Volume->ApfsFileSystemUUID.c_str()); |
| 726 | } |
| 727 | #else |
| 728 | DBG("\n"); |
| 729 | #endif |
| 730 | |
| 731 | Volume->ApfsFileSystemUUID = APFSPartitionUUIDExtractAsXString8(Volume->DevicePath); // NullXString8 if it's not an APFS volume |
| 732 | Volume->DiskKind = DISK_KIND_INTERNAL; // default |
| 733 | |
| 734 | // get block i/o |
| 735 | Status = gBS->HandleProtocol(Volume->DeviceHandle, &gEfiBlockIoProtocolGuid, (VOID **) &(Volume->BlockIO)); |
| 736 | if (EFI_ERROR(Status)) { |
| 737 | Volume->BlockIO = NULL; |
| 738 | // DBG(" Warning: Can't get BlockIO protocol.\n"); |
| 739 | // WaitForSingleEvent (gST->ConIn->WaitForKey, 0); |
| 740 | // gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); |
| 741 | |
| 742 | return Status; |
| 743 | } |
| 744 | |
| 745 | Bootable = FALSE; |
| 746 | if (Volume->BlockIO->Media->BlockSize == 2048){ |
| 747 | // DBG(" Found optical drive\n"); |
| 748 | Volume->DiskKind = DISK_KIND_OPTICAL; |
| 749 | Volume->BlockIOOffset = 0x10; // offset already applied for FS but not for blockio |
| 750 | ScanVolumeBootcode(Volume, &Bootable); |
| 751 | } else { |
no test coverage detected