Refactor BootOptions as XStringArray.

This commit is contained in:
Jief L 2020-04-26 16:07:30 +03:00
parent 2ccc95513e
commit af28b47c72
16 changed files with 294 additions and 230 deletions

View File

@ -59,7 +59,7 @@ typedef struct {
// Images load options
//
UINT32 LoadOptionsSize;///< The size in bytes of LoadOptions.
VOID *LoadOptions; ///< A pointer to the image's binary load options.
VOID JCONST *LoadOptions; ///< A pointer to the image's binary load options.
//
// Location of where image was loaded

View File

@ -1,5 +1,5 @@
#ifndef __XTOOLSCOMMON_H__
#define __XTOOLSCOMMON_H__
#ifndef __XTOOLSCONF_H__
#define __XTOOLSCONF_H__
#include <posix.h>

View File

@ -854,7 +854,7 @@ CUSTOM_LOADER_ENTRY
DuplicateEntry->Path = EfiStrDuplicate (Entry->Path);
}
DuplicateEntry->Options = Entry->Options;
DuplicateEntry->LoadOptions = Entry->LoadOptions;
if (Entry->FullTitle.notEmpty()) {
DuplicateEntry->FullTitle = Entry->FullTitle;
@ -1878,15 +1878,17 @@ FillinCustomEntry (
Prop = GetProperty(DictPointer, "AddArguments");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Options.notEmpty()) {
Entry->Options.SPrintf("%s %s", Entry->Options.c_str(), Prop->string);
} else {
Entry->Options.SPrintf("%s", Prop->string);
}
// if (Entry->LoadOptions.notEmpty()) {
// Entry->Options.SPrintf("%s %s", Entry->Options.c_str(), Prop->string);
// } else {
// Entry->Options.SPrintf("%s", Prop->string);
// }
Entry->LoadOptions = Split<XStringArray>(Prop->string, " ");
} else {
Prop = GetProperty(DictPointer, "Arguments");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
Entry->Options.SPrintf("%s", Prop->string);
// Entry->Options.SPrintf("%s", Prop->string);
Entry->LoadOptions = Split<XStringArray>(Prop->string, " ");
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
}
}
@ -2037,8 +2039,9 @@ FillinCustomEntry (
Entry->VolumeType = GetVolumeType(DictPointer);
if (Entry->Options.isEmpty() && OSTYPE_IS_WINDOWS(Entry->Type)) {
Entry->Options.SPrintf("-s -h");
if (Entry->LoadOptions.isEmpty() && OSTYPE_IS_WINDOWS(Entry->Type)) {
Entry->LoadOptions.Add("-s");
Entry->LoadOptions.Add("-h");
}
if (Entry->Title.isEmpty()) {
if (OSTYPE_IS_OSX_RECOVERY(Entry->Type)) {
@ -2308,7 +2311,7 @@ FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer)
// } else {
// Entry->Options.SPrintf("%s", Prop->string);
// }
Entry->Options.SPrintf("%s", Prop->string);
Entry->LoadOptions = Split<XStringArray>(Prop->string, " ");
}
Prop = GetProperty(DictPointer, "FullTitle");

View File

@ -99,7 +99,7 @@ struct CUSTOM_LOADER_ENTRY {
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
CONST CHAR16 *Path;
XString Options;
XStringArray LoadOptions;
XStringW FullTitle;
XStringW Title;
@ -148,7 +148,7 @@ struct CUSTOM_TOOL_ENTRY {
CHAR16 *ImagePath;
CHAR16 *Volume;
CHAR16 *Path;
XString Options;
XStringArray LoadOptions;
XStringW FullTitle;
XStringW Title;
CHAR16 Hotkey;

View File

@ -711,11 +711,16 @@ public:
// int Compare(const char32_t* S) const { return ::Compare<T, char32_t>(m_data, S); };
// int Compare(const wchar_t* S) const { return ::Compare<T, wchar_t>(m_data, S); };
//
template<typename O, class OtherXStringClass>
bool equal(const XStringAbstract<O, OtherXStringClass>& S) const { return XStringAbstract__compare(m_data, S.s(), false) == 0; }
template<typename O>
bool equal(const O* S) const { return XStringAbstract__compare(m_data, S, false) == 0; }
template<typename O, class OtherXStringClass>
bool equalIC(const XStringAbstract<O, OtherXStringClass>& S) const { return XStringAbstract__compare(m_data, S.s(), true) == 0; }
template<typename O>
bool equalIC(const O* S) const { return XStringAbstract__compare(m_data, S, true) == 0; }
// bool startWith(const T* S) const { return (memcmp(data(), S, wcslen(S)) == 0); }
// bool SubStringEqual(size_t Pos, const T* S) const { return (memcmp(data(Pos), S, wcslen(S)) == 0); }
public:

View File

@ -37,8 +37,14 @@ class XStringArray_/* : public XStringArraySuper*/
/* [] */
template<typename IntegralType, enable_if(is_integral(IntegralType))>
const XStringClass& operator [](IntegralType i) const { return array[i]; }
/* ElementAt */
template<typename IntegralType, enable_if(is_integral(IntegralType))>
const XStringClass& elementAt(IntegralType i) const { return array[i]; }
template<typename IntegralType, enable_if(is_integral(IntegralType))>
XStringClass& elementAt(IntegralType i) { return array[i]; }
const XStringClass& dbg(size_t i) const { return array[i]; }
// const XStringClass& dbg(size_t i) const { return array[i]; }
XStringClass ConcatAll(const XStringClass& Separator = ", "_XS, const XStringClass& Prefix = NullXString, const XStringClass& Suffix = NullXString) const
@ -75,36 +81,47 @@ class XStringArray_/* : public XStringArraySuper*/
template<class OtherXStringArrayClass>
bool operator !=(const OtherXStringArrayClass& aXStrings) const { return !Equal(aXStrings); }
template<class OtherXStringClass>
/* contains */
template<typename CharType, enable_if(is_char(CharType))>
bool contains(const CharType* s) const
{
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
if ( array.ElementAt(i).equal(s) ) return true;
}
return false;
}
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
bool contains(const OtherXStringClass &S) const
{
xsize i;
for ( i=0 ; i<array.size() ; i+=1 ) {
if ( array.ElementAt(i) == S ) return true;
return contains(S.s());
}
/* containsIC */
template<typename CharType, enable_if(is_char(CharType))>
bool containsIC(const CharType* s) const
{
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
if ( array.ElementAt(i).equalIC(s) ) return true;
}
return false;
}
template<class OtherXStringClass>
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
bool containsIC(const OtherXStringClass &S) const
{
xsize i;
for ( i=0 ; i<XStringArraySuper::size() ; i+=1 ) {
if ( this->ElementAt(i).EqualIC(S) ) return true;
return containsIC(S.s());
}
/* ContainsStartWithIC */
template<typename CharType, enable_if(is_char(CharType))>
bool containsStartWithIC(const CharType* s) const
{
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
if ( array.ElementAt(i).startWithIC(s) ) return true;
}
return false;
}
template<class OtherXStringClass>
bool ContainsStartWithIC(const OtherXStringClass &S) const
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
bool containsStartWithIC(const OtherXStringClass &S) const
{
xsize i;
for ( i=0 ; i<XStringArraySuper::size() ; i+=1 ) {
if ( this->ElementAt(i).startWith(S) ) return true;
}
return false;
return ContainsStartWithIC(S.s());
}
@ -148,15 +165,24 @@ class XStringArray_/* : public XStringArraySuper*/
void AddNoNull(const XStringClass &aString) { if ( !aString.isEmpty() ) array.AddCopy(aString); }
void AddEvenNull(const XStringClass &aString) { array.AddCopy(aString); }
template<typename CharType, enable_if(is_char(CharType))>
void Add(const CharType* s)
{
XStringClass* xstr = new XStringClass;
xstr->strcpy(s);
array.AddReference(xstr, true);
}
void Add(const XStringClass &aString) { array.AddCopy(aString); }
void AddReference(XStringClass *newElement, bool FreeIt) { array.AddReference(newElement, FreeIt); }
template<class OtherXStringClass>
void Add(const XStringArray_<OtherXStringClass> &aStrings)
void import(const XStringArray_<OtherXStringClass> &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
AddCopy(aStrings[i]);
array.AddCopy(aStrings[i]);
}
}
@ -164,7 +190,7 @@ class XStringArray_/* : public XStringArraySuper*/
{
if ( !contains(aString) ) array.AddCopy(aString);
}
void AddID(const XStringArray_ &aStrings) /* ignore Duplicate */
void importID(const XStringArray_ &aStrings) /* ignore Duplicate */
{
xsize i;

View File

@ -119,82 +119,82 @@ const XImage& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EF
return *IconX;
}
XString AddLoadOption(IN CONST XString& LoadOptions, IN CONST XString& LoadOption)
{
// LoadOptions assumed out
// If either option strings are null nothing to do
if (LoadOptions.isEmpty()) //initially empty so return new option even if empty
{
// return LoadOption
return LoadOption;
}
// If there is no option or it is already present duplicate original
else {
if ( LoadOptions.contains(LoadOption) ) return LoadOptions; //good
// Otherwise add option
// return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption
return LoadOptions + " "_XS + LoadOption; //why not?
}
}
XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption)
{
// CONST CHAR16 *Placement;
// CHAR16 *NewLoadOptions;
// UINTN Length, Offset, OptionLength;
//DBG("LoadOptions: '%ls', remove LoadOption: '%ls'\n", LoadOptions, LoadOption);
// If there are no options then nothing to do
if (LoadOptions.isEmpty()) return ""_XS;
// If there is no option to remove then duplicate original
if (LoadOption.isEmpty()) return LoadOptions;
// If not present duplicate original
xsize Offset = LoadOptions.indexOf(LoadOption);
if ( Offset == MAX_XSIZE ) return LoadOptions;
// Get placement of option in original options
// Offset = (Placement - LoadOptions);
xsize Length = LoadOptions.length();
xsize OptionLength = LoadOption.length();
// If this is just part of some larger option (contains non-space at the beginning or end)
if ((Offset > 0 && LoadOptions[Offset - 1] != ' ') ||
((Offset + OptionLength) < Length && LoadOptions[Offset + OptionLength] != ' ')) {
return LoadOptions;
}
// Consume preceeding spaces
while (Offset > 0 && LoadOptions[Offset - 1] == ' ') {
OptionLength++;
Offset--;
}
// Consume following spaces
while (LoadOptions[Offset + OptionLength] == ' ') {
OptionLength++;
}
// If it's the whole string return NULL
if (OptionLength == Length) return ""_XS;
XString NewLoadOptions;
if (Offset == 0) {
// Simple case - we just need substring after OptionLength position
NewLoadOptions = LoadOptions.subString(OptionLength, MAX_XSIZE);
} else {
// Copy preceeding substring
NewLoadOptions = LoadOptions.subString(0, Offset);
// CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16));
if ((Offset + OptionLength) < Length) {
// Copy following substring, but include one space also
OptionLength--;
NewLoadOptions += LoadOptions.subString(Offset + OptionLength, MAX_XSIZE);
// CopyMem(NewLoadOptions + Offset, LoadOptions + Offset + OptionLength, (Length - OptionLength - Offset) * sizeof(CHAR16));
}
}
return NewLoadOptions;
}
//
//XString AddLoadOption(IN CONST XString& LoadOptions, IN CONST XString& LoadOption)
//{
// // LoadOptions assumed out
// // If either option strings are null nothing to do
// if (LoadOptions.isEmpty()) //initially empty so return new option even if empty
// {
// // return LoadOption
// return LoadOption;
// }
// // If there is no option or it is already present duplicate original
// else {
// if ( LoadOptions.contains(LoadOption) ) return LoadOptions; //good
// // Otherwise add option
//// return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption
// return LoadOptions + " "_XS + LoadOption; //why not?
// }
//}
//
//XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption)
//{
//// CONST CHAR16 *Placement;
//// CHAR16 *NewLoadOptions;
//// UINTN Length, Offset, OptionLength;
//
// //DBG("LoadOptions: '%ls', remove LoadOption: '%ls'\n", LoadOptions, LoadOption);
// // If there are no options then nothing to do
// if (LoadOptions.isEmpty()) return ""_XS;
// // If there is no option to remove then duplicate original
// if (LoadOption.isEmpty()) return LoadOptions;
// // If not present duplicate original
// xsize Offset = LoadOptions.indexOf(LoadOption);
// if ( Offset == MAX_XSIZE ) return LoadOptions;
//
// // Get placement of option in original options
//// Offset = (Placement - LoadOptions);
// xsize Length = LoadOptions.length();
// xsize OptionLength = LoadOption.length();
//
// // If this is just part of some larger option (contains non-space at the beginning or end)
// if ((Offset > 0 && LoadOptions[Offset - 1] != ' ') ||
// ((Offset + OptionLength) < Length && LoadOptions[Offset + OptionLength] != ' ')) {
// return LoadOptions;
// }
//
// // Consume preceeding spaces
// while (Offset > 0 && LoadOptions[Offset - 1] == ' ') {
// OptionLength++;
// Offset--;
// }
//
// // Consume following spaces
// while (LoadOptions[Offset + OptionLength] == ' ') {
// OptionLength++;
// }
//
// // If it's the whole string return NULL
// if (OptionLength == Length) return ""_XS;
//
// XString NewLoadOptions;
// if (Offset == 0) {
// // Simple case - we just need substring after OptionLength position
// NewLoadOptions = LoadOptions.subString(OptionLength, MAX_XSIZE);
// } else {
// // Copy preceeding substring
// NewLoadOptions = LoadOptions.subString(0, Offset);
//// CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16));
// if ((Offset + OptionLength) < Length) {
// // Copy following substring, but include one space also
// OptionLength--;
// NewLoadOptions += LoadOptions.subString(Offset + OptionLength, MAX_XSIZE);
//// CopyMem(NewLoadOptions + Offset, LoadOptions + Offset + OptionLength, (Length - OptionLength - Offset) * sizeof(CHAR16));
// }
// }
// return NewLoadOptions;
//}
#define TO_LOWER(ch) (((ch >= L'A') && (ch <= L'Z')) ? ((ch - L'A') + L'a') : ch)
INTN StrniCmp(IN CONST CHAR16 *Str1,

View File

@ -10,8 +10,8 @@
#include "../cpp_foundation/XString.h"
XString AddLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption);
XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption);
//XString AddLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption);
//XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption);
INTN
StrniCmp (

View File

@ -161,7 +161,9 @@ BOOLEAN AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& LoaderTi
}
Entry->Volume = Volume;
Entry->DevicePathString = Volume->DevicePathString;
Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD"_XS : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB"_XS : "HD"_XS);
// Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD"_XS : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB"_XS : "HD"_XS);
Entry->LoadOptions.setEmpty();
Entry->LoadOptions.Add((Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD" : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB" : "HD"));
// create the submenu
// SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
SubScreen = new REFIT_MENU_SCREEN();

