Home | History | Annotate | Download | only in UefiDpLib
      1 /** @file
      2   Main file for NULL named library for install1 shell command functions.
      3 
      4   Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
      5   This program and the accompanying materials
      6   are licensed and made available under the terms and conditions of the BSD License
      7   which accompanies this 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 "UefiDpLib.h"
     16 
     17 STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
     18 EFI_HANDLE gDpHiiHandle = NULL;
     19 
     20 #define DP_HII_GUID \
     21   { \
     22   0xeb832fd9, 0x9089, 0x4898, { 0x83, 0xc9, 0x41, 0x61, 0x8f, 0x5c, 0x48, 0xb9 } \
     23   }
     24 
     25 EFI_GUID gDpHiiGuid = DP_HII_GUID;
     26 
     27 /**
     28   Function to get the filename with help context if HII will not be used.
     29 
     30   @return   The filename with help text in it.
     31 **/
     32 CONST CHAR16*
     33 EFIAPI
     34 UefiDpLibGetManFileName (
     35   VOID
     36   )
     37 {
     38   return (mFileName);
     39 }
     40 
     41 /**
     42   Constructor for the Shell Level 1 Commands library.
     43 
     44   Install the handlers for level 1 UEFI Shell 2.0 commands.
     45 
     46   @param ImageHandle    the image handle of the process
     47   @param SystemTable    the EFI System Table pointer
     48 
     49   @retval EFI_SUCCESS        the shell command handlers were installed sucessfully
     50   @retval EFI_UNSUPPORTED    the shell level required was not found.
     51 **/
     52 EFI_STATUS
     53 EFIAPI
     54 UefiDpLibConstructor (
     55   IN EFI_HANDLE        ImageHandle,
     56   IN EFI_SYSTEM_TABLE  *SystemTable
     57   )
     58 {
     59   //
     60   // check our bit of the profiles mask
     61   //
     62   if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {
     63     return (EFI_SUCCESS);
     64   }
     65 
     66   //
     67   // 3rd parameter 'HII strings array' must be name of .uni strings file followed by 'Strings', e.g. mycommands.uni must be
     68   // specified as 'mycommandsStrings' because the build Autogen process defines this as a string array for the strings in your
     69   // .uni file.  Examine your Build folder under your package's DEBUG folder and you will find it defined in a xxxStrDefs.h file.
     70   //
     71   gDpHiiHandle = HiiAddPackages (&gDpHiiGuid, gImageHandle, UefiDpLibStrings, NULL);
     72   if (gDpHiiHandle == NULL) {
     73     return (EFI_DEVICE_ERROR);
     74   }
     75 
     76   //
     77   // install our shell command handlers that are always installed
     78   //
     79   ShellCommandRegisterCommandName(L"dp", ShellCommandRunDp , UefiDpLibGetManFileName, 0, L"", FALSE, gDpHiiHandle, STRING_TOKEN(STR_GET_HELP_DP));
     80 
     81   return (EFI_SUCCESS);
     82 }
     83 
     84 /**
     85   Destructor for the library.  free any resources.
     86 
     87   @param ImageHandle            The image handle of the process.
     88   @param SystemTable            The EFI System Table pointer.
     89 **/
     90 EFI_STATUS
     91 EFIAPI
     92 UefiDpLibDestructor (
     93   IN EFI_HANDLE        ImageHandle,
     94   IN EFI_SYSTEM_TABLE  *SystemTable
     95   )
     96 {
     97   if (gDpHiiHandle != NULL) {
     98     HiiRemovePackages(gDpHiiHandle);
     99   }
    100   return (EFI_SUCCESS);
    101 }
    102