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