Home | History | Annotate | Download | only in UefiShellNetwork1CommandsLib
      1 /** @file
      2   Main file for NULL named library for network1 shell command functions.
      3 
      4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved. <BR>
      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 #include "UefiShellNetwork1CommandsLib.h"
     15 
     16 CONST CHAR16 gShellNetwork1FileName[] = L"ShellCommands";
     17 EFI_HANDLE gShellNetwork1HiiHandle = NULL;
     18 
     19 /**
     20   return the file name of the help text file if not using HII.
     21 
     22   @return The string pointer to the file name.
     23 **/
     24 CONST CHAR16*
     25 EFIAPI
     26 ShellCommandGetManFileNameNetwork1 (
     27   VOID
     28   )
     29 {
     30   return (gShellNetwork1FileName);
     31 }
     32 
     33 /**
     34   Constructor for the Shell Network1 Commands library.
     35 
     36   Install the handlers for Network1 UEFI Shell 2.0 profile commands.
     37 
     38   @param ImageHandle            The image handle of the process.
     39   @param SystemTable            The EFI System Table pointer.
     40 
     41   @retval EFI_SUCCESS           The shell command handlers were installed sucessfully.
     42   @retval EFI_UNSUPPORTED       The shell level required was not found.
     43 **/
     44 EFI_STATUS
     45 EFIAPI
     46 ShellNetwork1CommandsLibConstructor (
     47   IN EFI_HANDLE        ImageHandle,
     48   IN EFI_SYSTEM_TABLE  *SystemTable
     49   )
     50 {
     51   gShellNetwork1HiiHandle = NULL;
     52 
     53   //
     54   // check our bit of the profiles mask
     55   //
     56   if ((PcdGet8(PcdShellProfileMask) & BIT3) == 0) {
     57     return (EFI_SUCCESS);
     58   }
     59 
     60   gShellNetwork1HiiHandle = HiiAddPackages (&gShellNetwork1HiiGuid, gImageHandle, UefiShellNetwork1CommandsLibStrings, NULL);
     61   if (gShellNetwork1HiiHandle == NULL) {
     62     return (EFI_DEVICE_ERROR);
     63   }
     64   //
     65   // install our shell command handlers
     66   //
     67   ShellCommandRegisterCommandName(L"ping",    ShellCommandRunPing     , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_PING));
     68   ShellCommandRegisterCommandName(L"ifconfig",ShellCommandRunIfconfig , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_IFCONFIG));
     69 
     70   return (EFI_SUCCESS);
     71 }
     72 
     73 /**
     74   Destructor for the library.  free any resources.
     75 
     76   @param ImageHandle            The image handle of the process.
     77   @param SystemTable            The EFI System Table pointer.
     78 **/
     79 EFI_STATUS
     80 EFIAPI
     81 ShellNetwork1CommandsLibDestructor (
     82   IN EFI_HANDLE        ImageHandle,
     83   IN EFI_SYSTEM_TABLE  *SystemTable
     84   )
     85 {
     86   if (gShellNetwork1HiiHandle != NULL) {
     87     HiiRemovePackages(gShellNetwork1HiiHandle);
     88   }
     89   return (EFI_SUCCESS);
     90 }
     91