Improvements to EFI volume support
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 30s
Builds / ExectOS (i686) (push) Successful in 28s

This commit is contained in:
Rafal Kupiec 2023-12-30 17:20:20 +01:00
parent 5b64cf21a0
commit 9aaf8ddb68
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 31 additions and 31 deletions

View File

@ -94,10 +94,10 @@ BlGetSecureBootStatus();
XTCDECL
EFI_STATUS
BlGetVolumeDevicePath(IN PCHAR SystemPath,
BlGetVolumeDevicePath(IN PWCHAR SystemPath,
OUT PEFI_DEVICE_PATH_PROTOCOL *DevicePath,
OUT PCHAR *ArcName,
OUT PCHAR *Path);
OUT PWCHAR *ArcName,
OUT PWCHAR *Path);
XTCDECL
VOID
@ -233,9 +233,9 @@ BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices);
XTCDECL
EFI_STATUS
BlpDissectVolumeArcPath(IN PCHAR SystemPath,
OUT PCHAR *ArcName,
OUT PCHAR *Path,
BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
OUT PWCHAR *ArcName,
OUT PWCHAR *Path,
OUT PUSHORT DriveType,
OUT PULONG DriveNumber,
OUT PULONG PartNumber);

View File

@ -70,7 +70,7 @@ BlEnumerateBlockDevices()
Status = BlpDiscoverEfiBlockDevices(&BlockDevices);
if(Status != STATUS_EFI_SUCCESS)
{
BlDebugPrint(L"ERROR: Failed to discover EFI block devices (status code: %lx)\n", Status);
BlDebugPrint(L"ERROR: Failed to discover EFI block devices (Status Code: 0x%lx)\n", Status);
return Status;
}
@ -169,7 +169,7 @@ BlEnumerateBlockDevices()
Status = BlMemoryAllocatePool(sizeof(EFI_BLOCK_DEVICE), (PVOID *)&BlockDevice);
if(Status != STATUS_EFI_SUCCESS)
{
BlDebugPrint(L"ERROR: Unable to allocate memory pool for block device (status code: %lx)\n", Status);
BlDebugPrint(L"ERROR: Failed to allocate memory pool for block device (Status Code: 0x%lx)\n", Status);
return STATUS_EFI_OUT_OF_RESOURCES;
}
@ -294,16 +294,16 @@ BlFindVolumeDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL FsHandle,
*/
XTCDECL
EFI_STATUS
BlGetVolumeDevicePath(IN PCHAR SystemPath,
BlGetVolumeDevicePath(IN PWCHAR SystemPath,
OUT PEFI_DEVICE_PATH_PROTOCOL *DevicePath,
OUT PCHAR *ArcName,
OUT PCHAR *Path)
OUT PWCHAR *ArcName,
OUT PWCHAR *Path)
{
PEFI_BLOCK_DEVICE Device;
USHORT DriveType;
ULONG DriveNumber;
ULONG PartNumber;
PCHAR Volume;
PWCHAR Volume;
ULONG PathLength;
PLIST_ENTRY ListEntry;
EFI_STATUS Status;
@ -333,13 +333,13 @@ BlGetVolumeDevicePath(IN PCHAR SystemPath,
if(PathLength == GUID_STRING_LENGTH)
{
/* This is EFI GUID */
BlDebugPrint(L"EFI/GPT GUID in system path is not supported yet\n");
BlDebugPrint(L"WARNING: EFI/GPT GUID in system path is not supported\n");
return STATUS_EFI_UNSUPPORTED;
}
else if(PathLength == PARTUUID_STRING_LENGTH)
{
/* This is MBR UUID */
BlDebugPrint(L"MBR partition UUID in system path is not supported yet\n");
BlDebugPrint(L"WARNING: MBR partition UUID in system path is not supported\n");
return STATUS_EFI_UNSUPPORTED;
}
else
@ -358,7 +358,7 @@ BlGetVolumeDevicePath(IN PCHAR SystemPath,
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to parse system path */
BlDebugPrint(L"Failed to parse system path: '%s' with status code: %lx\n", SystemPath, Status);
BlDebugPrint(L"ERROR: Failed to parse system path: '%s' (Status Code: 0x%lx)\n", SystemPath, Status);
return Status;
}
@ -382,7 +382,7 @@ BlGetVolumeDevicePath(IN PCHAR SystemPath,
if(*DevicePath == NULL)
{
/* Failed to find volume */
BlDebugPrint(L"Volume (DriveType: %u, DriveNumber: %lu, PartNumber: %lu) not found\n",
BlDebugPrint(L"ERROR: Volume (DriveType: %u, DriveNumber: %lu, PartNumber: %lu) not found\n",
DriveType, DriveNumber, PartNumber);
return STATUS_EFI_NOT_FOUND;
}
@ -617,7 +617,7 @@ BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to locate handles */
BlDebugPrint(L"ERROR: Failed to locate block devices handles (status code: %lx)\n", Status);
BlDebugPrint(L"ERROR: Failed to locate block devices handles (Status Code: 0x%lx)\n", Status);
return Status;
}
@ -634,7 +634,7 @@ BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
if(Status != STATUS_EFI_SUCCESS || Io == NULL)
{
/* Failed to open I/O protocol, skip it */
BlDebugPrint(L"WARNING: Failed to open EFI Block I/O protocol (status code: %lx)\n", Status);
BlDebugPrint(L"WARNING: Failed to open EFI Block I/O protocol (Status Code: 0x%lx)\n", Status);
continue;
}
@ -652,7 +652,7 @@ BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
if(Status != STATUS_EFI_SUCCESS || DevicePath == NULL)
{
/* Device failed to handle DP protocol */
BlDebugPrint(L"WARNING: Unable to open DevicePath protocol (status code: %lx)\n", Status);
BlDebugPrint(L"WARNING: Unable to open DevicePath protocol (Status Code: 0x%lx)\n", Status);
EfiSystemTable->BootServices->CloseProtocol(Handles[Index], &IoGuid, EfiImageHandle, NULL);
continue;
}
@ -662,7 +662,7 @@ BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
if(Status != STATUS_EFI_SUCCESS)
{
/* Memory allocation failure */
BlDebugPrint(L"ERROR: Unable to allocate memory pool for block device (status code: %lx)\n", Status);
BlDebugPrint(L"ERROR: Failed to allocate memory pool for block device (Status Code: 0x%lx)\n", Status);
EfiSystemTable->BootServices->CloseProtocol(Handles[Index], &DevicePathGuid, EfiImageHandle, NULL);
EfiSystemTable->BootServices->CloseProtocol(Handles[Index], &IoGuid, EfiImageHandle, NULL);
return Status;
@ -705,14 +705,14 @@ BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
*/
XTCDECL
EFI_STATUS
BlpDissectVolumeArcPath(IN PCHAR SystemPath,
OUT PCHAR *ArcName,
OUT PCHAR *Path,
BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
OUT PWCHAR *ArcName,
OUT PWCHAR *Path,
OUT PUSHORT DriveType,
OUT PULONG DriveNumber,
OUT PULONG PartNumber)
{
PCHAR ArcPath, LocalArcName;
PWCHAR ArcPath, LocalArcName;
ULONG ArcLength = 0;
/* Set default values */
@ -721,20 +721,20 @@ BlpDissectVolumeArcPath(IN PCHAR SystemPath,
*PartNumber = 0;
/* Look for the ARC path */
if(RtlCompareStringInsensitive(SystemPath, "ramdisk(0)", 0) == 0)
if(RtlCompareWideStringInsensitive(SystemPath, L"ramdisk(0)", 0) == 0)
{
/* This is RAM disk */
ArcLength = 10;
*DriveType = XTBL_BOOT_DEVICE_RAMDISK;
}
else if(RtlCompareStringInsensitive(SystemPath, "multi(0)disk(0)", 0) == 0)
else if(RtlCompareWideStringInsensitive(SystemPath, L"multi(0)disk(0)", 0) == 0)
{
/* This is a multi-disk port */
ArcLength = 15;
ArcPath = SystemPath + ArcLength;
/* Check for disk type */
if(RtlCompareStringInsensitive(ArcPath, "cdrom(", 0) == 0)
if(RtlCompareWideStringInsensitive(ArcPath, L"cdrom(", 0) == 0)
{
/* This is an optical drive */
ArcLength += 6;
@ -755,7 +755,7 @@ BlpDissectVolumeArcPath(IN PCHAR SystemPath,
*DriveType = XTBL_BOOT_DEVICE_CDROM;
ArcLength++;
}
else if(RtlCompareStringInsensitive(ArcPath, "fdisk(", 0) == 0)
else if(RtlCompareWideStringInsensitive(ArcPath, L"fdisk(", 0) == 0)
{
/* This is a floppy drive */
ArcLength += 6;
@ -776,7 +776,7 @@ BlpDissectVolumeArcPath(IN PCHAR SystemPath,
*DriveType = XTBL_BOOT_DEVICE_FLOPPY;
ArcLength++;
}
else if(RtlCompareStringInsensitive(ArcPath, "rdisk(", 0) == 0)
else if(RtlCompareWideStringInsensitive(ArcPath, L"rdisk(", 0) == 0)
{
/* This is a hard disk */
ArcLength += 6;
@ -799,7 +799,7 @@ BlpDissectVolumeArcPath(IN PCHAR SystemPath,
ArcPath = SystemPath + ArcLength;
/* Look for a partition */
if(RtlCompareStringInsensitive(ArcPath, "partition(", 0) == 0)
if(RtlCompareWideStringInsensitive(ArcPath, L"partition(", 0) == 0)
{
/* Partition information found */
ArcLength += 10;
@ -893,7 +893,7 @@ BlpDuplicateDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath)
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to allocate memory */
BlDebugPrint(L"ERROR: Unable to allocate memory pool for device path duplicate\n");
BlDebugPrint(L"ERROR: Failed to allocate memory pool for device path duplicate (Status Code: 0x%lx)\n", Status);
return NULL;
}