]> git.proxmox.com Git - mirror_edk2.git/blame - EdkNt32Pkg/Dxe/PlatformBds/Generic/String.c
Add some definitions in Framework FV 0.9 spec but not in PI 1.0.
[mirror_edk2.git] / EdkNt32Pkg / Dxe / PlatformBds / Generic / String.c
CommitLineData
878ddf1f 1/*++\r
2\r
fa332de7 3Copyright (c) 2006 - 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
878ddf1f 11\r
12Module Name:\r
13\r
14 string.c\r
15\r
16Abstract:\r
17\r
18 String support\r
19\r
20Revision History\r
21\r
22--*/\r
23\r
24#include "Bds.h"\r
25#include "String.h"\r
26#include "Language.h"\r
27\r
28extern UINT8 BdsStrings[];\r
29\r
30EFI_GUID gBdsStringPackGuid = { 0x7bac95d3, 0xddf, 0x42f3, 0x9e, 0x24, 0x7c, 0x64, 0x49, 0x40, 0x37, 0x9a };\r
31\r
32EFI_STATUS\r
33InitializeStringSupport (\r
34 VOID\r
35 )\r
36/*++\r
37\r
38Routine Description:\r
fa332de7 39\r
878ddf1f 40 Initialize HII global accessor for string support\r
41\r
42Arguments:\r
43 None\r
44\r
45Returns:\r
46 String from ID.\r
47\r
48--*/\r
49{\r
50 EFI_STATUS Status;\r
51 EFI_HII_PACKAGES *PackageList;\r
52 //\r
53 // There should only ever be one HII protocol\r
54 //\r
55 Status = gBS->LocateProtocol (\r
56 &gEfiHiiProtocolGuid,\r
57 NULL,\r
58 &Hii\r
59 );\r
60 if (!EFI_ERROR (Status)) {\r
61 PackageList = PreparePackages (1, &gBdsStringPackGuid, BdsStrings);\r
62 Status = Hii->NewPack (Hii, PackageList, &gStringPackHandle);\r
fa332de7 63 FreePool (PackageList);\r
878ddf1f 64 }\r
65\r
66 return Status;\r
67}\r
68\r
69CHAR16 *\r
70GetStringById (\r
71 IN STRING_REF Id\r
72 )\r
73/*++\r
74\r
75Routine Description:\r
76\r
77 Get string by string id from HII Interface\r
78\r
79Arguments:\r
80\r
81 Id - String ID.\r
fa332de7 82\r
878ddf1f 83Returns:\r
84\r
85 CHAR16 * - String from ID.\r
86 NULL - If error occurs.\r
87\r
88--*/\r
89{\r
90 CHAR16 *String;\r
91 UINTN StringLength;\r
92 EFI_STATUS Status;\r
93\r
94 //\r
95 // Set default string size assumption at no more than 256 bytes\r
96 //\r
97 StringLength = 0x100;\r
98\r
99 String = AllocateZeroPool (StringLength);\r
100 if (String == NULL) {\r
101 //\r
102 // If this happens, we are oh-so-dead, but return a NULL in any case.\r
103 //\r
104 return NULL;\r
105 }\r
106 //\r
107 // Get the current string for the current Language\r
108 //\r
109 Status = Hii->GetString (Hii, gStringPackHandle, Id, FALSE, NULL, &StringLength, String);\r
110 if (EFI_ERROR (Status)) {\r
111 if (Status == EFI_BUFFER_TOO_SMALL) {\r
112 //\r
113 // Free the old pool\r
114 //\r
fa332de7 115 FreePool (String);\r
878ddf1f 116\r
117 //\r
118 // Allocate new pool with correct value\r
119 //\r
120 String = AllocatePool (StringLength);\r
121 ASSERT (String != NULL);\r
122\r
123 Status = Hii->GetString (Hii, gStringPackHandle, Id, FALSE, NULL, &StringLength, String);\r
124 if (!EFI_ERROR (Status)) {\r
125 return String;\r
126 }\r
127 }\r
128\r
129 return NULL;\r
130 }\r
131\r
132 return String;\r
133}\r