View File

@ -44,6 +44,8 @@
#include "../Platform/Nvram.h"
#include "../Platform/APFS.h"
#include "../Platform/guid.h"
#include "../refit/lib.h"
#include "../gui/REFIT_MENU_SCREEN.h"
#ifndef DEBUG_ALL
#define DEBUG_SCAN_LOADER 1
@ -65,7 +67,7 @@ const XStringW LINUX_ISSUE_PATH = L"\\etc\\issue"_XSW;
const XString LINUX_LOADER_PATH = "vmlinuz"_XS;
const XStringW LINUX_FULL_LOADER_PATH = SWPrintf("%ls\\%s", LINUX_BOOT_PATH, LINUX_LOADER_PATH.c_str());
#define LINUX_LOADER_SEARCH_PATH L"vmlinuz*"
const XString LINUX_DEFAULT_OPTIONS = "ro add_efi_memmap quiet splash vt.handoff=7"_XS;
const XStringArray LINUX_DEFAULT_OPTIONS = Split<XStringArray>("ro add_efi_memmap quiet splash vt.handoff=7", " ");
#if defined(MDE_CPU_X64)
#define BOOT_LOADER_PATH L"\\EFI\\BOOT\\BOOTX64.efi"
@ -346,10 +348,10 @@ STATIC CONST XString LinuxInitImagePath[] = {
};
STATIC CONST UINTN LinuxInitImagePathCount = (sizeof(LinuxInitImagePath) / sizeof(CHAR16 *));
STATIC XString LinuxKernelOptions(IN EFI_FILE_PROTOCOL *Dir,
STATIC XStringArray LinuxKernelOptions(IN EFI_FILE_PROTOCOL *Dir,
IN CONST CHAR16 *Version,
IN CONST CHAR16 *PartUUID,
IN CONST XString& Options OPTIONAL)
IN CONST XStringArray& Options OPTIONAL)
{
UINTN Index = 0;
if ((Dir == NULL) || (PartUUID == NULL)) {
@ -359,12 +361,20 @@ STATIC XString LinuxKernelOptions(IN EFI_FILE_PROTOCOL *Dir,
XStringW InitRd = SWPrintf(LinuxInitImagePath[Index++].c_str(), (Version == NULL) ? L"" : Version);
if (InitRd.notEmpty()) {
if (FileExists(Dir, InitRd.wc_str())) {
XString CustomOptions = SPrintf("root=/dev/disk/by-partuuid/%ls initrd=%ls\\%ls %s %s", PartUUID, LINUX_BOOT_ALT_PATH, InitRd.wc_str(), LINUX_DEFAULT_OPTIONS.c_str(), Options.c_str());
XStringArray CustomOptions;
CustomOptions.Add(SPrintf("root=/dev/disk/by-partuuid/%ls", PartUUID));
CustomOptions.Add(SPrintf("initrd=%ls\\%ls", LINUX_BOOT_ALT_PATH, InitRd.wc_str()));
CustomOptions.import(LINUX_DEFAULT_OPTIONS);
CustomOptions.import(Options);
return CustomOptions;
}
}
}
return SPrintf("root=/dev/disk/by-partuuid/%ls %s %s", PartUUID, LINUX_DEFAULT_OPTIONS.c_str(), Options.c_str());
XStringArray CustomOptions;
CustomOptions.Add(SPrintf("root=/dev/disk/by-partuuid/%ls", PartUUID));
CustomOptions.import(LINUX_DEFAULT_OPTIONS);
CustomOptions.import(Options);
return CustomOptions;
}
STATIC BOOLEAN isFirstRootUUID(REFIT_VOLUME *Volume)
@ -430,7 +440,7 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry)
return Status;
}
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST XString& LoaderOptions,
IN CONST XStringArray& LoaderOptions,
IN CONST XStringW& FullTitle,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume,
@ -589,14 +599,20 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->DevicePath = LoaderDevicePath;
Entry->DevicePathString = LoaderDevicePathString;
Entry->Flags = OSFLAG_SET(Flags, OSFLAG_USEGRAPHICS);
if (LoaderOptions.notEmpty()) {
if (OSFLAG_ISSET(Flags, OSFLAG_NODEFAULTARGS)) {
Entry->LoadOptions = LoaderOptions;
} else {
Entry->LoadOptions = SPrintf("%s %s", gSettings.BootArgs, LoaderOptions.c_str());
}
} else if ((AsciiStrLen(gSettings.BootArgs) > 0) && OSFLAG_ISUNSET(Flags, OSFLAG_NODEFAULTARGS)) {
Entry->LoadOptions = SPrintf("%s", gSettings.BootArgs);
// if (LoaderOptions.notEmpty()) {
// if (OSFLAG_ISSET(Flags, OSFLAG_NODEFAULTARGS)) {
// Entry->LoadOptions = LoaderOptions;
// } else {
// Entry->LoadOptions = SPrintf("%s %s", gSettings.BootArgs, LoaderOptions.c_str());
// }
// } else if ((AsciiStrLen(gSettings.BootArgs) > 0) && OSFLAG_ISUNSET(Flags, OSFLAG_NODEFAULTARGS)) {
// Entry->LoadOptions = SPrintf("%s", gSettings.BootArgs);
// }
if (OSFLAG_ISSET(Flags, OSFLAG_NODEFAULTARGS)) {
Entry->LoadOptions = LoaderOptions;
}else{
Entry->LoadOptions = Split<XStringArray>(gSettings.BootArgs, " ");
Entry->LoadOptions.import(LoaderOptions);
}
//actions
Entry->AtClick = ActionSelect;
@ -805,7 +821,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
if (Guid) {
SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
}
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.c_str());
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.ConcatAll(" "_XS).c_str());
// loader-specific submenu entries
if (Entry->LoaderType == OSTYPE_OSX ||
Entry->LoaderType == OSTYPE_OSX_INSTALLER ||
@ -921,10 +937,10 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
if (SubEntry) {
if (Quiet) {
SubEntry->Title.SWPrintf("%ls verbose", Entry->Title.s());
SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, "quiet"_XS);
SubEntry->LoadOptions.removeIC("quiet"_XS);
} else {
SubEntry->Title.SWPrintf("%ls quiet", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "quiet"_XS);
SubEntry->LoadOptions.AddID("quiet"_XS);
}
}
SubScreen->AddMenuEntry(SubEntry, true);
@ -932,10 +948,10 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
if (SubEntry) {
if (WithSplash) {
SubEntry->Title.SWPrintf("%ls without splash", Entry->Title.s());
SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, "splash"_XS);
SubEntry->LoadOptions.removeIC("splash"_XS);
} else {
SubEntry->Title.SWPrintf("%ls with splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "splash"_XS);
SubEntry->LoadOptions.AddID("splash"_XS);
}
}
SubScreen->AddMenuEntry(SubEntry, true);
@ -944,25 +960,30 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
if (WithSplash) {
if (Quiet) {
SubEntry->Title.SWPrintf("%ls verbose without splash", Entry->Title.s());
SubEntry->LoadOptions = RemoveLoadOption(RemoveLoadOption(Entry->LoadOptions, "splash"_XS), "quiet"_XS);
SubEntry->LoadOptions.removeIC("splash"_XS);
SubEntry->LoadOptions.removeIC("quiet"_XS);
} else {
SubEntry->Title.SWPrintf("%ls quiet without splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(RemoveLoadOption(Entry->LoadOptions, "splash"_XS), "quiet"_XS);
SubEntry->LoadOptions.removeIC("splash"_XS);
SubEntry->LoadOptions.Add("quiet"_XS);
}
} else if (Quiet) {
// TempOptions = RemoveLoadOption(Entry->LoadOptions, "quiet"_XS);
// TempOptions.RemoveIC("quiet"_XS);
SubEntry->Title.SWPrintf("%ls verbose with splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "splash"_XS);
SubEntry->LoadOptions.AddID("splash"_XS);
// FreePool(TempOptions);
} else {
SubEntry->Title.SWPrintf("%ls quiet with splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "quiet splash"_XS);
SubEntry->LoadOptions.AddID("quiet"_XS);
SubEntry->LoadOptions.AddID("splash"_XS);
}
}
SubScreen->AddMenuEntry(SubEntry, true);
} else if ((Entry->LoaderType == OSTYPE_WIN) || (Entry->LoaderType == OSTYPE_WINEFI)) {
// by default, skip the built-in selection and boot from hard disk only
Entry->LoadOptions.SPrintf("-s -h");
Entry->LoadOptions.setEmpty();
Entry->LoadOptions.Add("-s"_XS);
Entry->LoadOptions.Add("-h"_XS);
// default entry
SubEntry = Entry->getPartiallyDuplicatedEntry();
@ -980,7 +1001,9 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.takeValueFrom("Boot Windows from CD-ROM");
SubEntry->LoadOptions.SPrintf("-s -c");
Entry->LoadOptions.setEmpty();
Entry->LoadOptions.Add("-s"_XS);
Entry->LoadOptions.Add("-c"_XS);
SubScreen->AddMenuEntry(SubEntry, true);
}
@ -988,7 +1011,8 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
if (SubEntry) {
SubEntry->Title.SWPrintf("Run %ls in text mode", FileName);
SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_USEGRAPHICS);
SubEntry->LoadOptions.SPrintf(" -v");
Entry->LoadOptions.setEmpty();
Entry->LoadOptions.Add("-v"_XS);
SubEntry->LoaderType = OSTYPE_OTHER; // Sothor - Why are we using OSTYPE_OTHER here?
SubScreen->AddMenuEntry(SubEntry, true);
}
@ -999,7 +1023,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
Entry->SubScreen = SubScreen;
// DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n", Entry->Title, Entry->LoaderType, Entry->OSVersion);
}
BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST XString& LoaderOptions,
BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST XStringArray& LoaderOptions,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume, IN XImage *Image,
IN UINT8 OSType, IN UINT8 Flags)
@ -1075,16 +1099,16 @@ VOID AddPRSEntry(REFIT_VOLUME *Volume)
switch (WhatBoot) {
case Paper:
case (Paper | Rock):
AddLoaderEntry(PaperBoot, ""_XS, L"macOS InstallP"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
AddLoaderEntry(PaperBoot, NullXStringArray, L"macOS InstallP"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
break;
case Scissor:
case (Paper | Scissor):
AddLoaderEntry(ScissorBoot, ""_XS, L"macOS InstallS"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
AddLoaderEntry(ScissorBoot, NullXStringArray, L"macOS InstallS"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
break;
case Rock:
case (Rock | Scissor):
case (Rock | Scissor | Paper):
AddLoaderEntry(RockBoot, ""_XS, L"macOS InstallR"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
AddLoaderEntry(RockBoot, NullXStringArray, L"macOS InstallR"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
break;
default:
@ -1138,40 +1162,40 @@ VOID ScanLoader(VOID)
if (FileExists(Volume->RootDir, L"\\Install OS X Mavericks.app") ||
FileExists(Volume->RootDir, L"\\Install OS X Yosemite.app") ||
FileExists(Volume->RootDir, L"\\Install OS X El Capitan.app")) {
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.9 - 10.11
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", NullXStringArray, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.9 - 10.11
} else {
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
}
} else if (FileExists(Volume->RootDir, L"\\.IAPhysicalMedia") && FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
}
// 2nd stage - InstallESD/AppStore/startosinstall/Fusion Drive
AddLoaderEntry(L"\\Mac OS X Install Data\\boot.efi", ""_XS, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(L"\\OS X Install Data\\boot.efi", ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(L"\\macOS Install Data\\boot.efi", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.12.3
AddLoaderEntry(L"\\macOS Install Data\\Locked Files\\Boot Files\\boot.efi", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12.4+
AddLoaderEntry(L"\\Mac OS X Install Data\\boot.efi", NullXStringArray, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(L"\\OS X Install Data\\boot.efi", NullXStringArray, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(L"\\macOS Install Data\\boot.efi", NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.12.3
AddLoaderEntry(L"\\macOS Install Data\\Locked Files\\Boot Files\\boot.efi", NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12.4+
AddPRSEntry(Volume); // 10.12+
// Netinstall
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter", NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
// Use standard location for boot.efi, according to the install files is present
// That file indentifies a DVD/ESD/BaseSystem/Fusion Drive Install Media, so when present, check standard path to avoid entry duplication
if (FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\Mac OS X Installer.app")) {
// InstallDVD/BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.6/10.7
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.6/10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\OS X Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\macOS Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12+
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12+
} else if (FileExists(Volume->RootDir, L"\\BaseSystem.dmg") && FileExists(Volume->RootDir, L"\\mach_kernel")) {
// InstallESD
if (FileExists(Volume->RootDir, L"\\MacOSX_Media_Background.png")) {
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8
}
} else if (FileExists(Volume->RootDir, L"\\com.apple.boot.R\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
FileExists(Volume->RootDir, L"\\com.apple.boot.P\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
@ -1179,20 +1203,20 @@ VOID ScanLoader(VOID)
if (StriStr(Volume->VolName, L"Recovery") != NULL) {
// FileVault of HFS+
// TODO: need info for 10.11 and lower
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS FileVault"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"macOS FileVault"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
} else {
// Fusion Drive
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.11
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.11
}
} else if (!FileExists(Volume->RootDir, L"\\.IAPhysicalMedia")) {
// Installed
if (EFI_ERROR(GetRootUUID(Volume)) || isFirstRootUUID(Volume)) {
if (!FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"Mac OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.6 - 10.7
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"Mac OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.6 - 10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.8 - 10.11
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.8 - 10.11
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"macOS"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
}
}
}
@ -1209,32 +1233,32 @@ VOID ScanLoader(VOID)
StrnCpy(APFSRecBootPath + 1, CurrentUUID, 36);
StrnCpy(APFSInstallBootPath + 1, CurrentUUID, 36);
//Try to add FileVault entry
AddLoaderEntry(APFSFVBootPath, ""_XS, L"FileVault Prebooter"_XSW, Volume, NULL, OSTYPE_OSX, 0);
AddLoaderEntry(APFSFVBootPath, NullXStringArray, L"FileVault Prebooter"_XSW, Volume, NULL, OSTYPE_OSX, 0);
//Try to add Recovery APFS entry
AddLoaderEntry(APFSRecBootPath, ""_XS, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
AddLoaderEntry(APFSRecBootPath, NullXStringArray, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
//Try to add macOS install entry
AddLoaderEntry(APFSInstallBootPath, ""_XS, L"macOS Install Prebooter"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
AddLoaderEntry(APFSInstallBootPath, NullXStringArray, L"macOS Install Prebooter"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
FreePool(CurrentUUID);
}
}
// check for Mac OS X Recovery Boot
AddLoaderEntry(L"\\com.apple.recovery.boot\\boot.efi", ""_XS, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
AddLoaderEntry(L"\\com.apple.recovery.boot\\boot.efi", NullXStringArray, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
// Sometimes, on some systems (HP UEFI, if Win is installed first)
// it is needed to get rid of bootmgfw.efi to allow starting of
// Clover as /efi/boot/bootx64.efi from HD. We can do that by renaming
// bootmgfw.efi to bootmgfw-orig.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw-orig.efi", ""_XS, L"Microsoft EFI"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw-orig.efi", NullXStringArray, L"Microsoft EFI"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu
// If there is bootmgfw-orig.efi, then do not check for bootmgfw.efi
// since on some systems this will actually be CloverX64.efi
// renamed to bootmgfw.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw.efi", ""_XS, L"Microsoft EFI Boot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw.efi", NullXStringArray, L"Microsoft EFI Boot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu. This entry is redundant so excluded
// AddLoaderEntry(L"\\bootmgr.efi", L"", L"Microsoft EFI mgrboot", Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu on CDROM
if (!AddLoaderEntry(L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi", ""_XS, L"Microsoft EFI cdboot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0)) {
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI", ""_XS, L"Microsoft EFI CDBOOT"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
if (!AddLoaderEntry(L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi", NullXStringArray, L"Microsoft EFI cdboot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0)) {
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI", NullXStringArray, L"Microsoft EFI CDBOOT"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
}
#if defined(ANDX86)
if (TRUE) { //gSettings.AndroidScan
@ -1250,7 +1274,7 @@ VOID ScanLoader(VOID)
XImage ImageX;
XStringW IconXSW = XStringW().takeValueFrom(AndroidEntryData[Index].Icon);
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str());
AddLoaderEntry(AndroidEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
AddLoaderEntry(AndroidEntryData[Index].Path, NullXStringArray, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
}
}
@ -1288,7 +1312,7 @@ VOID ScanLoader(VOID)
XImage ImageX; //will the image be destroyed or rewritten by next image after the cycle end?
// load from directory, as we don't have linux icons preloaded
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + OSName).wc_str());
AddLoaderEntry(File.wc_str(), ""_XS, LoaderTitle, Volume,
AddLoaderEntry(File.wc_str(), NullXStringArray, LoaderTitle, Volume,
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
} //anyway continue search other entries
}
@ -1299,7 +1323,7 @@ VOID ScanLoader(VOID)
XImage ImageX;
XStringW IconXSW = XStringW().takeValueFrom(LinuxEntryData[Index].Icon);
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str());
AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
AddLoaderEntry(LinuxEntryData[Index].Path, NullXStringArray, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
}
}
@ -1332,7 +1356,7 @@ VOID ScanLoader(VOID)
// get the kernel file path
Path = PoolPrint(L"%s\\%s", LINUX_BOOT_PATH, FileInfo->FileName);
if (Path != NULL) {
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
XStringArray Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, NullXStringArray);
// Add the entry
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
@ -1363,7 +1387,7 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
XStringArray Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, NullXStringArray);
// Add the entry
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
FreePool(Path);
@ -1390,7 +1414,7 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
XStringArray Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, NullXStringArray);
// Add the entry
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
FreePool(Path);
@ -1417,7 +1441,7 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
XString Options = LinuxKernelOptions(Iter.DirHandle, XStringW().takeValueFrom(Basename(Path) + LINUX_LOADER_PATH.length()).wc_str(), PartUUID, ""_XS);
XStringArray Options = LinuxKernelOptions(Iter.DirHandle, XStringW().takeValueFrom(Basename(Path) + LINUX_LOADER_PATH.length()).wc_str(), PartUUID, NullXStringArray);
// Add the entry
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
FreePool(Path);
@ -1448,7 +1472,7 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
XString Options = LinuxKernelOptions(Iter.DirHandle, XStringW().takeValueFrom(Basename(Path) + LINUX_LOADER_PATH.length()).wc_str(), PartUUID, ""_XS);
XStringArray Options = LinuxKernelOptions(Iter.DirHandle, XStringW().takeValueFrom(Basename(Path) + LINUX_LOADER_PATH.length()).wc_str(), PartUUID, NullXStringArray);
// Add the entry
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
@ -1480,7 +1504,7 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
XStringArray Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, NullXStringArray);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
FreePool(Path);
}
@ -1494,7 +1518,7 @@ VOID ScanLoader(VOID)
// get the kernel file path
Path = PoolPrint(L"%s\\%s", LINUX_BOOT_PATH, FileInfo->FileName);
if (Path != NULL) {
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
XStringArray Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, NullXStringArray);
// Add the entry
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
FreePool(Path);
@ -1518,15 +1542,15 @@ VOID ScanLoader(VOID)
} //if linux scan
// DBG("search for optical UEFI\n");
if (Volume->DiskKind == DISK_KIND_OPTICAL) {
AddLoaderEntry(BOOT_LOADER_PATH, ""_XS, L"UEFI optical"_XSW, Volume, NULL, OSTYPE_OTHER, 0);
AddLoaderEntry(BOOT_LOADER_PATH, NullXStringArray, L"UEFI optical"_XSW, Volume, NULL, OSTYPE_OTHER, 0);
}
// DBG("search for internal UEFI\n");
if (Volume->DiskKind == DISK_KIND_INTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, ""_XS, L"UEFI internal"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
AddLoaderEntry(BOOT_LOADER_PATH, NullXStringArray, L"UEFI internal"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
// DBG("search for external UEFI\n");
if (Volume->DiskKind == DISK_KIND_EXTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, ""_XS, L"UEFI external"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
AddLoaderEntry(BOOT_LOADER_PATH, NullXStringArray, L"UEFI external"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
}
@ -1859,7 +1883,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
do
{
// Search for linux kernels
XString CustomOptions = Custom->Options;
XStringArray CustomOptions = Custom->LoadOptions;
if (FindCustomPath && (Custom->KernelScan == KERNEL_SCAN_ALL)) {
EFI_FILE_INFO *FileInfo = NULL;
// Get the next kernel path or stop looking
@ -1884,7 +1908,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
// Check to make sure we should update custom options or not
if (FindCustomPath && OSFLAG_ISUNSET(Custom->Flags, OSFLAG_NODEFAULTARGS)) {
// Find the init ram image and select root
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath) + LINUX_LOADER_PATH.length(), PartUUID, Custom->Options);
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath) + LINUX_LOADER_PATH.length(), PartUUID, Custom->LoadOptions);
}
// Check to make sure that this entry is not hidden or disabled by another custom entry
if (!IsSubEntry) {
@ -2048,7 +2072,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
if (Guid) {
SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
}
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.c_str());
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.ConcatAll(" "_XS).c_str());
DBG("Create sub entries\n");
for (CustomSubEntry = Custom->SubEntries; CustomSubEntry; CustomSubEntry = CustomSubEntry->Next) {
if (!CustomSubEntry->Settings) {

View File

@ -37,6 +37,8 @@
#include "../refit/menu.h"
#include "../refit/screen.h"
#include "../libeg/XImage.h"
#include "../refit/lib.h"
#include "../gui/REFIT_MENU_SCREEN.h"
//
// Clover File location to boot from on removable media devices
@ -73,7 +75,7 @@
STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume, const XImage& Image,
IN CHAR16 ShortcutLetter, IN CONST XString& Options)
IN CHAR16 ShortcutLetter, IN CONST XStringArray& Options)
{
REFIT_MENU_ENTRY_LOADER_TOOL *Entry;
// Check the loader exists
@ -160,21 +162,24 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.SWPrintf("Add Clover boot options for all entries");
SubEntry->LoadOptions.SPrintf("BO-ADD");
SubEntry->LoadOptions.setEmpty();
SubEntry->LoadOptions.Add("BO-ADD");
SubScreen->AddMenuEntry(SubEntry, true);
}
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.SWPrintf("Remove all Clover boot options");
SubEntry->LoadOptions.SPrintf("BO-REMOVE");
SubEntry->LoadOptions.setEmpty();
SubEntry->LoadOptions.Add("BO-REMOVE");
SubScreen->AddMenuEntry(SubEntry, true);
}
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.SWPrintf("Print all UEFI boot options to log");
SubEntry->LoadOptions.SPrintf("BO-PRINT");
SubEntry->LoadOptions.setEmpty();
SubEntry->LoadOptions.Add("BO-PRINT");
SubScreen->AddMenuEntry(SubEntry, true);
}
@ -194,8 +199,8 @@ VOID ScanTool(VOID)
// DBG("Scanning for tools...\n");
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_SHELL)) {
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS);
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXStringArray)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXStringArray);
}
}
@ -310,10 +315,10 @@ VOID AddCustomTool(VOID)
Image.LoadXImage(ThemeX.ThemeDir, Custom->ImagePath);
}
if (Image.isEmpty()) {
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->Options);
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->LoadOptions);
} else {
// Create a legacy entry for this volume
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, Image, Custom->Hotkey, Custom->Options);
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, Image, Custom->Hotkey, Custom->LoadOptions);
}
DBG("match!\n");
// break; // break scan volumes, continue scan entries -- why?

