diff --git a/Application/ResetSystem/ResetSystem.c b/Application/ResetSystem/ResetSystem.c new file mode 100644 index 0000000000000000000000000000000000000000..669ed50cbab7507b00ab93ec53bbc4c2912d1c6c --- /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 0000000000000000000000000000000000000000..2c5f8a4ec4fcc0a0a7fd6dc7c27ed701df42014f --- /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 418e902054ae7263be8cddbc542a455333dd666d..16c34e14ac7914bee7f0a78a80311ce3e0c161a3 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 da3d469501e061d84876d6f3a547c540b686d702..7567bf4d4512e8dbc632626c375ad20114a55586 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 80779d99e455d5f7920f394fedbb6d45fdd03675..e5d34376b9381fe0f17b01eada874689bc866c81 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index ee12a3843bdacb17d710d067202ca848faf227d5..5ef840ab1a055be40ea4c78e4f203afb6f8a670c 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 21a9f163227490258cf5be49bb56295e40d41732..3317b17cdb4f2791bbc72c72beed072e3de02a29 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 8aef448e13d397b06e449d01eeb696bdc4de032e..d9e7d727b186d302f9ce06624f64ea3911099635 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 e2d8040132095aa0bcb3464dfec629f3698f38d6..b2a96b47a647bbe6396fe38cff0bb26a102d6288 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 104e38e07138a51641135ebd3fe83b8b0f33a1df..98fc2834792b0f552a9d0d08e46ac379d6b4e47a 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 a6951b0a058b8a1759cf0c1d457f56dc820b7b28..47ec529b221ca397b6cc7a586801e60d8cc1ad55 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 17b0c6621227894477f9fe16ab2786fdb05f0d3e..ffba2f1b1d2d771c6654b272878aa984027103aa 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