xref: /freebsd/sys/contrib/edk2/Include/Protocol/UnicodeCollation.h (revision f439973d6726c3be929c8fb3b1545b8b1744abc3)
1*f439973dSWarner Losh /** @file
2*f439973dSWarner Losh   Unicode Collation protocol that follows the UEFI 2.0 specification.
3*f439973dSWarner Losh   This protocol is used to allow code running in the boot services environment
4*f439973dSWarner Losh   to perform lexical comparison functions on Unicode strings for given languages.
5*f439973dSWarner Losh 
6*f439973dSWarner Losh Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
7*f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent
8*f439973dSWarner Losh 
9*f439973dSWarner Losh **/
10*f439973dSWarner Losh 
11*f439973dSWarner Losh #ifndef __UNICODE_COLLATION_H__
12*f439973dSWarner Losh #define __UNICODE_COLLATION_H__
13*f439973dSWarner Losh 
14*f439973dSWarner Losh #define EFI_UNICODE_COLLATION_PROTOCOL_GUID \
15*f439973dSWarner Losh   { \
16*f439973dSWarner Losh     0x1d85cd7f, 0xf43d, 0x11d2, {0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
17*f439973dSWarner Losh   }
18*f439973dSWarner Losh 
19*f439973dSWarner Losh #define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \
20*f439973dSWarner Losh   { \
21*f439973dSWarner Losh     0xa4c751fc, 0x23ae, 0x4c3e, {0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49 } \
22*f439973dSWarner Losh   }
23*f439973dSWarner Losh 
24*f439973dSWarner Losh typedef struct _EFI_UNICODE_COLLATION_PROTOCOL EFI_UNICODE_COLLATION_PROTOCOL;
25*f439973dSWarner Losh 
26*f439973dSWarner Losh ///
27*f439973dSWarner Losh /// Protocol GUID name defined in EFI1.1.
28*f439973dSWarner Losh ///
29*f439973dSWarner Losh #define UNICODE_COLLATION_PROTOCOL  EFI_UNICODE_COLLATION_PROTOCOL_GUID
30*f439973dSWarner Losh 
31*f439973dSWarner Losh ///
32*f439973dSWarner Losh /// Protocol defined in EFI1.1.
33*f439973dSWarner Losh ///
34*f439973dSWarner Losh typedef EFI_UNICODE_COLLATION_PROTOCOL UNICODE_COLLATION_INTERFACE;
35*f439973dSWarner Losh 
36*f439973dSWarner Losh ///
37*f439973dSWarner Losh /// Protocol data structures and defines
38*f439973dSWarner Losh ///
39*f439973dSWarner Losh #define EFI_UNICODE_BYTE_ORDER_MARK  (CHAR16) (0xfeff)
40*f439973dSWarner Losh 
41*f439973dSWarner Losh //
42*f439973dSWarner Losh // Protocol member functions
43*f439973dSWarner Losh //
44*f439973dSWarner Losh 
45*f439973dSWarner Losh /**
46*f439973dSWarner Losh   Performs a case-insensitive comparison of two Null-terminated strings.
47*f439973dSWarner Losh 
48*f439973dSWarner Losh   @param  This A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
49*f439973dSWarner Losh   @param  Str1 A pointer to a Null-terminated string.
50*f439973dSWarner Losh   @param  Str2 A pointer to a Null-terminated string.
51*f439973dSWarner Losh 
52*f439973dSWarner Losh   @retval 0   Str1 is equivalent to Str2.
53*f439973dSWarner Losh   @retval >0  Str1 is lexically greater than Str2.
54*f439973dSWarner Losh   @retval <0  Str1 is lexically less than Str2.
55*f439973dSWarner Losh 
56*f439973dSWarner Losh **/
57*f439973dSWarner Losh typedef
58*f439973dSWarner Losh INTN
59*f439973dSWarner Losh (EFIAPI *EFI_UNICODE_COLLATION_STRICOLL)(
60*f439973dSWarner Losh   IN EFI_UNICODE_COLLATION_PROTOCOL         *This,
61*f439973dSWarner Losh   IN CHAR16                                 *Str1,
62*f439973dSWarner Losh   IN CHAR16                                 *Str2
63*f439973dSWarner Losh   );
64*f439973dSWarner Losh 
65*f439973dSWarner Losh /**
66*f439973dSWarner Losh   Performs a case-insensitive comparison of a Null-terminated
67*f439973dSWarner Losh   pattern string and a Null-terminated string.
68*f439973dSWarner Losh 
69*f439973dSWarner Losh   @param  This    A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
70*f439973dSWarner Losh   @param  String  A pointer to a Null-terminated string.
71*f439973dSWarner Losh   @param  Pattern A pointer to a Null-terminated pattern string.
72*f439973dSWarner Losh 
73*f439973dSWarner Losh   @retval TRUE    Pattern was found in String.
74*f439973dSWarner Losh   @retval FALSE   Pattern was not found in String.
75*f439973dSWarner Losh 
76*f439973dSWarner Losh **/
77*f439973dSWarner Losh typedef
78*f439973dSWarner Losh BOOLEAN
79*f439973dSWarner Losh (EFIAPI *EFI_UNICODE_COLLATION_METAIMATCH)(
80*f439973dSWarner Losh   IN EFI_UNICODE_COLLATION_PROTOCOL         *This,
81*f439973dSWarner Losh   IN CHAR16                                 *String,
82*f439973dSWarner Losh   IN CHAR16                                 *Pattern
83*f439973dSWarner Losh   );
84*f439973dSWarner Losh 
85*f439973dSWarner Losh /**
86*f439973dSWarner Losh   Converts all the characters in a Null-terminated string to
87*f439973dSWarner Losh   lower case characters.
88*f439973dSWarner Losh 
89*f439973dSWarner Losh   @param  This   A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
90*f439973dSWarner Losh   @param  String A pointer to a Null-terminated string.
91*f439973dSWarner Losh 
92*f439973dSWarner Losh **/
93*f439973dSWarner Losh typedef
94*f439973dSWarner Losh VOID
95*f439973dSWarner Losh (EFIAPI *EFI_UNICODE_COLLATION_STRLWR)(
96*f439973dSWarner Losh   IN EFI_UNICODE_COLLATION_PROTOCOL         *This,
97*f439973dSWarner Losh   IN OUT CHAR16                             *Str
98*f439973dSWarner Losh   );
99*f439973dSWarner Losh 
100*f439973dSWarner Losh /**
101*f439973dSWarner Losh   Converts all the characters in a Null-terminated string to upper
102*f439973dSWarner Losh   case characters.
103*f439973dSWarner Losh 
104*f439973dSWarner Losh   @param  This   A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
105*f439973dSWarner Losh   @param  String A pointer to a Null-terminated string.
106*f439973dSWarner Losh 
107*f439973dSWarner Losh **/
108*f439973dSWarner Losh typedef
109*f439973dSWarner Losh VOID
110*f439973dSWarner Losh (EFIAPI *EFI_UNICODE_COLLATION_STRUPR)(
111*f439973dSWarner Losh   IN EFI_UNICODE_COLLATION_PROTOCOL         *This,
112*f439973dSWarner Losh   IN OUT CHAR16                             *Str
113*f439973dSWarner Losh   );
114*f439973dSWarner Losh 
115*f439973dSWarner Losh /**
116*f439973dSWarner Losh   Converts an 8.3 FAT file name in an OEM character set to a Null-terminated
117*f439973dSWarner Losh   string.
118*f439973dSWarner Losh 
119*f439973dSWarner Losh   @param  This    A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
120*f439973dSWarner Losh   @param  FatSize The size of the string Fat in bytes.
121*f439973dSWarner Losh   @param  Fat     A pointer to a Null-terminated string that contains an 8.3 file
122*f439973dSWarner Losh                   name using an 8-bit OEM character set.
123*f439973dSWarner Losh   @param  String  A pointer to a Null-terminated string. The string must
124*f439973dSWarner Losh                   be allocated in advance to hold FatSize characters.
125*f439973dSWarner Losh 
126*f439973dSWarner Losh **/
127*f439973dSWarner Losh typedef
128*f439973dSWarner Losh VOID
129*f439973dSWarner Losh (EFIAPI *EFI_UNICODE_COLLATION_FATTOSTR)(
130*f439973dSWarner Losh   IN EFI_UNICODE_COLLATION_PROTOCOL         *This,
131*f439973dSWarner Losh   IN UINTN                                  FatSize,
132*f439973dSWarner Losh   IN CHAR8                                  *Fat,
133*f439973dSWarner Losh   OUT CHAR16                                *String
134*f439973dSWarner Losh   );
135*f439973dSWarner Losh 
136*f439973dSWarner Losh /**
137*f439973dSWarner Losh   Converts a Null-terminated string to legal characters in a FAT
138*f439973dSWarner Losh   filename using an OEM character set.
139*f439973dSWarner Losh 
140*f439973dSWarner Losh   @param  This    A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
141*f439973dSWarner Losh   @param  String  A pointer to a Null-terminated string.
142*f439973dSWarner Losh   @param  FatSize The size of the string Fat in bytes.
143*f439973dSWarner Losh   @param  Fat     A pointer to a string that contains the converted version of
144*f439973dSWarner Losh                   String using legal FAT characters from an OEM character set.
145*f439973dSWarner Losh 
146*f439973dSWarner Losh   @retval TRUE    One or more conversions failed and were substituted with '_'
147*f439973dSWarner Losh   @retval FALSE   None of the conversions failed.
148*f439973dSWarner Losh 
149*f439973dSWarner Losh **/
150*f439973dSWarner Losh typedef
151*f439973dSWarner Losh BOOLEAN
152*f439973dSWarner Losh (EFIAPI *EFI_UNICODE_COLLATION_STRTOFAT)(
153*f439973dSWarner Losh   IN EFI_UNICODE_COLLATION_PROTOCOL         *This,
154*f439973dSWarner Losh   IN CHAR16                                 *String,
155*f439973dSWarner Losh   IN UINTN                                  FatSize,
156*f439973dSWarner Losh   OUT CHAR8                                 *Fat
157*f439973dSWarner Losh   );
158*f439973dSWarner Losh 
159*f439973dSWarner Losh ///
160*f439973dSWarner Losh /// The EFI_UNICODE_COLLATION_PROTOCOL is used to perform case-insensitive
161*f439973dSWarner Losh /// comparisons of strings.
162*f439973dSWarner Losh ///
163*f439973dSWarner Losh struct _EFI_UNICODE_COLLATION_PROTOCOL {
164*f439973dSWarner Losh   EFI_UNICODE_COLLATION_STRICOLL      StriColl;
165*f439973dSWarner Losh   EFI_UNICODE_COLLATION_METAIMATCH    MetaiMatch;
166*f439973dSWarner Losh   EFI_UNICODE_COLLATION_STRLWR        StrLwr;
167*f439973dSWarner Losh   EFI_UNICODE_COLLATION_STRUPR        StrUpr;
168*f439973dSWarner Losh 
169*f439973dSWarner Losh   //
170*f439973dSWarner Losh   // for supporting fat volumes
171*f439973dSWarner Losh   //
172*f439973dSWarner Losh   EFI_UNICODE_COLLATION_FATTOSTR      FatToStr;
173*f439973dSWarner Losh   EFI_UNICODE_COLLATION_STRTOFAT      StrToFat;
174*f439973dSWarner Losh 
175*f439973dSWarner Losh   ///
176*f439973dSWarner Losh   /// A Null-terminated ASCII string array that contains one or more language codes.
177*f439973dSWarner Losh   /// When this field is used for UnicodeCollation2, it is specified in RFC 4646 format.
178*f439973dSWarner Losh   /// When it is used for UnicodeCollation, it is specified in ISO 639-2 format.
179*f439973dSWarner Losh   ///
180*f439973dSWarner Losh   CHAR8                               *SupportedLanguages;
181*f439973dSWarner Losh };
182*f439973dSWarner Losh 
183*f439973dSWarner Losh extern EFI_GUID  gEfiUnicodeCollationProtocolGuid;
184*f439973dSWarner Losh extern EFI_GUID  gEfiUnicodeCollation2ProtocolGuid;
185*f439973dSWarner Losh 
186*f439973dSWarner Losh #endif
187