Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement legacy OS booting support #482

Merged
merged 56 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
324b514
OcFileLib: Add OcDiskGetDevicePath function
Goldfish64 Jul 31, 2023
6a4a475
OcFileLib: Fix uncrustify on previous commit
Goldfish64 Jul 31, 2023
50b0e45
OcBootManagementLib: Add initial functions for Mac legacy booting
Goldfish64 Jul 31, 2023
86717d4
OcBootManagementLib: Fix Windows build error
Goldfish64 Jul 31, 2023
5a51120
OcBootManagementLib: Fix Windows build error
Goldfish64 Jul 31, 2023
9893ce7
OcBootManagementLib: Add legacy boot entry detection
Goldfish64 Jul 31, 2023
8cd0086
OcBootManagementLib: Fix incorrect device path allocation
Goldfish64 Aug 2, 2023
44fb3ac
OcBootManagementLib: Improve MBR detection
Goldfish64 Aug 5, 2023
3756798
OcBootManagementLib: Fix previous commit
Goldfish64 Aug 5, 2023
323a420
OcBootManagementLib: Handle legacy default boot entry
Goldfish64 Aug 5, 2023
9fd5aae
OcBootManagementLib: Fix hang on certain Mac models during legacy start
Goldfish64 Aug 6, 2023
f93f52b
OcBootManagementLib: Cleanup MBR detecting logging
Goldfish64 Aug 6, 2023
b26ce6e
OcBootManagementLib: Fix logging
Goldfish64 Aug 6, 2023
52b6eb7
OcBootManagementLib: Fix assertion for unknown legacy OS name
Goldfish64 Aug 6, 2023
a4cb596
OcBootManagementLib: Add legacy CD boot support
Goldfish64 Aug 6, 2023
0a92019
OcBootManagementLib: Only attempt Apple legacy boot when available
Goldfish64 Aug 7, 2023
3b6d8b8
OcBootManagementLib: Move legacy type detection into library
Goldfish64 Aug 7, 2023
c9abfda
OcLegacyThunkLib: Consolidate 16-bit thunking interface into library
Goldfish64 Aug 8, 2023
83af80a
OcLegacyThunkLib: Fix codestyle
Goldfish64 Aug 8, 2023
af72514
OcLegacyThunkLib: Fix comments
Goldfish64 Aug 8, 2023
4776b98
OcLegacyThunkLib: Return status from init functions
Goldfish64 Aug 8, 2023
7f83d12
OcLegacyThunkLib: Fix previous commit
Goldfish64 Aug 9, 2023
b4bb4b5
OcLegacyThunkLib: Fix previous commit
Goldfish64 Aug 9, 2023
7601bc5
OcLegacyThunkLib: Add missing package
Goldfish64 Aug 10, 2023
9a29c01
OpenLegacyBoot: Move legacy functionality into standalone driver
Goldfish64 Aug 10, 2023
3a31eca
OpenLegacyBoot: Cleanup state variables
Goldfish64 Aug 12, 2023
61eeb93
OpenLegacyBoot: Add initial support for PC legacy boot interface
Goldfish64 Aug 12, 2023
5b8063f
OpenLegacyBoot: Switch to separate action type for legacy entries
Goldfish64 Aug 14, 2023
a0628f0
OcLegacyThunkLib: Add missing library reference to IoLib
Goldfish64 Aug 14, 2023
2e8456e
OcLegacyThunkLib: Add missing protocol reference
Goldfish64 Aug 14, 2023
667d9c3
OpenLegacyBoot: Fix CI build issues
Goldfish64 Aug 14, 2023
d5de545
OpenLegacyBoot: Fix prefix on debug prints
Goldfish64 Aug 14, 2023
387adeb
OpenLegacyBoot: Fix previous commit
Goldfish64 Aug 15, 2023
e03a577
OpenLegacyBoot: Implement active partition switching
Goldfish64 Aug 17, 2023
ed62e4e
OcFileLib: Add El-Torito read function
Goldfish64 Aug 19, 2023
c70ad78
OpenLegacyBoot: Switch to Block I/O for legacy detection
Goldfish64 Aug 19, 2023
d3f5845
OcFileLib: Fix Windows builds
Goldfish64 Aug 19, 2023
6335b33
OpenLegacyBoot: Cleanup picker entry creation
Goldfish64 Aug 19, 2023
52d1fe9
OpenLegacyBoot: Fix Windows builds
Goldfish64 Aug 19, 2023
86b0f06
OpenLegacyBoot: Fix external device handling
Goldfish64 Aug 19, 2023
1208503
OpenLegacyBoot: Fix device path storage on legacy entries
Goldfish64 Aug 20, 2023
dabc04a
OcBootManagementLib: Fix Apple legacy interface default entry handling
Goldfish64 Aug 20, 2023
9a71056
OcBootManagementLib: Fix device path use after free
Goldfish64 Aug 20, 2023
5b9861b
OpenLegacyBoot: Detect BIOS disk address for PC boot
Goldfish64 Aug 20, 2023
8c96647
Docs: Add BootCampHD to LegacySchema in sample configs
Goldfish64 Aug 20, 2023
bbb7dee
BootLoader: Start only boot sector in protective MBR in boot0
Goldfish64 Aug 20, 2023
cf88226
OcLegacyThunkLib: Fix incorrect timer handling
Goldfish64 Aug 21, 2023
24d8c51
Merge branch 'master' into legacy-os-boot
Goldfish64 Aug 23, 2023
4821ae9
OpenLegacyBoot: Add support for setting legacy entry as default
Goldfish64 Aug 26, 2023
ec656db
OcBootManagementLib: Fix previous commit
Goldfish64 Aug 26, 2023
48b3beb
OpenDuet: Use PcdTurnOffUsbLegacySupport PCD instead
Goldfish64 Aug 26, 2023
aca0384
OcBootManagementLib: Allow external boot system entries to use custom…
Goldfish64 Aug 27, 2023
e8c9724
OpenCanopy: Fix labels for external boot system entries
Goldfish64 Aug 27, 2023
608a01e
OpenLegacyBoot: Implement custom entry names from .contentDetails
Goldfish64 Aug 27, 2023
7e8555a
OpenLegacyBoot: Add --hide-devices option
Goldfish64 Aug 27, 2023
f9a6965
OcFileLib: Use ReadUnaligned32 for MBR table checks
Goldfish64 Sep 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Docs/Sample.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@
<string>nvda_drv</string>
<string>prev-lang:kbd</string>
<string>backlight-level</string>
<string>BootCampHD</string>
</array>
<key>8BE4DF61-93CA-11D2-AA0D-00E098032B8C</key>
<array>
Expand Down
1 change: 1 addition & 0 deletions Docs/SampleCustom.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,7 @@
<string>nvda_drv</string>
<string>prev-lang:kbd</string>
<string>backlight-level</string>
<string>BootCampHD</string>
</array>
<key>8BE4DF61-93CA-11D2-AA0D-00E098032B8C</key>
<array>
Expand Down
119 changes: 82 additions & 37 deletions Include/Acidanthera/Library/OcBootManagementLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ typedef UINT32 OC_BOOT_ENTRY_TYPE;
#define OC_BOOT_EXTERNAL_OS BIT6
#define OC_BOOT_EXTERNAL_TOOL BIT7
#define OC_BOOT_SYSTEM BIT8
#define OC_BOOT_EXTERNAL_SYSTEM BIT9

