X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellCEntryLib%2FUefiShellCEntryLib.c;h=7fcdedbb05c9da979f7ddd8b18bbc8ed2a006dfb;hb=28165f245f26bad4dae86cda3d17458726a9a82f;hp=ce41166573eb6adad0168e8cc34ff40a07145b99;hpb=92fbbb5d09d52f72801756b2c95d90a137fadb90;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c index ce41166573..7fcdedbb05 100644 --- a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c +++ b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c @@ -1,44 +1,45 @@ /** @file - Provides application point extension for "C" style main funciton + Provides application point extension for "C" style main funciton -Copyright (c) 2009, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php + Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include #include +#include #include -#include +#include +#include #include -INTN -EFIAPI -ShellAppMain ( - IN INTN Argc, - IN CHAR16 **Argv - ); - /** - UEFI entry point for an application that will in turn call a C - style ShellAppMain function. + UEFI entry point for an application that will in turn call the + ShellAppMain function which has parameters similar to a standard C + main function. + + An application that uses UefiShellCEntryLib must have a ShellAppMain + function as prototyped in Include/Library/ShellCEntryLib.h. + + Note that the Shell uses POSITIVE integers for error values, while UEFI + uses NEGATIVE values. If the application is to be used within a script, + it needs to return one of the SHELL_STATUS values defined in Protocol/Shell.h. + + @param ImageHandle The image handle of the UEFI Application. + @param SystemTable A pointer to the EFI System Table. - This application must have a function defined as follows: + @retval EFI_SUCCESS The application exited normally. + @retval Other An error occurred. - INTN - EFIAPI - ShellAppMain ( - IN INTN Argc, - IN CHAR16 **Argv - ); **/ EFI_STATUS EFIAPI @@ -47,7 +48,7 @@ ShellCEntryLib ( IN EFI_SYSTEM_TABLE *SystemTable ) { - INT32 ReturnFromMain; + INTN ReturnFromMain; EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol; EFI_SHELL_INTERFACE *EfiShellInterface; EFI_STATUS Status; @@ -56,13 +57,13 @@ ShellCEntryLib ( EfiShellParametersProtocol = NULL; EfiShellInterface = NULL; - Status = SystemTable->BootServices->OpenProtocol(ImageHandle, + Status = SystemTable->BootServices->OpenProtocol(ImageHandle, &gEfiShellParametersProtocolGuid, (VOID **)&EfiShellParametersProtocol, ImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); + ); if (!EFI_ERROR(Status)) { // // use shell 2.0 interface @@ -70,33 +71,29 @@ ShellCEntryLib ( ReturnFromMain = ShellAppMain ( EfiShellParametersProtocol->Argc, EfiShellParametersProtocol->Argv - ); + ); } else { // // try to get shell 1.0 interface instead. // - Status = SystemTable->BootServices->OpenProtocol(ImageHandle, + Status = SystemTable->BootServices->OpenProtocol(ImageHandle, &gEfiShellInterfaceGuid, (VOID **)&EfiShellInterface, ImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); + ); if (!EFI_ERROR(Status)) { // // use shell 1.0 interface - // + // ReturnFromMain = ShellAppMain ( EfiShellInterface->Argc, EfiShellInterface->Argv - ); + ); } else { ASSERT(FALSE); } } - if (ReturnFromMain == 0) { - return (EFI_SUCCESS); - } else { - return (EFI_UNSUPPORTED); - } + return ReturnFromMain; }