Skip to content

Commit fb8e429

Browse files
committed
WIP: changes for checking boot nvram
1 parent 4cb9e92 commit fb8e429

File tree

6 files changed

+53
-27
lines changed

6 files changed

+53
-27
lines changed

Application/BootHelper/BhConfig.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,11 @@ BhConfigurationInit (
251251
IN UINT32 Size
252252
)
253253
{
254-
BOOLEAN Success;
254+
BOOLEAN Success;
255+
UINT32 ErrorCount;
255256

256257
BH_GLOBAL_CONFIG_CONSTRUCT (Config, sizeof (*Config));
257-
Success = ParseSerialized (Config, &mRootConfigurationInfo, Buffer, Size);
258+
Success = ParseSerialized (Config, &mRootConfigurationInfo, Buffer, Size, &ErrorCount);
258259

259260
if (!Success) {
260261
BH_GLOBAL_CONFIG_DESTRUCT (Config, sizeof (*Config));

Application/BootHelper/BhConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <Library/DebugLib.h>
2323
#include <Library/OcSerializeLib.h>
2424
#include <Library/OcBootManagementLib.h>
25-
#include <Library/OcConfigurationConstants.h>
25+
#include <Library/OcConfigurationLib.h>
2626

2727
/**
2828
Config section

Application/BootHelper/BootHelper.c

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
#include "Utils.h"
3434

3535
BOOLEAN mInteractive = TRUE;
36-
BOOLEAN mClearScreen = FALSE;
36+
BOOLEAN mClearScreen = TRUE;
3737
BOOLEAN mKeyPromptOnExit = FALSE;
38+
BOOLEAN mLoadConfig = FALSE;
3839
BH_ON_EXIT mBhOnExit = BhOnExitExit;
3940

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

59-
#define EFI_APPLE_GUID \
60+
#define EFI_APPLE_BOOT_GUID \
6061
{ 0x7c436110, 0xab2a, 0x4bbb, {0xa8, 0x80, 0xfe, 0x41, 0x99, 0x5c, 0x9f, 0x82} }
61-
STATIC EFI_GUID gEfiAppleGuid = EFI_APPLE_GUID;
62+
STATIC EFI_GUID gEfiAppleBootGuid = EFI_APPLE_BOOT_GUID;
63+
64+
#define EFI_APPLE_VENDOR_GUID \
65+
{ 0x4d1ede05, 0x38c7, 0x4a6a, {0x9c, 0xc6, 0x4b, 0xcc, 0xa8, 0xb3, 0x8c, 0x14} }
66+
STATIC EFI_GUID gEfiAppleVendorGuid = EFI_APPLE_VENDOR_GUID;
6267

6368
// with zero terminator
6469
STATIC CHAR8 gBootArgsVal[] = "-no_compat_check";
@@ -72,7 +77,7 @@ DisplayAppleVar(
7277
BOOLEAN isString
7378
)
7479
{
75-
DisplayNvramValueWithoutGuid(Name, &gEfiAppleGuid, isString);
80+
DisplayNvramValueWithoutGuid(Name, &gEfiAppleBootGuid, isString);
7681
}
7782

7883
EFI_STATUS
@@ -82,7 +87,7 @@ ToggleAppleVar(
8287
UINTN PreferredSize
8388
)
8489
{
85-
return ToggleOrSetVar(Name, &gEfiAppleGuid, PreferredValue, PreferredSize, TRUE);
90+
return ToggleOrSetVar(Name, &gEfiAppleBootGuid, PreferredValue, PreferredSize, TRUE);
8691
}
8792

8893
EFI_STATUS
@@ -92,7 +97,7 @@ SetAppleVar(
9297
UINTN PreferredSize
9398
)
9499
{
95-
return ToggleOrSetVar(Name, &gEfiAppleGuid, PreferredValue, PreferredSize, FALSE);
100+
return ToggleOrSetVar(Name, &gEfiAppleBootGuid, PreferredValue, PreferredSize, FALSE);
96101
}
97102

98103
void ToggleBootArgs()
@@ -124,18 +129,19 @@ EFI_STATUS
124129
EFIAPI
125130
BhMain ()
126131
{
127-
BOOLEAN showOCVersion = FALSE;
132+
BOOLEAN showOCVersion = TRUE;
128133

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

133138
SetColour(EFI_LIGHTMAGENTA);
134139
Print(L"macOS NVRAM Boot Helper\n");
135-
Print(L"0.2.8 oc-340\n");
140+
Print(L"0.2.9 guid\n");
136141
SetColour(EFI_WHITE);
137-
Print(L"\n");
138142

143+
#if 0
144+
Print(L"\n");
139145
CONST CHAR8 *AsciiPicker;
140146
AsciiPicker = OC_BLOB_GET (&mBootHelperConfiguration.Config.Xanana);
141147
for (UINTN i = 0; ; i++) {
@@ -144,15 +150,27 @@ BhMain ()
144150
Print (L"%c", (CHAR16)c);
145151
}
146152
Print(L"\n");
153+
#endif
154+
155+
if (showOCVersion) {
156+
Print(L"\n");
157+
DisplayNvramValueWithoutGuid(L"opencore-version", &gEfiOpenCoreGuid, TRUE);
158+
}
159+
160+
Print(L"\n");
161+
DisplayNvramValueWithoutGuid(L"SSN", &gEfiAppleVendorGuid, TRUE);
162+
DisplayNvramValueWithoutGuid(L"system-id", &gEfiAppleVendorGuid, TRUE);
163+
DisplayNvramValueWithoutGuid(L"ROM", &gEfiAppleVendorGuid, TRUE);
164+
DisplayNvramValueWithoutGuid(L"HW_ROM", &gEfiAppleVendorGuid, TRUE);
165+
DisplayNvramValueWithoutGuid(L"MLB", &gEfiAppleVendorGuid, TRUE);
166+
DisplayNvramValueWithoutGuid(L"HW_MLB", &gEfiAppleVendorGuid, TRUE);
147167

148168
#if 1
169+
Print(L"\n");
149170
DisplayAppleVar(L"boot-args", TRUE);
150171
DisplayAppleVar(L"csr-active-config", FALSE);
151172
DisplayAppleVar(L"StartupMute", TRUE);
152173
#endif
153-
if (showOCVersion) {
154-
DisplayNvramValueWithoutGuid(L"opencore-version", &gEfiOpenCoreGuid, TRUE);
155-
}
156174

157175
SetColour(EFI_LIGHTRED);
158176
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");
@@ -284,20 +302,26 @@ BhConfigAndMain (
284302
{
285303
EFI_STATUS Status;
286304

287-
DEBUG ((DEBUG_INFO, "BH: BhConfigAndMain calling BhConfigLoad...\n"));
288-
Status = BhConfigLoad (
289-
Storage,
290-
&mBootHelperConfiguration,
291-
mOpenCoreVaultKey
292-
);
305+
if (mLoadConfig) {
306+
DEBUG ((DEBUG_INFO, "BH: BhConfigAndMain calling BhConfigLoad...\n"));
307+
Status = BhConfigLoad (
308+
Storage,
309+
&mBootHelperConfiguration,
310+
mOpenCoreVaultKey
311+
);
293312

294-
if (EFI_ERROR (Status)) {
295-
return Status;
313+
if (EFI_ERROR (Status)) {
314+
return Status;
315+
}
316+
} else {
317+
DEBUG ((DEBUG_WARN, "BH: Load config disabled\n"));
296318
}
297319

298320
Status = BhMain();
299321

300-
BhConfigurationFree (&mBootHelperConfiguration);
322+
if (mLoadConfig) {
323+
BhConfigurationFree (&mBootHelperConfiguration);
324+
}
301325

302326
return Status;
303327
}

Application/BootHelper/BootHelper.inf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
[LibraryClasses]
5252
BaseLib
5353
BaseMemoryLib
54-
MemoryAllocationLib
54+
MemoryAllocationLib ### TEST - What does removing this break? And why do(n't) we need OcConfigurationLib?
55+
OcConfigurationLib
5556
OcConsoleControlEntryModeGenericLib
5657
OcStorageLib
5758
UefiApplicationEntryPoint

Application/BootHelper/DisplayVars.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ DisplayNvramValueOptionalGuid (
186186
VOID *Data;
187187

188188
if (displayGuid) {
189-
Print(L"%g:", Name);
189+
Print(L"%g:", Guid);
190190
}
191191

192192
Print(L"%s", Name);

BootHelperPkg.dsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
3131
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
3232
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
33-
# OcConfigurationLib|OpenCorePkg/Library/OcConfigurationLib/OcConfigurationLib.inf
33+
OcConfigurationLib|OpenCorePkg/Library/OcConfigurationLib/OcConfigurationLib.inf
3434
OcConsoleControlEntryModeGenericLib|OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeGenericLib.inf
3535
OcStorageLib|OpenCorePkg/Library/OcStorageLib/OcStorageLib.inf
3636
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

0 commit comments

Comments
 (0)