Second set of changes based on a review of the code comments in the Include directory...
[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 __PI_LIB_H__
17 #define __PI_LIB_H__
18
19 #include <Pi/PiFirmwareFile.h>
20
21
22 /**
23 Searches all the available firmware volumes and returns the first matching FFS section.
24
25 This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid.
26 The order in which the firmware volumes are searched is not deterministic. For each FFS file found, a search
27 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance instances
28 of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
29 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
30 It is the caller's responsibility to use FreePool() to free the allocated buffer.
31 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections
32 are retrieved from an FFS file based on SectionType and SectionInstance.
33
34 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
35 the search will be retried with a section type of EFI_SECTION_PE32.
36 This function must be called with a TPL <= TPL_NOTIFY.
37
38 If NameGuid is NULL, then ASSERT().
39 If Buffer is NULL, then ASSERT().
40 If Size is NULL, then ASSERT().
41
42
43 @param NameGuid A pointer to to the FFS filename GUID to search for within
44 any of the firmware volumes in the platform.
45 @param SectionType Indicates the FFS section type to search for within the FFS file specified by NameGuid.
46 @param SectionInstance Indicates which section instance within the FFS file specified by NameGuid to retrieve.
47 @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.
48 It is the caller's responsibility to free this buffer using FreePool().
49 @param Size On output, a pointer to the size, in bytes, of Buffer.
50
51 @retval EFI_SUCCESS The specified FFS section was returned.
52 @retval EFI_NOT_FOUND The specified FFS section could not be found.
53 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
54 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.
55 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that
56 contains the matching FFS section does not allow reads.
57 **/
58 EFI_STATUS
59 EFIAPI
60 GetSectionFromAnyFv (
61 IN CONST EFI_GUID *NameGuid,
62 IN EFI_SECTION_TYPE SectionType,
63 IN UINTN SectionInstance,
64 OUT VOID **Buffer,
65 OUT UINTN *Size
66 );
67
68 /**
69 Searches the firmware volume that the currently executing module was loaded from and returns the first matching FFS section.
70
71 This function searches the firmware volume that the currently executing module was loaded
72 from for an FFS file with an FFS filename specified by NameGuid. If the FFS file is found, a search
73 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance
74 instances of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
75 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
76 It is the caller's responsibility to use FreePool() to free the allocated buffer.
77 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections are retrieved from
78 an FFS file based on SectionType and SectionInstance.
79
80 If the currently executing module was not loaded from a firmware volume, then EFI_NOT_FOUND is returned.
81 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
82 the search will be retried with a section type of EFI_SECTION_PE32.
83
84 This function must be called with a TPL <= TPL_NOTIFY.
85 If NameGuid is NULL, then ASSERT().
86 If Buffer is NULL, then ASSERT().
87 If Size is NULL, then ASSERT().
88
89 @param NameGuid A pointer to to the FFS filename GUID to search for within
90 the firmware volumes that the currently executing module was loaded from.
91 @param SectionType Indicates the FFS section type to search for within the FFS file specified by NameGuid.
92 @param SectionInstance Indicates which section instance within the FFS file specified by NameGuid to retrieve.
93 @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.
94 It is the caller's responsibility to free this buffer using FreePool().
95 @param Size On output, a pointer to the size, in bytes, of Buffer.
96
97
98 @retval EFI_SUCCESS The specified FFS section was returned.
99 @retval EFI_NOT_FOUND The specified FFS section could not be found.
100 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
101 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.
102 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that
103 contains the matching FFS section does not allow reads.
104 **/
105 EFI_STATUS
106 EFIAPI
107 GetSectionFromFv (
108 IN CONST EFI_GUID *NameGuid,
109 IN EFI_SECTION_TYPE SectionType,
110 IN UINTN SectionInstance,
111 OUT VOID **Buffer,
112 OUT UINTN *Size
113 );
114
115
116 /**
117 Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.
118
119 This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.
120 If the FFS file contains at least SectionInstance instances of the FFS section specified by SectionType,
121 then the SectionInstance instance is returned in Buffer. Buffer is allocated using AllocatePool(),
122 and the size of the allocated buffer is returned in Size. It is the caller's responsibility
123 to use FreePool() to free the allocated buffer. See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for
124 details on how sections are retrieved from an FFS file based on SectionType and SectionInstance.
125
126 If the currently executing module was not loaded from an FFS file, then EFI_NOT_FOUND is returned.
127 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
128 the search will be retried with a section type of EFI_SECTION_PE32.
129 This function must be called with a TPL <= TPL_NOTIFY.
130
131 If Buffer is NULL, then ASSERT().
132 If Size is NULL, then ASSERT().
133
134
135 @param SectionType Indicates the FFS section type to search for within the FFS file
136 that the currently executing module was loaded from.
137 @param SectionInstance Indicates which section instance to retrieve within the FFS file
138 that the currently executing module was loaded from.
139 @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.
140 It is the caller's responsibility to free this buffer using FreePool().
141 @param Size On output, a pointer to the size, in bytes, of Buffer.
142
143 @retval EFI_SUCCESS The specified FFS section was returned.
144 @retval EFI_NOT_FOUND The specified FFS section could not be found.
145 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
146 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.
147 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that
148 contains the matching FFS section does not allow reads.
149
150 **/
151 EFI_STATUS
152 EFIAPI
153 GetSectionFromFfs (
154 IN EFI_SECTION_TYPE SectionType,
155 IN UINTN SectionInstance,
156 OUT VOID **Buffer,
157 OUT UINTN *Size
158 );
159
160 #endif
161