]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
fix parameter type
[mirror_edk2.git] / ShellPkg / Library / UefiShellCEntryLib / UefiShellCEntryLib.c
1 /** @file
2 Provides application point extension for "C" style main funciton
3
4 Copyright (c) 2009, Intel Corporation
5 All rights reserved. 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 <Base.h>
16
17 #include <Protocol/SimpleFileSystem.h>
18 #include <Protocol/EfiShellInterface.h>
19 #include <Protocol/EfiShellParameters.h>
20
21 #include <Library/ShellCEntryLib.h>
22 #include <Library/DebugLib.h>
23
24 /**
25 UEFI entry point for an application that will in turn call the
26 ShellAppMain function which has parameters similar to a standard C
27 main function.
28
29 An application that uses UefiShellCEntryLib must have a ShellAppMain
30 function as prototyped in Include/Library/ShellCEntryLib.h.
31
32 @param ImageHandle The image handle of the UEFI Application.
33 @param SystemTable A pointer to the EFI System Table.
34
35 @retval EFI_SUCCESS The application exited normally.
36 @retval Other An error occurred.
37
38 **/
39 EFI_STATUS
40 EFIAPI
41 ShellCEntryLib (
42 IN EFI_HANDLE ImageHandle,
43 IN EFI_SYSTEM_TABLE *SystemTable
44 )
45 {
46 INTN ReturnFromMain;
47 EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;
48 EFI_SHELL_INTERFACE *EfiShellInterface;
49 EFI_STATUS Status;
50
51 ReturnFromMain = -1;
52 EfiShellParametersProtocol = NULL;
53 EfiShellInterface = NULL;
54
55 Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
56 &gEfiShellParametersProtocolGuid,
57 (VOID **)&EfiShellParametersProtocol,
58 ImageHandle,
59 NULL,
60 EFI_OPEN_PROTOCOL_GET_PROTOCOL
61 );
62 if (!EFI_ERROR(Status)) {
63 //
64 // use shell 2.0 interface
65 //
66 ReturnFromMain = ShellAppMain (
67 EfiShellParametersProtocol->Argc,
68 EfiShellParametersProtocol->Argv
69 );
70 } else {
71 //
72 // try to get shell 1.0 interface instead.
73 //
74 Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
75 &gEfiShellInterfaceGuid,
76 (VOID **)&EfiShellInterface,
77 ImageHandle,
78 NULL,
79 EFI_OPEN_PROTOCOL_GET_PROTOCOL
80 );
81 if (!EFI_ERROR(Status)) {
82 //
83 // use shell 1.0 interface
84 //
85 ReturnFromMain = ShellAppMain (
86 EfiShellInterface->Argc,
87 EfiShellInterface->Argv
88 );
89 } else {
90 ASSERT(FALSE);
91 }
92 }
93 if (ReturnFromMain == 0) {
94 return (EFI_SUCCESS);
95 } else {
96 return (EFI_UNSUPPORTED);
97 }
98 }