View File

@ -2604,9 +2604,9 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
TimeoutSeconds = 0;
if (MenuExit == MENU_EXIT_DETAILS && MainChosenEntry->SubScreen != NULL) {
XString TmpArgs;
XStringArray TmpArgs;
if (AsciiStrLen(gSettings.BootArgs) > 0) {
TmpArgs.SPrintf("%s", gSettings.BootArgs);
TmpArgs = Split<XStringArray>(gSettings.BootArgs, " ");
}
SubMenuIndex = -1;
@ -2647,7 +2647,7 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
}
if (/*MenuExit == MENU_EXIT_ENTER &&*/ MainChosenEntry->getLOADER_ENTRY()) {
if (MainChosenEntry->getLOADER_ENTRY()->LoadOptions.notEmpty()) {
snprintf(gSettings.BootArgs, 255, "%s", MainChosenEntry->getLOADER_ENTRY()->LoadOptions.c_str());
snprintf(gSettings.BootArgs, 255, "%s", MainChosenEntry->getLOADER_ENTRY()->LoadOptions.ConcatAll(" "_XS).c_str());
} else {
ZeroMem(&gSettings.BootArgs, 255);
}

View File

@ -260,7 +260,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
{
public:
CONST CHAR16 *DevicePathString;
XString LoadOptions; //moved here for compatibility with legacy
XStringArray LoadOptions; //moved here for compatibility with legacy
CONST CHAR16 *LoaderPath;
XImage DriveImage;
XImage BadgeImage;

View File

@ -71,7 +71,7 @@ CONST CHAR16 *VBIOS_BIN = L"EFI\\CLOVER\\misc\\c0000.bin";
INPUT_ITEM *InputItems = NULL;
INTN TextStyle; //why global? It will be class SCREEN member
UINT32 EncodeOptions(const XString& Options)
UINT32 EncodeOptions(const XStringArray& Options)
{
UINT32 OptionsBits = 0;
INTN Index;
@ -98,13 +98,13 @@ VOID DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry)
}
for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON
if (gSettings.OptionsBits & (1 << Index)) {
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, ArgOptional[Index]);
Entry->LoadOptions.AddID(ArgOptional[Index]);
}
}
//remove unchecked options
for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON
if ((gSettings.OptionsBits & (1 << Index)) == 0) {
Entry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, ArgOptional[Index]);
Entry->LoadOptions.remove(ArgOptional[Index]);
}
}
@ -115,14 +115,16 @@ VOID DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry)
if (AsciiOSVersionToUint64(loaderEntry->OSVersion) >= AsciiOSVersionToUint64("10.12")) {
gSettings.NvidiaWeb = TRUE;
} else {
Entry->LoadOptions = AddLoadOption(loaderEntry->LoadOptions, ArgOptional[INX_NVWEBON]);
Entry->LoadOptions = loaderEntry->LoadOptions;
Entry->LoadOptions.AddID(ArgOptional[INX_NVWEBON]);
}
}
if ((gSettings.OptionsBits & OPT_NVWEBON) == 0) {
if (AsciiOSVersionToUint64(loaderEntry->OSVersion) >= AsciiOSVersionToUint64("10.12")) {
gSettings.NvidiaWeb = FALSE;
} else {
Entry->LoadOptions = RemoveLoadOption(loaderEntry->LoadOptions, ArgOptional[INX_NVWEBON]);
Entry->LoadOptions = loaderEntry->LoadOptions;
Entry->LoadOptions.removeIC(ArgOptional[INX_NVWEBON]);
}
}
}

