]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/DxeFileExplorerProtocol/DxeFileExplorerProtocol.c
MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
[mirror_edk2.git] / MdeModulePkg / Library / DxeFileExplorerProtocol / DxeFileExplorerProtocol.c
1 /** @file
2 Instance of file explorer Library based on gEfiFileExplorerProtocolGuid.
3
4 Implement the file explorer library instance by wrap the interface
5 provided in the file explorer protocol. This protocol is defined as the internal
6 protocol related to this implementation, not in the public spec. So, this
7 library instance is only for this code base.
8
9 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17
18 **/
19
20 #include <Uefi.h>
21 #include <Base.h>
22 #include <Protocol/FileExplorer.h>
23
24 #include <Library/FileExplorerLib.h>
25
26 #include <Library/BaseLib.h>
27 #include <Library/DebugLib.h>
28
29 EFI_FILE_EXPLORER_PROTOCOL *mProtocol = NULL;
30
31 /**
32 The constructor function caches the pointer to file explorer protocol.
33
34 The constructor function locates Print2 protocol from protocol database.
35 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
36
37 @param ImageHandle The firmware allocated handle for the EFI image.
38 @param SystemTable A pointer to the EFI System Table.
39
40 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
41
42 **/
43 EFI_STATUS
44 EFIAPI
45 FileExplorerConstructor (
46 IN EFI_HANDLE ImageHandle,
47 IN EFI_SYSTEM_TABLE *SystemTable
48 )
49 {
50 EFI_STATUS Status;
51
52 Status = SystemTable->BootServices->LocateProtocol (
53 &gEfiFileExplorerProtocolGuid,
54 NULL,
55 (VOID**) &mProtocol
56 );
57 ASSERT_EFI_ERROR (Status);
58 ASSERT (mProtocol != NULL);
59
60 return Status;
61 }
62
63 /**
64 Choose a file in the specified directory.
65
66 If user input NULL for the RootDirectory, will choose file in the system.
67
68 If user input *File != NULL, function will return the allocate device path
69 info for the choosed file, caller has to free the memory after use it.
70
71 @param RootDirectory Pointer to the root directory.
72 @param FileType The file type need to choose.
73 @param ChooseHandler Function pointer to the extra task need to do
74 after choose one file.
75 @param File Return the device path for the last time chosed file.
76
77 @retval EFI_SUCESS Choose file success.
78 @retval EFI_INVALID_PARAMETER Both ChooseHandler and return device path are NULL
79 One of them must not NULL.
80 @retval Other errors Choose file failed.
81 **/
82 EFI_STATUS
83 EFIAPI
84 ChooseFile (
85 IN EFI_DEVICE_PATH_PROTOCOL *RootDirectory,
86 IN CHAR16 *FileType, OPTIONAL
87 IN CHOOSE_HANDLER ChooseHandler, OPTIONAL
88 OUT EFI_DEVICE_PATH_PROTOCOL **File OPTIONAL
89 )
90 {
91 return mProtocol->ChooseFile (RootDirectory, FileType, ChooseHandler, File);
92 }
93