]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
MdeModulePkg: implement NULL instance of HobLib library class
[mirror_edk2.git] / MdeModulePkg / Library / BaseHobLibNull / BaseHobLibNull.c
1 /** @file
2 Provide Hob Library functions for build testing only.
3
4 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
6 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 #include <Uefi.h>
17 #include <Pi/PiMultiPhase.h>
18
19 #include <Library/DebugLib.h>
20 #include <Library/HobLib.h>
21
22 /**
23 Returns the pointer to the HOB list.
24
25 This function returns the pointer to first HOB in the list.
26 For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
27 to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through
28 the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
29 Since the System Configuration Table does not exist that the time the DXE Core is
30 launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
31 to manage the pointer to the HOB list.
32
33 If the pointer to the HOB list is NULL, then ASSERT().
34
35 @return The pointer to the HOB list.
36
37 **/
38 VOID *
39 EFIAPI
40 GetHobList (
41 VOID
42 )
43 {
44 ASSERT (FALSE);
45 return NULL;
46 }
47
48 /**
49 Returns the next instance of a HOB type from the starting HOB.
50
51 This function searches the first instance of a HOB type from the starting HOB pointer.
52 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
53 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
54 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
55 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
56
57 If HobStart is NULL, then ASSERT().
58
59 @param Type The HOB type to return.
60 @param HobStart The starting HOB pointer to search from.
61
62 @return The next instance of a HOB type from the starting HOB.
63
64 **/
65 VOID *
66 EFIAPI
67 GetNextHob (
68 IN UINT16 Type,
69 IN CONST VOID *HobStart
70 )
71 {
72 ASSERT (FALSE);
73 return NULL;
74 }
75
76 /**
77 Returns the first instance of a HOB type among the whole HOB list.
78
79 This function searches the first instance of a HOB type among the whole HOB list.
80 If there does not exist such HOB type in the HOB list, it will return NULL.
81
82 If the pointer to the HOB list is NULL, then ASSERT().
83
84 @param Type The HOB type to return.
85
86 @return The next instance of a HOB type from the starting HOB.
87
88 **/
89 VOID *
90 EFIAPI
91 GetFirstHob (
92 IN UINT16 Type
93 )
94 {
95 ASSERT (FALSE);
96 return NULL;
97 }
98
99 /**
100 Returns the next instance of the matched GUID HOB from the starting HOB.
101
102 This function searches the first instance of a HOB from the starting HOB pointer.
103 Such HOB should satisfy two conditions:
104 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
105 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
106 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
107 to extract the data section and its size information, respectively.
108 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
109 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
110 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
111
112 If Guid is NULL, then ASSERT().
113 If HobStart is NULL, then ASSERT().
114
115 @param Guid The GUID to match with in the HOB list.
116 @param HobStart A pointer to a Guid.
117
118 @return The next instance of the matched GUID HOB from the starting HOB.
119
120 **/
121 VOID *
122 EFIAPI
123 GetNextGuidHob (
124 IN CONST EFI_GUID *Guid,
125 IN CONST VOID *HobStart
126 )
127 {
128 ASSERT (FALSE);
129 return NULL;
130 }
131
132 /**
133 Returns the first instance of the matched GUID HOB among the whole HOB list.
134
135 This function searches the first instance of a HOB among the whole HOB list.
136 Such HOB should satisfy two conditions:
137 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
138 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
139 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
140 to extract the data section and its size information, respectively.
141
142 If the pointer to the HOB list is NULL, then ASSERT().
143 If Guid is NULL, then ASSERT().
144
145 @param Guid The GUID to match with in the HOB list.
146
147 @return The first instance of the matched GUID HOB among the whole HOB list.
148
149 **/
150 VOID *
151 EFIAPI
152 GetFirstGuidHob (
153 IN CONST EFI_GUID *Guid
154 )
155 {
156 ASSERT (FALSE);
157 return NULL;
158 }
159
160 /**
161 Get the system boot mode from the HOB list.
162
163 This function returns the system boot mode information from the
164 PHIT HOB in HOB list.
165
166 If the pointer to the HOB list is NULL, then ASSERT().
167
168 @param VOID.
169
170 @return The Boot Mode.
171
172 **/
173 EFI_BOOT_MODE
174 EFIAPI
175 GetBootModeHob (
176 VOID
177 )
178 {
179 ASSERT (FALSE);
180 return MAX_UINT32;
181 }
182
183 /**
184 Builds a HOB for a loaded PE32 module.
185
186 This function builds a HOB for a loaded PE32 module.
187 It can only be invoked during PEI phase;
188 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
189
190 If ModuleName is NULL, then ASSERT().
191 If there is no additional space for HOB creation, then ASSERT().
192
193 @param ModuleName The GUID File Name of the module.
194 @param MemoryAllocationModule The 64 bit physical address of the module.
195 @param ModuleLength The length of the module in bytes.
196 @param EntryPoint The 64 bit physical address of the module entry point.
197
198 **/
199 VOID
200 EFIAPI
201 BuildModuleHob (
202 IN CONST EFI_GUID *ModuleName,
203 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
204 IN UINT64 ModuleLength,
205 IN EFI_PHYSICAL_ADDRESS EntryPoint
206 )
207 {
208 ASSERT (FALSE);
209 }
210
211 /**
212 Builds a HOB that describes a chunk of system memory with Owner GUID.
213
214 This function builds a HOB that describes a chunk of system memory.
215 It can only be invoked during PEI phase;
216 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
217
218 If there is no additional space for HOB creation, then ASSERT().
219
220 @param ResourceType The type of resource described by this HOB.
221 @param ResourceAttribute The resource attributes of the memory described by this HOB.
222 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
223 @param NumberOfBytes The length of the memory described by this HOB in bytes.
224 @param OwnerGUID GUID for the owner of this resource.
225
226 **/
227 VOID
228 EFIAPI
229 BuildResourceDescriptorWithOwnerHob (
230 IN EFI_RESOURCE_TYPE ResourceType,
231 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
232 IN EFI_PHYSICAL_ADDRESS PhysicalStart,
233 IN UINT64 NumberOfBytes,
234 IN EFI_GUID *OwnerGUID
235 )
236 {
237 ASSERT (FALSE);
238 }
239
240 /**
241 Builds a HOB that describes a chunk of system memory.
242
243 This function builds a HOB that describes a chunk of system memory.
244 It can only be invoked during PEI phase;
245 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
246
247 If there is no additional space for HOB creation, then ASSERT().
248
249 @param ResourceType The type of resource described by this HOB.
250 @param ResourceAttribute The resource attributes of the memory described by this HOB.
251 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
252 @param NumberOfBytes The length of the memory described by this HOB in bytes.
253
254 **/
255 VOID
256 EFIAPI
257 BuildResourceDescriptorHob (
258 IN EFI_RESOURCE_TYPE ResourceType,
259 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
260 IN EFI_PHYSICAL_ADDRESS PhysicalStart,
261 IN UINT64 NumberOfBytes
262 )
263 {
264 ASSERT (FALSE);
265 }
266
267 /**
268 Builds a customized HOB tagged with a GUID for identification and returns
269 the start address of GUID HOB data.
270
271 This function builds a customized HOB tagged with a GUID for identification
272 and returns the start address of GUID HOB data so that caller can fill the customized data.
273 The HOB Header and Name field is already stripped.
274 It can only be invoked during PEI phase;
275 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
276
277 If Guid is NULL, then ASSERT().
278 If there is no additional space for HOB creation, then ASSERT().
279 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
280 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
281
282 @param Guid The GUID to tag the customized HOB.
283 @param DataLength The size of the data payload for the GUID HOB.
284
285 @retval NULL The GUID HOB could not be allocated.
286 @retval others The start address of GUID HOB data.
287
288 **/
289 VOID *
290 EFIAPI
291 BuildGuidHob (
292 IN CONST EFI_GUID *Guid,
293 IN UINTN DataLength
294 )
295 {
296 ASSERT (FALSE);
297 return NULL;
298 }
299
300 /**
301 Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
302 data field, and returns the start address of the GUID HOB data.
303
304 This function builds a customized HOB tagged with a GUID for identification and copies the input
305 data to the HOB data field and returns the start address of the GUID HOB data. It can only be
306 invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
307 The HOB Header and Name field is already stripped.
308 It can only be invoked during PEI phase;
309 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
310
311 If Guid is NULL, then ASSERT().
312 If Data is NULL and DataLength > 0, then ASSERT().
313 If there is no additional space for HOB creation, then ASSERT().
314 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
315 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
316
317 @param Guid The GUID to tag the customized HOB.
318 @param Data The data to be copied into the data field of the GUID HOB.
319 @param DataLength The size of the data payload for the GUID HOB.
320
321 @retval NULL The GUID HOB could not be allocated.
322 @retval others The start address of GUID HOB data.
323
324 **/
325 VOID *
326 EFIAPI
327 BuildGuidDataHob (
328 IN CONST EFI_GUID *Guid,
329 IN VOID *Data,
330 IN UINTN DataLength
331 )
332 {
333 ASSERT (FALSE);
334 return NULL;
335 }
336
337 /**
338 Builds a Firmware Volume HOB.
339
340 This function builds a Firmware Volume HOB.
341 It can only be invoked during PEI phase;
342 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
343
344 If there is no additional space for HOB creation, then ASSERT().
345 If the FvImage buffer is not at its required alignment, then ASSERT().
346
347 @param BaseAddress The base address of the Firmware Volume.
348 @param Length The size of the Firmware Volume in bytes.
349
350 **/
351 VOID
352 EFIAPI
353 BuildFvHob (
354 IN EFI_PHYSICAL_ADDRESS BaseAddress,
355 IN UINT64 Length
356 )
357 {
358 ASSERT (FALSE);
359 }
360
361 /**
362 Builds a EFI_HOB_TYPE_FV2 HOB.
363
364 This function builds a EFI_HOB_TYPE_FV2 HOB.
365 It can only be invoked during PEI phase;
366 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
367
368 If there is no additional space for HOB creation, then ASSERT().
369 If the FvImage buffer is not at its required alignment, then ASSERT().
370
371 @param BaseAddress The base address of the Firmware Volume.
372 @param Length The size of the Firmware Volume in bytes.
373 @param FvName The name of the Firmware Volume.
374 @param FileName The name of the file.
375
376 **/
377 VOID
378 EFIAPI
379 BuildFv2Hob (
380 IN EFI_PHYSICAL_ADDRESS BaseAddress,
381 IN UINT64 Length,
382 IN CONST EFI_GUID *FvName,
383 IN CONST EFI_GUID *FileName
384 )
385 {
386 ASSERT (FALSE);
387 }
388
389 /**
390 Builds a EFI_HOB_TYPE_FV3 HOB.
391
392 This function builds a EFI_HOB_TYPE_FV3 HOB.
393 It can only be invoked during PEI phase;
394 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
395
396 If there is no additional space for HOB creation, then ASSERT().
397 If the FvImage buffer is not at its required alignment, then ASSERT().
398
399 @param BaseAddress The base address of the Firmware Volume.
400 @param Length The size of the Firmware Volume in bytes.
401 @param AuthenticationStatus The authentication status.
402 @param ExtractedFv TRUE if the FV was extracted as a file within
403 another firmware volume. FALSE otherwise.
404 @param FvName The name of the Firmware Volume.
405 Valid only if IsExtractedFv is TRUE.
406 @param FileName The name of the file.
407 Valid only if IsExtractedFv is TRUE.
408
409 **/
410 VOID
411 EFIAPI
412 BuildFv3Hob (
413 IN EFI_PHYSICAL_ADDRESS BaseAddress,
414 IN UINT64 Length,
415 IN UINT32 AuthenticationStatus,
416 IN BOOLEAN ExtractedFv,
417 IN CONST EFI_GUID *FvName, OPTIONAL
418 IN CONST EFI_GUID *FileName OPTIONAL
419 )
420 {
421 ASSERT (FALSE);
422 }
423
424 /**
425 Builds a Capsule Volume HOB.
426
427 This function builds a Capsule Volume HOB.
428 It can only be invoked during PEI phase;
429 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
430
431 If the platform does not support Capsule Volume HOBs, then ASSERT().
432 If there is no additional space for HOB creation, then ASSERT().
433
434 @param BaseAddress The base address of the Capsule Volume.
435 @param Length The size of the Capsule Volume in bytes.
436
437 **/
438 VOID
439 EFIAPI
440 BuildCvHob (
441 IN EFI_PHYSICAL_ADDRESS BaseAddress,
442 IN UINT64 Length
443 )
444 {
445 ASSERT (FALSE);
446 }
447
448 /**
449 Builds a HOB for the CPU.
450
451 This function builds a HOB for the CPU.
452 It can only be invoked during PEI phase;
453 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
454
455 If there is no additional space for HOB creation, then ASSERT().
456
457 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
458 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
459
460 **/
461 VOID
462 EFIAPI
463 BuildCpuHob (
464 IN UINT8 SizeOfMemorySpace,
465 IN UINT8 SizeOfIoSpace
466 )
467 {
468 ASSERT (FALSE);
469 }
470
471 /**
472 Builds a HOB for the Stack.
473
474 This function builds a HOB for the stack.
475 It can only be invoked during PEI phase;
476 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
477
478 If there is no additional space for HOB creation, then ASSERT().
479
480 @param BaseAddress The 64 bit physical address of the Stack.
481 @param Length The length of the stack in bytes.
482
483 **/
484 VOID
485 EFIAPI
486 BuildStackHob (
487 IN EFI_PHYSICAL_ADDRESS BaseAddress,
488 IN UINT64 Length
489 )
490 {
491 ASSERT (FALSE);
492 }
493
494 /**
495 Builds a HOB for the BSP store.
496
497 This function builds a HOB for BSP store.
498 It can only be invoked during PEI phase;
499 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
500
501 If there is no additional space for HOB creation, then ASSERT().
502
503 @param BaseAddress The 64 bit physical address of the BSP.
504 @param Length The length of the BSP store in bytes.
505 @param MemoryType The type of memory allocated by this HOB.
506
507 **/
508 VOID
509 EFIAPI
510 BuildBspStoreHob (
511 IN EFI_PHYSICAL_ADDRESS BaseAddress,
512 IN UINT64 Length,
513 IN EFI_MEMORY_TYPE MemoryType
514 )
515 {
516 ASSERT (FALSE);
517 }
518
519 /**
520 Builds a HOB for the memory allocation.
521
522 This function builds a HOB for the memory allocation.
523 It can only be invoked during PEI phase;
524 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
525
526 If there is no additional space for HOB creation, then ASSERT().
527
528 @param BaseAddress The 64 bit physical address of the memory.
529 @param Length The length of the memory allocation in bytes.
530 @param MemoryType The type of memory allocated by this HOB.
531
532 **/
533 VOID
534 EFIAPI
535 BuildMemoryAllocationHob (
536 IN EFI_PHYSICAL_ADDRESS BaseAddress,
537 IN UINT64 Length,
538 IN EFI_MEMORY_TYPE MemoryType
539 )
540 {
541 ASSERT (FALSE);
542 }