View File

@ -20,7 +20,7 @@ extern CONST CHAR16 *VBIOS_BIN;
extern INPUT_ITEM *InputItems;
VOID DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry);
UINT32 EncodeOptions(const XString& Options);
UINT32 EncodeOptions(const XStringArray& Options);

View File

@ -197,7 +197,7 @@ bailout:
static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle,
IN CONST XString& LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST XStringArray& LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST CHAR16 *ImageTitle,
OUT UINTN *ErrorInStep)
{
@ -229,13 +229,13 @@ static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle,
if (LoadOptionsPrefix != NULL) {
// NOTE: That last space is also added by the EFI shell and seems to be significant
// when passing options to Apple's boot.efi...
loadOptionsW = SWPrintf("%ls %s ", LoadOptionsPrefix, LoadOptions.c_str());
loadOptionsW = SWPrintf("%ls %s ", LoadOptionsPrefix, LoadOptions.ConcatAll(" "_XS).wc_str());
}else{
loadOptionsW = SWPrintf("%s ", LoadOptions.c_str()); // Jief : should we add a space ? Wasn't the case before big refactoring. Yes, a space required.
loadOptionsW = SWPrintf("%s ", LoadOptions.ConcatAll(" "_XS).wc_str()); // Jief : should we add a space ? Wasn't the case before big refactoring. Yes, a space required.
}
// NOTE: We also include the terminating null in the length for safety.
ChildLoadedImage->LoadOptions = (void*)EfiStrDuplicate(loadOptionsW.wc_str()); //will it be deleted after the procedure exit?
ChildLoadedImage->LoadOptionsSize = (UINT32)loadOptionsW.sizeInBytes() + sizeof(wchar_t);
ChildLoadedImage->LoadOptions = loadOptionsW.wc_str(); //will it be deleted after the procedure exit? Yes, if we don't copy loadOptionsW, so it'll be freed at the end of method
//((UINT32)StrLen(LoadOptions) + 1) * sizeof(CHAR16);
DBG("start image '%ls'\n", ImageTitle);
DBG("Using load options '%ls'\n", (CHAR16*)ChildLoadedImage->LoadOptions);
@ -309,7 +309,7 @@ static EFI_STATUS LoadEFIImage(IN EFI_DEVICE_PATH *DevicePath,
static EFI_STATUS StartEFIImage(IN EFI_DEVICE_PATH *DevicePath,
IN CONST XString& LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST XStringArray& LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST CHAR16 *ImageTitle,
OUT UINTN *ErrorInStep,
OUT EFI_HANDLE *NewImageHandle)
@ -750,7 +750,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
}
// Set boot argument for kernel if no caches, this should force kernel loading
if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) && !Entry->LoadOptions.containsIC("Kernel="_XS) ) {
if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) && !Entry->LoadOptions.containsStartWithIC("Kernel=") ) {
XString KernelLocation;
if (Entry->OSVersion && AsciiOSVersionToUint64(Entry->OSVersion) <= AsciiOSVersionToUint64("10.9")) {
@ -759,7 +759,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
// used for 10.10, 10.11, and new version.
KernelLocation.SPrintf("\"Kernel=/System/Library/Kernels/kernel\"");
}
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, KernelLocation);
Entry->LoadOptions.AddID(KernelLocation);
}
//we are booting OSX - restore emulation if it's not installed before g boot.efi
@ -776,7 +776,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
// If KPDebug is true boot in verbose mode to see the debug messages
if ((Entry->KernelAndKextPatches != NULL) && Entry->KernelAndKextPatches->KPDebug) {
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-v"_XS);
Entry->LoadOptions.AddID("-v"_XS);
}
DbgHeader("RestSetup macOS");
@ -803,9 +803,9 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
if ( gDriversFlags.AptioFixLoaded &&
!DoHibernateWake &&
!Entry->LoadOptions.contains("slide=") ) {
!Entry->LoadOptions.containsStartWithIC("slide=") ) {
// Add slide=0 argument for ML+ if not present
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "slide=0"_XS);
Entry->LoadOptions.AddID("slide=0"_XS);
}
@ -817,9 +817,9 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
(AsciiStrStr(gCPUStructure.BrandString, "Celeron") || AsciiStrStr(gCPUStructure.BrandString, "Pentium")) &&
(AsciiOSVersionToUint64(Entry->OSVersion) >= AsciiOSVersionToUint64("10.8.5")) &&
(AsciiOSVersionToUint64(Entry->OSVersion) < AsciiOSVersionToUint64("10.12")) &&
(!Entry->LoadOptions.contains("-xcpm"_XS))) {
(!Entry->LoadOptions.containsIC("-xcpm"))) {
// add "-xcpm" argv if not present on Haswell+ Celeron/Pentium
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-xcpm"_XS);
Entry->LoadOptions.AddID("-xcpm"_XS);
}
// add -xcpm on Ivy Bridge if set KernelXCPM and system version is 10.8.5 - 10.11.x
@ -827,9 +827,9 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
gCPUStructure.Model == CPU_MODEL_IVY_BRIDGE &&
(AsciiOSVersionToUint64(Entry->OSVersion) >= AsciiOSVersionToUint64("10.8.5")) &&
(AsciiOSVersionToUint64(Entry->OSVersion) < AsciiOSVersionToUint64("10.12")) &&
(!Entry->LoadOptions.contains("-xcpm"))) {
(!Entry->LoadOptions.containsIC("-xcpm"))) {
// add "-xcpm" argv if not present on Ivy Bridge
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-xcpm"_XS);
Entry->LoadOptions.AddID("-xcpm"_XS);
}
if (AudioIo) {
@ -849,10 +849,8 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
// which is wrong
// apianti - only block console output if using graphics
// but don't block custom boot logo
if ( Entry->LoadOptions.containsIC("-v"_XS) ) {
if ( Entry->LoadOptions.containsIC("-v") ) {
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_USEGRAPHICS);
} else if ( Entry->LoadOptions.isEmpty() ) {
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, " "_XS);
}
}
else if (OSTYPE_IS_WINDOWS(Entry->LoaderType)) {
@ -979,8 +977,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
// Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), NULL, NULL);
// DBG("StartEFILoadedImage\n");
StartEFILoadedImage(ImageHandle, Entry->LoadOptions,
Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), NULL);
StartEFILoadedImage(ImageHandle, Entry->LoadOptions, Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), NULL);
// Unlock boot screen
if (EFI_ERROR(Status = UnlockBootScreen())) {
DBG("Failed to unlock custom boot screen: %s!\n", strerror(Status));
@ -1153,7 +1150,7 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
snwprintf(FileName, 512, "%ls\\%ls", Path, DirEntry->FileName);
Status = StartEFIImage(FileDevicePath(SelfLoadedImage->DeviceHandle, FileName),
""_XS, DirEntry->FileName, DirEntry->FileName, NULL, &DriverHandle);
NullXStringArray, DirEntry->FileName, DirEntry->FileName, NULL, &DriverHandle);
if (EFI_ERROR(Status)) {
continue;
}
@ -2434,7 +2431,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
//now it is a time to set RtVariables
SetVariablesFromNvram();
XString TmpArgs = SPrintf("%s ", gSettings.BootArgs);
XStringArray TmpArgs = Split<XStringArray>(gSettings.BootArgs, " ");
DBG("after NVRAM boot-args=%s\n", gSettings.BootArgs);
gSettings.OptionsBits = EncodeOptions(TmpArgs);
// DBG("initial OptionsBits %X\n", gSettings.OptionsBits);