mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcMiscLib: Introduce GetArguments function
This commit is contained in:
parent
c15042a920
commit
5e5ca3fb8b
@ -24,31 +24,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#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
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
ChipTune.c
|
||||
|
||||
[Protocols]
|
||||
gEfiShellParametersProtocolGuid
|
||||
gAppleHighDefinitionAudioProtocolGuid
|
||||
gAppleBeepGenProtocolGuid
|
||||
|
||||
|
||||
@ -17,33 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiApplicationEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/OcMiscLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Protocol/OcFirmwareRuntime.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
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
OpenControl.c
|
||||
|
||||
[Protocols]
|
||||
gEfiShellParametersProtocolGuid
|
||||
gOcFirmwareRuntimeProtocolGuid
|
||||
|
||||
[Packages]
|
||||
@ -47,6 +46,7 @@
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
OcConsoleControlEntryModeGenericLib
|
||||
OcMiscLib
|
||||
UefiApplicationEntryPoint
|
||||
UefiBootServicesTableLib
|
||||
UefiLib
|
||||
|
||||
@ -20,47 +20,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/ShellParameters.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
GetArguments (
|
||||
OUT UINTN *Argc,
|
||||
OUT CHAR16 ***Argv
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID**) &ShellParameters
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*Argc = ShellParameters->Argc;
|
||||
*Argv = ShellParameters->Argv;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID**) &LoadedImage
|
||||
);
|
||||
if (EFI_ERROR (Status) || LoadedImage->LoadOptions == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
STATIC CHAR16 *StArgv[2] = {L"Self", NULL};
|
||||
StArgv[1] = LoadedImage->LoadOptions;
|
||||
*Argc = ARRAY_SIZE (StArgv);
|
||||
*Argv = StArgv;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
|
||||
@ -34,10 +34,6 @@
|
||||
[Sources]
|
||||
ResetSystem.c
|
||||
|
||||
[Protocols]
|
||||
gEfiShellParametersProtocolGuid
|
||||
gEfiLoadedImageProtocolGuid
|
||||
|
||||
[Packages]
|
||||
EfiPkg/EfiPkg.dec
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
@ -22,32 +22,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Library/UefiApplicationEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Protocol/DevicePath.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
|
||||
|
||||
@ -34,9 +34,6 @@
|
||||
[Sources]
|
||||
RtcRw.c
|
||||
|
||||
[Protocols]
|
||||
gEfiShellParametersProtocolGuid
|
||||
|
||||
[Packages]
|
||||
EfiPkg/EfiPkg.dec
|
||||
MdePkg/MdePkg.dec
|
||||
@ -44,6 +41,7 @@
|
||||
|
||||
[LibraryClasses]
|
||||
OcConsoleLib
|
||||
OcMiscLib
|
||||
OcRtcLib
|
||||
UefiApplicationEntryPoint
|
||||
UefiBootServicesTableLib
|
||||
|
||||
@ -52,6 +52,22 @@ ApplyPatch (
|
||||
);
|
||||
|
||||
/**
|
||||
Obtain application arguments.
|
||||
|
||||
@param[out] Argc Argument count.
|
||||
@param[out] Argv Argument list.
|
||||
|
||||
@retval EFI_SUCCESS on success.
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetArguments (
|
||||
OUT UINTN *Argc,
|
||||
OUT CHAR16 ***Argv
|
||||
);
|
||||
|
||||
/**
|
||||
Uninstall all protocols with the specified GUID.
|
||||
|
||||
@param[in] Protocol The published unique identifier of the protocol. It is the caller’s responsibility to pass in
|
||||
a valid GUID.
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
|
||||
[Protocols]
|
||||
gEfiPciIoProtocolGuid
|
||||
gEfiShellParametersProtocolGuid
|
||||
gEfiLoadedImageProtocolGuid
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
@ -46,5 +48,5 @@
|
||||
DataPatcher.c
|
||||
DirectReset.c
|
||||
ReleaseUsbOwnership.c
|
||||
UninstallAllProtocolInterfaces.c
|
||||
ProtocolSupport.c
|
||||
Math.c
|
||||
|
||||
@ -17,13 +17,46 @@
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/ShellParameters.h>
|
||||
|
||||
/**
|
||||
@param[in] Protocol The published unique identifier of the protocol. It is the caller’s responsibility to pass in
|
||||
a valid GUID.
|
||||
EFI_STATUS
|
||||
GetArguments (
|
||||
OUT UINTN *Argc,
|
||||
OUT CHAR16 ***Argv
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID**) &ShellParameters
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*Argc = ShellParameters->Argc;
|
||||
*Argv = ShellParameters->Argv;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID**) &LoadedImage
|
||||
);
|
||||
if (EFI_ERROR (Status) || LoadedImage->LoadOptions == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
STATIC CHAR16 *StArgv[2] = {L"Self", NULL};
|
||||
StArgv[1] = LoadedImage->LoadOptions;
|
||||
*Argc = ARRAY_SIZE (StArgv);
|
||||
*Argv = StArgv;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@retval EFI_SUCCESS on success.
|
||||
**/
|
||||
EFI_STATUS
|
||||
UninstallAllProtocolInstances (
|
||||
EFI_GUID *Protocol
|
||||
Loading…
x
Reference in New Issue
Block a user