]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/Library/BdsLib.h
ArmPkg: Move IS_DEVICE_PATH_NODE for sharing
[mirror_edk2.git] / ArmPkg / Include / Library / BdsLib.h
1 /** @file
2 *
3 * Copyright (c) 2013-2015, ARM Limited. All rights reserved.
4 *
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
15 #ifndef __BDS_ENTRY_H__
16 #define __BDS_ENTRY_H__
17
18 #define IS_DEVICE_PATH_NODE(node,type,subtype) \
19 (((node)->Type == (type)) && ((node)->SubType == (subtype)))
20
21 /**
22 This is defined by the UEFI specs, don't change it
23 **/
24 typedef struct {
25 UINT16 LoadOptionIndex;
26 EFI_LOAD_OPTION *LoadOption;
27 UINTN LoadOptionSize;
28
29 UINT32 Attributes;
30 UINT16 FilePathListLength;
31 CHAR16 *Description;
32 EFI_DEVICE_PATH_PROTOCOL *FilePathList;
33
34 VOID* OptionalData;
35 UINTN OptionalDataSize;
36 } BDS_LOAD_OPTION;
37
38 /**
39 Connect a Device Path and return the handle of the driver that support this DevicePath
40
41 @param DevicePath Device Path of the File to connect
42 @param Handle Handle of the driver that support this DevicePath
43 @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath
44
45 @retval EFI_SUCCESS A driver that matches the Device Path has been found
46 @retval EFI_NOT_FOUND No handles match the search.
47 @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL
48
49 **/
50 EFI_STATUS
51 BdsConnectDevicePath (
52 IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
53 OUT EFI_HANDLE *Handle,
54 OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath
55 );
56
57 /**
58 Connect all DXE drivers
59
60 @retval EFI_SUCCESS All drivers have been connected
61 @retval EFI_NOT_FOUND No handles match the search.
62 @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
63
64 **/
65 EFI_STATUS
66 BdsConnectAllDrivers (
67 VOID
68 );
69
70 /**
71 Return the value of a global variable defined by its VariableName.
72 The variable must be defined with the VendorGuid gEfiGlobalVariableGuid.
73
74 @param VariableName A Null-terminated string that is the name of the vendor's
75 variable.
76 @param DefaultValue Value returned by the function if the variable does not exist
77 @param DataSize On input, the size in bytes of the return Data buffer.
78 On output the size of data returned in Data.
79 @param Value Value read from the UEFI Variable or copy of the default value
80 if the UEFI Variable does not exist
81
82 @retval EFI_SUCCESS All drivers have been connected
83 @retval EFI_NOT_FOUND No handles match the search.
84 @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
85
86 **/
87 EFI_STATUS
88 GetGlobalEnvironmentVariable (
89 IN CONST CHAR16* VariableName,
90 IN VOID* DefaultValue,
91 IN OUT UINTN* Size,
92 OUT VOID** Value
93 );
94
95 /**
96 Return the value of the variable defined by its VariableName and VendorGuid
97
98 @param VariableName A Null-terminated string that is the name of the vendor's
99 variable.
100 @param VendorGuid A unique identifier for the vendor.
101 @param DefaultValue Value returned by the function if the variable does not exist
102 @param DataSize On input, the size in bytes of the return Data buffer.
103 On output the size of data returned in Data.
104 @param Value Value read from the UEFI Variable or copy of the default value
105 if the UEFI Variable does not exist
106
107 @retval EFI_SUCCESS All drivers have been connected
108 @retval EFI_NOT_FOUND No handles match the search.
109 @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
110
111 **/
112 EFI_STATUS
113 GetEnvironmentVariable (
114 IN CONST CHAR16* VariableName,
115 IN EFI_GUID* VendorGuid,
116 IN VOID* DefaultValue,
117 IN OUT UINTN* Size,
118 OUT VOID** Value
119 );
120
121 EFI_STATUS
122 BootOptionFromLoadOptionIndex (
123 IN UINT16 LoadOptionIndex,
124 OUT BDS_LOAD_OPTION** BdsLoadOption
125 );
126
127 EFI_STATUS
128 BootOptionFromLoadOptionVariable (
129 IN CHAR16* BootVariableName,
130 OUT BDS_LOAD_OPTION** BdsLoadOption
131 );
132
133 EFI_STATUS
134 BootOptionToLoadOptionVariable (
135 IN BDS_LOAD_OPTION* BdsLoadOption
136 );
137
138 UINT16
139 BootOptionAllocateBootIndex (
140 VOID
141 );
142
143 /**
144 Start an EFI Application from a Device Path
145
146 @param ParentImageHandle Handle of the calling image
147 @param DevicePath Location of the EFI Application
148
149 @retval EFI_SUCCESS All drivers have been connected
150 @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
151 @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
152
153 **/
154 EFI_STATUS
155 BdsStartEfiApplication (
156 IN EFI_HANDLE ParentImageHandle,
157 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
158 IN UINTN LoadOptionsSize,
159 IN VOID* LoadOptions
160 );
161
162 EFI_STATUS
163 BdsLoadImage (
164 IN EFI_DEVICE_PATH *DevicePath,
165 IN EFI_ALLOCATE_TYPE Type,
166 IN OUT EFI_PHYSICAL_ADDRESS* Image,
167 OUT UINTN *FileSize
168 );
169
170 /**
171 * Call BS.ExitBootServices with the appropriate Memory Map information
172 */
173 EFI_STATUS
174 ShutdownUefiBootServices (
175 VOID
176 );
177
178 /**
179 Locate an EFI application in a the Firmware Volumes by its name
180
181 @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
182 @param DevicePath EFI Device Path of the EFI application
183
184 @return EFI_SUCCESS The function completed successfully.
185 @return EFI_NOT_FOUND The protocol could not be located.
186 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
187
188 **/
189 EFI_STATUS
190 LocateEfiApplicationInFvByName (
191 IN CONST CHAR16* EfiAppName,
192 OUT EFI_DEVICE_PATH **DevicePath
193 );
194
195 /**
196 Locate an EFI application in a the Firmware Volumes by its GUID
197
198 @param EfiAppGuid Guid of the EFI Application into the Firmware Volume
199 @param DevicePath EFI Device Path of the EFI application
200
201 @return EFI_SUCCESS The function completed successfully.
202 @return EFI_NOT_FOUND The protocol could not be located.
203 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
204
205 **/
206 EFI_STATUS
207 LocateEfiApplicationInFvByGuid (
208 IN CONST EFI_GUID *EfiAppGuid,
209 OUT EFI_DEVICE_PATH **DevicePath
210 );
211
212 #endif