forked from acidanthera/OpenCorePkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
518 changed files
with
168,999 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** @file | ||
Run Apple Boot Picker. | ||
Copyright (c) 2020, vit9696. All rights reserved.<BR> | ||
This program and the accompanying materials | ||
are licensed and made available under the terms and conditions of the BSD License | ||
which accompanies this distribution. The full text of the license may be found at | ||
http://opensource.org/licenses/bsd-license.php | ||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
**/ | ||
|
||
#include <PiDxe.h> | ||
#include <Guid/AppleFile.h> | ||
#include <Library/BaseMemoryLib.h> | ||
#include <Library/DebugLib.h> | ||
#include <Library/MemoryAllocationLib.h> | ||
#include <Library/OcBootManagementLib.h> | ||
#include <Library/OcConsoleLib.h> | ||
#include <Library/OcMiscLib.h> | ||
#include <Library/OcFileLib.h> | ||
#include <Library/UefiApplicationEntryPoint.h> | ||
#include <Library/UefiBootServicesTableLib.h> | ||
#include <Library/UefiLib.h> | ||
#include <Protocol/DevicePath.h> | ||
#include <Protocol/GraphicsOutput.h> | ||
|
||
EFI_STATUS | ||
EFIAPI | ||
UefiMain ( | ||
IN EFI_HANDLE ImageHandle, | ||
IN EFI_SYSTEM_TABLE *SystemTable | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; | ||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Pixel; | ||
UINTN Index; | ||
|
||
gBS->SetWatchdogTimer (0, 0, 0, NULL); | ||
|
||
OcProvideConsoleGop (FALSE); | ||
|
||
OcSetConsoleResolution (0, 0, 0); | ||
|
||
Status = gBS->HandleProtocol ( | ||
gST->ConsoleOutHandle, | ||
&gEfiGraphicsOutputProtocolGuid, | ||
(VOID **) &Gop | ||
); | ||
|
||
if (EFI_ERROR (Status)) { | ||
// | ||
// Note: Ensure that stall value is within UINT32 in nanoseconds. | ||
// | ||
for (Index = 0; Index < 10; ++Index) { | ||
gBS->Stall (SECONDS_TO_MICROSECONDS (1)); | ||
} | ||
return Status; | ||
} | ||
|
||
Status = OcRunAppleBootPicker (); | ||
|
||
Pixel.Raw = 0x0; | ||
if (Status == EFI_NOT_FOUND) { | ||
// | ||
// Red. No BootPicker in firmware or we cannot get it. | ||
// | ||
Pixel.Pixel.Red = 0xFF; | ||
} else if (Status == EFI_UNSUPPORTED) { | ||
// | ||
// Yellow. BootPicker does not start. | ||
// | ||
Pixel.Pixel.Red = 0xFF; | ||
Pixel.Pixel.Green = 0xFF; | ||
} else if (EFI_ERROR (Status) /* Status == EFI_INVALID_PARAMETER */) { | ||
// | ||
// Fuchsia. BootPicker does not load. | ||
// | ||
Pixel.Pixel.Blue = 0xFF; | ||
Pixel.Pixel.Red = 0xFF; | ||
} else { | ||
// | ||
// Green. BootPicker started but returned. | ||
// | ||
Pixel.Pixel.Green = 0xFF; | ||
} | ||
|
||
Gop->Blt ( | ||
Gop, | ||
&Pixel.Pixel, | ||
EfiBltVideoFill, | ||
0, | ||
0, | ||
0, | ||
0, | ||
Gop->Mode->Info->HorizontalResolution, | ||
Gop->Mode->Info->VerticalResolution, | ||
0 | ||
); | ||
|
||
// | ||
// Note: Ensure that stall value is within UINT32 in nanoseconds. | ||
// | ||
for (Index = 0; Index < 10; ++Index) { | ||
gBS->Stall (SECONDS_TO_MICROSECONDS (1)); | ||
} | ||
|
||
return EFI_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
## @file | ||
# Run Apple Boot Picker. | ||
# | ||
# Copyright (c) 2018, vit9696. All rights reserved.<BR> | ||
# | ||
# This program and the accompanying materials | ||
# are licensed and made available under the terms and conditions of the BSD License | ||
# which accompanies this distribution. The full text of the license may be found at | ||
# http://opensource.org/licenses/bsd-license.php | ||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = BootKicker | ||
FILE_GUID = 3099A880-582F-44BA-8DA3-F4A875F3E34D | ||
MODULE_TYPE = UEFI_APPLICATION | ||
VERSION_STRING = 1.0 | ||
ENTRY_POINT = UefiMain | ||
|
||
# | ||
# This flag specifies whether HII resource section is generated into PE image. | ||
# | ||
UEFI_HII_RESOURCE_SECTION = TRUE | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC | ||
# | ||
|
||
[Sources] | ||
BootKicker.c | ||
|
||
[Guids] | ||
gAppleBootPickerFileGuid | ||
|
||
[Protocols] | ||
gEfiDevicePathProtocolGuid | ||
gEfiFirmwareVolumeProtocolGuid | ||
gEfiGraphicsOutputProtocolGuid | ||
|
||
[Packages] | ||
EfiPkg/EfiPkg.dec | ||
MdePkg/MdePkg.dec | ||
OcSupportPkg/OcSupportPkg.dec | ||
|
||
[LibraryClasses] | ||
OcBootManagementLib | ||
OcConsoleLib | ||
OcFileLib | ||
UefiApplicationEntryPoint | ||
UefiBootServicesTableLib | ||
UefiLib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/** @file | ||
Play beep. | ||
Copyright (c) 2020, vit9696. All rights reserved.<BR> | ||
This program and the accompanying materials | ||
are licensed and made available under the terms and conditions of the BSD License | ||
which accompanies this distribution. The full text of the license may be found at | ||
http://opensource.org/licenses/bsd-license.php | ||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
**/ | ||
|
||
#include <Uefi.h> | ||
#include <Library/BaseMemoryLib.h> | ||
#include <Library/OcDebugLogLib.h> | ||
#include <Library/MemoryAllocationLib.h> | ||
#include <Library/OcConsoleLib.h> | ||
#include <Library/OcMiscLib.h> | ||
#include <Library/UefiApplicationEntryPoint.h> | ||
#include <Library/UefiBootServicesTableLib.h> | ||
#include <Library/UefiLib.h> | ||
#include <Protocol/DevicePath.h> | ||
#include <Protocol/AppleHda.h> | ||
#include <Protocol/AppleBeepGen.h> | ||
#include <Protocol/ShellParameters.h> | ||
|
||
STATIC | ||
EFI_STATUS | ||
GetArguments ( | ||
OUT UINTN *Argc, | ||
OUT CHAR16 ***Argv | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters; | ||
|
||
Status = gBS->HandleProtocol ( | ||
gImageHandle, | ||
&gEfiShellParametersProtocolGuid, | ||
(VOID**) &ShellParameters | ||
); | ||
if (EFI_ERROR (Status)) { | ||
return Status; | ||
} | ||
|
||
*Argc = ShellParameters->Argc; | ||
*Argv = ShellParameters->Argv; | ||
return EFI_SUCCESS; | ||
} | ||
|
||
EFI_STATUS | ||
EFIAPI | ||
UefiMain ( | ||
IN EFI_HANDLE ImageHandle, | ||
IN EFI_SYSTEM_TABLE *SystemTable | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
UINTN Argc; | ||
CHAR16 **Argv; | ||
APPLE_HIGH_DEFINITION_AUDIO_PROTOCOL *HdaProtocol; | ||
APPLE_BEEP_GEN_PROTOCOL *BeepGenProtocol; | ||
UINTN Count; | ||
UINTN Signal; | ||
UINTN Silence; | ||
UINTN Frequency; | ||
|
||
gBS->SetWatchdogTimer (0, 0, 0, NULL); | ||
|
||
OcProvideConsoleGop (FALSE); | ||
|
||
OcConsoleControlSetMode (EfiConsoleControlScreenText); | ||
|
||
OcSetConsoleResolution (0, 0, 0); | ||
|
||
Status = GetArguments (&Argc, &Argv); | ||
if (EFI_ERROR (Status) || Argc < 5) { | ||
Print (L"Usage: ChipTune <any|hda|beep> <count> <signal> <silence> [<frequency>]\n"); | ||
return EFI_SUCCESS; | ||
} | ||
|
||
Status = StrDecimalToUintnS (Argv[2], NULL, &Count); | ||
if (EFI_ERROR (Status)) { | ||
Print (L"Invalid count value - %r\n", Status); | ||
return EFI_SUCCESS; | ||
} | ||
|
||
Status = StrDecimalToUintnS (Argv[3], NULL, &Signal); | ||
if (EFI_ERROR (Status)) { | ||
Print (L"Invalid signal length value - %r\n", Status); | ||
return EFI_SUCCESS; | ||
} | ||
|
||
Status = StrDecimalToUintnS (Argv[4], NULL, &Silence); | ||
if (EFI_ERROR (Status)) { | ||
Print (L"Invalid silence length value - %r\n", Status); | ||
return EFI_SUCCESS; | ||
} | ||
|
||
if (Argc >= 6) { | ||
Status = StrDecimalToUintnS (Argv[5], NULL, &Frequency); | ||
if (EFI_ERROR (Status)) { | ||
Print (L"Invalid frequency value - %r\n", Status); | ||
return EFI_SUCCESS; | ||
} | ||
} else { | ||
Frequency = 0; | ||
} | ||
|
||
HdaProtocol = NULL; | ||
BeepGenProtocol = NULL; | ||
|
||
if (StrCmp (Argv[1], L"any") == 0 || StrCmp (Argv[1], L"beep") == 0) { | ||
Status = gBS->LocateProtocol ( | ||
&gAppleBeepGenProtocolGuid, | ||
NULL, | ||
(VOID **) &BeepGenProtocol | ||
); | ||
if (EFI_ERROR (Status) || BeepGenProtocol->GenBeep == NULL) { | ||
Print (L"Beep protocol is unusable - %r\n", Status); | ||
BeepGenProtocol = NULL; | ||
} | ||
} | ||
|
||
if (BeepGenProtocol == NULL && (StrCmp (Argv[1], L"any") == 0 || StrCmp (Argv[1], L"hda") == 0)) { | ||
Status = gBS->LocateProtocol ( | ||
&gAppleHighDefinitionAudioProtocolGuid, | ||
NULL, | ||
(VOID **) &HdaProtocol | ||
); | ||
if (EFI_ERROR (Status) || HdaProtocol->PlayTone == NULL) { | ||
Print (L"HDA protocol is unusable - %r\n", Status); | ||
HdaProtocol = NULL; | ||
} | ||
} | ||
|
||
Print ( | ||
L"Trying playback %u %Lu %Lu %d\n", | ||
(UINT32) Count, | ||
(UINT64) Signal, | ||
(UINT64) Silence, | ||
(UINT64) Frequency | ||
); | ||
|
||
if (BeepGenProtocol != NULL) { | ||
Status = BeepGenProtocol->GenBeep ( | ||
Count, | ||
Signal, | ||
Silence | ||
); | ||
} else if (HdaProtocol != NULL) { | ||
Status = HdaProtocol->PlayTone ( | ||
HdaProtocol, | ||
(UINT32) Count, | ||
Signal, | ||
Silence, | ||
Frequency | ||
); | ||
} else { | ||
Status = EFI_UNSUPPORTED; | ||
} | ||
|
||
if (EFI_ERROR (Status)) { | ||
Print (L"Playback failure - %r\n", Status); | ||
} | ||
|
||
return EFI_SUCCESS; | ||
} |
Oops, something went wrong.