]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/DxeServicesLib.h
aea99dec3af30aa1f16ae4e8dbf653c030d18bf7
[mirror_edk2.git] / MdePkg / Include / Library / DxeServicesLib.h
1 /** @file
2 MDE DXE Services Library provides functions that simplify the development of DXE Drivers.
3 These functions help access data from sections of FFS files.
4
5 Copyright (c) 2008, Intel Corporation<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __DXE_SERVICES_LIB_H__
17 #define __DXE_SERVICES_LIB_H__
18
19 /**
20 Searches all the availables firmware volumes and returns the first matching FFS section.
21
22 This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid.
23 The order that the firmware volumes is searched is not deterministic. For each FFS file found a search
24 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance instances
25 of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
26 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
27 It is the caller's responsibility to use FreePool() to free the allocated buffer.
28 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections
29 are retrieved from an FFS file based on SectionType and SectionInstance.
30
31 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
32 the search will be retried with a section type of EFI_SECTION_PE32.
33 This function must be called with a TPL <= TPL_NOTIFY.
34
35 If NameGuid is NULL, then ASSERT().
36 If Buffer is NULL, then ASSERT().
37 If Size is NULL, then ASSERT().
38
39
40 @param NameGuid A pointer to to the FFS filename GUID to search for within
41 any of the firmware volumes in the platform.
42 @param SectionType Indicates the FFS section type to search for within the FFS file specified by NameGuid.
43 @param SectionInstance Indicates which section instance within the FFS file specified by NameGuid to retrieve.
44 @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.
45 Is it the caller's responsibility to free this buffer using FreePool().
46 @param Size On output, a pointer to the size, in bytes, of Buffer.
47
48 @retval EFI_SUCCESS The specified FFS section was returned.
49 @retval EFI_NOT_FOUND The specified FFS section could not be found.
50 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
51 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.
52 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that
53 contains the matching FFS section does not allow reads.
54 **/
55 EFI_STATUS
56 EFIAPI
57 GetSectionFromAnyFv (
58 IN CONST EFI_GUID *NameGuid,
59 IN EFI_SECTION_TYPE SectionType,
60 IN UINTN SectionInstance,
61 OUT VOID **Buffer,
62 OUT UINTN *Size
63 );
64
65 /**
66 Searches the firmware volume that the currently executing module was loaded from and returns the first matching FFS section.
67
68 This function searches the firmware volume that the currently executing module was loaded
69 from for an FFS file with an FFS filename specified by NameGuid. If the FFS file is found a search
70 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance
71 instances of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
72 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
73 It is the caller's responsibility to use FreePool() to free the allocated buffer.
74 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections are retrieved from
75 an FFS file based on SectionType and SectionInstance.
76
77 If the currently executing module was not loaded from a firmware volume, then EFI_NOT_FOUND is returned.
78 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
79 the search will be retried with a section type of EFI_SECTION_PE32.
80
81 This function must be called with a TPL <= TPL_NOTIFY.
82 If NameGuid is NULL, then ASSERT().
83 If Buffer is NULL, then ASSERT().
84 If Size is NULL, then ASSERT().
85
86 @param NameGuid A pointer to to the FFS filename GUID to search for within
87 the firmware volumes that the currently executing module was loaded from.
88 @param SectionType Indicates the FFS section type to search for within the FFS file specified by NameGuid.
89 @param SectionInstance Indicates which section instance within the FFS file specified by NameGuid to retrieve.
90 @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.
91 Is it the caller's responsibility to free this buffer using FreePool().
92 @param Size On output, a pointer to the size, in bytes, of Buffer.
93
94
95 @retval EFI_SUCCESS The specified FFS section was returned.
96 @retval EFI_NOT_FOUND The specified FFS section could not be found.
97 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
98 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.
99 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that
100 contains the matching FFS section does not allow reads.
101 **/
102 EFI_STATUS
103 EFIAPI
104 GetSectionFromFv (
105 IN CONST EFI_GUID *NameGuid,
106 IN EFI_SECTION_TYPE SectionType,
107 IN UINTN SectionInstance,
108 OUT VOID **Buffer,
109 OUT UINTN *Size
110 );
111
112
113 /**
114 Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.
115
116 This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.
117 If the FFS file contains at least SectionInstance instances of the FFS section specified by SectionType,
118 then the SectionInstance instance is returned in Buffer. Buffer is allocated using AllocatePool(),
119 and the size of the allocated buffer is returned in Size. It is the caller's responsibility
120 to use FreePool() to free the allocated buffer. See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for
121 details on how sections are retrieved from an FFS file based on SectionType and SectionInstance.
122
123 If the currently executing module was not loaded from an FFS file, then EFI_NOT_FOUND is returned.
124 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
125 the search will be retried with a section type of EFI_SECTION_PE32.
126 This function must be called with a TPL <= TPL_NOTIFY.
127
128 If Buffer is NULL, then ASSERT().
129 If Size is NULL, then ASSERT().
130
131
132 @param SectionType Indicates the FFS section type to search for within the FFS file
133 that the currently executing module was loaded from.
134 @param SectionInstance Indicates which section instance to retrieve within the FFS file
135 that the currently executing module was loaded from.
136 @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.
137 Is it the caller's responsibility to free this buffer using FreePool().
138 @param Size On output, a pointer to the size, in bytes, of Buffer.
139
140 @retval EFI_SUCCESS The specified FFS section was returned.
141 @retval EFI_NOT_FOUND The specified FFS section could not be found.
142 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
143 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.
144 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that
145 contains the matching FFS section does not allow reads.
146
147 **/
148 EFI_STATUS
149 EFIAPI
150 GetSectionFromFfs (
151 IN EFI_SECTION_TYPE SectionType,
152 IN UINTN SectionInstance,
153 OUT VOID **Buffer,
154 OUT UINTN *Size
155 );
156
157 #endif
158