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