X-Git-Url: https://code.delx.au/refind/blobdiff_plain/4944145c8979880d164195efcd9dae809c5bbf7e..2f0e524a93415ad4a3128320dfc043841c3a0da8:/refind/lib.c diff --git a/refind/lib.c b/refind/lib.c index 492541a..416a1f1 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -310,25 +310,12 @@ EFI_STATUS EfivarSetRaw(EFI_GUID *vendor, CHAR16 *name, CHAR8 *buf, UINTN size, // list functions // -VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialElementCount) -{ - UINTN AllocateCount; - - *ElementCount = InitialElementCount; - if (*ElementCount > 0) { - AllocateCount = (*ElementCount + 7) & ~7; // next multiple of 8 - *ListPtr = AllocatePool(sizeof(VOID *) * AllocateCount); - } else { - *ListPtr = NULL; - } -} - VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID *NewElement) { UINTN AllocateCount; - if ((*ElementCount & 7) == 0) { - AllocateCount = *ElementCount + 8; + if ((*ElementCount & 15) == 0) { + AllocateCount = *ElementCount + 16; if (*ElementCount == 0) *ListPtr = AllocatePool(sizeof(VOID *) * AllocateCount); else @@ -576,6 +563,13 @@ static VOID SetFilesystemData(IN UINT8 *Buffer, IN UINTN BufferSize, IN OUT REFI } // if } // search for FAT and NTFS magic + // If no other filesystem is identified and block size is right, assume + // it's ISO-9660.... + if (Volume->BlockIO->Media->BlockSize == 2048) { + Volume->FSType = FS_TYPE_ISO9660; + return; + } + } // if ((Buffer != NULL) && (Volume != NULL)) } // UINT32 SetFilesystemData() @@ -603,8 +597,9 @@ static VOID ScanVolumeBootcode(REFIT_VOLUME *Volume, BOOLEAN *Bootable) Volume->BlockIO, Volume->BlockIO->Media->MediaId, Volume->BlockIOOffset, SAMPLE_SIZE, Buffer); if (!EFI_ERROR(Status)) { - SetFilesystemData(Buffer, SAMPLE_SIZE, Volume); + } + if ((Status == EFI_SUCCESS) && (GlobalConfig.LegacyType == LEGACY_TYPE_MAC)) { if ((*((UINT16 *)(Buffer + 510)) == 0xaa55 && Buffer[0] != 0) && (FindMem(Buffer, 512, "EXFAT", 5) == -1)) { *Bootable = TRUE; Volume->HasBootCode = TRUE; @@ -624,15 +619,6 @@ static VOID ScanVolumeBootcode(REFIT_VOLUME *Volume, BOOLEAN *Bootable) Volume->OSIconName = L"grub,linux"; Volume->OSName = L"Linux"; -// // Below doesn't produce a bootable entry, so commented out for the moment.... -// // GRUB in BIOS boot partition: -// } else if (FindMem(Buffer, 512, "Geom\0Read\0 Error", 16) >= 0) { -// Volume->HasBootCode = TRUE; -// Volume->OSIconName = L"grub,linux"; -// Volume->OSName = L"Linux"; -// Volume->VolName = L"BIOS Boot Partition"; -// *Bootable = TRUE; - } else if ((*((UINT32 *)(Buffer + 502)) == 0 && *((UINT32 *)(Buffer + 506)) == 50000 && *((UINT16 *)(Buffer + 510)) == 0xaa55) || @@ -862,20 +848,30 @@ static CHAR16 *GetVolumeName(REFIT_VOLUME *Volume) { return FoundName; } // static CHAR16 *GetVolumeName() -// Determine the unique GUID and name of the volume and store them. +// Determine the unique GUID, type code GUID, and name of the volume and store them. static VOID SetPartGuidAndName(REFIT_VOLUME *Volume, EFI_DEVICE_PATH_PROTOCOL *DevicePath) { HARDDRIVE_DEVICE_PATH *HdDevicePath; + GPT_ENTRY *PartInfo; - if (Volume == NULL) + if ((Volume == NULL) || (DevicePath == NULL)) return; if ((DevicePath->Type == MEDIA_DEVICE_PATH) && (DevicePath->SubType == MEDIA_HARDDRIVE_DP)) { HdDevicePath = (HARDDRIVE_DEVICE_PATH*) DevicePath; if (HdDevicePath->SignatureType == SIGNATURE_TYPE_GUID) { Volume->PartGuid = *((EFI_GUID*) HdDevicePath->Signature); - Volume->PartName = PartNameFromGuid(&(Volume->PartGuid)); - } // if - } // if + PartInfo = FindPartWithGuid(&(Volume->PartGuid)); + if (PartInfo) { + Volume->PartName = StrDuplicate(PartInfo->name); + CopyMem(&(Volume->PartTypeGuid), PartInfo->type_guid, sizeof(EFI_GUID)); + if (GuidsAreEqual (&(Volume->PartTypeGuid), &gFreedesktopRootGuid)) { + GlobalConfig.DiscoveredRoot = Volume; + Print(L"Found match!\n"); + PauseForKey(); + } // if (GUIDs match) + } // if (PartInfo exists) + } // if (GPT disk) + } // if (disk device) } // VOID SetPartGuid() // Return TRUE if NTFS boot files are found or if Volume is unreadable, @@ -1572,6 +1568,19 @@ BOOLEAN StriSubCmp(IN CHAR16 *SmallStr, IN CHAR16 *BigStr) { return (Found); } // BOOLEAN StriSubCmp() +// Convert input string to all-lowercase. +VOID ToLower(CHAR16 * MyString) { + UINTN i = 0; + + if (MyString) { + while (MyString[i] != L'\0') { + if ((MyString[i] >= L'A') && (MyString[i] <= L'Z')) + MyString[i] = MyString[i] - L'A' + L'a'; + i++; + } // while + } // if +} // VOID ToLower() + // Merges two strings, creating a new one and returning a pointer to it. // If AddChar != 0, the specified character is placed between the two original // strings (unless the first string is NULL or empty). The original input @@ -2189,5 +2198,5 @@ EFI_GUID StringAsGuid(CHAR16 * InString) { // Returns TRUE if the two GUIDs are equal, FALSE otherwise BOOLEAN GuidsAreEqual(EFI_GUID *Guid1, EFI_GUID *Guid2) { return (CompareMem(Guid1, Guid2, 16) == 0); -} // BOOLEAN CompareGuids() +} // BOOLEAN GuidsAreEqual()