Skip to content

Commit

Permalink
WIP: changes for checking boot nvram
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebeaton committed Feb 14, 2021
1 parent 4cb9e92 commit fb8e429
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 27 deletions.
5 changes: 3 additions & 2 deletions Application/BootHelper/BhConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ BhConfigurationInit (
IN UINT32 Size
)
{
BOOLEAN Success;
BOOLEAN Success;
UINT32 ErrorCount;

BH_GLOBAL_CONFIG_CONSTRUCT (Config, sizeof (*Config));
Success = ParseSerialized (Config, &mRootConfigurationInfo, Buffer, Size);
Success = ParseSerialized (Config, &mRootConfigurationInfo, Buffer, Size, &ErrorCount);

if (!Success) {
BH_GLOBAL_CONFIG_DESTRUCT (Config, sizeof (*Config));
Expand Down
2 changes: 1 addition & 1 deletion Application/BootHelper/BhConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <Library/DebugLib.h>
#include <Library/OcSerializeLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcConfigurationConstants.h>
#include <Library/OcConfigurationLib.h>

/**
Config section
Expand Down
66 changes: 45 additions & 21 deletions Application/BootHelper/BootHelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
#include "Utils.h"

BOOLEAN mInteractive = TRUE;
BOOLEAN mClearScreen = FALSE;
BOOLEAN mClearScreen = TRUE;
BOOLEAN mKeyPromptOnExit = FALSE;
BOOLEAN mLoadConfig = FALSE;
BH_ON_EXIT mBhOnExit = BhOnExitExit;

#if false
Expand All @@ -56,9 +57,13 @@ UefiUnload (
{ 0x4d1fda02, 0x38c7, 0x4a6a, {0x9c, 0xc6, 0x4b, 0xcc, 0xa8, 0xb3, 0x01, 0x02} }
STATIC EFI_GUID gEfiOpenCoreGuid = EFI_OPEN_CORE_GUID;

#define EFI_APPLE_GUID \
#define EFI_APPLE_BOOT_GUID \
{ 0x7c436110, 0xab2a, 0x4bbb, {0xa8, 0x80, 0xfe, 0x41, 0x99, 0x5c, 0x9f, 0x82} }
STATIC EFI_GUID gEfiAppleGuid = EFI_APPLE_GUID;
STATIC EFI_GUID gEfiAppleBootGuid = EFI_APPLE_BOOT_GUID;

#define EFI_APPLE_VENDOR_GUID \
{ 0x4d1ede05, 0x38c7, 0x4a6a, {0x9c, 0xc6, 0x4b, 0xcc, 0xa8, 0xb3, 0x8c, 0x14} }
STATIC EFI_GUID gEfiAppleVendorGuid = EFI_APPLE_VENDOR_GUID;

// with zero terminator
STATIC CHAR8 gBootArgsVal[] = "-no_compat_check";
Expand All @@ -72,7 +77,7 @@ DisplayAppleVar(
BOOLEAN isString
)
{
DisplayNvramValueWithoutGuid(Name, &gEfiAppleGuid, isString);
DisplayNvramValueWithoutGuid(Name, &gEfiAppleBootGuid, isString);
}

EFI_STATUS
Expand All @@ -82,7 +87,7 @@ ToggleAppleVar(
UINTN PreferredSize
)
{
return ToggleOrSetVar(Name, &gEfiAppleGuid, PreferredValue, PreferredSize, TRUE);
return ToggleOrSetVar(Name, &gEfiAppleBootGuid, PreferredValue, PreferredSize, TRUE);
}

EFI_STATUS
Expand All @@ -92,7 +97,7 @@ SetAppleVar(
UINTN PreferredSize
)
{
return ToggleOrSetVar(Name, &gEfiAppleGuid, PreferredValue, PreferredSize, FALSE);
return ToggleOrSetVar(Name, &gEfiAppleBootGuid, PreferredValue, PreferredSize, FALSE);
}

void ToggleBootArgs()
Expand Down Expand Up @@ -124,18 +129,19 @@ EFI_STATUS
EFIAPI
BhMain ()
{
BOOLEAN showOCVersion = FALSE;
BOOLEAN showOCVersion = TRUE;

while (TRUE) {
// inter alia, we want to clear the other stuff on the hidden text screen, before switching to viewing the text...
if (mClearScreen) gST->ConOut->ClearScreen(gST->ConOut);

SetColour(EFI_LIGHTMAGENTA);
Print(L"macOS NVRAM Boot Helper\n");
Print(L"0.2.8 oc-340\n");
Print(L"0.2.9 guid\n");
SetColour(EFI_WHITE);
Print(L"\n");

#if 0
Print(L"\n");
CONST CHAR8 *AsciiPicker;
AsciiPicker = OC_BLOB_GET (&mBootHelperConfiguration.Config.Xanana);
for (UINTN i = 0; ; i++) {
Expand All @@ -144,15 +150,27 @@ BhMain ()
Print (L"%c", (CHAR16)c);
}
Print(L"\n");
#endif

if (showOCVersion) {
Print(L"\n");
DisplayNvramValueWithoutGuid(L"opencore-version", &gEfiOpenCoreGuid, TRUE);
}

Print(L"\n");
DisplayNvramValueWithoutGuid(L"SSN", &gEfiAppleVendorGuid, TRUE);
DisplayNvramValueWithoutGuid(L"system-id", &gEfiAppleVendorGuid, TRUE);
DisplayNvramValueWithoutGuid(L"ROM", &gEfiAppleVendorGuid, TRUE);
DisplayNvramValueWithoutGuid(L"HW_ROM", &gEfiAppleVendorGuid, TRUE);
DisplayNvramValueWithoutGuid(L"MLB", &gEfiAppleVendorGuid, TRUE);
DisplayNvramValueWithoutGuid(L"HW_MLB", &gEfiAppleVendorGuid, TRUE);

#if 1
Print(L"\n");
DisplayAppleVar(L"boot-args", TRUE);
DisplayAppleVar(L"csr-active-config", FALSE);
DisplayAppleVar(L"StartupMute", TRUE);
#endif
if (showOCVersion) {
DisplayNvramValueWithoutGuid(L"opencore-version", &gEfiOpenCoreGuid, TRUE);
}

SetColour(EFI_LIGHTRED);
Print(L"\nboot-[A]rgs; [B]ig Sur; [C]atalina; Startup[M]ute\n[R]eboot; [S]hutdown; [Q]uit; E[x]it; [L]ist\n");
Expand Down Expand Up @@ -284,20 +302,26 @@ BhConfigAndMain (
{
EFI_STATUS Status;

DEBUG ((DEBUG_INFO, "BH: BhConfigAndMain calling BhConfigLoad...\n"));
Status = BhConfigLoad (
Storage,
&mBootHelperConfiguration,
mOpenCoreVaultKey
);
if (mLoadConfig) {
DEBUG ((DEBUG_INFO, "BH: BhConfigAndMain calling BhConfigLoad...\n"));
Status = BhConfigLoad (
Storage,
&mBootHelperConfiguration,
mOpenCoreVaultKey
);

if (EFI_ERROR (Status)) {
return Status;
if (EFI_ERROR (Status)) {
return Status;
}
} else {
DEBUG ((DEBUG_WARN, "BH: Load config disabled\n"));
}

Status = BhMain();

BhConfigurationFree (&mBootHelperConfiguration);
if (mLoadConfig) {
BhConfigurationFree (&mBootHelperConfiguration);
}

return Status;
}
Expand Down
3 changes: 2 additions & 1 deletion Application/BootHelper/BootHelper.inf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
[LibraryClasses]
BaseLib
BaseMemoryLib
MemoryAllocationLib
MemoryAllocationLib ### TEST - What does removing this break? And why do(n't) we need OcConfigurationLib?
OcConfigurationLib
OcConsoleControlEntryModeGenericLib
OcStorageLib
UefiApplicationEntryPoint
Expand Down
2 changes: 1 addition & 1 deletion Application/BootHelper/DisplayVars.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ DisplayNvramValueOptionalGuid (
VOID *Data;

if (displayGuid) {
Print(L"%g:", Name);
Print(L"%g:", Guid);
}

Print(L"%s", Name);
Expand Down
2 changes: 1 addition & 1 deletion BootHelperPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
# OcConfigurationLib|OpenCorePkg/Library/OcConfigurationLib/OcConfigurationLib.inf
OcConfigurationLib|OpenCorePkg/Library/OcConfigurationLib/OcConfigurationLib.inf
OcConsoleControlEntryModeGenericLib|OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeGenericLib.inf
OcStorageLib|OpenCorePkg/Library/OcStorageLib/OcStorageLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
Expand Down

0 comments on commit fb8e429

Please sign in to comment.