]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Conf/Migration/R8Lib.c
Add porting Guide to obsolete Edk Library interfaces.
[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 //
53 // Porting Guide:
54 // This obsolete Edk library interface installs driver binding protocol.
55 // If the entry point of that module only invoke this function, it can
56 // use UefiDriverModuleLib in MdePkg and expose "DriverBinding" protocol interface
57 // at the <Externs> tag, build tool will auto generate code to handle it.
58 // For example:
59 // <Externs>
60 // <Extern>
61 // <DriverBinding>gFatDriverBinding</DriverBinding>
62 // </Extern>
63 // </Externs>
64 //
65 DriverBinding->ImageHandle = ImageHandle;
66
67 DriverBinding->DriverBindingHandle = DriverBindingHandle;
68
69 return gBS->InstallProtocolInterface (
70 &DriverBinding->DriverBindingHandle,
71 &gEfiDriverBindingProtocolGuid,
72 EFI_NATIVE_INTERFACE,
73 DriverBinding
74 );
75 }
76 ////~
77
78 ////
79 EFI_STATUS
80 R8_EfiLibInstallAllDriverProtocols (
81 IN EFI_HANDLE ImageHandle,
82 IN EFI_SYSTEM_TABLE * SystemTable,
83 IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding,
84 IN EFI_HANDLE DriverBindingHandle,
85 IN EFI_COMPONENT_NAME_PROTOCOL * ComponentName, OPTIONAL
86 IN EFI_DRIVER_CONFIGURATION_PROTOCOL * DriverConfiguration, OPTIONAL
87 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL * DriverDiagnostics OPTIONAL
88 )
89 /*++
90
91 Routine Description:
92
93 Intialize a driver by installing the Driver Binding Protocol onto the
94 driver's DriverBindingHandle. This is typically the same as the driver's
95 ImageHandle, but it can be different if the driver produces multiple
96 DriverBinding Protocols. This function also initializes the EFI Driver
97 Library that initializes the global variables gST, gBS, gRT.
98
99 Arguments:
100
101 ImageHandle - The image handle of the driver
102
103 SystemTable - The EFI System Table that was passed to the driver's entry point
104
105 DriverBinding - A Driver Binding Protocol instance that this driver is producing
106
107 DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
108 parameter is NULL, then a new handle is created.
109
110 ComponentName - A Component Name Protocol instance that this driver is producing
111
112 DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing
113
114 DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing
115
116 Returns:
117
118 EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle
119
120 Otherwise, then return status from gBS->InstallProtocolInterface()
121
122 --*/
123 {
124 //
125 // Porting Guide:
126 // This obsolete Edk library interface installs driver binding protocol
127 // with optional component name, driver configuration & driver diagnotics protocols.
128 // If the entry point of that module only invoke this function, it can
129 // use UefiDriverModuleLib in MdePkg and expose "DriverBinding", "ComponentName",
130 // "DriverConfiguration" and "DriverDiagnostics" protocol interfaces.
131 // at the <Externs> tag, build tool will auto generate code to handle it.
132 // For example:
133 // <Externs>
134 // <Extern>
135 // <DriverBinding>gFatDriverBinding</DriverBinding>
136 // </Extern>
137 // <Extern>
138 // <ComponentName>gFatComponentName</ComponentName>
139 // </Extern>
140 // </Externs>
141 //
142 EFI_STATUS Status;
143
144 Status = R8_EfiLibInstallDriverBinding (ImageHandle, SystemTable, DriverBinding, DriverBindingHandle);
145 if (EFI_ERROR (Status)) {
146 return Status;
147 }
148
149 if (ComponentName != NULL) {
150 Status = gBS->InstallProtocolInterface (
151 &DriverBinding->DriverBindingHandle,
152 &gEfiComponentNameProtocolGuid,
153 EFI_NATIVE_INTERFACE,
154 ComponentName
155 );
156 if (EFI_ERROR (Status)) {
157 return Status;
158 }
159 }
160
161 if (DriverConfiguration != NULL) {
162 Status = gBS->InstallProtocolInterface (
163 &DriverBinding->DriverBindingHandle,
164 &gEfiDriverConfigurationProtocolGuid,
165 EFI_NATIVE_INTERFACE,
166 DriverConfiguration
167 );
168 if (EFI_ERROR (Status)) {
169 return Status;
170 }
171 }
172
173 if (DriverDiagnostics != NULL) {
174 Status = gBS->InstallProtocolInterface (
175 &DriverBinding->DriverBindingHandle,
176 &gEfiDriverDiagnosticsProtocolGuid,
177 EFI_NATIVE_INTERFACE,
178 DriverDiagnostics
179 );
180 if (EFI_ERROR (Status)) {
181 return Status;
182 }
183 }
184
185 return EFI_SUCCESS;
186 }
187 ////~
188
189 ////
190 BOOLEAN
191 R8_EfiLibCompareLanguage (
192 IN CHAR8 *Language1,
193 IN CHAR8 *Language2
194 )
195 /*++
196
197 Routine Description:
198
199 Compare whether two names of languages are identical.
200
201 Arguments:
202
203 Language1 - Name of language 1
204 Language2 - Name of language 2
205
206 Returns:
207
208 TRUE - same
209 FALSE - not same
210
211 --*/
212 {
213 //
214 // Porting Guide:
215 // This library interface is simply obsolete.
216 // Include the source code to user code.
217 //
218 UINTN Index;
219
220 for (Index = 0; Index < 3; Index++) {
221 if (Language1[Index] != Language2[Index]) {
222 return FALSE;
223 }
224 }
225
226 return TRUE;
227 }
228 ////~
229
230 ////#BaseLib
231 EFI_STATUS
232 R8_BufToHexString (
233 IN OUT CHAR16 *Str,
234 IN OUT UINTN *HexStringBufferLength,
235 IN UINT8 *Buf,
236 IN UINTN Len
237 )
238 /*++
239
240 Routine Description:
241 Converts binary buffer to Unicode string.
242 At a minimum, any blob of data could be represented as a hex string.
243
244 Arguments:
245 Str - Pointer to the string.
246 HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
247 If routine return with EFI_SUCCESS, containing length of hex string buffer.
248 If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
249 Buf - Buffer to be converted from.
250 Len - Length in bytes of the buffer to be converted.
251
252 Returns:
253 EFI_SUCCESS: Routine success.
254 EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
255
256 --*/
257 {
258 //
259 // Porting Guide:
260 // This library interface is simply obsolete.
261 // Include the source code to user code.
262 //
263 UINTN Idx;
264 UINT8 Byte;
265 UINTN StrLen;
266
267 //
268 // Make sure string is either passed or allocate enough.
269 // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
270 // Plus the Unicode termination character.
271 //
272 StrLen = Len * 2;
273 if (StrLen > ((*HexStringBufferLength) - 1)) {
274 *HexStringBufferLength = StrLen + 1;
275 return EFI_BUFFER_TOO_SMALL;
276 }
277
278 *HexStringBufferLength = StrLen + 1;
279 //
280 // Ends the string.
281 //
282 Str[StrLen] = L'\0';
283
284 for (Idx = 0; Idx < Len; Idx++) {
285
286 Byte = Buf[Idx];
287 Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
288 Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
289 }
290
291 return EFI_SUCCESS;
292 }
293 ////~
294
295 ////
296 VOID
297 R8_EfiStrTrim (
298 IN OUT CHAR16 *str,
299 IN CHAR16 CharC
300 )
301 /*++
302
303 Routine Description:
304
305 Removes (trims) specified leading and trailing characters from a string.
306
307 Arguments:
308
309 str - Pointer to the null-terminated string to be trimmed. On return,
310 str will hold the trimmed string.
311 CharC - Character will be trimmed from str.
312
313 Returns:
314
315 --*/
316 {
317 //
318 // Porting Guide:
319 // This library interface is simply obsolete.
320 // Include the source code to user code.
321 //
322 CHAR16 *p1;
323 CHAR16 *p2;
324
325 if (*str == 0) {
326 return;
327 }
328
329 //
330 // Trim off the leading and trailing characters c
331 //
332 for (p1 = str; *p1 && *p1 == CharC; p1++) {
333 ;
334 }
335
336 p2 = str;
337 if (p2 == p1) {
338 while (*p1) {
339 p2++;
340 p1++;
341 }
342 } else {
343 while (*p1) {
344 *p2 = *p1;
345 p1++;
346 p2++;
347 }
348 *p2 = 0;
349 }
350
351
352 for (p1 = str + StrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) {
353 ;
354 }
355 if (p1 != str + StrLen(str) - 1) {
356 *(p1 + 1) = 0;
357 }
358 }
359 ////~
360
361 ////#PrintLib
362 UINTN
363 R8_EfiValueToHexStr (
364 IN OUT CHAR16 *Buffer,
365 IN UINT64 Value,
366 IN UINTN Flags,
367 IN UINTN Width
368 )
369 /*++
370
371 Routine Description:
372
373 VSPrint worker function that prints a Value as a hex number in Buffer
374
375 Arguments:
376
377 Buffer - Location to place ascii hex string of Value.
378
379 Value - Hex value to convert to a string in Buffer.
380
381 Flags - Flags to use in printing Hex string, see file header for details.
382
383 Width - Width of hex value.
384
385 Returns:
386
387 Number of characters printed.
388
389 --*/
390 {
391 //
392 // Porting Guide:
393 // Edk II BasePrintLib function UnicodeValueToString does not support
394 // to convert Value to Hex String.
395 // Include the source code to user code or use the full PrintLib funtion
396 // UnicodeVSPrintAsciiFormat (Buffer, MAXIMUM_VALUE_CHARACTERS, "%x", Value) instead.
397 //
398
399 CHAR16 TempBuffer[MAXIMUM_VALUE_CHARACTERS];
400 CHAR16 *TempStr;
401 CHAR16 Prefix;
402 CHAR16 *BufferPtr;
403 UINTN Count;
404 UINTN Index;
405
406 TempStr = TempBuffer;
407 BufferPtr = Buffer;
408
409 //
410 // Count starts at one since we will null terminate. Each iteration of the
411 // loop picks off one nibble. Oh yea TempStr ends up backwards
412 //
413 Count = 0;
414
415 if (Width > MAXIMUM_VALUE_CHARACTERS - 1) {
416 Width = MAXIMUM_VALUE_CHARACTERS - 1;
417 }
418
419 do {
420 //
421 // If Width == 0, it means no limit.
422 //
423 if ((Width != 0) && (Count >= Width)) {
424 break;
425 }
426
427 Index = ((UINTN)Value & 0xf);
428 *(TempStr++) = mHexStr[Index];
429 Value = RShiftU64 (Value, 4);
430 Count++;
431 } while (Value != 0);
432
433 if (Flags & PREFIX_ZERO) {
434 Prefix = '0';
435 } else {
436 Prefix = ' ';
437 }
438
439 Index = Count;
440 if (!(Flags & LEFT_JUSTIFY)) {
441 for (; Index < Width; Index++) {
442 *(TempStr++) = Prefix;
443 }
444 }
445
446 //
447 // Reverse temp string into Buffer.
448 //
449 while (TempStr != TempBuffer) {
450 *(BufferPtr++) = *(--TempStr);
451 }
452
453 *BufferPtr = 0;
454 return Index;
455 }
456 ////~
457
458
459
460 ////
461 EFI_STATUS
462 R8_HexStringToBuf (
463 IN OUT UINT8 *Buf,
464 IN OUT UINTN *Len,
465 IN CHAR16 *Str,
466 OUT UINTN *ConvertedStrLen OPTIONAL
467 )
468 /*++
469
470 Routine Description:
471 Converts Unicode string to binary buffer.
472 The conversion may be partial.
473 The first character in the string that is not hex digit stops the conversion.
474 At a minimum, any blob of data could be represented as a hex string.
475
476 Arguments:
477 Buf - Pointer to buffer that receives the data.
478 Len - Length in bytes of the buffer to hold converted data.
479 If routine return with EFI_SUCCESS, containing length of converted data.
480 If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
481 Str - String to be converted from.
482 ConvertedStrLen - Length of the Hex String consumed.
483
484 Returns:
485 EFI_SUCCESS: Routine Success.
486 EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
487 EFI_
488
489 --*/
490 {
491 //
492 // Porting Guide:
493 // This library interface is simply obsolete.
494 // Include the source code to user code.
495 //
496
497 UINTN HexCnt;
498 UINTN Idx;
499 UINTN BufferLength;
500 UINT8 Digit;
501 UINT8 Byte;
502
503 //
504 // Find out how many hex characters the string has.
505 //
506 for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
507
508 if (HexCnt == 0) {
509 *Len = 0;
510 return EFI_SUCCESS;
511 }
512 //
513 // Two Unicode characters make up 1 buffer byte. Round up.
514 //
515 BufferLength = (HexCnt + 1) / 2;
516
517 //
518 // Test if buffer is passed enough.
519 //
520 if (BufferLength > (*Len)) {
521 *Len = BufferLength;
522 return EFI_BUFFER_TOO_SMALL;
523 }
524
525 *Len = BufferLength;
526
527 for (Idx = 0; Idx < HexCnt; Idx++) {
528
529 IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
530
531 //
532 // For odd charaters, write the lower nibble for each buffer byte,
533 // and for even characters, the upper nibble.
534 //
535 if ((Idx & 1) == 0) {
536 Byte = Digit;
537 } else {
538 Byte = Buf[Idx / 2];
539 Byte &= 0x0F;
540 Byte |= Digit << 4;
541 }
542
543 Buf[Idx / 2] = Byte;
544 }
545
546 if (ConvertedStrLen != NULL) {
547 *ConvertedStrLen = HexCnt;
548 }
549
550 return EFI_SUCCESS;
551 }
552 ////~
553
554 ////
555 BOOLEAN
556 R8_IsHexDigit (
557 OUT UINT8 *Digit,
558 IN CHAR16 Char
559 )
560 /*++
561
562 Routine Description:
563 Determines if a Unicode character is a hexadecimal digit.
564 The test is case insensitive.
565
566 Arguments:
567 Digit - Pointer to byte that receives the value of the hex character.
568 Char - Unicode character to test.
569
570 Returns:
571 TRUE - If the character is a hexadecimal digit.
572 FALSE - Otherwise.
573
574 --*/
575 {
576 //
577 // Porting Guide:
578 // This library interface is simply obsolete.
579 // Include the source code to user code.
580 //
581
582 if ((Char >= L'0') && (Char <= L'9')) {
583 *Digit = (UINT8) (Char - L'0');
584 return TRUE;
585 }
586
587 if ((Char >= L'A') && (Char <= L'F')) {
588 *Digit = (UINT8) (Char - L'A' + 0x0A);
589 return TRUE;
590 }
591
592 if ((Char >= L'a') && (Char <= L'f')) {
593 *Digit = (UINT8) (Char - L'a' + 0x0A);
594 return TRUE;
595 }
596
597 return FALSE;
598 }
599 ////~
600
601 ////
602 CHAR16
603 R8_NibbleToHexChar (
604 IN UINT8 Nibble
605 )
606 /*++
607
608 Routine Description:
609 Converts the low nibble of a byte to hex unicode character.
610
611 Arguments:
612 Nibble - lower nibble of a byte.
613
614 Returns:
615 Hex unicode character.
616
617 --*/
618 {
619 //
620 // Porting Guide:
621 // This library interface is simply obsolete.
622 // Include the source code to user code.
623 //
624
625 Nibble &= 0x0F;
626 if (Nibble <= 0x9) {
627 return (CHAR16)(Nibble + L'0');
628 }
629
630 return (CHAR16)(Nibble - 0xA + L'A');
631 }
632 ////~
633
634 ////#HobLib
635 VOID *
636 R8_GetHob (
637 IN UINT16 Type,
638 IN VOID *HobStart
639 )
640 /*++
641
642 Routine Description:
643
644 This function returns the first instance of a HOB type in a HOB list.
645
646 Arguments:
647
648 Type The HOB type to return.
649 HobStart The first HOB in the HOB list.
650
651 Returns:
652
653 HobStart There were no HOBs found with the requested type.
654 else Returns the first HOB with the matching type.
655
656 --*/
657 {
658 //
659 // Porting Guide:
660 // Edk II HobLib GetNextHob () is an equivelent function with the following exceptions:
661 // 1. GetNextHob () does not allow NULL value as the argument of HobStart by ASSERT ()
662 // 2. GetNextHob () will return NULL instead of returning HobStart when such kind of
663 // HOB can be retrieved, so caller does not need to re-check the return HOB type any longer.
664 //
665
666 VOID *Hob;
667 //
668 // Return input if not found
669 //
670 if (HobStart == NULL) {
671 return HobStart;
672 }
673 Hob = GetNextHob (Type, HobStart);
674 if (Hob == NULL) {
675 return HobStart;
676 }
677
678 return Hob;
679 }
680 ////~
681
682 ////
683 UINTN
684 R8_GetHobListSize (
685 IN VOID *HobStart
686 )
687 /*++
688
689 Routine Description:
690
691 Get size of hob list.
692
693 Arguments:
694
695 HobStart - Start pointer of hob list
696
697 Returns:
698
699 Size of hob list.
700
701 --*/
702 {
703 //
704 // Porting Guide:
705 // This library interface is simply obsolete.
706 // Include the source code to user code.
707 //
708 EFI_PEI_HOB_POINTERS Hob;
709 UINTN Size;
710
711 Hob.Raw = HobStart;
712 Size = 0;
713
714 while (Hob.Header->HobType != EFI_HOB_TYPE_END_OF_HOB_LIST) {
715 Size += Hob.Header->HobLength;
716 Hob.Raw += Hob.Header->HobLength;
717 }
718
719 Size += Hob.Header->HobLength;
720
721 return Size;
722 }
723 ////~
724
725 ////
726 UINT32
727 R8_GetHobVersion (
728 IN VOID *HobStart
729 )
730 /*++
731
732 Routine Description:
733
734 Get hob version.
735
736 Arguments:
737
738 HobStart - Start pointer of hob list
739
740 Returns:
741
742 Hob version.
743
744 --*/
745 {
746 //
747 // Porting Guide:
748 // This library interface is simply obsolete.
749 // Include the source code to user code.
750 //
751
752 EFI_PEI_HOB_POINTERS Hob;
753
754 Hob.Raw = HobStart;
755 return Hob.HandoffInformationTable->Version;
756 }
757 ////~
758
759 ////
760 EFI_STATUS
761 R8_GetHobBootMode (
762 IN VOID *HobStart,
763 OUT EFI_BOOT_MODE *BootMode
764 )
765 /*++
766
767 Routine Description:
768
769 Get current boot mode.
770
771 Arguments:
772
773 HobStart - Start pointer of hob list
774
775 BootMode - Current boot mode recorded in PHIT hob
776
777 Returns:
778
779 EFI_NOT_FOUND - Invalid hob header
780
781 EFI_SUCCESS - Boot mode found
782
783 --*/
784 {
785 //
786 // Porting Guide:
787 // This library interface is simply obsolete.
788 // Include the source code to user code.
789 // In fact, since EFI_HANDOFF_HOB must be the first Hob,
790 // the following code can retrieve boot mode.
791 //
792 // EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
793 //
794 // HandOffHob = GetHobList ();
795 // ASSERT (HandOffHob->Header.HobType = EFI_HOB_TYPE_HANDOFF);
796 //
797 // BootMode = HandOffHob->BootMode;
798 //
799 EFI_PEI_HOB_POINTERS Hob;
800
801 Hob.Raw = HobStart;
802 if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
803 return EFI_NOT_FOUND;
804 }
805
806 *BootMode = Hob.HandoffInformationTable->BootMode;
807 return EFI_SUCCESS;
808 }
809 ////~
810
811
812 ////#HobLib
813 EFI_STATUS
814 R8_GetCpuHobInfo (
815 IN VOID *HobStart,
816 OUT UINT8 *SizeOfMemorySpace,
817 OUT UINT8 *SizeOfIoSpace
818 )
819 /*++
820
821 Routine Description:
822
823 Get information recorded in CPU hob (Memory space size, Io space size)
824
825 Arguments:
826
827 HobStart - Start pointer of hob list
828
829 SizeOfMemorySpace - Size of memory size
830
831 SizeOfIoSpace - Size of IO size
832
833 Returns:
834
835 EFI_NOT_FOUND - CPU hob not found
836
837 EFI_SUCCESS - CPU hob found and information got.
838
839 --*/
840 {
841 //
842 // Porting Guide:
843 // This library interface is simply obsolete.
844 // Include the source code to user code.
845 // If Cpu HOB info is indispensable, user is able to ASSERT ()
846 // first to save error handling code
847 // For example:
848 //
849 // EFI_HOB_CPU *CpuHob;
850 //
851 // CpuHob = GetHob (EFI_HOB_TYPE_CPU, HobStart);
852 // ASSERT (CpuHob != NULL);
853 //
854 // ...
855 //
856 EFI_HOB_CPU *CpuHob;
857
858 CpuHob = GetHob (EFI_HOB_TYPE_CPU, HobStart);
859 if (CpuHob == NULL) {
860 return EFI_NOT_FOUND;
861 }
862
863 *SizeOfMemorySpace = CpuHob->SizeOfMemorySpace;
864 *SizeOfIoSpace = CpuHob->SizeOfIoSpace;
865 return EFI_SUCCESS;
866 }
867 ////~
868
869 ////#HobLib
870 EFI_STATUS
871 R8_GetDxeCoreHobInfo (
872 IN VOID *HobStart,
873 OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
874 OUT UINT64 *Length,
875 OUT VOID **EntryPoint,
876 OUT EFI_GUID **FileName
877 )
878 /*++
879
880 Routine Description:
881
882 Get memory allocation hob created for DXE core and extract its information
883
884 Arguments:
885
886 HobStart - Start pointer of the hob list
887 BaseAddress - Start address of memory allocated for DXE core
888 Length - Length of memory allocated for DXE core
889 EntryPoint - DXE core file name
890 FileName - File Name
891
892 Returns:
893
894 EFI_NOT_FOUND - DxeCoreHob not found
895 EFI_SUCCESS - DxeCoreHob found and information got
896
897 --*/
898 {
899 //
900 // Porting Guide:
901 // This library interface is simply obsolete.
902 // Include the source code to user code.
903 //
904 EFI_PEI_HOB_POINTERS DxeCoreHob;
905
906 for (DxeCoreHob.Raw = HobStart;
907 (DxeCoreHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw)) != NULL;
908 DxeCoreHob.Raw = GET_NEXT_HOB (DxeCoreHob)) {
909 if (CompareGuid (&DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.Name,
910 &gEfiHobMemeryAllocModuleGuid)) {
911 *BaseAddress = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress;
912 *Length = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength;
913 *EntryPoint = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint;
914 *FileName = &DxeCoreHob.MemoryAllocationModule->ModuleName;
915 return EFI_SUCCESS;
916 }
917 }
918
919 return EFI_NOT_FOUND;
920 }
921 ////~
922
923 ////#HobLib
924 EFI_STATUS
925 R8_GetNextFirmwareVolumeHob (
926 IN OUT VOID **HobStart,
927 OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
928 OUT UINT64 *Length
929 )
930 /*++
931
932 Routine Description:
933
934 Get next firmware volume hob from HobStart
935
936 Arguments:
937
938 HobStart - Start pointer of hob list
939
940 BaseAddress - Start address of next firmware volume
941
942 Length - Length of next firmware volume
943
944 Returns:
945
946 EFI_NOT_FOUND - Next firmware volume not found
947
948 EFI_SUCCESS - Next firmware volume found with address information
949
950 --*/
951 {
952 //
953 // Porting Guide:
954 // This library interface is simply obsolete.
955 // Include the source code to user code.
956 // Pay attention that caller is REQUIRED to update HobStart with:
957 // *HobStart = GET_NEXT_HOB (FirmwareVolumeHob)
958 //
959 // If FV HOB info is indispensable, user is able to ASSERT ()
960 // first to save error handling code
961 // For example:
962 //
963 // EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
964 //
965 // FirmwareVolumeHob = GetHob (EFI_HOB_TYPE_FV, HobStart);
966 // ASSERT (FirmwareVolumeHob != NULL);
967 //
968 // ...
969 //
970
971 EFI_PEI_HOB_POINTERS FirmwareVolumeHob;
972
973 FirmwareVolumeHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, *HobStart);
974 if (FirmwareVolumeHob.Raw != NULL) {
975 return EFI_NOT_FOUND;
976 }
977
978 *BaseAddress = FirmwareVolumeHob.FirmwareVolume->BaseAddress;
979 *Length = FirmwareVolumeHob.FirmwareVolume->Length;
980
981 *HobStart = GET_NEXT_HOB (FirmwareVolumeHob);
982
983 return EFI_SUCCESS;
984 }
985 ////~
986
987 ////#HobLib
988 EFI_STATUS
989 R8_GetNextGuidHob (
990 IN OUT VOID **HobStart,
991 IN EFI_GUID * Guid,
992 OUT VOID **Buffer,
993 OUT UINTN *BufferSize OPTIONAL
994 )
995 /*++
996
997 Routine Description:
998 Get the next guid hob.
999
1000 Arguments:
1001 HobStart A pointer to the start hob.
1002 Guid A pointer to a guid.
1003 Buffer A pointer to the buffer.
1004 BufferSize Buffer size.
1005
1006 Returns:
1007 Status code.
1008
1009 EFI_NOT_FOUND - Next Guid hob not found
1010
1011 EFI_SUCCESS - Next Guid hob found and data for this Guid got
1012
1013 EFI_INVALID_PARAMETER - invalid parameter
1014
1015 --*/
1016 {
1017 //
1018 // Porting Guide:
1019 // This library interface is changed substantially with R9 counerpart GetNextGuidHob ().
1020 // 1. R9 GetNextGuidHob has two parameters and returns the matched GUID HOB from the StartHob.
1021 // 2. R9 GetNextGuidHob does not strip the HOB header, so caller is required to apply
1022 // GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () to extract the data section and its
1023 // size info respectively.
1024 // 3. this function does not skip the starting HOB pointer unconditionally:
1025 // it returns HobStart back if HobStart itself meets the requirement;
1026 // caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
1027 //
1028 EFI_PEI_HOB_POINTERS GuidHob;
1029
1030 if (Buffer == NULL) {
1031 return EFI_INVALID_PARAMETER;
1032 }
1033
1034 GuidHob.Raw = GetNextGuidHob (Guid, *HobStart);
1035 if (GuidHob == NULL) {
1036 return EFI_NOT_FOUND;
1037 }
1038
1039 *Buffer = GET_GUID_HOB_DATA (GuidHob.Guid);
1040 if (BufferSize != NULL) {
1041 *BufferSize = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);
1042 }
1043
1044 *HobStart = GET_NEXT_HOB (GuidHob);
1045
1046 return EFI_SUCCESS;
1047 }
1048 ////~
1049
1050 ////#HobLib
1051 EFI_STATUS
1052 R8_GetPalEntryHobInfo (
1053 IN VOID *HobStart,
1054 OUT EFI_PHYSICAL_ADDRESS *PalEntry
1055 )
1056 /*++
1057
1058 Routine Description:
1059
1060 Get PAL entry from PalEntryHob
1061
1062 Arguments:
1063
1064 HobStart - Start pointer of hob list
1065
1066 PalEntry - Pointer to PAL entry
1067
1068 Returns:
1069
1070 Status code.
1071
1072 --*/
1073 {
1074 EFI_HOB_GUID_TYPE *GuidHob;
1075
1076 GuidHob = GetNextGuidHob (&gPalEntryHob, HobStart);
1077
1078 if (GuidHob == NULL) {
1079 return EFI_NOT_FOUND;
1080 }
1081
1082 *PalEntry = *((EFI_PHYSICAL_ADDRESS *) GET_GUID_HOB_DATA (GuidHob));
1083 return EFI_SUCCESS;
1084 }
1085 ////~
1086
1087 ////#HobLib
1088 EFI_STATUS
1089 R8_GetIoPortSpaceAddressHobInfo (
1090 IN VOID *HobStart,
1091 OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress
1092 )
1093 /*++
1094
1095 Routine Description:
1096
1097 Get IO port space address from IoBaseHob.
1098
1099 Arguments:
1100
1101 HobStart - Start pointer of hob list
1102
1103 IoPortSpaceAddress - IO port space address
1104
1105 Returns:
1106
1107 Status code
1108
1109 --*/
1110 {
1111 //
1112 // Porting Guide:
1113 // This library interface is simply obsolete.
1114 // Include the source code to user code.
1115 //
1116 EFI_HOB_GUID_TYPE *GuidHob;
1117
1118 GuidHob = GetNextGuidHob (&gEfiIoBaseHobGuid, HobStart);
1119
1120 if (GuidHob == NULL) {
1121 return EFI_NOT_FOUND;
1122 }
1123
1124 *IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) GET_GUID_HOB_DATA (GuidHob));
1125 return EFI_SUCCESS;
1126 }
1127 ////~
1128