diff --git a/Application/ResetSystem/ResetSystem.c b/Application/ResetSystem/ResetSystem.c new file mode 100644 index 00000000..669ed50c --- /dev/null +++ b/Application/ResetSystem/ResetSystem.c @@ -0,0 +1,101 @@ +/** @file + Play beep. + +Copyright (c) 2020, vit9696. All rights reserved.
+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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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; + CHAR16 *Mode; + EFI_RESET_TYPE ResetMode; + + Status = GetArguments (&Argc, &Argv); + if (!EFI_ERROR (Status) && Argc >= 2) { + Mode = Argv[1]; + } else { + DEBUG ((DEBUG_INFO, "OCRST: Assuming default to be ResetCold...\n")); + Mode = L"ResetCold"; + } + + if (StrCmp (Mode, L"ColdReset") == 0) { + DEBUG ((DEBUG_INFO, "OCRST: Perform cold reset...\n")); + ResetMode = EfiResetCold; + } else if (StrCmp (Mode, L"WarmReset") == 0) { + DEBUG ((DEBUG_INFO, "OCRST: Perform warm reset...\n")); + ResetMode = EfiResetWarm; + } else if (StrCmp (Mode, L"Shutdown") == 0) { + DEBUG ((DEBUG_INFO, "OCRST: Perform shutdown...\n")); + ResetMode = EfiResetShutdown; + } else { + DEBUG ((DEBUG_INFO, "OCRST: Unknown argument %s, defaulting to cold reset...\n", Mode)); + ResetMode = EfiResetCold; + } + + gRT->ResetSystem ( + ResetMode, + EFI_SUCCESS, + 0, + NULL + ); + + DEBUG ((DEBUG_INFO, "OCRST: Failed to reset, trying direct\n")); + + DirectRestCold (); + + DEBUG ((DEBUG_INFO, "OCRST: Failed to reset directly, entering dead loop\n")); + + CpuDeadLoop (); + + return EFI_SUCCESS; //< Unreachable +} diff --git a/Application/ResetSystem/ResetSystem.inf b/Application/ResetSystem/ResetSystem.inf new file mode 100644 index 00000000..2c5f8a4e --- /dev/null +++ b/Application/ResetSystem/ResetSystem.inf @@ -0,0 +1,52 @@ +## @file +# Reset system in some way. +# +# Copyright (c) 2020, vit9696. All rights reserved.
+# +# 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 = ResetSystem + FILE_GUID = E0CAD01B-51A1-4591-87FF-EA9216D431BD + 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] + ResetSystem.c + +[Protocols] + gEfiShellParametersProtocolGuid + +[Packages] + EfiPkg/EfiPkg.dec + MdePkg/MdePkg.dec + OpenCorePkg/OpenCorePkg.dec + +[LibraryClasses] + BaseLib + DebugLib + OcMiscLib + UefiApplicationEntryPoint + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + UefiLib diff --git a/Application/RtcRw/RtcRw.c b/Application/RtcRw/RtcRw.c index 418e9020..16c34e14 100644 --- a/Application/RtcRw/RtcRw.c +++ b/Application/RtcRw/RtcRw.c @@ -1,5 +1,5 @@ /** @file - Play beep. + RTC memory read/write. Copyright (c) 2020, vit9696. All rights reserved.
This program and the accompanying materials diff --git a/Changelog.md b/Changelog.md index da3d4695..7567bf4d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,7 @@ OpenCore Changelog - Added `PatchAppleRtcChecksum` kernel quirk - Added `AppleRtcRam` protocol implementation - Renamed `Protocols` to `ProtocolOverrides` for clarity +- Added ResetSystem tool to allow shutdown/reset actions in the menu #### v0.5.7 - Added TimeMachine detection to picker diff --git a/Docs/Configuration.pdf b/Docs/Configuration.pdf index 80779d99..e5d34376 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index ee12a384..5ef840ab 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -4044,6 +4044,9 @@ Some of the known tools are listed below (builtin tools are marked with \textbf{ with a broad range of firmwares. \\ \href{https://github.com/acidanthera/OpenCorePkg}{\texttt{PavpProvision}} & Perform EPID provisioning (requires certificate data configuration). \\ +\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{ResetSystem}}\textbf{*} +& Utility to perform system reset. Takes reset type as an argument: + \texttt{ColdReset}, \texttt{WarmReset}, \texttt{Shutdown}. Defaults to \texttt{ColdReset}. \\ \href{https://github.com/acidanthera/OpenCorePkg}{\texttt{RtcRw}}\textbf{*} & Utility to read and write RTC (CMOS) memory. \\ \href{https://github.com/acidanthera/OpenCorePkg}{\texttt{VerifyMsrE2}}\textbf{*} diff --git a/Docs/Differences/Differences.pdf b/Docs/Differences/Differences.pdf index 21a9f163..3317b17c 100644 Binary files a/Docs/Differences/Differences.pdf and b/Docs/Differences/Differences.pdf differ diff --git a/Docs/Differences/Differences.tex b/Docs/Differences/Differences.tex index 8aef448e..d9e7d727 100644 --- a/Docs/Differences/Differences.tex +++ b/Docs/Differences/Differences.tex @@ -1,7 +1,7 @@ \documentclass[]{article} %DIF LATEXDIFF DIFFERENCE FILE %DIF DEL PreviousConfiguration.tex Tue Apr 7 19:32:13 2020 -%DIF ADD ../Configuration.tex Mon Apr 20 09:29:28 2020 +%DIF ADD ../Configuration.tex Mon Apr 20 13:11:07 2020 \usepackage{lmodern} \usepackage{amssymb,amsmath} @@ -4116,7 +4116,10 @@ Some of the known tools are listed below (builtin tools are marked with \textbf{ with a broad range of firmwares. \\ \href{https://github.com/acidanthera/OpenCorePkg}{\texttt{PavpProvision}} & Perform EPID provisioning (requires certificate data configuration). \\ -\DIFaddbegin \href{https://github.com/acidanthera/OpenCorePkg}{\texttt{RtcRw}}\textbf{\DIFadd{*}} +\DIFaddbegin \href{https://github.com/acidanthera/OpenCorePkg}{\texttt{ResetSystem}}\textbf{\DIFadd{*}} +& \DIFadd{Utility to perform system reset. Takes reset type as an argument: + }\texttt{\DIFadd{ColdReset}}\DIFadd{, }\texttt{\DIFadd{WarmReset}}\DIFadd{, }\texttt{\DIFadd{Shutdown}}\DIFadd{. Defaults to }\texttt{\DIFadd{ColdReset}}\DIFadd{. }\\ +\href{https://github.com/acidanthera/OpenCorePkg}{\texttt{RtcRw}}\textbf{\DIFadd{*}} & \DIFadd{Utility to read and write RTC (CMOS) memory. }\\ \DIFaddend \href{https://github.com/acidanthera/OpenCorePkg}{\texttt{VerifyMsrE2}}\textbf{*} & Check \texttt{CFG Lock} (MSR \texttt{0xE2} write protection) consistency across all cores. diff --git a/Docs/Sample.plist b/Docs/Sample.plist index e2d80401..b2a96b47 100644 --- a/Docs/Sample.plist +++ b/Docs/Sample.plist @@ -649,6 +649,20 @@ Path memcheck/memcheck.efi + + Arguments + Shutdown + Auxiliary + + Comment + Perform shutdown + Enabled + + Name + Shutdown + Path + ResetSystem.efi + NVRAM diff --git a/Docs/SampleFull.plist b/Docs/SampleFull.plist index 104e38e0..98fc2834 100644 --- a/Docs/SampleFull.plist +++ b/Docs/SampleFull.plist @@ -649,6 +649,20 @@ Path memcheck/memcheck.efi + + Arguments + Shutdown + Auxiliary + + Comment + Perform shutdown + Enabled + + Name + Shutdown + Path + ResetSystem.efi + NVRAM diff --git a/OpenCorePkg.dsc b/OpenCorePkg.dsc index a6951b0a..47ec529b 100755 --- a/OpenCorePkg.dsc +++ b/OpenCorePkg.dsc @@ -151,6 +151,7 @@ OpenCorePkg/Application/MmapDump/MmapDump.inf OpenCorePkg/Application/OpenControl/OpenControl.inf OpenCorePkg/Application/PavpProvision/PavpProvision.inf + OpenCorePkg/Application/ResetSystem/ResetSystem.inf OpenCorePkg/Application/RtcRw/RtcRw.inf OpenCorePkg/Application/VerifyMsrE2/VerifyMsrE2.inf OpenCorePkg/Debug/GdbSyms/GdbSyms.inf diff --git a/macbuild.tool b/macbuild.tool index 17b0c662..ffba2f1b 100755 --- a/macbuild.tool +++ b/macbuild.tool @@ -36,6 +36,7 @@ package() { cp HiiDatabase.efi tmp/EFI/OC/Drivers/ || exit 1 cp KeyTester.efi tmp/EFI/OC/Tools/ || exit 1 cp MmapDump.efi tmp/EFI/OC/Tools/ || exit 1 + cp ResetSystem.efi tmp/EFI/OC/Tools || exit 1 cp RtcRw.efi tmp/EFI/OC/Tools || exit 1 cp NvmExpressDxe.efi tmp/EFI/OC/Drivers/ || exit 1 cp OpenCanopy.efi tmp/EFI/OC/Drivers/ || exit 1