]>
Commit | Line | Data |
---|---|---|
1c280088 | 1 | /** @file\r |
2 | MDE PI library functions and macros\r | |
3 | \r | |
4 | Copyright (c) 2007, Intel Corporation \r | |
5 | All rights reserved. This program and the accompanying materials \r | |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef __PI_LIB_H__\r | |
16 | #define __PI_LIB_H__\r | |
17 | \r | |
18 | #include <Pi/PiFirmwareFile.h>\r | |
19 | \r | |
b0d803fe | 20 | \r |
21 | /**\r | |
22 | Allocate and fill a buffer from the Firmware Section identified by a Firmware File GUID name and a Firmware \r | |
166152e8 | 23 | Section type and instance number from any Firmware Volumes in the system.\r |
b0d803fe | 24 | \r |
166152e8 | 25 | The function will read the first Firmware Section sepcifed by NameGuid, SectionType and Instance by searching\r |
26 | for all Firmware Volumes in the system. \r | |
b0d803fe | 27 | \r |
28 | The search order for Firmware Volumes in the system is determistic but abitrary if no new Firmware Volume is installed\r | |
29 | into the system. The search order for the section specified by SectionType within a Firmware File is defined by\r | |
30 | EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization \r | |
31 | Shared Architectural Elements for detailes.\r | |
32 | \r | |
33 | If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r | |
34 | data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r | |
35 | read Firmware Section data from the Firmware File. If no such section specified is found to match , \r | |
36 | EFI_NOT_FOUND is returned.\r | |
37 | \r | |
38 | The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r | |
39 | by this function. This function can only be called at TPL_NOTIFY and below.\r | |
40 | \r | |
41 | If NameGuid is NULL, then ASSERT();\r | |
42 | If Buffer is NULL, then ASSERT();\r | |
43 | If Size is NULL, then ASSERT().\r | |
44 | \r | |
45 | @param NameGuid The GUID name of a Firmware File.\r | |
46 | @param SectionType The Firmware Section type.\r | |
47 | @param Instance The instance number of Firmware Section to read from starting from 0.\r | |
48 | @param Buffer On output, Buffer contains the the data read from the section in the Firmware File found.\r | |
49 | @param Size On output, the size of Buffer.\r | |
50 | \r | |
51 | @retval EFI_SUCCESS The image is found and data and size is returned.\r | |
52 | @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.\r | |
53 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r | |
54 | @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r | |
55 | @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.\r | |
56 | \r | |
57 | **/\r | |
58 | \r | |
59 | EFI_STATUS\r | |
60 | EFIAPI\r | |
166152e8 | 61 | PiLibGetSectionFromAnyFv (\r |
b0d803fe | 62 | IN CONST EFI_GUID *NameGuid,\r |
63 | IN EFI_SECTION_TYPE SectionType,\r | |
64 | IN UINTN Instance,\r | |
65 | OUT VOID **Buffer,\r | |
66 | OUT UINTN *Size\r | |
67 | )\r | |
68 | ;\r | |
69 | \r | |
70 | /**\r | |
71 | Allocate and fill a buffer from a Firmware Section identified by a Firmware File GUID name, a Firmware \r | |
72 | Section type and instance number from the same Firmware Volume with the caller's FFS.\r | |
73 | \r | |
74 | This functions first locates the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance for same Firmrware Volume\r | |
75 | which also contains the FFS of the caller in order to carry out the Firmware Volume read operation. \r | |
76 | The function then reads the Firmware Section found sepcifed by NameGuid, SectionType and Instance. \r | |
77 | \r | |
78 | The search order for the section specified by SectionType within a Firmware File is defined by\r | |
79 | EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization \r | |
80 | Shared Architectural Elements for detailes.\r | |
81 | \r | |
82 | If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r | |
83 | data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r | |
84 | read Firmware Section data from the Firmware File. If no such section specified is found to match , \r | |
85 | EFI_NOT_FOUND is returned.\r | |
86 | \r | |
87 | The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r | |
88 | by this function. This function can be only called at TPL_NOTIFY and below.\r | |
89 | \r | |
90 | If FvHandle is NULL, then ASSERT ();\r | |
91 | If NameGuid is NULL, then ASSERT();\r | |
92 | If Buffer is NULL, then ASSERT();\r | |
93 | If Size is NULL, then ASSERT().\r | |
94 | \r | |
95 | @param NameGuid The GUID name of a Firmware File.\r | |
96 | @param SectionType The Firmware Section type.\r | |
97 | @param Instance The instance number of Firmware Section to read from starting from 0.\r | |
98 | @param Buffer On output, Buffer contains the the data read from the section in the Firmware File found.\r | |
99 | @param Size On output, the size of Buffer.\r | |
100 | \r | |
101 | @retval EFI_SUCCESS The image is found and data and size is returned.\r | |
102 | @retval EFI_UNSUPPORTED FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.\r | |
103 | @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.\r | |
104 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r | |
105 | @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r | |
106 | @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.\r | |
107 | \r | |
108 | **/\r | |
109 | \r | |
110 | EFI_STATUS\r | |
111 | EFIAPI\r | |
166152e8 | 112 | PiLibGetSectionFromCurrentFv (\r |
b0d803fe | 113 | IN CONST EFI_GUID *NameGuid,\r |
114 | IN EFI_SECTION_TYPE SectionType,\r | |
115 | IN UINTN Instance,\r | |
116 | OUT VOID **Buffer,\r | |
117 | OUT UINTN *Size\r | |
118 | )\r | |
119 | ;\r | |
120 | \r | |
121 | \r | |
122 | /**\r | |
123 | Allocate and fill a buffer from the first Firmware Section in the same Firmware File as the caller of this function.\r | |
124 | \r | |
125 | The function will read the first Firmware Section found sepcifed by NameGuid and SectionType from the \r | |
126 | Firmware Volume specified by FvHandle. On this FvHandle, an EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance \r | |
127 | should be located succesfully in order to carry out the Firmware Volume operations.\r | |
128 | \r | |
129 | The search order for the section type specified by SectionType in the Firmware File is using a depth-first \r | |
130 | and left-to-right algorithm through all sections. The first section found to match SectionType will be returned. \r | |
131 | \r | |
132 | If SectionType is EFI_SECTION_PE32, EFI_SECTION_PE32 will be used as Firmware Section type \r | |
133 | to read Firmware Section data from the Firmware File. If no such section exists, the function will try \r | |
134 | to read a Firmware File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.\r | |
135 | \r | |
136 | If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r | |
137 | data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r | |
138 | read Firmware Section data from the Firmware File. If no such section exists, the function will try to read a Firmware \r | |
139 | File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.\r | |
140 | \r | |
141 | The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r | |
142 | by this function. This function can only be called at TPL_NOTIFY and below.\r | |
143 | \r | |
144 | If FvHandle is NULL and WithinImage is TRUE, then ASSERT ();\r | |
145 | If NameGuid is NULL, then ASSERT();\r | |
146 | If Buffer is NULL, then ASSERT();\r | |
147 | If Size is NULL, then ASSERT().\r | |
148 | \r | |
149 | @param NameGuid The GUID name of a Firmware File.\r | |
150 | @param SectionType The Firmware Section type.\r | |
151 | @param Buffer On output, Buffer contains the the data read from the section in the Firmware File found.\r | |
152 | @param Size On output, the size of Buffer.\r | |
153 | \r | |
154 | @retval EFI_SUCCESS The image is found and data and size is returned.\r | |
155 | @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.\r | |
156 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r | |
157 | @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r | |
158 | @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.\r | |
159 | \r | |
160 | **/\r | |
161 | \r | |
162 | EFI_STATUS\r | |
163 | EFIAPI\r | |
166152e8 | 164 | PiLibGetSectionFromCurrentFfs (\r |
b0d803fe | 165 | IN EFI_SECTION_TYPE SectionType,\r |
166 | IN UINTN Instance,\r | |
167 | OUT VOID **Buffer,\r | |
168 | OUT UINTN *Size\r | |
169 | )\r | |
170 | ;\r | |
1c280088 | 171 | \r |
172 | #endif\r | |
173 | \r |