2020-04-04 14:27:02 +02:00
|
|
|
/*
|
|
|
|
* refit/menu.c
|
|
|
|
* Menu functions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Christoph Pfisterer
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name of Christoph Pfisterer nor the names of the
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* THIS will most likely disappear soon !
|
|
|
|
*/
|
|
|
|
|
2020-04-24 08:36:29 +02:00
|
|
|
#include <Platform.h>
|
|
|
|
//#include "../refit/lib.h"
|
|
|
|
//#include "menu_items/menu_items.h"
|
|
|
|
//#include "../entry_scan/common.h"
|
2020-04-04 14:27:02 +02:00
|
|
|
|
2020-04-05 14:25:39 +02:00
|
|
|
CONST XString ArgOptional[NUM_OPT] = {
|
|
|
|
"arch=i386"_XS, //0
|
|
|
|
"arch=x86_64"_XS, //1
|
2020-04-28 08:54:43 +02:00
|
|
|
"-v"_XS, //2
|
|
|
|
"-f"_XS, //3
|
|
|
|
"-s"_XS, //4
|
|
|
|
"-x"_XS, //5
|
2020-04-05 14:25:39 +02:00
|
|
|
"nv_disable=1"_XS, //6
|
|
|
|
"slide=0"_XS, //7
|
|
|
|
"darkwake=0"_XS, //8
|
|
|
|
"-xcpm"_XS, //9
|
|
|
|
"-gux_no_idle"_XS, //10
|
|
|
|
"-gux_nosleep"_XS, //11
|
|
|
|
"-gux_nomsi"_XS, //12
|
|
|
|
"-gux_defer_usb2"_XS, //13
|
|
|
|
"keepsyms=1"_XS, //14
|
|
|
|
"debug=0x100"_XS, //15
|
|
|
|
"kextlog=0xffff"_XS, //16
|
|
|
|
"-alcoff"_XS, //17
|
|
|
|
"-shikioff"_XS, //18
|
|
|
|
"nvda_drv=1"_XS //19
|
2020-04-04 14:27:02 +02:00
|
|
|
};
|
|
|
|
CONST CHAR16 *VBIOS_BIN = L"EFI\\CLOVER\\misc\\c0000.bin";
|
|
|
|
|
|
|
|
INPUT_ITEM *InputItems = NULL;
|
|
|
|
INTN TextStyle; //why global? It will be class SCREEN member
|
|
|
|
|
2020-04-26 15:07:30 +02:00
|
|
|
UINT32 EncodeOptions(const XStringArray& Options)
|
2020-04-04 14:27:02 +02:00
|
|
|
{
|
|
|
|
UINT32 OptionsBits = 0;
|
|
|
|
INTN Index;
|
2020-04-05 14:25:39 +02:00
|
|
|
if (Options.isEmpty()) {
|
2020-04-04 14:27:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
for (Index = 0; Index < NUM_OPT; Index++) {
|
2020-04-23 22:43:35 +02:00
|
|
|
if ( Options.contains(ArgOptional[Index]) ) {
|
2020-04-04 14:27:02 +02:00
|
|
|
OptionsBits |= (1 << Index);
|
|
|
|
if (Index == 1) {
|
|
|
|
OptionsBits &= ~1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OptionsBits;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry)
|
|
|
|
{
|
|
|
|
//set checked option
|
|
|
|
INTN Index;
|
|
|
|
if (!Entry) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON
|
|
|
|
if (gSettings.OptionsBits & (1 << Index)) {
|
2020-04-26 15:07:30 +02:00
|
|
|
Entry->LoadOptions.AddID(ArgOptional[Index]);
|
2020-04-04 14:27:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//remove unchecked options
|
|
|
|
for (Index = 0; Index < INX_NVWEBON; Index++) { //not including INX_NVWEBON
|
|
|
|
if ((gSettings.OptionsBits & (1 << Index)) == 0) {
|
2020-04-26 15:07:30 +02:00
|
|
|
Entry->LoadOptions.remove(ArgOptional[Index]);
|
2020-04-04 14:27:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Entry->getLOADER_ENTRY()) {
|
|
|
|
LOADER_ENTRY* loaderEntry = Entry->getLOADER_ENTRY();
|
|
|
|
// Only for non-legacy entries, as LEGACY_ENTRY doesn't have OSVersion
|
|
|
|
if (gSettings.OptionsBits & OPT_NVWEBON) {
|
|
|
|
if (AsciiOSVersionToUint64(loaderEntry->OSVersion) >= AsciiOSVersionToUint64("10.12")) {
|
|
|
|
gSettings.NvidiaWeb = TRUE;
|
|
|
|
} else {
|
2020-04-26 15:07:30 +02:00
|
|
|
Entry->LoadOptions = loaderEntry->LoadOptions;
|
|
|
|
Entry->LoadOptions.AddID(ArgOptional[INX_NVWEBON]);
|
2020-04-04 14:27:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((gSettings.OptionsBits & OPT_NVWEBON) == 0) {
|
|
|
|
if (AsciiOSVersionToUint64(loaderEntry->OSVersion) >= AsciiOSVersionToUint64("10.12")) {
|
|
|
|
gSettings.NvidiaWeb = FALSE;
|
|
|
|
} else {
|
2020-04-26 15:07:30 +02:00
|
|
|
Entry->LoadOptions = loaderEntry->LoadOptions;
|
|
|
|
Entry->LoadOptions.removeIC(ArgOptional[INX_NVWEBON]);
|
2020-04-04 14:27:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|