]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c
clean up for IPF ICC tool chain.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiToUefiHiiThunk / HiiHandle.c
1 /**@file
2 This file is for functins related to assign and free Framework HII handle number.
3
4 Copyright (c) 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15
16 #include "HiiHandle.h"
17
18 //
19 // FRAMEWORK_EFI_HII_HANDLE
20 //
21 UINT8 mHandle[1024 * 8] = {0};
22
23 VOID
24 InitHiiHandleDatabase (
25 VOID
26 )
27 {
28 //
29 // FRAMEWORK_EFI_HII_HANDLE 0 is reserved.
30 // Set Bit 0 in mHandle[0] to 1.
31 //
32 mHandle[0] |= 1 << 0;
33 }
34
35
36 EFI_STATUS
37 AllocateHiiHandle (
38 FRAMEWORK_EFI_HII_HANDLE *Handle
39 )
40 {
41 UINTN Index;
42
43 for (Index = 0; Index < sizeof (mHandle) * 8; Index++) {
44 if ((mHandle[Index / 8] & (1 << (Index % 8))) == 0) {
45 mHandle[Index / 8] = (UINT8) (mHandle[Index / 8] | (1 << (Index % 8)));
46 *Handle = (FRAMEWORK_EFI_HII_HANDLE) Index;
47 ASSERT (*Handle != 0);
48 return EFI_SUCCESS;
49 }
50 }
51
52 return EFI_OUT_OF_RESOURCES;
53 }
54
55 VOID
56 FreeHiiHandle (
57 FRAMEWORK_EFI_HII_HANDLE Handle
58 )
59 {
60 UINT16 Num;
61
62 Num = (UINT16) Handle;
63
64 ASSERT ((mHandle [Num / 8] & (1 << (Num % 8))) != 0);
65 mHandle [Num / 8] = (UINT8) (mHandle [Num / 8] & (~(1 << (Num % 8))));
66 }