xref: /freebsd/sys/contrib/edk2/Include/Protocol/HiiString.h (revision f439973d6726c3be929c8fb3b1545b8b1744abc3)
1*f439973dSWarner Losh /** @file
2*f439973dSWarner Losh   The file provides services to manipulate string data.
3*f439973dSWarner Losh 
4*f439973dSWarner Losh Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5*f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent
6*f439973dSWarner Losh 
7*f439973dSWarner Losh   @par Revision Reference:
8*f439973dSWarner Losh   This Protocol was introduced in UEFI Specification 2.1.
9*f439973dSWarner Losh 
10*f439973dSWarner Losh **/
11*f439973dSWarner Losh 
12*f439973dSWarner Losh #ifndef __HII_STRING_H__
13*f439973dSWarner Losh #define __HII_STRING_H__
14*f439973dSWarner Losh 
15*f439973dSWarner Losh #include <Protocol/HiiFont.h>
16*f439973dSWarner Losh 
17*f439973dSWarner Losh #define EFI_HII_STRING_PROTOCOL_GUID \
18*f439973dSWarner Losh   { 0xfd96974, 0x23aa, 0x4cdc, { 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a } }
19*f439973dSWarner Losh 
20*f439973dSWarner Losh typedef struct _EFI_HII_STRING_PROTOCOL EFI_HII_STRING_PROTOCOL;
21*f439973dSWarner Losh 
22*f439973dSWarner Losh /**
23*f439973dSWarner Losh   This function adds the string String to the group of strings owned by PackageList, with the
24*f439973dSWarner Losh   specified font information StringFontInfo, and returns a new string id.
25*f439973dSWarner Losh   The new string identifier is guaranteed to be unique within the package list.
26*f439973dSWarner Losh   That new string identifier is reserved for all languages in the package list.
27*f439973dSWarner Losh 
28*f439973dSWarner Losh   @param  This                   A pointer to the EFI_HII_STRING_PROTOCOL instance.
29*f439973dSWarner Losh   @param  PackageList            The handle of the package list where this string will
30*f439973dSWarner Losh                                  be added.
31*f439973dSWarner Losh   @param  StringId               On return, contains the new strings id, which is
32*f439973dSWarner Losh                                  unique within PackageList.
33*f439973dSWarner Losh   @param  Language               Points to the language for the new string.
34*f439973dSWarner Losh   @param  LanguageName           Points to the printable language name to associate
35*f439973dSWarner Losh                                  with the passed in  Language field.If LanguageName
36*f439973dSWarner Losh                                  is not NULL and the string package header's
37*f439973dSWarner Losh                                  LanguageName  associated with a given Language is
38*f439973dSWarner Losh                                  not zero, the LanguageName being passed in will
39*f439973dSWarner Losh                                  be ignored.
40*f439973dSWarner Losh   @param  String                 Points to the new null-terminated string.
41*f439973dSWarner Losh   @param  StringFontInfo         Points to the new string's font information or
42*f439973dSWarner Losh                                  NULL if the string should have the default system
43*f439973dSWarner Losh                                  font, size and style.
44*f439973dSWarner Losh 
45*f439973dSWarner Losh   @retval EFI_SUCCESS            The new string was added successfully.
46*f439973dSWarner Losh   @retval EFI_NOT_FOUND          The specified PackageList could not be found in
47*f439973dSWarner Losh                                  database.
48*f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES   Could not add the string due to lack of resources.
49*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  String is NULL, or StringId is NULL, or Language is NULL.
50*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  The specified StringFontInfo does not exist in
51*f439973dSWarner Losh                                  current database.
52*f439973dSWarner Losh 
53*f439973dSWarner Losh **/
54*f439973dSWarner Losh typedef
55*f439973dSWarner Losh EFI_STATUS
56*f439973dSWarner Losh (EFIAPI *EFI_HII_NEW_STRING)(
57*f439973dSWarner Losh   IN CONST  EFI_HII_STRING_PROTOCOL   *This,
58*f439973dSWarner Losh   IN        EFI_HII_HANDLE            PackageList,
59*f439973dSWarner Losh   OUT       EFI_STRING_ID             *StringId,
60*f439973dSWarner Losh   IN CONST  CHAR8                     *Language,
61*f439973dSWarner Losh   IN  CONST CHAR16                    *LanguageName  OPTIONAL,
62*f439973dSWarner Losh   IN CONST  EFI_STRING                String,
63*f439973dSWarner Losh   IN CONST  EFI_FONT_INFO             *StringFontInfo OPTIONAL
64*f439973dSWarner Losh   );
65*f439973dSWarner Losh 
66*f439973dSWarner Losh /**
67*f439973dSWarner Losh   This function retrieves the string specified by StringId which is associated
68*f439973dSWarner Losh   with the specified PackageList in the language Language and copies it into
69*f439973dSWarner Losh   the buffer specified by String.
70*f439973dSWarner Losh 
71*f439973dSWarner Losh   @param  This                   A pointer to the EFI_HII_STRING_PROTOCOL instance.
72*f439973dSWarner Losh   @param  Language               Points to the language for the retrieved string.
73*f439973dSWarner Losh   @param  PackageList            The package list in the HII database to search for
74*f439973dSWarner Losh                                  the  specified string.
75*f439973dSWarner Losh   @param  StringId               The string's id, which is unique within
76*f439973dSWarner Losh                                  PackageList.
77*f439973dSWarner Losh   @param  String                 Points to the new null-terminated string.
78*f439973dSWarner Losh   @param  StringSize             On entry, points to the size of the buffer pointed
79*f439973dSWarner Losh                                  to by  String, in bytes. On return, points to the
80*f439973dSWarner Losh                                  length of the string, in bytes.
81*f439973dSWarner Losh   @param  StringFontInfo         If not NULL, points to the string's font
82*f439973dSWarner Losh                                  information.  It's caller's responsibility to free
83*f439973dSWarner Losh                                  this buffer.
84*f439973dSWarner Losh 
85*f439973dSWarner Losh   @retval EFI_SUCCESS            The string was returned successfully.
86*f439973dSWarner Losh   @retval EFI_NOT_FOUND          The string specified by StringId is not available.
87*f439973dSWarner Losh                                  The specified PackageList is not in the database.
88*f439973dSWarner Losh   @retval EFI_INVALID_LANGUAGE    The string specified by StringId is available but
89*f439973dSWarner Losh                                   not in the specified language.
90*f439973dSWarner Losh   @retval EFI_BUFFER_TOO_SMALL   The buffer specified by StringSize is too small to
91*f439973dSWarner Losh                                  hold the string.
92*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER   The Language or StringSize was NULL.
93*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER   The value referenced by StringSize was not zero and
94*f439973dSWarner Losh                                   String was NULL.
95*f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES    There were insufficient resources to complete the
96*f439973dSWarner Losh                                   request.
97*f439973dSWarner Losh 
98*f439973dSWarner Losh **/
99*f439973dSWarner Losh typedef
100*f439973dSWarner Losh EFI_STATUS
101*f439973dSWarner Losh (EFIAPI *EFI_HII_GET_STRING)(
102*f439973dSWarner Losh   IN CONST  EFI_HII_STRING_PROTOCOL *This,
103*f439973dSWarner Losh   IN CONST  CHAR8                   *Language,
104*f439973dSWarner Losh   IN        EFI_HII_HANDLE          PackageList,
105*f439973dSWarner Losh   IN        EFI_STRING_ID           StringId,
106*f439973dSWarner Losh   OUT       EFI_STRING              String,
107*f439973dSWarner Losh   IN OUT    UINTN                   *StringSize,
108*f439973dSWarner Losh   OUT       EFI_FONT_INFO           **StringFontInfo OPTIONAL
109*f439973dSWarner Losh   );
110*f439973dSWarner Losh 
111*f439973dSWarner Losh /**
112*f439973dSWarner Losh   This function updates the string specified by StringId in the specified PackageList to the text
113*f439973dSWarner Losh   specified by String and, optionally, the font information specified by StringFontInfo.
114*f439973dSWarner Losh 
115*f439973dSWarner Losh   @param  This                   A pointer to the EFI_HII_STRING_PROTOCOL instance.
116*f439973dSWarner Losh   @param  PackageList            The package list containing the strings.
117*f439973dSWarner Losh   @param  StringId               The string's id, which is unique within
118*f439973dSWarner Losh                                  PackageList.
119*f439973dSWarner Losh   @param  Language               Points to the language for the updated string.
120*f439973dSWarner Losh   @param  String                 Points to the new null-terminated string.
121*f439973dSWarner Losh   @param  StringFontInfo         Points to the string's font information or NULL if
122*f439973dSWarner Losh                                  the  string font information is not changed.
123*f439973dSWarner Losh 
124*f439973dSWarner Losh   @retval EFI_SUCCESS            The string was updated successfully.
125*f439973dSWarner Losh   @retval EFI_NOT_FOUND          The string specified by StringId is not in the
126*f439973dSWarner Losh                                  database.
127*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  The String or Language was NULL.
128*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  The specified StringFontInfo does not exist in
129*f439973dSWarner Losh                                  current database.
130*f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES   The system is out of resources to accomplish the
131*f439973dSWarner Losh                                  task.
132*f439973dSWarner Losh 
133*f439973dSWarner Losh **/
134*f439973dSWarner Losh typedef
135*f439973dSWarner Losh EFI_STATUS
136*f439973dSWarner Losh (EFIAPI *EFI_HII_SET_STRING)(
137*f439973dSWarner Losh   IN CONST  EFI_HII_STRING_PROTOCOL *This,
138*f439973dSWarner Losh   IN        EFI_HII_HANDLE          PackageList,
139*f439973dSWarner Losh   IN        EFI_STRING_ID           StringId,
140*f439973dSWarner Losh   IN CONST  CHAR8                   *Language,
141*f439973dSWarner Losh   IN        EFI_STRING              String,
142*f439973dSWarner Losh   IN CONST  EFI_FONT_INFO           *StringFontInfo OPTIONAL
143*f439973dSWarner Losh   );
144*f439973dSWarner Losh 
145*f439973dSWarner Losh /**
146*f439973dSWarner Losh   This function returns the list of supported languages.
147*f439973dSWarner Losh 
148*f439973dSWarner Losh   @param  This                   A pointer to the EFI_HII_STRING_PROTOCOL instance.
149*f439973dSWarner Losh   @param  PackageList            The package list to examine.
150*f439973dSWarner Losh   @param  Languages              Points to the buffer to hold the returned
151*f439973dSWarner Losh                                  null-terminated ASCII string.
152*f439973dSWarner Losh   @param  LanguagesSize          On entry, points to the size of the buffer pointed
153*f439973dSWarner Losh                                  to by Languages, in bytes. On return, points to
154*f439973dSWarner Losh                                  the length of Languages, in bytes.
155*f439973dSWarner Losh 
156*f439973dSWarner Losh   @retval EFI_SUCCESS            The languages were returned successfully.
157*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  The LanguagesSize was NULL.
158*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  The value referenced by LanguagesSize is not zero
159*f439973dSWarner Losh                                  and Languages is NULL.
160*f439973dSWarner Losh   @retval EFI_BUFFER_TOO_SMALL   The LanguagesSize is too small to hold the list of
161*f439973dSWarner Losh                                  supported languages. LanguageSize is updated to
162*f439973dSWarner Losh                                  contain the required size.
163*f439973dSWarner Losh   @retval EFI_NOT_FOUND          Could not find string package in specified
164*f439973dSWarner Losh                                  packagelist.
165*f439973dSWarner Losh 
166*f439973dSWarner Losh **/
167*f439973dSWarner Losh typedef
168*f439973dSWarner Losh EFI_STATUS
169*f439973dSWarner Losh (EFIAPI *EFI_HII_GET_LANGUAGES)(
170*f439973dSWarner Losh   IN CONST  EFI_HII_STRING_PROTOCOL   *This,
171*f439973dSWarner Losh   IN        EFI_HII_HANDLE            PackageList,
172*f439973dSWarner Losh   IN OUT    CHAR8                     *Languages,
173*f439973dSWarner Losh   IN OUT    UINTN                     *LanguagesSize
174*f439973dSWarner Losh   );
175*f439973dSWarner Losh 
176*f439973dSWarner Losh /**
177*f439973dSWarner Losh   Each string package has associated with it a single primary language and zero
178*f439973dSWarner Losh   or more secondary languages. This routine returns the secondary languages
179*f439973dSWarner Losh   associated with a package list.
180*f439973dSWarner Losh 
181*f439973dSWarner Losh   @param  This                   A pointer to the EFI_HII_STRING_PROTOCOL instance.
182*f439973dSWarner Losh   @param  PackageList            The package list to examine.
183*f439973dSWarner Losh   @param  PrimaryLanguage        Points to the null-terminated ASCII string that specifies
184*f439973dSWarner Losh                                  the primary language. Languages are specified in the
185*f439973dSWarner Losh                                  format specified in Appendix M of the UEFI 2.0 specification.
186*f439973dSWarner Losh   @param  SecondaryLanguages     Points to the buffer to hold the returned null-terminated
187*f439973dSWarner Losh                                  ASCII string that describes the list of
188*f439973dSWarner Losh                                  secondary languages for the specified
189*f439973dSWarner Losh                                  PrimaryLanguage. If there are no secondary
190*f439973dSWarner Losh                                  languages, the function returns successfully, but
191*f439973dSWarner Losh                                  this is set to NULL.
192*f439973dSWarner Losh   @param  SecondaryLanguagesSize On entry, points to the size of the buffer pointed
193*f439973dSWarner Losh                                  to by SecondaryLanguages, in bytes. On return,
194*f439973dSWarner Losh                                  points to the length of SecondaryLanguages in bytes.
195*f439973dSWarner Losh 
196*f439973dSWarner Losh   @retval EFI_SUCCESS            Secondary languages were correctly returned.
197*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  PrimaryLanguage or SecondaryLanguagesSize was NULL.
198*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER  The value referenced by SecondaryLanguagesSize is not
199*f439973dSWarner Losh                                  zero and SecondaryLanguages is NULL.
200*f439973dSWarner Losh   @retval EFI_BUFFER_TOO_SMALL   The buffer specified by SecondaryLanguagesSize is
201*f439973dSWarner Losh                                  too small to hold the returned information.
202*f439973dSWarner Losh                                  SecondaryLanguageSize is updated to hold the size of
203*f439973dSWarner Losh                                  the buffer required.
204*f439973dSWarner Losh   @retval EFI_INVALID_LANGUAGE   The language specified by PrimaryLanguage is not
205*f439973dSWarner Losh                                  present in the specified package list.
206*f439973dSWarner Losh   @retval EFI_NOT_FOUND          The specified PackageList is not in the Database.
207*f439973dSWarner Losh 
208*f439973dSWarner Losh **/
209*f439973dSWarner Losh typedef
210*f439973dSWarner Losh EFI_STATUS
211*f439973dSWarner Losh (EFIAPI *EFI_HII_GET_2ND_LANGUAGES)(
212*f439973dSWarner Losh   IN CONST  EFI_HII_STRING_PROTOCOL   *This,
213*f439973dSWarner Losh   IN        EFI_HII_HANDLE            PackageList,
214*f439973dSWarner Losh   IN CONST  CHAR8                     *PrimaryLanguage,
215*f439973dSWarner Losh   IN OUT    CHAR8                     *SecondaryLanguages,
216*f439973dSWarner Losh   IN OUT    UINTN                     *SecondaryLanguagesSize
217*f439973dSWarner Losh   );
218*f439973dSWarner Losh 
219*f439973dSWarner Losh ///
220*f439973dSWarner Losh /// Services to manipulate the string.
221*f439973dSWarner Losh ///
222*f439973dSWarner Losh struct _EFI_HII_STRING_PROTOCOL {
223*f439973dSWarner Losh   EFI_HII_NEW_STRING           NewString;
224*f439973dSWarner Losh   EFI_HII_GET_STRING           GetString;
225*f439973dSWarner Losh   EFI_HII_SET_STRING           SetString;
226*f439973dSWarner Losh   EFI_HII_GET_LANGUAGES        GetLanguages;
227*f439973dSWarner Losh   EFI_HII_GET_2ND_LANGUAGES    GetSecondaryLanguages;
228*f439973dSWarner Losh };
229*f439973dSWarner Losh 
230*f439973dSWarner Losh extern EFI_GUID  gEfiHiiStringProtocolGuid;
231*f439973dSWarner Losh 
232*f439973dSWarner Losh #endif
233