17#include <Library/DebugLib.h>
18#include <Library/MemoryAllocationLib.h>
19#include <Library/UefiLib.h>
20#include <Library/UefiBootServicesTableLib.h>
21#include <Protocol/LoadedImage.h>
22#include <Protocol/ShellParameters.h>
30 STATIC CHAR16 *StArgv[2] = { L
"Self", NULL };
33 EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
34 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
36 Status =
gBS->HandleProtocol (
39 (VOID **)&ShellParameters
41 if (!EFI_ERROR (Status)) {
42 *Argc = ShellParameters->Argc;
43 *Argv = ShellParameters->Argv;
47 Status =
gBS->HandleProtocol (
53 if (EFI_ERROR (Status)) {
54 DEBUG ((DEBUG_WARN,
"OCM: LoadedImage cannot be located - %r\n", Status));
57 if (EFI_ERROR (Status) || (LoadedImage->LoadOptions == NULL)) {
63 StArgv[1] = LoadedImage->LoadOptions;
80 Status =
gBS->LocateHandleBuffer (
88 if (Status == EFI_NOT_FOUND) {
92 if (EFI_ERROR (Status)) {
96 for (Index = 0; Index < NoHandles; ++Index) {
97 Status =
gBS->HandleProtocol (
103 if (EFI_ERROR (Status)) {
107 Status =
gBS->UninstallProtocolInterface (
113 if (EFI_ERROR (Status)) {
126 IN EFI_GUID *Protocol,
132 Status =
gBS->HandleProtocol (
137 if (EFI_ERROR (Status)) {
138 Status =
gBS->LocateProtocol (
150 IN EFI_GUID *Protocol
155 EFI_HANDLE *HandleBuffer;
159 Status =
gBS->LocateHandleBuffer (
166 if (EFI_ERROR (Status)) {
173 FreePool (HandleBuffer);
180 IN EFI_GUID *Protocol,
182 IN CONST CHAR8 *CallerName OPTIONAL,
183 IN CONST CHAR8 *ProtocolName OPTIONAL
189 Status =
gBS->LocateProtocol (
195 if (EFI_ERROR (Status)) {
197 if (ErrorLevel != 0) {
198 if (ProtocolName != NULL) {
199 DEBUG ((ErrorLevel,
"OCM: %a cannot get protocol %s - %r\n", CallerName, ProtocolName, Status));
201 DEBUG ((ErrorLevel,
"OCM: %a cannot get protocol %g - %r\n", CallerName, Protocol, Status));
#define ARRAY_SIZE(Array)
APPLE_EVENT_HANDLE Handle
EFI_STATUS OcUninstallAllProtocolInstances(EFI_GUID *Protocol)
EFI_STATUS GetArguments(OUT UINTN *Argc, OUT CHAR16 ***Argv)
VOID * OcGetProtocol(IN EFI_GUID *Protocol, IN UINTN ErrorLevel, IN CONST CHAR8 *CallerName OPTIONAL, IN CONST CHAR8 *ProtocolName OPTIONAL)
EFI_STATUS OcHandleProtocolFallback(IN EFI_HANDLE Handle, IN EFI_GUID *Protocol, OUT VOID **Interface)
UINTN OcCountProtocolInstances(IN EFI_GUID *Protocol)
EFI_GUID gEfiShellParametersProtocolGuid
EFI_GUID gEfiLoadedImageProtocolGuid