[BOOTLIB]: Fix a few subtle bugs which made us incorrectly believe that we were booting from a raw removable drive. We now correctly detect that we are booting off CDROM media. Of course, now everything else is hopelessly broken and we've regressed to die before we get anywhere. Progress.

svn path=/trunk/; revision=70540
This commit is contained in:
Alex Ionescu 2016-01-08 00:15:00 +00:00
parent e0df0d3663
commit 79e72915d9
3 changed files with 20 additions and 10 deletions

View file

@ -1085,7 +1085,7 @@ BmFwVerifySelfIntegrity (
EfiPrintf(L"Device Type %d Local Type %d\r\n", BlpBootDevice->DeviceType, BlpBootDevice->Local.Type); EfiPrintf(L"Device Type %d Local Type %d\r\n", BlpBootDevice->DeviceType, BlpBootDevice->Local.Type);
if ((BlpBootDevice->DeviceType == LocalDevice) && if ((BlpBootDevice->DeviceType == LocalDevice) &&
(BlpBootDevice->Local.Type == CdRomDevice) && (BlpBootDevice->Local.Type == CdRomDevice) &&
(BlpApplicationFlags & BL_APPLICATION_ENTRY_FLAG_NO_GUID)) (BlpApplicationFlags & BL_APPLICATION_FLAG_CONVERTED_FROM_EFI))
{ {
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -44,14 +44,21 @@ EfiIsDevicePathParent (
_In_ EFI_DEVICE_PATH *DevicePath2 _In_ EFI_DEVICE_PATH *DevicePath2
) )
{ {
EFI_DEVICE_PATH* CurrentPath1;
EFI_DEVICE_PATH* CurrentPath2;
USHORT Length1, Length2; USHORT Length1, Length2;
/* Start with the current nodes */
CurrentPath1 = DevicePath1;
CurrentPath2 = DevicePath2;
/* Loop each element of the device path */ /* Loop each element of the device path */
while (!IsDevicePathEndType(DevicePath1) && !IsDevicePathEndType(DevicePath2)) while (!(IsDevicePathEndType(CurrentPath1)) &&
!(IsDevicePathEndType(CurrentPath2)))
{ {
/* Check if the element has a different length */ /* Check if the element has a different length */
Length1 = DevicePathNodeLength(DevicePath1); Length1 = DevicePathNodeLength(CurrentPath1);
Length2 = DevicePathNodeLength(DevicePath2); Length2 = DevicePathNodeLength(CurrentPath2);
if (Length1 != Length2) if (Length1 != Length2)
{ {
/* Then they're not related */ /* Then they're not related */
@ -59,25 +66,25 @@ EfiIsDevicePathParent (
} }
/* Check if the rest of the element data matches */ /* Check if the rest of the element data matches */
if (RtlCompareMemory(DevicePath1, DevicePath2, Length1) != Length1) if (RtlCompareMemory(CurrentPath1, CurrentPath2, Length1) != Length1)
{ {
/* Nope, not related */ /* Nope, not related */
return NULL; return NULL;
} }
/* Move to the next element */ /* Move to the next element */
DevicePath1 = NextDevicePathNode(DevicePath1); CurrentPath1 = NextDevicePathNode(CurrentPath1);
DevicePath2 = NextDevicePathNode(DevicePath2); CurrentPath2 = NextDevicePathNode(CurrentPath2);
} }
/* If the last element in path 1 is empty, then path 2 is the child (deeper) */ /* If the last element in path 1 is empty, then path 2 is the child (deeper) */
if (!IsDevicePathEndType(DevicePath1)) if (!IsDevicePathEndType(CurrentPath1))
{ {
return DevicePath2; return DevicePath2;
} }
/* If the last element in path 2 is empty, then path 1 is the child (deeper) */ /* If the last element in path 2 is empty, then path 1 is the child (deeper) */
if (!IsDevicePathEndType(DevicePath2)) if (!IsDevicePathEndType(CurrentPath2))
{ {
return DevicePath1; return DevicePath1;
} }

View file

@ -920,7 +920,8 @@ BlockIoEfiGetChildHandle (
/* Yup, return back to caller */ /* Yup, return back to caller */
ChildProtocolInterface->Handle = Handle; ChildProtocolInterface->Handle = Handle;
ChildProtocolInterface->Interface = DevicePath; ChildProtocolInterface->Interface = DevicePath;
break; Status = STATUS_SUCCESS;
goto Quickie;
} }
/* Close the device path */ /* Close the device path */
@ -930,6 +931,7 @@ BlockIoEfiGetChildHandle (
/* If we got here, nothing was found */ /* If we got here, nothing was found */
Status = STATUS_NO_SUCH_DEVICE; Status = STATUS_NO_SUCH_DEVICE;
Quickie:
/* Free the handle array buffer */ /* Free the handle array buffer */
BlMmFreeHeap(DeviceHandles); BlMmFreeHeap(DeviceHandles);
return Status; return Status;
@ -981,6 +983,7 @@ BlockIoEfiGetDeviceInformation (
/* Iteratate twice -- once for the top level, once for the bottom */ /* Iteratate twice -- once for the top level, once for the bottom */
for (i = 0, Found = FALSE; Found == FALSE && Protocol[i].Handle; i++) for (i = 0, Found = FALSE; Found == FALSE && Protocol[i].Handle; i++)
{ {
/* Check what kind of leaf node device this is */
LeafNode = EfiGetLeafNode(Protocol[i].Interface); LeafNode = EfiGetLeafNode(Protocol[i].Interface);
EfiPrintf(L"Pass %d, Leaf node: %p Type: %d\r\n", i, LeafNode, LeafNode->Type); EfiPrintf(L"Pass %d, Leaf node: %p Type: %d\r\n", i, LeafNode, LeafNode->Type);
if (LeafNode->Type == ACPI_DEVICE_PATH) if (LeafNode->Type == ACPI_DEVICE_PATH)