2 Obsolete library interfaces.
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.
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
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.
20 R8_EfiLibCompareLanguage (
28 Compare whether two names of languages are identical.
32 Language1 - Name of language 1
33 Language2 - Name of language 2
44 // This library interface is simply obsolete.
45 // Include the source code to user code.
49 for (Index
= 0; Index
< 3; Index
++) {
50 if (Language1
[Index
] != Language2
[Index
]) {
63 IN OUT UINTN
*HexStringBufferLength
,
70 Converts binary buffer to Unicode string.
71 At a minimum, any blob of data could be represented as a hex string.
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.
82 EFI_SUCCESS - Routine success.
83 EFI_BUFFER_TOO_SMALL - The hex string buffer is too small.
89 // This library interface is simply obsolete.
90 // Include the source code to user code.
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.
102 if (StrLen
> ((*HexStringBufferLength
) - 1)) {
103 *HexStringBufferLength
= StrLen
+ 1;
104 return EFI_BUFFER_TOO_SMALL
;
107 *HexStringBufferLength
= StrLen
+ 1;
113 for (Idx
= 0; Idx
< Len
; Idx
++) {
116 Str
[StrLen
- 1 - Idx
* 2] = NibbleToHexChar (Byte
);
117 Str
[StrLen
- 2 - Idx
* 2] = NibbleToHexChar ((UINT8
)(Byte
>> 4));
134 Removes (trims) specified leading and trailing characters from a string.
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.
146 // This library interface is simply obsolete.
147 // Include the source code to user code.
157 // Trim off the leading and trailing characters c
159 for (p1
= str
; *p1
&& *p1
== CharC
; p1
++) {
179 for (p1
= str
+ StrLen(str
) - 1; p1
>= str
&& *p1
== CharC
; p1
--) {
182 if (p1
!= str
+ StrLen(str
) - 1) {
190 R8_EfiValueToHexStr (
191 IN OUT CHAR16
*Buffer
,
200 VSPrint worker function that prints a Value as a hex number in Buffer
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.
211 Number of characters printed.
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.
223 CHAR16 TempBuffer
[MAXIMUM_VALUE_CHARACTERS
];
230 TempStr
= TempBuffer
;
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
239 if (Width
> MAXIMUM_VALUE_CHARACTERS
- 1) {
240 Width
= MAXIMUM_VALUE_CHARACTERS
- 1;
245 // If Width == 0, it means no limit.
247 if ((Width
!= 0) && (Count
>= Width
)) {
251 Index
= ((UINTN
)Value
& 0xf);
252 *(TempStr
++) = mHexStr
[Index
];
253 Value
= RShiftU64 (Value
, 4);
255 } while (Value
!= 0);
257 if (Flags
& PREFIX_ZERO
) {
264 if (!(Flags
& LEFT_JUSTIFY
)) {
265 for (; Index
< Width
; Index
++) {
266 *(TempStr
++) = Prefix
;
271 // Reverse temp string into Buffer.
273 while (TempStr
!= TempBuffer
) {
274 *(BufferPtr
++) = *(--TempStr
);
290 OUT UINTN
*ConvertedStrLen OPTIONAL
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.
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.
309 EFI_SUCCESS - Routine Success.
310 EFI_BUFFER_TOO_SMALL - The buffer is too small to hold converted data.
316 // This library interface is simply obsolete.
317 // Include the source code to user code.
327 // Find out how many hex characters the string has.
329 for (Idx
= 0, HexCnt
= 0; IsHexDigit (&Digit
, Str
[Idx
]); Idx
++, HexCnt
++);
336 // Two Unicode characters make up 1 buffer byte. Round up.
338 BufferLength
= (HexCnt
+ 1) / 2;
341 // Test if buffer is passed enough.
343 if (BufferLength
> (*Len
)) {
345 return EFI_BUFFER_TOO_SMALL
;
350 for (Idx
= 0; Idx
< HexCnt
; Idx
++) {
352 IsHexDigit (&Digit
, Str
[HexCnt
- 1 - Idx
]);
355 // For odd charaters, write the lower nibble for each buffer byte,
356 // and for even characters, the upper nibble.
358 if ((Idx
& 1) == 0) {
369 if (ConvertedStrLen
!= NULL
) {
370 *ConvertedStrLen
= HexCnt
;
386 Determines if a Unicode character is a hexadecimal digit.
387 The test is case insensitive.
390 Digit - Pointer to byte that receives the value of the hex character.
391 Char - Unicode character to test.
394 TRUE - If the character is a hexadecimal digit.
401 // This library interface is simply obsolete.
402 // Include the source code to user code.
405 if ((Char
>= L
'0') && (Char
<= L
'9')) {
406 *Digit
= (UINT8
) (Char
- L
'0');
410 if ((Char
>= L
'A') && (Char
<= L
'F')) {
411 *Digit
= (UINT8
) (Char
- L
'A' + 0x0A);
415 if ((Char
>= L
'a') && (Char
<= L
'f')) {
416 *Digit
= (UINT8
) (Char
- L
'a' + 0x0A);
432 Converts the low nibble of a byte to hex unicode character.
435 Nibble - lower nibble of a byte.
438 Hex unicode character.
444 // This library interface is simply obsolete.
445 // Include the source code to user code.
450 return (CHAR16
)(Nibble
+ L
'0');
453 return (CHAR16
)(Nibble
- 0xA + L
'A');
467 This function returns the first instance of a HOB type in a HOB list.
471 Type - The HOB type to return.
472 HobStart - The first HOB in the HOB list.
476 HobStart - There were no HOBs found with the requested type.
477 Other - The first HOB with the matching type.
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.
491 // Return input if not found
493 if (HobStart
== NULL
) {
496 Hob
= GetNextHob (Type
, HobStart
);
514 Get size of hob list.
518 HobStart - Start pointer of hob list
528 // This library interface is simply obsolete.
529 // Include the source code to user code.
531 EFI_PEI_HOB_POINTERS Hob
;
537 while (Hob
.Header
->HobType
!= EFI_HOB_TYPE_END_OF_HOB_LIST
) {
538 Size
+= Hob
.Header
->HobLength
;
539 Hob
.Raw
+= Hob
.Header
->HobLength
;
542 Size
+= Hob
.Header
->HobLength
;
561 HobStart - Start pointer of hob list
571 // This library interface is simply obsolete.
572 // Include the source code to user code.
575 EFI_PEI_HOB_POINTERS Hob
;
578 return Hob
.HandoffInformationTable
->Version
;
586 OUT EFI_BOOT_MODE
*BootMode
592 Get current boot mode.
596 HobStart - Start pointer of hob list
597 BootMode - Current boot mode recorded in PHIT hob
601 EFI_NOT_FOUND - Invalid hob header
602 EFI_SUCCESS - Boot mode found
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.
613 // EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
615 // HandOffHob = GetHobList ();
616 // ASSERT (HandOffHob->Header.HobType == EFI_HOB_TYPE_HANDOFF);
618 // BootMode = HandOffHob->BootMode;
620 EFI_PEI_HOB_POINTERS Hob
;
623 if (Hob
.Header
->HobType
!= EFI_HOB_TYPE_HANDOFF
) {
624 return EFI_NOT_FOUND
;
627 *BootMode
= Hob
.HandoffInformationTable
->BootMode
;
637 OUT UINT8
*SizeOfMemorySpace
,
638 OUT UINT8
*SizeOfIoSpace
644 Get information recorded in CPU hob (Memory space size, Io space size)
648 HobStart - Start pointer of hob list
649 SizeOfMemorySpace - Size of memory size
650 SizeOfIoSpace - Size of IO size
654 EFI_NOT_FOUND - CPU hob not found
655 EFI_SUCCESS - CPU hob found and information got.
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
667 // EFI_HOB_CPU *CpuHob;
669 // CpuHob = GetHob (EFI_HOB_TYPE_CPU, HobStart);
670 // ASSERT (CpuHob != NULL);
676 CpuHob
= GetHob (EFI_HOB_TYPE_CPU
, HobStart
);
677 if (CpuHob
== NULL
) {
678 return EFI_NOT_FOUND
;
681 *SizeOfMemorySpace
= CpuHob
->SizeOfMemorySpace
;
682 *SizeOfIoSpace
= CpuHob
->SizeOfIoSpace
;
689 R8_GetDxeCoreHobInfo (
691 OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
693 OUT VOID
**EntryPoint
,
694 OUT EFI_GUID
**FileName
700 Get memory allocation hob created for DXE core and extract its information
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
712 EFI_NOT_FOUND - DxeCoreHob not found
713 EFI_SUCCESS - DxeCoreHob found and information got
719 // This library interface is simply obsolete.
720 // Include the source code to user code.
722 EFI_PEI_HOB_POINTERS DxeCoreHob
;
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
;
737 return EFI_NOT_FOUND
;
743 R8_GetNextFirmwareVolumeHob (
744 IN OUT VOID
**HobStart
,
745 OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
,
752 Get next firmware volume hob from HobStart
756 HobStart - Start pointer of hob list
757 BaseAddress - Start address of next firmware volume
758 Length - Length of next firmware volume
762 EFI_NOT_FOUND - Next firmware volume not found
763 EFI_SUCCESS - Next firmware volume found with address information
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)
774 // If FV HOB info is indispensable, user is able to ASSERT ()
775 // first to save error handling code
778 // EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
780 // FirmwareVolumeHob = GetHob (EFI_HOB_TYPE_FV, HobStart);
781 // ASSERT (FirmwareVolumeHob != NULL);
786 EFI_PEI_HOB_POINTERS FirmwareVolumeHob
;
788 FirmwareVolumeHob
.Raw
= GetNextHob (EFI_HOB_TYPE_FV
, *HobStart
);
789 if (FirmwareVolumeHob
.Raw
!= NULL
) {
790 return EFI_NOT_FOUND
;
793 *BaseAddress
= FirmwareVolumeHob
.FirmwareVolume
->BaseAddress
;
794 *Length
= FirmwareVolumeHob
.FirmwareVolume
->Length
;
796 *HobStart
= GET_NEXT_HOB (FirmwareVolumeHob
);
805 IN OUT VOID
**HobStart
,
808 OUT UINTN
*BufferSize OPTIONAL
813 Get the next guid hob.
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.
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
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.
839 EFI_PEI_HOB_POINTERS GuidHob
;
841 if (Buffer
== NULL
) {
842 return EFI_INVALID_PARAMETER
;
845 GuidHob
.Raw
= GetNextGuidHob (Guid
, *HobStart
);
846 if (GuidHob
.Raw
== NULL
) {
847 return EFI_NOT_FOUND
;
850 *Buffer
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
851 if (BufferSize
!= NULL
) {
852 *BufferSize
= GET_GUID_HOB_DATA_SIZE (GuidHob
.Guid
);
855 *HobStart
= GET_NEXT_HOB (GuidHob
);
863 R8_GetPalEntryHobInfo (
865 OUT EFI_PHYSICAL_ADDRESS
*PalEntry
871 Get PAL entry from PalEntryHob
875 HobStart - Start pointer of hob list
876 PalEntry - Pointer to PAL entry
884 EFI_HOB_GUID_TYPE
*GuidHob
;
886 GuidHob
= GetNextGuidHob (&gPalEntryHob
, HobStart
);
888 if (GuidHob
== NULL
) {
889 return EFI_NOT_FOUND
;
892 *PalEntry
= *((EFI_PHYSICAL_ADDRESS
*) GET_GUID_HOB_DATA (GuidHob
));
899 R8_GetIoPortSpaceAddressHobInfo (
901 OUT EFI_PHYSICAL_ADDRESS
*IoPortSpaceAddress
907 Get IO port space address from IoBaseHob.
911 HobStart - Start pointer of hob list
912 IoPortSpaceAddress - IO port space address
922 // This library interface is simply obsolete.
923 // Include the source code to user code.
925 EFI_HOB_GUID_TYPE
*GuidHob
;
927 GuidHob
= GetNextGuidHob (&gEfiIoBaseHobGuid
, HobStart
);
929 if (GuidHob
== NULL
) {
930 return EFI_NOT_FOUND
;
933 *IoPortSpaceAddress
= *((EFI_PHYSICAL_ADDRESS
*) GET_GUID_HOB_DATA (GuidHob
));
949 Builds a custom HOB that is tagged with a GUID for identification
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
959 EFI_SUCCESS - Hob is successfully built.
960 Others - Errors occur while creating new Hob
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..
972 HobData
= BuildGuidHob (Guid
, DataLength
);
974 // This step is necessary to be compatible with R8 interface!
976 *Hob
= (VOID
*) ((UINT8
*) HobData
- sizeof (EFI_HOB_GUID_TYPE
));