/**
Picker mode.
Expand Down Expand Up @@ -193,6 +194,26 @@ EFI_STATUS
IN OUT OC_PICKER_CONTEXT *PickerContext
);

/**
Action to perform as part of executing an external boot system boot entry.
**/
typedef
EFI_STATUS
(*OC_BOOT_EXTERNAL_SYSTEM_ACTION) (
IN OUT OC_PICKER_CONTEXT *PickerContext,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);

/**
Gets Device Path for external boot system boot entry.
**/
typedef
EFI_STATUS
(*OC_BOOT_EXTERNAL_SYSTEM_GET_DP) (
IN OUT OC_PICKER_CONTEXT *PickerContext,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);

/**
Discovered boot entry.
Note, inner resources must be freed with FreeBootEntry.
Expand All @@ -201,103 +222,111 @@ typedef struct OC_BOOT_ENTRY_ {
//
// Link in entry list in OC_BOOT_FILESYSTEM.
//
LIST_ENTRY Link;
LIST_ENTRY Link;
//
// Device path to booter or its directory.
// Can be NULL, for example, for custom or system entries.
//
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
//
// Action to perform on execution. Only valid for system entries.
//
OC_BOOT_SYSTEM_ACTION SystemAction;
OC_BOOT_SYSTEM_ACTION SystemAction;
//
// Action to perform on execution. Only valid for external boot system entries.
//
OC_BOOT_EXTERNAL_SYSTEM_ACTION ExternalSystemAction;
//
// Gets Device Path for external boot system boot entry. Only valid for external boot system entries.
//
OC_BOOT_EXTERNAL_SYSTEM_GET_DP ExternalSystemGetDevicePath;
//
// Id under which to save entry as default.
//
CHAR16 *Id;
CHAR16 *Id;
//
// Obtained human visible name.
//
CHAR16 *Name;
CHAR16 *Name;
//
// Obtained boot path directory.
// For custom entries this contains tool path.
//
CHAR16 *PathName;
CHAR16 *PathName;
//
// Content flavour.
//
CHAR8 *Flavour;
CHAR8 *Flavour;
//
// Heuristical value signaling inferred type of booted os.
// WARNING: Non-definitive, do not rely on for any security purposes.
//
OC_BOOT_ENTRY_TYPE Type;
OC_BOOT_ENTRY_TYPE Type;
//
// Entry index number, assigned by picker.
//
UINT32 EntryIndex;
UINT32 EntryIndex;
//
// Set when this entry is an externally available entry (e.g. USB).
//
BOOLEAN IsExternal;
BOOLEAN IsExternal;
//
// Should try booting from first dmg found in DevicePath.
//
BOOLEAN IsFolder;
BOOLEAN IsFolder;
//
// Set when this entry refers to a generic booter (e.g. BOOTx64.EFI).
//
BOOLEAN IsGeneric;
BOOLEAN IsGeneric;
//
// Set when this entry refers to a custom boot entry.
//
BOOLEAN IsCustom;
BOOLEAN IsCustom;
//
// Set when entry was created by OC_BOOT_ENTRY_PROTOCOL.
//
BOOLEAN IsBootEntryProtocol;
BOOLEAN IsBootEntryProtocol;
//
// Set when entry is identified as macOS installer.
//
BOOLEAN IsAppleInstaller;
BOOLEAN IsAppleInstaller;
//
// Should make this option default boot option.
//
BOOLEAN SetDefault;
BOOLEAN SetDefault;
//
// Should launch this entry in text mode.
//
BOOLEAN LaunchInText;
BOOLEAN LaunchInText;
//
// Should expose real device path when dealing with custom entries.
//
BOOLEAN ExposeDevicePath;
BOOLEAN ExposeDevicePath;
//
// Should disable OpenRuntime NVRAM protection around invocation of tool.
//
BOOLEAN FullNvramAccess;
BOOLEAN FullNvramAccess;
//
// Partition UUID of entry device.
// Set for non-system action boot entry protocol boot entries only.
//
EFI_GUID UniquePartitionGUID;
EFI_GUID UniquePartitionGUID;
//
// Load option data (usually "boot args") size.
//
UINT32 LoadOptionsSize;
UINT32 LoadOptionsSize;
//
// Load option data (usually "boot args").
//
VOID *LoadOptions;
VOID *LoadOptions;
//
// Audio base path for system action. Boot Entry Protocol only.
//
CHAR8 *AudioBasePath;
CHAR8 *AudioBasePath;
//
// Audio base type for system action. Boot Entry Protocol only.
//
CHAR8 *AudioBaseType;
CHAR8 *AudioBaseType;
} OC_BOOT_ENTRY;

/**
Expand Down Expand Up @@ -557,56 +586,72 @@ typedef struct {
// Multiple entries may share an id - allows e.g. newest version
// of Linux install to automatically become selected default.
//
CONST CHAR8 *Id;
CONST CHAR8 *Id;
//
// Entry name.
//
CONST CHAR8 *Name;
CONST CHAR8 *Name;
//
// Absolute device path to file for user custom entries,
// file path relative to device root for boot entry protocol.
//
CONST CHAR8 *Path;
CONST CHAR8 *Path;
//
// Entry boot arguments.
//
CONST CHAR8 *Arguments;
CONST CHAR8 *Arguments;
//
// Content flavour.
//
CONST CHAR8 *Flavour;
CONST CHAR8 *Flavour;
//
// Whether this entry is auxiliary.
//
BOOLEAN Auxiliary;
BOOLEAN Auxiliary;
//
// Whether this entry is a tool.
//
BOOLEAN Tool;
BOOLEAN Tool;
//
// Whether it should be started in text mode.
//
BOOLEAN TextMode;
BOOLEAN TextMode;
//
// Whether we should pass the actual device path (if possible).
//
BOOLEAN RealPath;
BOOLEAN RealPath;
//
// Should disable OpenRuntime NVRAM protection around invocation of tool.
//
BOOLEAN FullNvramAccess;
BOOLEAN FullNvramAccess;
//
// System action. Boot Entry Protocol only. Optional.
//
OC_BOOT_SYSTEM_ACTION SystemAction;
OC_BOOT_SYSTEM_ACTION SystemAction;
//
// Audio base path for system action. Boot Entry Protocol only. Optional.
//
CHAR8 *AudioBasePath;
CHAR8 *AudioBasePath;
//
// Audio base type for system action. Boot Entry Protocol only. Optional.
//
CHAR8 *AudioBaseType;
CHAR8 *AudioBaseType;
//
// External boot system action. Boot Entry Protocol only. Optional.
//
OC_BOOT_EXTERNAL_SYSTEM_ACTION ExternalSystemAction;
//
// Gets Device Path for external boot system boot entry. Boot Entry Protocol only. Optional.
//
OC_BOOT_EXTERNAL_SYSTEM_GET_DP ExternalSystemGetDevicePath;
//
// External boot system Device Path. Boot Entry Protocol only. Optional.
//
EFI_DEVICE_PATH_PROTOCOL *ExternalSystemDevicePath;
//
// Whether this entry should be labeled as external to the system. Boot Entry Protocol only. Optional.
//
BOOLEAN External;
} OC_PICKER_ENTRY;

/**
Expand Down
Loading