OcBootManagementLib: Cleanup bootstrap code even further

This commit is contained in:
vit9696 2021-01-31 21:31:34 +03:00
parent 8c0ca12a12
commit 7066f9bea4
9 changed files with 23 additions and 33 deletions

View File

@ -65,10 +65,10 @@ LoadOpenCore (
&& UnicodeGetParentDirectory (LoaderPath)) {
DEBUG ((DEBUG_INFO, "BS: Relative path - %s\n", LoaderPath));
PrefixPathSize = StrSize (LoaderPath);
if (LoaderPathSize - PrefixPathSize >= L_STR_SIZE (OPEN_CORE_DRIVER_PATH)) {
if (LoaderPathSize - PrefixPathSize >= L_STR_SIZE (OPEN_CORE_APP_PATH)) {
RootPathLength = PrefixPathSize / sizeof (CHAR16) - 1;
LoaderPath[RootPathLength] = '\\';
CopyMem (&LoaderPath[RootPathLength + 1], OPEN_CORE_DRIVER_PATH, L_STR_SIZE (OPEN_CORE_DRIVER_PATH));
CopyMem (&LoaderPath[RootPathLength + 1], OPEN_CORE_APP_PATH, L_STR_SIZE (OPEN_CORE_APP_PATH));
Buffer = ReadFile (FileSystem, LoaderPath, &BufferSize, BASE_16MB);
DEBUG ((DEBUG_INFO, "BS: Startup path - %s (%p)\n", LoaderPath, Buffer));
@ -93,12 +93,12 @@ LoadOpenCore (
DEBUG ((
DEBUG_INFO,
"BS: Fallback to absolute path - %s\n",
OPEN_CORE_ROOT_PATH L"\\" OPEN_CORE_DRIVER_PATH
OPEN_CORE_ROOT_PATH L"\\" OPEN_CORE_APP_PATH
));
Buffer = ReadFile (
FileSystem,
OPEN_CORE_ROOT_PATH L"\\" OPEN_CORE_DRIVER_PATH,
OPEN_CORE_ROOT_PATH L"\\" OPEN_CORE_APP_PATH,
&BufferSize,
BASE_16MB
);
@ -107,7 +107,7 @@ LoadOpenCore (
// Failure to allocate this one is not too critical, as we will still be able
// to choose it as a default path.
//
ImagePath = FileDevicePath (DeviceHandle, OPEN_CORE_ROOT_PATH L"\\" OPEN_CORE_DRIVER_PATH);
ImagePath = FileDevicePath (DeviceHandle, OPEN_CORE_ROOT_PATH L"\\" OPEN_CORE_APP_PATH);
}
}
@ -152,7 +152,7 @@ UefiMain (
//
// We have just started at EFI/BOOT/BOOTx64.efi.
// We need to run OpenCore on this partition as it failed automatically.
// The image is optionally located at OPEN_CORE_DRIVER_PATH file.
// The image is optionally located at OPEN_CORE_APP_PATH file.
//
LoadedImage = NULL;

View File

@ -1392,9 +1392,7 @@ OcRegisterBootstrapBootOption (
IN CONST CHAR16 *OptionName,
IN EFI_HANDLE DeviceHandle,
IN CONST CHAR16 *FilePath,
IN BOOLEAN ShortForm,
IN CHAR16 *MatchSuffix,
IN UINTN MatchSuffixLen
IN BOOLEAN ShortForm
);
/**

View File

@ -404,7 +404,7 @@ OcGetNextLoadOptionDevicePath (
BOOLEAN
OcDevicePathHasFilePathSuffix (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CHAR16 *Suffix,
IN CONST CHAR16 *Suffix,
IN UINTN SuffixLen
);

View File

@ -48,7 +48,7 @@
#define OPEN_CORE_ROOT_PATH L"EFI\\OC"
#define OPEN_CORE_DRIVER_PATH L"OpenCore.efi"
#define OPEN_CORE_APP_PATH L"OpenCore.efi"
#define OPEN_CORE_CONFIG_PATH L"config.plist"

View File

@ -240,8 +240,8 @@ OcAsciiEndsWith (
INTN
EFIAPI
OcStriCmp (
IN CHAR16 *FirstString,
IN CHAR16 *SecondString
IN CONST CHAR16 *FirstString,
IN CONST CHAR16 *SecondString
);
/**

View File

@ -903,7 +903,7 @@ InternalGetBoostrapOptionData (
OUT EFI_DEVICE_PATH_PROTOCOL **LoadPath,
IN UINT16 *BootOptions,
IN UINTN NumBootOptions,
IN CHAR16 *MatchSuffix,
IN CONST CHAR16 *MatchSuffix,
IN UINTN MatchSuffixLen
)
{
@ -960,9 +960,7 @@ InternalRegisterBootstrapBootOption (
IN CONST CHAR16 *OptionName,
IN EFI_HANDLE DeviceHandle,
IN CONST CHAR16 *FilePath,
IN BOOLEAN ShortForm,
IN CHAR16 *MatchSuffix,
IN UINTN MatchSuffixLen
IN BOOLEAN ShortForm
)
{
EFI_STATUS Status;
@ -1061,8 +1059,8 @@ InternalRegisterBootstrapBootOption (
&CurrDevicePath,
&BootOrder[1],
BootOrderSize / sizeof (*BootOrder),
MatchSuffix,
MatchSuffixLen
FilePath,
StrLen (FilePath)
);
CurrOptionExists = Option != NULL;
if (CurrOptionExists) {
@ -1210,9 +1208,7 @@ OcRegisterBootstrapBootOption (
IN CONST CHAR16 *OptionName,
IN EFI_HANDLE DeviceHandle,
IN CONST CHAR16 *FilePath,
IN BOOLEAN ShortForm,
IN CHAR16 *MatchSuffix,
IN UINTN MatchSuffixLen
IN BOOLEAN ShortForm
)
{
EFI_STATUS Status;
@ -1238,9 +1234,7 @@ OcRegisterBootstrapBootOption (
OptionName,
DeviceHandle,
FilePath,
ShortForm,
MatchSuffix,
MatchSuffixLen
ShortForm
);
if (FwRuntime != NULL) {

View File

@ -1254,7 +1254,7 @@ OcGetNumDevicePathInstances (
BOOLEAN
OcDevicePathHasFilePathSuffix (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CHAR16 *Suffix,
IN CONST CHAR16 *Suffix,
IN UINTN SuffixLen
)
{

View File

@ -623,12 +623,12 @@ RegisterLauncherOption (
UINTN BootstrapSize;
if (AsciiStrCmp (LauncherPath, "Default") == 0) {
BootstrapSize = StrSize (RootPath) + StrSize (OPEN_CORE_DRIVER_PATH);
BootstrapSize = StrSize (RootPath) + StrSize (OPEN_CORE_APP_PATH);
BootstrapPath = AllocatePool (BootstrapSize);
if (BootstrapPath == NULL) {
return 0;
}
UnicodeSPrint (BootstrapPath, BootstrapSize, L"%s\\%s", RootPath, OPEN_CORE_DRIVER_PATH);
UnicodeSPrint (BootstrapPath, BootstrapSize, L"%s\\%s", RootPath, OPEN_CORE_APP_PATH);
} else {
BootstrapPath = AsciiStrCopyToUnicode (LauncherPath, 0);
if (BootstrapPath == NULL) {
@ -640,9 +640,7 @@ RegisterLauncherOption (
L"OpenCore",
LoadHandle,
BootstrapPath,
ShortForm,
BootstrapPath,
StrLen (BootstrapPath)
ShortForm
);
FreePool (BootstrapPath);

View File

@ -25,8 +25,8 @@
INTN
EFIAPI
OcStriCmp (
IN CHAR16 *FirstString,
IN CHAR16 *SecondString
IN CONST CHAR16 *FirstString,
IN CONST CHAR16 *SecondString
)
{
CHAR16 UpperFirstString;