Home | History | Annotate | Download | only in ArmShellCmdRunAxf
      1 /** @file
      2 *
      3 *  Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
      4 *
      5 *  This program and the accompanying materials are licensed and made available
      6 *  under the terms and conditions of the BSD License which accompanies this
      7 *  distribution.  The full text of the license may be found at
      8 *  http://opensource.org/licenses/bsd-license.php
      9 *
     10 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 *
     13 **/
     14 
     15 #include <Uefi.h>
     16 
     17 #include <Library/BaseLib.h>
     18 #include <Library/DebugLib.h>
     19 #include <Library/UefiLib.h>
     20 #include <Library/ArmShellCmdLib.h>
     21 
     22 #include "ArmShellCmdRunAxf.h"
     23 
     24 EFI_HANDLE gRunAxfHiiHandle = NULL;
     25 
     26 #define RUNAXF_HII_GUID \
     27   { \
     28   0xf5a6413b, 0x78d5, 0x448e, { 0xa2, 0x15, 0x22, 0x82, 0x8e, 0xbc, 0x61, 0x61 } \
     29   }
     30 
     31 EFI_GUID gRunAxfHiiGuid = RUNAXF_HII_GUID;
     32 
     33 static EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolRunAxf = {
     34     L"runaxf",                             // *CommandName
     35     ShellDynCmdRunAxfHandler,              // Handler
     36     ShellDynCmdRunAxfGetHelp               // GetHelp
     37 };
     38 
     39 EFI_STATUS
     40 ShellDynCmdRunAxfInstall (
     41   IN EFI_HANDLE             ImageHandle
     42   )
     43 {
     44   EFI_STATUS Status;
     45 
     46   // Register our shell command
     47   Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
     48                  &gEfiShellDynamicCommandProtocolGuid,
     49                  &mShellDynCmdProtocolRunAxf,
     50                  NULL);
     51   if (EFI_ERROR (Status)) {
     52     return Status;
     53   }
     54 
     55   // Load the manual page for our command
     56   //
     57   // 3rd parameter 'HII strings array' must be name of .uni strings file
     58   // followed by 'Strings', e.g. mycommands.uni must be specified as
     59   // 'mycommandsStrings' because the build Autogen process defines this as a
     60   // string array for the strings in your .uni file.  Examine your Build folder
     61   // under your package's DEBUG folder and you will find it defined in a
     62   // xxxStrDefs.h file.
     63   //
     64   gRunAxfHiiHandle = HiiAddPackages (&gRunAxfHiiGuid, ImageHandle,
     65                                      ArmShellCmdRunAxfStrings, NULL);
     66   if (gRunAxfHiiHandle == NULL) {
     67     return EFI_UNSUPPORTED;
     68   }
     69 
     70   return EFI_SUCCESS;
     71 }
     72 
     73 
     74 EFI_STATUS
     75 ShellDynCmdRunAxfUninstall (
     76   IN EFI_HANDLE             ImageHandle
     77   )
     78 {
     79 
     80   EFI_STATUS Status;
     81 
     82   if (gRunAxfHiiHandle != NULL) {
     83     HiiRemovePackages (gRunAxfHiiHandle);
     84   }
     85 
     86   Status = gBS->UninstallMultipleProtocolInterfaces (ImageHandle,
     87                  &gEfiShellDynamicCommandProtocolGuid,
     88                  &mShellDynCmdProtocolRunAxf,
     89                  NULL);
     90   if (EFI_ERROR (Status)) {
     91     return Status;
     92   }
     93 
     94   return EFI_SUCCESS;
     95 }
     96