2 Module produce UC on top of UC2.
4 UEFI 2.1 specification supersedes Inte's EFI Specification 1.10.
5 UNICODE_COLLATION_PROTOCOL defined in Inte's EFI Specification 1.10 is replaced by
6 EFI_UNICODE_COLLATION_PROTOCOL in UEFI 2.1.
7 This module produces UC on top of UC2. This module is used on platform when both of
8 these two conditions are true:
9 1) EFI 1.10 module consuming UC present
10 2) And the rest of modules on the platform produce UC2
12 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
13 This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 #include <Protocol/UnicodeCollation.h>
26 #include <Library/BaseLib.h>
27 #include <Library/DebugLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/UefiLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/HiiLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/LanguageLib.h>
37 Performs a case-insensitive comparison of two Null-terminated strings.
39 @param This Protocol instance pointer.
40 @param Str1 A pointer to a Null-terminated string.
41 @param Str2 A pointer to a Null-terminated string.
43 @retval 0 Str1 is equivalent to Str2
44 @retval > 0 Str1 is lexically greater than Str2
45 @retval < 0 Str1 is lexically less than Str2
51 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
57 Converts all the characters in a Null-terminated string to
58 lower case characters.
60 @param This Protocol instance pointer.
61 @param Str A pointer to a Null-terminated string.
67 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
72 Converts all the characters in a Null-terminated string to upper
75 @param This Protocol instance pointer.
76 @param Str A pointer to a Null-terminated string.
82 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
87 Performs a case-insensitive comparison of a Null-terminated
88 pattern string and a Null-terminated string.
90 @param This Protocol instance pointer.
91 @param String A pointer to a Null-terminated string.
92 @param Pattern A pointer to a Null-terminated pattern string.
94 @retval TRUE Pattern was found in String.
95 @retval FALSE Pattern was not found in String.
101 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
107 Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.
109 @param This Protocol instance pointer.
110 @param FatSize The size of the string Fat in bytes.
111 @param Fat A pointer to a Null-terminated string that contains an 8.3 file
112 name using an OEM character set.
113 @param String A pointer to a Null-terminated string. The string must
114 be preallocated to hold FatSize characters.
120 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
127 Converts a Null-terminated string to legal characters in a FAT
128 filename using an OEM character set.
130 @param This Protocol instance pointer.
131 @param String A pointer to a Null-terminated string. The string must
132 be preallocated to hold FatSize characters.
133 @param FatSize The size of the string Fat in bytes.
134 @param Fat A pointer to a Null-terminated string that contains an 8.3 file
135 name using an OEM character set.
137 @retval TRUE Fat is a Long File Name
138 @retval FALSE Fat is an 8.3 file name
144 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
150 #define UC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('_', 'U', 'C', '_')
154 EFI_UNICODE_COLLATION_PROTOCOL Uc
;
155 EFI_UNICODE_COLLATION_PROTOCOL
*Uc2
;
158 #define UC_PRIVATE_DATA_FROM_THIS(a) CR (a, UC_PRIVATE_DATA, Uc, UC_PRIVATE_DATA_SIGNATURE)
161 // Firmware Volume Protocol template
163 EFI_EVENT mUcRegistration
;
165 UC_PRIVATE_DATA gUCPrivateDataTemplate
= {
166 UC_PRIVATE_DATA_SIGNATURE
,
183 This notification function is invoked when an instance of the
184 EFI_UNICODE_COLLATION_PROTOCOL2 is produced. It installs another instance of the
185 EFI_UNICODE_COLLATION_PROTOCOL on the same handle.
187 @param Event The event that occured
188 @param Context Context of event. Not used in this nofication function.
193 Uc2NotificationEvent (
201 UC_PRIVATE_DATA
*Private
;
202 EFI_UNICODE_COLLATION_PROTOCOL
*Uc2
;
205 BufferSize
= sizeof (Handle
);
206 Status
= gBS
->LocateHandle (
208 &gEfiUnicodeCollation2ProtocolGuid
,
213 if (EFI_ERROR (Status
)) {
215 // Exit Path of While Loop....
221 // Skip this handle if the Firmware Volume Protocol is already installed
223 Status
= gBS
->HandleProtocol (
225 &gEfiUnicodeCollationProtocolGuid
,
228 if (!EFI_ERROR (Status
)) {
233 // Allocate private data structure
235 Private
= AllocateCopyPool (sizeof (UC_PRIVATE_DATA
), &gUCPrivateDataTemplate
);
236 if (Private
== NULL
) {
241 // Retrieve the UC Protocol
243 Status
= gBS
->HandleProtocol (
245 &gEfiUnicodeCollation2ProtocolGuid
,
246 (VOID
**)&Private
->Uc2
248 ASSERT_EFI_ERROR (Status
);
251 // Fill in rest of private data structure
253 Private
->Uc
.SupportedLanguages
= ConvertLanguagesRfc4646ToIso639 (Private
->Uc2
->SupportedLanguages
);
255 if (Private
->Uc
.SupportedLanguages
!= NULL
) {
258 // Install Firmware Volume Protocol onto same handle
260 Status
= gBS
->InstallMultipleProtocolInterfaces (
262 &gEfiUnicodeCollationProtocolGuid
,
266 ASSERT_EFI_ERROR (Status
);
273 The user Entry Point for DXE driver. The user code starts with this function
274 as the real entry point for the image goes into a library that calls this
277 @param[in] ImageHandle The firmware allocated handle for the EFI image.
278 @param[in] SystemTable A pointer to the EFI System Table.
280 @retval EFI_SUCCESS The entry point is executed successfully.
281 @retval other Some error occurs when executing this entry point.
287 IN EFI_HANDLE ImageHandle
,
288 IN EFI_SYSTEM_TABLE
*SystemTable
291 EfiCreateProtocolNotifyEvent (
292 &gEfiUnicodeCollation2ProtocolGuid
,
294 Uc2NotificationEvent
,
303 Performs a case-insensitive comparison of two Null-terminated strings.
305 @param This Protocol instance pointer.
306 @param Str1 A pointer to a Null-terminated string.
307 @param Str2 A pointer to a Null-terminated string.
309 @retval 0 Str1 is equivalent to Str2
310 @retval > 0 Str1 is lexically greater than Str2
311 @retval < 0 Str1 is lexically less than Str2
317 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
322 UC_PRIVATE_DATA
*Private
;
324 Private
= UC_PRIVATE_DATA_FROM_THIS (This
);
326 return Private
->Uc2
->StriColl (Private
->Uc2
, Str1
, Str2
);
331 Converts all the characters in a Null-terminated string to
332 lower case characters.
334 @param This Protocol instance pointer.
335 @param Str A pointer to a Null-terminated string.
341 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
345 UC_PRIVATE_DATA
*Private
;
347 Private
= UC_PRIVATE_DATA_FROM_THIS (This
);
349 Private
->Uc2
->StrLwr (Private
->Uc2
, Str
);
354 Converts all the characters in a Null-terminated string to upper
357 @param This Protocol instance pointer.
358 @param Str A pointer to a Null-terminated string.
364 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
368 UC_PRIVATE_DATA
*Private
;
370 Private
= UC_PRIVATE_DATA_FROM_THIS (This
);
372 Private
->Uc2
->StrUpr (Private
->Uc2
, Str
);
376 Performs a case-insensitive comparison of a Null-terminated
377 pattern string and a Null-terminated string.
379 @param This Protocol instance pointer.
380 @param String A pointer to a Null-terminated string.
381 @param Pattern A pointer to a Null-terminated pattern string.
383 @retval TRUE Pattern was found in String.
384 @retval FALSE Pattern was not found in String.
390 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
395 UC_PRIVATE_DATA
*Private
;
397 Private
= UC_PRIVATE_DATA_FROM_THIS (This
);
399 return Private
->Uc2
->MetaiMatch (Private
->Uc2
, String
, Pattern
);
404 Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.
406 @param This Protocol instance pointer.
407 @param FatSize The size of the string Fat in bytes.
408 @param Fat A pointer to a Null-terminated string that contains an 8.3 file
409 name using an 8-bit OEM character set.
410 @param String A pointer to a Null-terminated string. The string must
411 be preallocated to hold FatSize characters.
417 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
423 UC_PRIVATE_DATA
*Private
;
425 Private
= UC_PRIVATE_DATA_FROM_THIS (This
);
427 Private
->Uc2
->FatToStr (Private
->Uc2
, FatSize
, Fat
, String
);
432 Converts a Null-terminated string to legal characters in a FAT
433 filename using an OEM character set.
435 @param This Protocol instance pointer.
436 @param String A pointer to a Null-terminated string. The string must
437 be preallocated to hold FatSize characters.
438 @param FatSize The size of the string Fat in bytes.
439 @param Fat A pointer to a Null-terminated string that contains an 8.3 file
440 name using an OEM character set.
442 @retval TRUE Fat is a Long File Name
443 @retval FALSE Fat is an 8.3 file name
449 IN EFI_UNICODE_COLLATION_PROTOCOL
*This
,
455 UC_PRIVATE_DATA
*Private
;
457 Private
= UC_PRIVATE_DATA_FROM_THIS (This
);
459 return Private
->Uc2
->StrToFat (Private
->Uc2
, String
, FatSize
, Fat
);