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