]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParserCommon.c
1) Add in IfrParser so that the FrameworkHii->GetDefaultImage can scan UEFI IFR opcod...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiToUefiHiiThunk / UefiIfrParserCommon.c
1 #include <PiDxe.h>
2 #include <Library/DebugLib.h>
3 #include <Library/HiiLib.h>
4 #include <Library/MemoryAllocationLib.h>
5 #include <Library/UefiBootServicesTableLib.h>
6
7
8 CHAR16 *gEmptyString = L" ";
9
10 /**
11 Get the string based on the StringId and HII Package List Handle.
12
13 @param Token The String's ID.
14 @param HiiHandle The package list in the HII database to search for
15 the specified string.
16
17 @return The output string.
18
19 **/
20 CHAR16 *
21 GetToken (
22 IN EFI_STRING_ID Token,
23 IN EFI_HII_HANDLE HiiHandle
24 )
25 {
26 EFI_STATUS Status;
27 CHAR16 *String;
28 UINTN BufferLength;
29
30 //
31 // Set default string size assumption at no more than 256 bytes
32 //
33 BufferLength = 0x100;
34 String = AllocateZeroPool (BufferLength);
35 ASSERT (String != NULL);
36
37 Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
38
39 if (Status == EFI_BUFFER_TOO_SMALL) {
40 gBS->FreePool (String);
41 String = AllocateZeroPool (BufferLength);
42 ASSERT (String != NULL);
43
44 Status = HiiLibGetString (HiiHandle, Token, String, &BufferLength);
45 }
46 ASSERT_EFI_ERROR (Status);
47
48 return String;
49 }
50
51 /**
52 Create a new string in HII Package List.
53
54 @param String The String to be added
55 @param HiiHandle The package list in the HII database to insert the
56 specified string.
57
58 @return The output string.
59
60 **/
61 EFI_STRING_ID
62 NewString (
63 IN CHAR16 *String,
64 IN EFI_HII_HANDLE HiiHandle
65 )
66 {
67 EFI_STRING_ID StringId;
68 EFI_STATUS Status;
69
70 StringId = 0;
71 Status = HiiLibNewString (HiiHandle, &StringId, String);
72 ASSERT_EFI_ERROR (Status);
73
74 return StringId;
75 }
76
77
78