Skip to content

Commit

Permalink
Tools: support case insensitive arguments (acidanthera#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhen-zen authored Apr 19, 2021
1 parent edb8a64 commit e7af094
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 24 deletions.
5 changes: 3 additions & 2 deletions Application/ChipTune/ChipTune.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/MemoryAllocationLib.h>
#include <Library/OcConsoleLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
Expand Down Expand Up @@ -87,7 +88,7 @@ UefiMain (
HdaProtocol = NULL;
BeepGenProtocol = NULL;

if (StrCmp (Argv[1], L"any") == 0 || StrCmp (Argv[1], L"beep") == 0) {
if (OcStriCmp (Argv[1], L"any") == 0 || OcStriCmp (Argv[1], L"beep") == 0) {
Status = gBS->LocateProtocol (
&gAppleBeepGenProtocolGuid,
NULL,
Expand All @@ -99,7 +100,7 @@ UefiMain (
}
}

if (BeepGenProtocol == NULL && (StrCmp (Argv[1], L"any") == 0 || StrCmp (Argv[1], L"hda") == 0)) {
if (BeepGenProtocol == NULL && (OcStriCmp (Argv[1], L"any") == 0 || OcStriCmp (Argv[1], L"hda") == 0)) {
Status = gBS->LocateProtocol (
&gAppleHighDefinitionAudioProtocolGuid,
NULL,
Expand Down
1 change: 1 addition & 0 deletions Application/ChipTune/ChipTune.inf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

[LibraryClasses]
OcConsoleLib
OcStringLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
UefiLib
1 change: 1 addition & 0 deletions Application/ControlMsrE2/ControlMsrE2.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiApplicationEntryPoint.h>
Expand Down
11 changes: 6 additions & 5 deletions Application/ControlMsrE2/ControlMsrE2.inf
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@
BaseLib
BaseMemoryLib
DebugLib
HiiLib
IoLib
MemoryAllocationLib
OcConsoleControlEntryModeGenericLib
OcMemoryLib
OcMiscLib
OcConsoleControlEntryModeGenericLib
OcStringLib
PcdLib
UefiApplicationEntryPoint
UefiLib
HiiLib
UefiHiiServicesLib
PcdLib
IoLib
UefiLib

[Guids]
gEfiHiiPlatformSetupFormsetGuid
Expand Down
6 changes: 3 additions & 3 deletions Application/ControlMsrE2/ControlMsrE2UI.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ InterpretArguments (

Token[TokenIndex] = '\0';

if (StrCmp (Parameter, L"lock") == 0) {
if (OcStriCmp (Parameter, L"lock") == 0) {
mArgumentFlags = ARG_LOCK;
} else if (StrCmp (Parameter, L"unlock") == 0) {
} else if (OcStriCmp (Parameter, L"unlock") == 0) {
mArgumentFlags = ARG_UNLOCK;
} else if (StrCmp (Parameter, L"interactive") == 0) {
} else if (OcStriCmp (Parameter, L"interactive") == 0) {
mArgumentFlags = ARG_INTERACTIVE;
} else {
Print (L"Unknown command line argument: %s\n", Parameter);
Expand Down
5 changes: 3 additions & 2 deletions Application/OpenControl/OpenControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>
#include <Library/UefiLib.h>
#include <Protocol/OcFirmwareRuntime.h>

Expand Down Expand Up @@ -47,13 +48,13 @@ UefiMain (
return EFI_SUCCESS;
}

if (StrCmp (Argv[1], L"disable") == 0) {
if (OcStriCmp (Argv[1], L"disable") == 0) {
ZeroMem (&Config, sizeof (Config));
FwRuntime->SetOverride (&Config);
return EFI_SUCCESS;
}

if (StrCmp (Argv[1], L"restore") == 0) {
if (OcStriCmp (Argv[1], L"restore") == 0) {
FwRuntime->SetOverride (NULL);
return EFI_SUCCESS;
}
Expand Down
1 change: 1 addition & 0 deletions Application/OpenControl/OpenControl.inf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
BaseMemoryLib
OcConsoleControlEntryModeGenericLib
OcMiscLib
OcStringLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
UefiLib
15 changes: 8 additions & 7 deletions Application/ResetSystem/ResetSystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/OcDebugLogLib.h>
#include <Library/OcDeviceMiscLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
Expand All @@ -43,11 +44,11 @@ UefiMain (
if (!EFI_ERROR (Status) && Argc >= 2) {
Mode = Argv[1];
} else {
DEBUG ((DEBUG_INFO, "OCRST: Assuming default to be ResetCold - %r\n", Status));
Mode = L"ColdReset";
DEBUG ((DEBUG_INFO, "OCRST: Assuming default to be coldreset - %r\n", Status));
Mode = L"coldreset";
}

if (StrCmp (Mode, L"Firmware") == 0) {
if (OcStriCmp (Mode, L"firmware") == 0) {
DEBUG ((DEBUG_INFO, "OCRST: Entering firmware...\n"));
DataSize = sizeof (OsIndications);
Status = gRT->GetVariable (
Expand Down Expand Up @@ -91,16 +92,16 @@ UefiMain (
DEBUG ((DEBUG_WARN, "OCRST: Failed to acquire firmware features - %r\n", Status));
return EFI_NOT_FOUND;
}
Mode = L"ColdReset";
Mode = L"coldreset";
}

if (StrCmp (Mode, L"ColdReset") == 0) {
if (OcStriCmp (Mode, L"coldreset") == 0) {
DEBUG ((DEBUG_INFO, "OCRST: Perform cold reset...\n"));
ResetMode = EfiResetCold;
} else if (StrCmp (Mode, L"WarmReset") == 0) {
} else if (OcStriCmp (Mode, L"warmreset") == 0) {
DEBUG ((DEBUG_INFO, "OCRST: Perform warm reset...\n"));
ResetMode = EfiResetWarm;
} else if (StrCmp (Mode, L"Shutdown") == 0) {
} else if (OcStriCmp (Mode, L"shutdown") == 0) {
DEBUG ((DEBUG_INFO, "OCRST: Perform shutdown...\n"));
ResetMode = EfiResetShutdown;
} else {
Expand Down
1 change: 1 addition & 0 deletions Application/ResetSystem/ResetSystem.inf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
DebugLib
OcDeviceMiscLib
OcMiscLib
OcStringLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
UefiRuntimeServicesTableLib
Expand Down
7 changes: 4 additions & 3 deletions Application/RtcRw/RtcRw.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/OcConsoleLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcRtcLib.h>
#include <Library/OcStringLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
Expand Down Expand Up @@ -48,7 +49,7 @@ UefiMain (

Status = GetArguments (&Argc, &Argv);
if (!EFI_ERROR (Status) && Argc >= 2) {
if (StrCmp (Argv[1], L"dump") == 0 && Argc == 2) {
if (OcStriCmp (Argv[1], L"dump") == 0 && Argc == 2) {
for (Index = 0; Index < ARRAY_SIZE (Rtc); ++Index) {
Rtc[Index] = OcRtcRead ((UINT8) Index);
}
Expand Down Expand Up @@ -79,7 +80,7 @@ UefiMain (
return EFI_SUCCESS;
}

if (StrCmp (Argv[1], L"read") == 0 && Argc == 3) {
if (OcStriCmp (Argv[1], L"read") == 0 && Argc == 3) {
Status = StrHexToUintnS (Argv[2], NULL, &Addr);
if (EFI_ERROR (Status) || Addr > 0xFF) {
Print (L"Invalid addr %LX - %r\n", (UINT64) Addr, Status);
Expand All @@ -90,7 +91,7 @@ UefiMain (
return EFI_SUCCESS;
}

if (StrCmp (Argv[1], L"write") == 0 && Argc == 4) {
if (OcStriCmp (Argv[1], L"write") == 0 && Argc == 4) {
Status = StrHexToUintnS (Argv[2], NULL, &Addr);
if (EFI_ERROR (Status) || Addr > 0xFF) {
Print (L"Invalid addr %LX - %r\n", (UINT64) Addr, Status);
Expand Down
1 change: 1 addition & 0 deletions Application/RtcRw/RtcRw.inf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
OcConsoleLib
OcMiscLib
OcRtcLib
OcStringLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
UefiLib
4 changes: 2 additions & 2 deletions Docs/Configuration.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5841,8 +5841,8 @@ \subsection{Tools and Applications}\label{uefitools}
& 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{Firmware}, \texttt{Shutdown}, \texttt{WarmReset}.
Defaults to \texttt{ColdReset}. \\
\texttt{coldreset}, \texttt{firmware}, \texttt{shutdown}, \texttt{warmreset}.
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{ControlMsrE2}}\textbf{*}
Expand Down

0 comments on commit e7af094

Please sign in to comment.