diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index a915c7a59f94b37e97036581eb587ce70724695f..e67ff2c7f0cf4fac44b146be6a1716965dd3250e 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -6290,7 +6290,8 @@ options may be specified in \texttt{UEFI/Drivers/Arguments}: remount as read-write) on distros which do not require it. To specify this option for specific distros only, use \texttt{partuuidopts:\{partuuid\}+=ro} instead of this flag. \item \texttt{0x00004000} (bit \texttt{14}) --- \texttt{LINUX\_BOOT\_LOG\_VERBOSE}, - Add additional debug log info about files encountered while scanning for Linux boot entries. + Add additional debug log info about files encountered and autodetect options added while scanning for + Linux boot entries. \item \texttt{0x00008000} (bit \texttt{15}) --- \texttt{LINUX\_BOOT\_ADD\_DEBUG\_INFO}, Adds a human readable file system type, followed by the first eight characters of the partition's unique partition uuid, to each generated entry name. Can help with debugging diff --git a/Platform/OpenLinuxBoot/Autodetect.c b/Platform/OpenLinuxBoot/Autodetect.c index 37915e9aa72f5c57fab5ca7bb074d1f5ada82334..fe41b84dedcd117e61eaef5524e3c11befac3c25 100644 --- a/Platform/OpenLinuxBoot/Autodetect.c +++ b/Platform/OpenLinuxBoot/Autodetect.c @@ -327,10 +327,14 @@ AutodetectBootOptions ( OC_PARSED_VAR *Option; EFI_GUID Guid; CHAR8 *AsciiStrValue; + CHAR8 *GrubVarName; + CHAR8 **NewOption; BOOLEAN Found; + BOOLEAN PlusOpts; if ((gLinuxBootFlags & LINUX_BOOT_ADD_RO) != 0) { - DEBUG ((OC_TRACE_KERNEL_OPTS, "LNX: Adding \"ro\"\n")); + DEBUG (((gLinuxBootFlags & LINUX_BOOT_LOG_VERBOSE) == 0 ? DEBUG_VERBOSE : DEBUG_INFO, + "LNX: Adding \"ro\"\n")); Status = AddOption (Options, "ro", FALSE); } @@ -360,19 +364,22 @@ AutodetectBootOptions ( } if (CompareMem (&gPartuuid, &Guid, sizeof (EFI_GUID)) != 0) { - DEBUG ((OC_TRACE_KERNEL_OPTS, "LNX: No match %g != %g\n", &gPartuuid, &Guid)); + DEBUG (((gLinuxBootFlags & LINUX_BOOT_LOG_VERBOSE) == 0 ? DEBUG_VERBOSE : DEBUG_INFO, + "LNX: No match partuuidopts:%g != %g\n", &Guid, &gPartuuid)); } else { - DEBUG ((OC_TRACE_KERNEL_OPTS, "LNX: Using partuuidopts=\"%s\"\n", Option->Unicode.Value)); + PlusOpts = OcUnicodeEndsWith (Option->Unicode.Name, L"+", FALSE); + + DEBUG (((gLinuxBootFlags & LINUX_BOOT_LOG_VERBOSE) == 0 ? DEBUG_VERBOSE : DEBUG_INFO, + "LNX: Using partuuidopts%a=\"%s\"\n", + PlusOpts ? "+" : "", + Option->Unicode.Value)); Status = AddOption (Options, Option->Unicode.Value, TRUE); if (EFI_ERROR (Status)) { return Status; } - // - // partuuidopts:{partuuid}+="...": use user options in addition to detected options. - // - if (!OcUnicodeEndsWith (Option->Unicode.Name, L"+", FALSE)) { + if (!PlusOpts) { return EFI_SUCCESS; } @@ -381,6 +388,43 @@ AutodetectBootOptions ( } } + // + // Use global defaults, if user has defined any. + // + for (Index = 0; Index < gParsedLoadOptions->Count; Index++) { + Option = OcFlexArrayItemAt (gParsedLoadOptions, Index); + // + // Don't use autoopts if partition specific partuuidopts already found. + // + if (!Found && StrCmp (Option->Unicode.Name, L"autoopts") == 0) { + if (Option->Unicode.Value == NULL) { + DEBUG ((DEBUG_WARN, "LNX: Missing value for %s\n", Option->Unicode.Name)); + continue; + } + + DEBUG (((gLinuxBootFlags & LINUX_BOOT_LOG_VERBOSE) == 0 ? DEBUG_VERBOSE : DEBUG_INFO, + "LNX: Using %s=\"%s\"\n", Option->Unicode.Name, Option->Unicode.Value)); + + Status = AddOption (Options, Option->Unicode.Value, TRUE); + return Status; + } else if (StrCmp (Option->Unicode.Name, L"autoopts+") == 0) { + if (Option->Unicode.Value == NULL) { + DEBUG ((DEBUG_WARN, "LNX: Missing value for %s\n", Option->Unicode.Name)); + continue; + } + + DEBUG (((gLinuxBootFlags & LINUX_BOOT_LOG_VERBOSE) == 0 ? DEBUG_VERBOSE : DEBUG_INFO, + "LNX: Using %s=\"%s\"\n", Option->Unicode.Name, Option->Unicode.Value)); + + Status = AddOption (Options, Option->Unicode.Value, TRUE); + if (EFI_ERROR (Status)) { + return Status; + } + + Found = TRUE; + } + } + // // Use options from GRUB default location. // @@ -393,21 +437,32 @@ AutodetectBootOptions ( // normally stored here, but are generated in the depths of grub scripts. // for (Index = 0; Index < (IsRescue ? 1u : 2u); Index++) { + if (Index == 0) { + GrubVarName = "GRUB_CMDLINE_LINUX"; + } else { + GrubVarName = "GRUB_CMDLINE_LINUX_DEFAULT"; + } if (OcParsedVarsGetAsciiStr ( mEtcDefaultGrubOptions, - Index == 0 ? "GRUB_CMDLINE_LINUX" : "GRUB_CMDLINE_LINUX_DEFAULT", + GrubVarName, &AsciiStrValue ) && AsciiStrValue != NULL) { + DEBUG (((gLinuxBootFlags & LINUX_BOOT_LOG_VERBOSE) == 0 ? DEBUG_VERBOSE : DEBUG_INFO, + "LNX: Using %a=\"%a\"\n", GrubVarName, AsciiStrValue)); + // - // Insert these after "ro" but before "partuuidopts+". + // Insert these after "ro" but any user specified opts. // if (AsciiStrValue[0] != '\0') { Status = InsertOption (InsertIndex, Options, AsciiStrValue, FALSE); if (EFI_ERROR (Status)) { return Status; } + // + // Must not bump this if empty option. + // InsertIndex++; } @@ -420,34 +475,6 @@ AutodetectBootOptions ( } } - // - // Use global defaults, if user has defined any. - // - for (Index = 0; Index < gParsedLoadOptions->Count; Index++) { - Option = OcFlexArrayItemAt (gParsedLoadOptions, Index); - if (!Found && StrCmp (Option->Unicode.Name, L"autoopts") == 0) { - if (Option->Unicode.Value == NULL) { - DEBUG ((DEBUG_WARN, "LNX: Missing value for %s\n", Option->Unicode.Name)); - continue; - } - - Status = AddOption (Options, Option->Unicode.Value, TRUE); - return Status; - } else if (StrCmp (Option->Unicode.Name, L"autoopts+") == 0) { - if (Option->Unicode.Value == NULL) { - DEBUG ((DEBUG_WARN, "LNX: Missing value for %s\n", Option->Unicode.Name)); - continue; - } - - Status = AddOption (Options, Option->Unicode.Value, TRUE); - if (EFI_ERROR (Status)) { - return Status; - } - - Found = TRUE; - } - } - // // It might be valid to have no options except "ro", but at least empty // string "GRUB_CMDLINE_LINUX" needs to be present in that case or we stop. @@ -457,7 +484,19 @@ AutodetectBootOptions ( return EFI_INVALID_PARAMETER; } - return EFI_SUCCESS; + // + // Insert root=PARTUUID=... option if we get to here. + // + DEBUG (((gLinuxBootFlags & LINUX_BOOT_LOG_VERBOSE) == 0 ? DEBUG_VERBOSE : DEBUG_INFO, + "LNX: Creating \"root=PARTUUID=%g\"\n", gPartuuid)); + + NewOption = OcFlexArrayInsertItem (Options, 0); + if (NewOption == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = CreateRootPartuuid (NewOption); + return Status; } STATIC @@ -564,20 +603,7 @@ GenerateEntriesForVmlinuzFiles ( } // - // root=PARTUUID=... option. - // - Option = OcFlexArrayAddItem (Entry->Options); - if (Option == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = CreateRootPartuuid (Option); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Remaining options. + // Add all options. // Status = AutodetectBootOptions (IsRescue, Entry->Options); if (EFI_ERROR (Status)) { diff --git a/Platform/OpenLinuxBoot/LinuxBootInternal.h b/Platform/OpenLinuxBoot/LinuxBootInternal.h index 0c50de57821a3df4e12080d5853ee06ead168ccf..55f84e79f5f5482a0272fd481bde35a30c93e547 100644 --- a/Platform/OpenLinuxBoot/LinuxBootInternal.h +++ b/Platform/OpenLinuxBoot/LinuxBootInternal.h @@ -10,10 +10,6 @@ #define OC_TRACE_GRUB_VARS DEBUG_VERBOSE #endif -#if !defined(OC_TRACE_KERNEL_OPTS) -#define OC_TRACE_KERNEL_OPTS DEBUG_VERBOSE -#endif - #include #include #include