2011-04-27 23:42:16 +02:00
|
|
|
/** @file
|
|
|
|
Constructor and Deconstructor functions for <wchar.h>.
|
|
|
|
|
|
|
|
Unless explicitly stated otherwise, the functions defined in this file order
|
|
|
|
two wide characters the same way as two integers of the underlying integer
|
|
|
|
type designated by wchar_t.
|
|
|
|
|
2011-06-28 04:34:10 +02:00
|
|
|
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
2011-04-27 23:42:16 +02:00
|
|
|
This program and the accompanying materials are licensed and made available under
|
|
|
|
the terms and conditions of the BSD License that accompanies this distribution.
|
|
|
|
The full text of the license may be found at
|
2011-06-28 04:34:10 +02:00
|
|
|
http://opensource.org/licenses/bsd-license.
|
2011-04-27 23:42:16 +02:00
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
**/
|
|
|
|
#include <Uefi.h>
|
2011-06-28 04:34:10 +02:00
|
|
|
#include <Library/DebugLib.h>
|
2011-04-27 23:42:16 +02:00
|
|
|
|
|
|
|
#include <LibConfig.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
/* Data initialized by the library constructor */
|
|
|
|
UINT8 *__wchar_bitmap = NULL;
|
|
|
|
UINTN __wchar_bitmap_size;
|
|
|
|
UINTN __wchar_bitmap_64;
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
__wchar_construct(
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
2011-06-28 04:34:10 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2011-04-27 23:42:16 +02:00
|
|
|
if( __wchar_bitmap == NULL) {
|
|
|
|
__wchar_bitmap_size = (WCHAR_MAX + 8) / 8U;
|
2011-06-28 04:34:10 +02:00
|
|
|
|
|
|
|
Status = SystemTable->BootServices->AllocatePool(
|
|
|
|
EfiBootServicesData, __wchar_bitmap_size, (VOID **)&__wchar_bitmap);
|
|
|
|
ASSERT(__wchar_bitmap != NULL);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
__wchar_bitmap = NULL;
|
|
|
|
EFIerrno = Status;
|
2011-04-27 23:42:16 +02:00
|
|
|
errno = ENOMEM;
|
|
|
|
return EFIerrno;
|
|
|
|
}
|
|
|
|
return RETURN_SUCCESS;
|
|
|
|
}
|
|
|
|
return RETURN_ALREADY_STARTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
__wchar_deconstruct(
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
2011-06-28 04:34:10 +02:00
|
|
|
EFI_STATUS Status = RETURN_SUCCESS;
|
|
|
|
|
2011-04-27 23:42:16 +02:00
|
|
|
if( __wchar_bitmap != NULL) {
|
2011-06-28 04:34:10 +02:00
|
|
|
Status = SystemTable->BootServices->FreePool( __wchar_bitmap);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2011-04-27 23:42:16 +02:00
|
|
|
__wchar_bitmap = NULL;
|
|
|
|
}
|
2011-06-28 04:34:10 +02:00
|
|
|
return Status;
|
2011-04-27 23:42:16 +02:00
|
|
|
}
|