提交 afd98238 编写于 作者: D Download-Fritz

OcBootManagementLib: Set 'Windows' name based on booter name

上级 bffded3a
......@@ -170,6 +170,10 @@ typedef struct OC_BOOT_ENTRY_ {
//
BOOLEAN IsFolder;
//
// Set when this entry refers to a generic booter (e.g. BOOTx64.EFI).
//
BOOLEAN IsGeneric;
//
// Should make this option default boot option.
//
BOOLEAN SetDefault;
......@@ -1005,14 +1009,16 @@ OcGetFileSystemPolicyType (
@param[in] DevicePath Device path.
@param[out] IsFolder Device path represents directory, optional.
@param[out] IsGeneric Device path represents generic booter, optional.
@retval entry type for potentially known bootloaders.
@retval OC_BOOT_UNKNOWN for unknown bootloaders.
**/
OC_BOOT_ENTRY_TYPE
OcGetBootDevicePathType (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
OUT BOOLEAN *IsFolder OPTIONAL
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
OUT BOOLEAN *IsFolder OPTIONAL,
OUT BOOLEAN *IsGeneric OPTIONAL
);
/**
......
......@@ -540,17 +540,18 @@ InternalDescribeBootEntry (
//
// Windows boot entry may have a custom name, so ensure OC_BOOT_WINDOWS is set correctly.
//
if (BootEntry->Type == OC_BOOT_UNKNOWN) {
if (BootEntry->Type == OC_BOOT_UNKNOWN && BootEntry->IsGeneric) {
DEBUG ((DEBUG_INFO, "OCB: Trying to detect Microsoft BCD\n"));
Status = ReadFileSize (FileSystem, L"\\EFI\\Microsoft\\Boot\\BCD", &BcdSize);
if (!EFI_ERROR (Status)) {
BootEntry->Type = OC_BOOT_WINDOWS;
if (BootEntry->Name == NULL) {
BootEntry->Name = AllocateCopyPool (sizeof (L"Windows"), L"Windows");
}
}
}
if (BootEntry->Type == OC_BOOT_WINDOWS && BootEntry->Name == NULL) {
BootEntry->Name = AllocateCopyPool (sizeof (L"Windows"), L"Windows");
}
if (BootEntry->Name == NULL) {
BootEntry->Name = GetVolumeLabel (FileSystem);
if (BootEntry->Name != NULL
......
......@@ -270,10 +270,11 @@ RegisterBootOption (
DEBUG ((
DEBUG_INFO,
"OCB: Registering entry %s (T:%d|F:%d|E:%d) - %s\n",
"OCB: Registering entry %s (T:%d|F:%d|G:%d|E:%d) - %s\n",
BootEntry->Name,
BootEntry->Type,
BootEntry->IsFolder,
BootEntry->IsGeneric,
BootEntry->IsExternal,
OC_HUMAN_STRING (TextDevicePath)
));
......@@ -349,8 +350,9 @@ AddBootEntryOnFileSystem (
OC_BOOT_ENTRY *ExistingEntry;
CHAR16 *TextDevicePath;
BOOLEAN IsFolder;
BOOLEAN IsGeneric;
EntryType = OcGetBootDevicePathType (DevicePath, &IsFolder);
EntryType = OcGetBootDevicePathType (DevicePath, &IsFolder, &IsGeneric);
DEBUG_CODE_BEGIN ();
......@@ -358,9 +360,10 @@ AddBootEntryOnFileSystem (
DEBUG ((
DEBUG_INFO,
"OCB: Adding entry type (T:%u|F:%d) - %s\n",
"OCB: Adding entry type (T:%u|F:%d|G:%d) - %s\n",
EntryType,
IsFolder,
IsGeneric,
OC_HUMAN_STRING (TextDevicePath)
));
......@@ -462,6 +465,7 @@ AddBootEntryOnFileSystem (
BootEntry->DevicePath = DevicePath;
BootEntry->Type = EntryType;
BootEntry->IsFolder = IsFolder;
BootEntry->IsGeneric = IsGeneric;
BootEntry->IsExternal = RecoveryPart ? FileSystem->RecoveryFs->External : FileSystem->External;
Status = InternalDescribeBootEntry (BootEntry);
......
......@@ -626,11 +626,13 @@ OcRunBootPicker (
if (!EFI_ERROR (Status)) {
DEBUG ((
DEBUG_INFO,
"OCB: Should boot from %u. %s (T:%d|F:%d|DEF:%d)\n",
"OCB: Should boot from %u. %s (T:%d|F:%d|G:%d|E:%d|DEF:%d)\n",
Chosen->EntryIndex,
Chosen->Name,
Chosen->Type,
Chosen->IsFolder,
Chosen->IsGeneric,
Chosen->IsExternal,
Chosen->SetDefault
));
......
......@@ -257,7 +257,8 @@ InternalCheckScanPolicy (
OC_BOOT_ENTRY_TYPE
OcGetBootDevicePathType (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
OUT BOOLEAN *IsFolder OPTIONAL
OUT BOOLEAN *IsFolder OPTIONAL,
OUT BOOLEAN *IsGeneric OPTIONAL
)
{
EFI_DEVICE_PATH_PROTOCOL *CurrNode;
......@@ -295,6 +296,10 @@ OcGetBootDevicePathType (
Type = OC_BOOT_APPLE_RECOVERY;
} else if (OcStrStrLength (LastNode->PathName, PathLen,
L"EFI\\APPLE", L_STR_LEN (L"EFI\\APPLE")) != NULL) {
//
// FIXME: Support separate file path nodes. Potentially introduce a
// retrieval function that uses a preallocated buffer.
//
Type = OC_BOOT_APPLE_FW_UPDATE;
}
}
......@@ -317,17 +322,20 @@ OcGetBootDevicePathType (
//
STATIC CONST CHAR16 *Bootloaders[] = {
L"boot.efi",
L"tmbootpicker.efi"
L"tmbootpicker.efi",
L"bootmgfw.efi"
};
STATIC CONST UINTN BootloaderLengths[] = {
L_STR_LEN (L"boot.efi"),
L_STR_LEN (L"tmbootpicker.efi")
L_STR_LEN (L"tmbootpicker.efi"),
L_STR_LEN (L"bootmgfw.efi")
};
STATIC CONST OC_BOOT_ENTRY_TYPE BootloaderTypes[] = {
OC_BOOT_APPLE_OS,
OC_BOOT_APPLE_TIME_MACHINE
OC_BOOT_APPLE_TIME_MACHINE,
OC_BOOT_WINDOWS
};
for (Index = 0; Index < ARRAY_SIZE (Bootloaders); ++Index) {
......@@ -345,6 +353,24 @@ OcGetBootDevicePathType (
}
}
CONST CHAR16 *GenericBootloader = &EFI_REMOVABLE_MEDIA_FILE_NAME[L_STR_LEN (L"\\EFI\\BOOT\\")];
CONST UINTN GenericBootloaderLength = L_STR_LEN (EFI_REMOVABLE_MEDIA_FILE_NAME) - L_STR_LEN (L"\\EFI\\BOOT\\");
if (IsGeneric != NULL) {
*IsGeneric = FALSE;
if (PathLen >= GenericBootloaderLength) {
RestLen = PathLen - GenericBootloaderLength;
if ((RestLen == 0 || LastNode->PathName[RestLen - 1] == L'\\')
&& CompareMem (
&LastNode->PathName[RestLen],
GenericBootloader,
GenericBootloaderLength * sizeof (LastNode->PathName[0])) == 0) {
*IsGeneric = TRUE;
}
}
}
return OC_BOOT_UNKNOWN;
}
......
......@@ -891,6 +891,10 @@ OcFileDevicePathFullName (
ASSERT (IsDevicePathValid (&FilePath->Header, 0));
ASSERT (PathNameSize == OcFileDevicePathFullNameSize (&FilePath->Header));
//
// FIXME: Insert separators between nodes if not present already.
//
do {
PathLen = OcFileDevicePathNameLen (FilePath);
CopyMem (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册