blob: 03815f49c5e7a95dd21c355c662e57ed3549600b [file] [log] [blame]
darylm5032aa62f22011-04-27 21:42:16 +00001/** @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
Daryl McDaniel7476ad72013-12-10 22:16:57 +00008 Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
darylm5032aa62f22011-04-27 21:42:16 +00009 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
darylm50353e1e5c2011-06-28 02:34:10 +000012 http://opensource.org/licenses/bsd-license.
darylm5032aa62f22011-04-27 21:42:16 +000013
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>
darylm50353e1e5c2011-06-28 02:34:10 +000018#include <Library/DebugLib.h>
darylm5032aa62f22011-04-27 21:42:16 +000019
20#include <LibConfig.h>
21
darylm5032aa62f22011-04-27 21:42:16 +000022#include <wchar.h>
23
24/* Data initialized by the library constructor */
25UINT8 *__wchar_bitmap = NULL;
26UINTN __wchar_bitmap_size;
27UINTN __wchar_bitmap_64;
28
29EFI_STATUS
30EFIAPI
31__wchar_construct(
32 IN EFI_HANDLE ImageHandle,
33 IN EFI_SYSTEM_TABLE *SystemTable
34 )
35{
darylm50353e1e5c2011-06-28 02:34:10 +000036 EFI_STATUS Status;
37
darylm5032aa62f22011-04-27 21:42:16 +000038 if( __wchar_bitmap == NULL) {
39 __wchar_bitmap_size = (WCHAR_MAX + 8) / 8U;
darylm50353e1e5c2011-06-28 02:34:10 +000040
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;
Daryl McDaniel6d16cca2013-12-10 21:42:59 +000046 return Status;
darylm5032aa62f22011-04-27 21:42:16 +000047 }
48 return RETURN_SUCCESS;
49 }
50 return RETURN_ALREADY_STARTED;
51}
52
53EFI_STATUS
54EFIAPI
55__wchar_deconstruct(
56 IN EFI_HANDLE ImageHandle,
57 IN EFI_SYSTEM_TABLE *SystemTable
58 )
59{
darylm50353e1e5c2011-06-28 02:34:10 +000060 EFI_STATUS Status = RETURN_SUCCESS;
61
darylm5032aa62f22011-04-27 21:42:16 +000062 if( __wchar_bitmap != NULL) {
darylm50353e1e5c2011-06-28 02:34:10 +000063 Status = SystemTable->BootServices->FreePool( __wchar_bitmap);
64 ASSERT_EFI_ERROR (Status);
darylm5032aa62f22011-04-27 21:42:16 +000065 __wchar_bitmap = NULL;
66 }
darylm50353e1e5c2011-06-28 02:34:10 +000067 return Status;
darylm5032aa62f22011-04-27 21:42:16 +000068}