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