// find the current directory
DevicePathAsString = DevicePathToStr(SelfLoadedImage->FilePath);
+ GlobalConfig.SelfDevicePath = FileDevicePath(SelfLoadedImage->DeviceHandle, DevicePathAsString);
CleanUpPathNameSlashes(DevicePathAsString);
MyFreePool(SelfDirPath);
Temp = FindPath(DevicePathAsString);
}
} // VOID FreeList()
-//
-// firmware device path discovery
-//
-
-static UINT8 LegacyLoaderMediaPathData[] = {
- 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
- 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
- 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
-};
-static EFI_DEVICE_PATH *LegacyLoaderMediaPath = (EFI_DEVICE_PATH *)LegacyLoaderMediaPathData;
-
-VOID ExtractLegacyLoaderPaths(EFI_DEVICE_PATH **PathList, UINTN MaxPaths, EFI_DEVICE_PATH **HardcodedPathList)
-{
- EFI_STATUS Status;
- UINTN HandleCount = 0;
- UINTN HandleIndex, HardcodedIndex;
- EFI_HANDLE *Handles;
- EFI_HANDLE Handle;
- UINTN PathCount = 0;
- UINTN PathIndex;
- EFI_LOADED_IMAGE *LoadedImage;
- EFI_DEVICE_PATH *DevicePath;
- BOOLEAN Seen;
-
- MaxPaths--; // leave space for the terminating NULL pointer
-
- // get all LoadedImage handles
- Status = LibLocateHandle(ByProtocol, &LoadedImageProtocol, NULL, &HandleCount, &Handles);
- if (CheckError(Status, L"while listing LoadedImage handles")) {
- if (HardcodedPathList) {
- for (HardcodedIndex = 0; HardcodedPathList[HardcodedIndex] && PathCount < MaxPaths; HardcodedIndex++)
- PathList[PathCount++] = HardcodedPathList[HardcodedIndex];
- }
- PathList[PathCount] = NULL;
- return;
- }
- for (HandleIndex = 0; HandleIndex < HandleCount && PathCount < MaxPaths; HandleIndex++) {
- Handle = Handles[HandleIndex];
-
- Status = refit_call3_wrapper(BS->HandleProtocol, Handle, &LoadedImageProtocol, (VOID **) &LoadedImage);
- if (EFI_ERROR(Status))
- continue; // This can only happen if the firmware scewed up, ignore it.
-
- Status = refit_call3_wrapper(BS->HandleProtocol, LoadedImage->DeviceHandle, &DevicePathProtocol, (VOID **) &DevicePath);
- if (EFI_ERROR(Status))
- continue; // This happens, ignore it.
-
- // Only grab memory range nodes
- if (DevicePathType(DevicePath) != HARDWARE_DEVICE_PATH || DevicePathSubType(DevicePath) != HW_MEMMAP_DP)
- continue;
-
- // Check if we have this device path in the list already
- // WARNING: This assumes the first node in the device path is unique!
- Seen = FALSE;
- for (PathIndex = 0; PathIndex < PathCount; PathIndex++) {
- if (DevicePathNodeLength(DevicePath) != DevicePathNodeLength(PathList[PathIndex]))
- continue;
- if (CompareMem(DevicePath, PathList[PathIndex], DevicePathNodeLength(DevicePath)) == 0) {
- Seen = TRUE;
- break;
- }
- }
- if (Seen)
- continue;
-
- PathList[PathCount++] = AppendDevicePath(DevicePath, LegacyLoaderMediaPath);
- }
- MyFreePool(Handles);
-
- if (HardcodedPathList) {
- for (HardcodedIndex = 0; HardcodedPathList[HardcodedIndex] && PathCount < MaxPaths; HardcodedIndex++)
- PathList[PathCount++] = HardcodedPathList[HardcodedIndex];
- }
- PathList[PathCount] = NULL;
-}
-
//
// volume functions
//
HARDDRIVE_DEVICE_PATH *HdDevicePath;
GPT_ENTRY *PartInfo;
- if ((Volume == NULL) || (DevicePath == NULL))
- return;
+ 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);
- 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;
- } // if (GUIDs match)
- } // if (PartInfo exists)
- } // if (GPT disk)
- } // if (disk device)
+ 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);
+ 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) &&
+ ((PartInfo->attributes & GPT_NO_AUTOMOUNT) == 0)) {
+ GlobalConfig.DiscoveredRoot = Volume;
+ } // if (GUIDs match && automounting OK)
+ Volume->IsMarkedReadOnly = ((PartInfo->attributes & GPT_READ_ONLY) > 0);
+ } // if (PartInfo exists)
+ } // if (GPT disk)
+ } // if (disk device)
} // VOID SetPartGuid()
// Return TRUE if NTFS boot files are found or if Volume is unreadable,