• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2     Constructor and Deconstructor functions for <wchar.h>.
3 
4     Unless explicitly stated otherwise, the functions defined in this file order
5     two wide characters the same way as two integers of the underlying integer
6     type designated by wchar_t.
7 
8     Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
9     This program and the accompanying materials are licensed and made available under
10     the terms and conditions of the BSD License that accompanies this distribution.
11     The full text of the license may be found at
12     http://opensource.org/licenses/bsd-license.
13 
14     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 **/
17 #include  <Uefi.h>
18 #include  <Library/DebugLib.h>
19 
20 #include  <LibConfig.h>
21 
22 #include  <wchar.h>
23 
24 /* Data initialized by the library constructor */
25 UINT8 *__wchar_bitmap       = NULL;
26 UINTN  __wchar_bitmap_size;
27 UINTN  __wchar_bitmap_64;
28 
29 EFI_STATUS
30 EFIAPI
__wchar_construct(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)31 __wchar_construct(
32   IN EFI_HANDLE        ImageHandle,
33   IN EFI_SYSTEM_TABLE  *SystemTable
34   )
35 {
36   EFI_STATUS  Status;
37 
38   if( __wchar_bitmap == NULL) {
39     __wchar_bitmap_size = (WCHAR_MAX + 8) / 8U;
40 
41     Status  = SystemTable->BootServices->AllocatePool(
42                 EfiBootServicesData, __wchar_bitmap_size, (VOID **)&__wchar_bitmap);
43     ASSERT(__wchar_bitmap != NULL);
44     if (EFI_ERROR (Status)) {
45       __wchar_bitmap = NULL;
46       return Status;
47     }
48     return  RETURN_SUCCESS;
49   }
50   return RETURN_ALREADY_STARTED;
51 }
52 
53 EFI_STATUS
54 EFIAPI
__wchar_deconstruct(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)55 __wchar_deconstruct(
56   IN EFI_HANDLE        ImageHandle,
57   IN EFI_SYSTEM_TABLE  *SystemTable
58   )
59 {
60   EFI_STATUS    Status  = RETURN_SUCCESS;
61 
62   if( __wchar_bitmap != NULL) {
63     Status = SystemTable->BootServices->FreePool( __wchar_bitmap);
64     ASSERT_EFI_ERROR (Status);
65     __wchar_bitmap = NULL;
66   }
67   return Status;
68 }
69