]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Conf/Migration/R8Lib.c
remove unnecessary check for NULL pointer.
[mirror_edk2.git] / Tools / Conf / Migration / R8Lib.c
1 /** @file
2 Obsolete library interfaces.
3
4 This file contains part of obsolete library interfaces in EDK.
5 User is recommended to follow the porting Guide in R8Lib.c to elimante them.
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 ////
19 BOOLEAN
20 R8_EfiLibCompareLanguage (
21 IN CHAR8 *Language1,
22 IN CHAR8 *Language2
23 )
24 /*++
25
26 Routine Description:
27
28 Compare whether two names of languages are identical.
29
30 Arguments:
31
32 Language1 - Name of language 1
33 Language2 - Name of language 2
34
35 Returns:
36
37 TRUE - same
38 FALSE - not same
39
40 --*/
41 {
42 //
43 // Porting Guide:
44 // This library interface is simply obsolete.
45 // Include the source code to user code.
46 //
47 UINTN Index;
48
49 for (Index = 0; Index < 3; Index++) {
50 if (Language1[Index] != Language2[Index]) {
51 return FALSE;
52 }
53 }
54
55 return TRUE;
56 }
57 ////~
58
59 ////#BaseLib
60 EFI_STATUS
61 R8_BufToHexString (
62 IN OUT CHAR16 *Str,
63 IN OUT UINTN *HexStringBufferLength,
64 IN UINT8 *Buf,
65 IN UINTN Len
66 )
67 /*++
68
69 Routine Description:
70 Converts binary buffer to Unicode string.
71 At a minimum, any blob of data could be represented as a hex string.
72
73 Arguments:
74 Str - Pointer to the string.
75 HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
76 If routine return with EFI_SUCCESS, containing length of hex string buffer.
77 If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
78 Buf - Buffer to be converted from.
79 Len - Length in bytes of the buffer to be converted.
80
81 Returns:
82 EFI_SUCCESS - Routine success.
83 EFI_BUFFER_TOO_SMALL - The hex string buffer is too small.
84
85 --*/
86 {
87 //
88 // Porting Guide:
89 // This library interface is simply obsolete.
90 // Include the source code to user code.
91 //
92 UINTN Idx;
93 UINT8 Byte;
94 UINTN StrLen;
95
96 //
97 // Make sure string is either passed or allocate enough.
98 // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
99 // Plus the Unicode termination character.
100 //
101 StrLen = Len * 2;
102 if (StrLen > ((*HexStringBufferLength) - 1)) {
103 *HexStringBufferLength = StrLen + 1;
104 return EFI_BUFFER_TOO_SMALL;
105 }
106
107 *HexStringBufferLength = StrLen + 1;
108 //
109 // Ends the string.
110 //
111 Str[StrLen] = L'\0';
112
113 for (Idx = 0; Idx < Len; Idx++) {
114
115 Byte = Buf[Idx];
116 Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
117 Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
118 }
119
120 return EFI_SUCCESS;
121 }
122 ////~
123
124 ////
125 VOID
126 R8_EfiStrTrim (
127 IN OUT CHAR16 *str,
128 IN CHAR16 CharC
129 )
130 /*++
131
132 Routine Description:
133
134 Removes (trims) specified leading and trailing characters from a string.
135
136 Arguments:
137
138 str - Pointer to the null-terminated string to be trimmed. On return,
139 str will hold the trimmed string.
140 CharC - Character will be trimmed from str.
141
142 --*/
143 {
144 //
145 // Porting Guide:
146 // This library interface is simply obsolete.
147 // Include the source code to user code.
148 //
149 CHAR16 *p1;
150 CHAR16 *p2;
151
152 if (*str == 0) {
153 return;
154 }
155
156 //
157 // Trim off the leading and trailing characters c
158 //
159 for (p1 = str; *p1 && *p1 == CharC; p1++) {
160 ;
161 }
162
163 p2 = str;
164 if (p2 == p1) {
165 while (*p1) {
166 p2++;
167 p1++;
168 }
169 } else {
170 while (*p1) {
171 *p2 = *p1;
172 p1++;
173 p2++;
174 }
175 *p2 = 0;
176 }
177
178
179 for (p1 = str + StrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) {
180 ;
181 }
182 if (p1 != str + StrLen(str) - 1) {
183 *(p1 + 1) = 0;
184 }
185 }
186 ////~
187
188 ////#PrintLib
189 UINTN
190 R8_EfiValueToHexStr (
191 IN OUT CHAR16 *Buffer,
192 IN UINT64 Value,
193 IN UINTN Flags,
194 IN UINTN Width
195 )
196 /*++
197
198 Routine Description:
199
200 VSPrint worker function that prints a Value as a hex number in Buffer
201
202 Arguments:
203
204 Buffer - Location to place ascii hex string of Value.
205 Value - Hex value to convert to a string in Buffer.
206 Flags - Flags to use in printing Hex string, see file header for details.
207 Width - Width of hex value.
208
209 Returns:
210
211 Number of characters printed.
212
213 --*/
214 {
215 //
216 // Porting Guide:
217 // Edk II BasePrintLib function UnicodeValueToString does not support
218 // to convert Value to Hex String.
219 // Include the source code to user code or use the full PrintLib funtion
220 // UnicodeVSPrintAsciiFormat (Buffer, MAXIMUM_VALUE_CHARACTERS, "%x", Value) instead.
221 //
222
223 CHAR16 TempBuffer[MAXIMUM_VALUE_CHARACTERS];
224 CHAR16 *TempStr;
225 CHAR16 Prefix;
226 CHAR16 *BufferPtr;
227 UINTN Count;
228 UINTN Index;
229
230 TempStr = TempBuffer;
231 BufferPtr = Buffer;
232
233 //
234 // Count starts at one since we will null terminate. Each iteration of the
235 // loop picks off one nibble. Oh yea TempStr ends up backwards
236 //
237 Count = 0;
238
239 if (Width > MAXIMUM_VALUE_CHARACTERS - 1) {
240 Width = MAXIMUM_VALUE_CHARACTERS - 1;
241 }
242
243 do {
244 //
245 // If Width == 0, it means no limit.
246 //
247 if ((Width != 0) && (Count >= Width)) {
248 break;
249 }
250
251 Index = ((UINTN)Value & 0xf);
252 *(TempStr++) = mHexStr[Index];
253 Value = RShiftU64 (Value, 4);
254 Count++;
255 } while (Value != 0);
256
257 if (Flags & PREFIX_ZERO) {
258 Prefix = '0';
259 } else {
260 Prefix = ' ';
261 }
262
263 Index = Count;
264 if (!(Flags & LEFT_JUSTIFY)) {
265 for (; Index < Width; Index++) {
266 *(TempStr++) = Prefix;
267 }
268 }
269
270 //
271 // Reverse temp string into Buffer.
272 //
273 while (TempStr != TempBuffer) {
274 *(BufferPtr++) = *(--TempStr);
275 }
276
277 *BufferPtr = 0;
278 return Index;
279 }
280 ////~
281
282
283
284 ////
285 EFI_STATUS
286 R8_HexStringToBuf (
287 IN OUT UINT8 *Buf,
288 IN OUT UINTN *Len,
289 IN CHAR16 *Str,
290 OUT UINTN *ConvertedStrLen OPTIONAL
291 )
292 /*++
293
294 Routine Description:
295 Converts Unicode string to binary buffer.
296 The conversion may be partial.
297 The first character in the string that is not hex digit stops the conversion.
298 At a minimum, any blob of data could be represented as a hex string.
299
300 Arguments:
301 Buf - Pointer to buffer that receives the data.
302 Len - Length in bytes of the buffer to hold converted data.
303 If routine return with EFI_SUCCESS, containing length of converted data.
304 If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
305 Str - String to be converted from.
306 ConvertedStrLen - Length of the Hex String consumed.
307
308 Returns:
309 EFI_SUCCESS - Routine Success.
310 EFI_BUFFER_TOO_SMALL - The buffer is too small to hold converted data.
311
312 --*/
313 {
314 //
315 // Porting Guide:
316 // This library interface is simply obsolete.
317 // Include the source code to user code.
318 //
319
320 UINTN HexCnt;
321 UINTN Idx;
322 UINTN BufferLength;
323 UINT8 Digit;
324 UINT8 Byte;
325
326 //
327 // Find out how many hex characters the string has.
328 //
329 for (Idx = 0, HexCnt = 0; R8_IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
330
331 if (HexCnt == 0) {
332 *Len = 0;
333 return EFI_SUCCESS;
334 }
335 //
336 // Two Unicode characters make up 1 buffer byte. Round up.
337 //
338 BufferLength = (HexCnt + 1) / 2;
339
340 //
341 // Test if buffer is passed enough.
342 //
343 if (BufferLength > (*Len)) {
344 *Len = BufferLength;
345 return EFI_BUFFER_TOO_SMALL;
346 }
347
348 *Len = BufferLength;
349
350 for (Idx = 0; Idx < HexCnt; Idx++) {
351
352 R8_IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
353
354 //
355 // For odd charaters, write the lower nibble for each buffer byte,
356 // and for even characters, the upper nibble.
357 //
358 if ((Idx & 1) == 0) {
359 Byte = Digit;
360 } else {
361 Byte = Buf[Idx / 2];
362 Byte &= 0x0F;
363 Byte = (UINT8) (Byte | Digit << 4);
364 }
365
366 Buf[Idx / 2] = Byte;
367 }
368
369 if (ConvertedStrLen != NULL) {
370 *ConvertedStrLen = HexCnt;
371 }
372
373 return EFI_SUCCESS;
374 }
375 ////~
376
377 ////
378 BOOLEAN
379 R8_IsHexDigit (
380 OUT UINT8 *Digit,
381 IN CHAR16 Char
382 )
383 /*++
384
385 Routine Description:
386 Determines if a Unicode character is a hexadecimal digit.
387 The test is case insensitive.
388
389 Arguments:
390 Digit - Pointer to byte that receives the value of the hex character.
391 Char - Unicode character to test.
392
393 Returns:
394 TRUE - If the character is a hexadecimal digit.
395 FALSE - Otherwise.
396
397 --*/
398 {
399 //
400 // Porting Guide:
401 // This library interface is simply obsolete.
402 // Include the source code to user code.
403 //
404
405 if ((Char >= L'0') && (Char <= L'9')) {
406 *Digit = (UINT8) (Char - L'0');
407 return TRUE;
408 }
409
410 if ((Char >= L'A') && (Char <= L'F')) {
411 *Digit = (UINT8) (Char - L'A' + 0x0A);
412 return TRUE;
413 }
414
415 if ((Char >= L'a') && (Char <= L'f')) {
416 *Digit = (UINT8) (Char - L'a' + 0x0A);
417 return TRUE;
418 }
419
420 return FALSE;
421 }
422 ////~
423
424 ////
425 CHAR16
426 R8_NibbleToHexChar (
427 IN UINT8 Nibble
428 )
429 /*++
430
431 Routine Description:
432 Converts the low nibble of a byte to hex unicode character.
433
434 Arguments:
435 Nibble - lower nibble of a byte.
436
437 Returns:
438 Hex unicode character.
439
440 --*/
441 {
442 //
443 // Porting Guide:
444 // This library interface is simply obsolete.
445 // Include the source code to user code.
446 //
447
448 Nibble &= 0x0F;
449 if (Nibble <= 0x9) {
450 return (CHAR16)(Nibble + L'0');
451 }
452
453 return (CHAR16)(Nibble - 0xA + L'A');
454 }
455 ////~
456
457 ////#HobLib
458 VOID *
459 R8_GetHob (
460 IN UINT16 Type,
461 IN VOID *HobStart
462 )
463 /*++
464
465 Routine Description:
466
467 This function returns the first instance of a HOB type in a HOB list.
468
469 Arguments:
470
471 Type - The HOB type to return.
472 HobStart - The first HOB in the HOB list.
473
474 Returns:
475
476 HobStart - There were no HOBs found with the requested type.
477 Other - The first HOB with the matching type.
478
479 --*/
480 {
481 //
482 // Porting Guide:
483 // Edk II HobLib GetNextHob () is an equivelent function with the following exceptions:
484 // 1. GetNextHob () does not allow NULL value as the argument of HobStart by ASSERT ()
485 // 2. GetNextHob () will return NULL instead of returning HobStart when such kind of
486 // HOB can be retrieved, so caller does not need to re-check the return HOB type any longer.
487 //
488
489 VOID *Hob;
490 //
491 // Return input if not found
492 //
493 if (HobStart == NULL) {
494 return HobStart;
495 }
496 Hob = GetNextHob (Type, HobStart);
497 if (Hob == NULL) {
498 return HobStart;
499 }
500
501 return Hob;
502 }
503 ////~
504
505 ////
506 UINTN
507 R8_GetHobListSize (
508 IN VOID *HobStart
509 )
510 /*++
511
512 Routine Description:
513
514 Get size of hob list.
515
516 Arguments:
517
518 HobStart - Start pointer of hob list
519
520 Returns:
521
522 Size of hob list.
523
524 --*/
525 {
526 //
527 // Porting Guide:
528 // This library interface is simply obsolete.
529 // Include the source code to user code.
530 //
531 EFI_PEI_HOB_POINTERS Hob;
532 UINTN Size;
533
534 Hob.Raw = HobStart;
535 Size = 0;
536
537 while (Hob.Header->HobType != EFI_HOB_TYPE_END_OF_HOB_LIST) {
538 Size += Hob.Header->HobLength;
539 Hob.Raw += Hob.Header->HobLength;
540 }
541
542 Size += Hob.Header->HobLength;
543
544 return Size;
545 }
546 ////~
547
548 ////
549 UINT32
550 R8_GetHobVersion (
551 IN VOID *HobStart
552 )
553 /*++
554
555 Routine Description:
556
557 Get hob version.
558
559 Arguments:
560
561 HobStart - Start pointer of hob list
562
563 Returns:
564
565 Hob version.
566
567 --*/
568 {
569 //
570 // Porting Guide:
571 // This library interface is simply obsolete.
572 // Include the source code to user code.
573 //
574
575 EFI_PEI_HOB_POINTERS Hob;
576
577 Hob.Raw = HobStart;
578 return Hob.HandoffInformationTable->Version;
579 }
580 ////~
581
582 ////
583 EFI_STATUS
584 R8_GetHobBootMode (
585 IN VOID *HobStart,
586 OUT EFI_BOOT_MODE *BootMode
587 )
588 /*++
589
590 Routine Description:
591
592 Get current boot mode.
593
594 Arguments:
595
596 HobStart - Start pointer of hob list
597 BootMode - Current boot mode recorded in PHIT hob
598
599 Returns:
600
601 EFI_NOT_FOUND - Invalid hob header
602 EFI_SUCCESS - Boot mode found
603
604 --*/
605 {
606 //
607 // Porting Guide:
608 // This library interface is simply obsolete.
609 // Include the source code to user code.
610 // In fact, since EFI_HANDOFF_HOB must be the first Hob,
611 // the following code can retrieve boot mode.
612 //
613 // EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
614 //
615 // HandOffHob = GetHobList ();
616 // ASSERT (HandOffHob->Header.HobType == EFI_HOB_TYPE_HANDOFF);
617 //
618 // BootMode = HandOffHob->BootMode;
619 //
620 EFI_PEI_HOB_POINTERS Hob;
621
622 Hob.Raw = HobStart;
623 if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
624 return EFI_NOT_FOUND;
625 }
626
627 *BootMode = Hob.HandoffInformationTable->BootMode;
628 return EFI_SUCCESS;
629 }
630 ////~
631
632
633 ////#HobLib
634 EFI_STATUS
635 R8_GetCpuHobInfo (
636 IN VOID *HobStart,
637 OUT UINT8 *SizeOfMemorySpace,
638 OUT UINT8 *SizeOfIoSpace
639 )
640 /*++
641
642 Routine Description:
643
644 Get information recorded in CPU hob (Memory space size, Io space size)
645
646 Arguments:
647
648 HobStart - Start pointer of hob list
649 SizeOfMemorySpace - Size of memory size
650 SizeOfIoSpace - Size of IO size
651
652 Returns:
653
654 EFI_NOT_FOUND - CPU hob not found
655 EFI_SUCCESS - CPU hob found and information got.
656
657 --*/
658 {
659 //
660 // Porting Guide:
661 // This library interface is simply obsolete.
662 // Include the source code to user code.
663 // If Cpu HOB info is indispensable, user is able to ASSERT ()
664 // first to save error handling code
665 // For example:
666 //
667 // EFI_HOB_CPU *CpuHob;
668 //
669 // CpuHob = GetHob (EFI_HOB_TYPE_CPU, HobStart);
670 // ASSERT (CpuHob != NULL);
671 //
672 // ...
673 //
674 EFI_HOB_CPU *CpuHob;
675
676 CpuHob = GetHob (EFI_HOB_TYPE_CPU, HobStart);
677 if (CpuHob == NULL) {
678 return EFI_NOT_FOUND;
679 }
680
681 *SizeOfMemorySpace = CpuHob->SizeOfMemorySpace;
682 *SizeOfIoSpace = CpuHob->SizeOfIoSpace;
683 return EFI_SUCCESS;
684 }
685 ////~
686
687 ////#HobLib
688 EFI_STATUS
689 R8_GetDxeCoreHobInfo (
690 IN VOID *HobStart,
691 OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
692 OUT UINT64 *Length,
693 OUT VOID **EntryPoint,
694 OUT EFI_GUID **FileName
695 )
696 /*++
697
698 Routine Description:
699
700 Get memory allocation hob created for DXE core and extract its information
701
702 Arguments:
703
704 HobStart - Start pointer of the hob list
705 BaseAddress - Start address of memory allocated for DXE core
706 Length - Length of memory allocated for DXE core
707 EntryPoint - DXE core file name
708 FileName - File Name
709
710 Returns:
711
712 EFI_NOT_FOUND - DxeCoreHob not found
713 EFI_SUCCESS - DxeCoreHob found and information got
714
715 --*/
716 {
717 //
718 // Porting Guide:
719 // This library interface is simply obsolete.
720 // Include the source code to user code.
721 //
722 EFI_PEI_HOB_POINTERS DxeCoreHob;
723
724 for (DxeCoreHob.Raw = HobStart;
725 (DxeCoreHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw)) != NULL;
726 DxeCoreHob.Raw = GET_NEXT_HOB (DxeCoreHob)) {
727 if (CompareGuid (&DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.Name,
728 &gEfiHobMemeryAllocModuleGuid)) {
729 *BaseAddress = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress;
730 *Length = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength;
731 *EntryPoint = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint;
732 *FileName = &DxeCoreHob.MemoryAllocationModule->ModuleName;
733 return EFI_SUCCESS;
734 }
735 }
736
737 return EFI_NOT_FOUND;
738 }
739 ////~
740
741 ////#HobLib
742 EFI_STATUS
743 R8_GetNextFirmwareVolumeHob (
744 IN OUT VOID **HobStart,
745 OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
746 OUT UINT64 *Length
747 )
748 /*++
749
750 Routine Description:
751
752 Get next firmware volume hob from HobStart
753
754 Arguments:
755
756 HobStart - Start pointer of hob list
757 BaseAddress - Start address of next firmware volume
758 Length - Length of next firmware volume
759
760 Returns:
761
762 EFI_NOT_FOUND - Next firmware volume not found
763 EFI_SUCCESS - Next firmware volume found with address information
764
765 --*/
766 {
767 //
768 // Porting Guide:
769 // This library interface is simply obsolete.
770 // Include the source code to user code.
771 // Pay attention that caller is REQUIRED to update HobStart with:
772 // *HobStart = GET_NEXT_HOB (FirmwareVolumeHob)
773 //
774 // If FV HOB info is indispensable, user is able to ASSERT ()
775 // first to save error handling code
776 // For example:
777 //
778 // EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
779 //
780 // FirmwareVolumeHob = GetHob (EFI_HOB_TYPE_FV, HobStart);
781 // ASSERT (FirmwareVolumeHob != NULL);
782 //
783 // ...
784 //
785
786 EFI_PEI_HOB_POINTERS FirmwareVolumeHob;
787
788 FirmwareVolumeHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, *HobStart);
789 if (FirmwareVolumeHob.Raw != NULL) {
790 return EFI_NOT_FOUND;
791 }
792
793 *BaseAddress = FirmwareVolumeHob.FirmwareVolume->BaseAddress;
794 *Length = FirmwareVolumeHob.FirmwareVolume->Length;
795
796 *HobStart = GET_NEXT_HOB (FirmwareVolumeHob);
797
798 return EFI_SUCCESS;
799 }
800 ////~
801
802 ////#HobLib
803 EFI_STATUS
804 R8_GetNextGuidHob (
805 IN OUT VOID **HobStart,
806 IN EFI_GUID * Guid,
807 OUT VOID **Buffer,
808 OUT UINTN *BufferSize OPTIONAL
809 )
810 /*++
811
812 Routine Description:
813 Get the next guid hob.
814
815 Arguments:
816 HobStart - A pointer to the start hob.
817 Guid - A pointer to a guid.
818 Buffer - A pointer to the buffer.
819 BufferSize - Buffer size.
820
821 Returns:
822 EFI_NOT_FOUND - Next Guid hob not found
823 EFI_SUCCESS - Next Guid hob found and data for this Guid got
824 EFI_INVALID_PARAMETER - invalid parameter
825
826 --*/
827 {
828 //
829 // Porting Guide:
830 // This library interface is changed substantially with R9 counerpart GetNextGuidHob ().
831 // 1. R9 GetNextGuidHob has two parameters and returns the matched GUID HOB from the StartHob.
832 // 2. R9 GetNextGuidHob does not strip the HOB header, so caller is required to apply
833 // GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () to extract the data section and its
834 // size info respectively.
835 // 3. this function does not skip the starting HOB pointer unconditionally:
836 // it returns HobStart back if HobStart itself meets the requirement;
837 // caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
838 //
839 EFI_PEI_HOB_POINTERS GuidHob;
840
841 if (Buffer == NULL) {
842 return EFI_INVALID_PARAMETER;
843 }
844
845 GuidHob.Raw = GetNextGuidHob (Guid, *HobStart);
846 if (GuidHob.Raw == NULL) {
847 return EFI_NOT_FOUND;
848 }
849
850 *Buffer = GET_GUID_HOB_DATA (GuidHob.Guid);
851 if (BufferSize != NULL) {
852 *BufferSize = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);
853 }
854
855 *HobStart = GET_NEXT_HOB (GuidHob);
856
857 return EFI_SUCCESS;
858 }
859 ////~
860
861 ////#HobLib
862 EFI_STATUS
863 R8_GetPalEntryHobInfo (
864 IN VOID *HobStart,
865 OUT EFI_PHYSICAL_ADDRESS *PalEntry
866 )
867 /*++
868
869 Routine Description:
870
871 Get PAL entry from PalEntryHob
872
873 Arguments:
874
875 HobStart - Start pointer of hob list
876 PalEntry - Pointer to PAL entry
877
878 Returns:
879
880 Status code.
881
882 --*/
883 {
884 EFI_HOB_GUID_TYPE *GuidHob;
885
886 GuidHob = GetNextGuidHob (&gPalEntryHob, HobStart);
887
888 if (GuidHob == NULL) {
889 return EFI_NOT_FOUND;
890 }
891
892 *PalEntry = *((EFI_PHYSICAL_ADDRESS *) GET_GUID_HOB_DATA (GuidHob));
893 return EFI_SUCCESS;
894 }
895 ////~
896
897 ////#HobLib
898 EFI_STATUS
899 R8_GetIoPortSpaceAddressHobInfo (
900 IN VOID *HobStart,
901 OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress
902 )
903 /*++
904
905 Routine Description:
906
907 Get IO port space address from IoBaseHob.
908
909 Arguments:
910
911 HobStart - Start pointer of hob list
912 IoPortSpaceAddress - IO port space address
913
914 Returns:
915
916 Status code
917
918 --*/
919 {
920 //
921 // Porting Guide:
922 // This library interface is simply obsolete.
923 // Include the source code to user code.
924 //
925 EFI_HOB_GUID_TYPE *GuidHob;
926
927 GuidHob = GetNextGuidHob (&gEfiIoBaseHobGuid, HobStart);
928
929 if (GuidHob == NULL) {
930 return EFI_NOT_FOUND;
931 }
932
933 *IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) GET_GUID_HOB_DATA (GuidHob));
934 return EFI_SUCCESS;
935 }
936 ////~
937
938 ////#HobLib
939 EFI_STATUS
940 R8_PeiBuildHobGuid (
941 IN EFI_GUID *Guid,
942 IN UINTN DataLength,
943 OUT VOID **Hob
944 )
945 /*++
946
947 Routine Description:
948
949 Builds a custom HOB that is tagged with a GUID for identification
950
951 Arguments:
952
953 Guid - The GUID of the custome HOB type
954 DataLength - The size of the data payload for the GUIDed HOB
955 Hob - Pointer to pointer to the created Hob
956
957 Returns:
958
959 EFI_SUCCESS - Hob is successfully built.
960 Others - Errors occur while creating new Hob
961
962 --*/
963 {
964 //
965 // Porting Guide: Apply the new interface of BuildGuidHob in R9 HobLib.
966 // Pay attention that the return value has been changed to the start address of
967 // GUID HOB data so that caller can fill the customized data.
968 // For BuildGuidHob (), the HOB Header and Name field is already stripped..
969 //
970 VOID *HobData;
971
972 HobData = BuildGuidHob (Guid, DataLength);
973 //
974 // This step is necessary to be compatible with R8 interface!
975 //
976 *Hob = (VOID *) ((UINT8 *) HobData - sizeof (EFI_HOB_GUID_TYPE));
977
978 return EFI_SUCCESS;
979 }
980 ////~