summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-20 14:17:24 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-20 14:17:24 +0000
commitd4775f2a4c46a1ff5cda0724079f25aa302b06bd (patch)
tree69293cc55b6884808520992f183d2d8f74eb0f09 /EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c
parent1a8802f76332b8c9374c9d392cbaff1dd229b765 (diff)
downloadedk2-platforms-d4775f2a4c46a1ff5cda0724079f25aa302b06bd.tar.xz
1) Add in fix to handle the case when a form is not related to a buffer storage.
2) Allocate Hii Handle from a bitfield array so Framework Hii Handle can be recycled. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5700 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c
new file mode 100644
index 0000000000..78eae0f1e0
--- /dev/null
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiHandle.c
@@ -0,0 +1,66 @@
+/**@file
+ Framework HII handle database allocation and deallocation functins.
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+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 "HiiHandle.h"
+
+//
+// FRAMEWORK_EFI_HII_HANDLE
+//
+UINT8 mHandle[1024 * 8] = {0};
+
+VOID
+InitHiiHandleDatabase (
+ VOID
+ )
+{
+ //
+ // FRAMEWORK_EFI_HII_HANDLE 0 is reserved.
+ // Set Bit 0 in mHandle[0] to 1.
+ //
+ mHandle[0] |= 1 << 0;
+}
+
+
+EFI_STATUS
+AllocateHiiHandle (
+ FRAMEWORK_EFI_HII_HANDLE *Handle
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof (mHandle) * 8; Index++) {
+ if ((mHandle[Index / 8] & (1 << (Index % 8))) == 0) {
+ mHandle[Index / 8] |= (1 << (Index % 8));
+ *Handle = (FRAMEWORK_EFI_HII_HANDLE) Index;
+ ASSERT (*Handle != 0);
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_OUT_OF_RESOURCES;
+}
+
+VOID
+FreeHiiHandle (
+ FRAMEWORK_EFI_HII_HANDLE Handle
+ )
+{
+ UINT16 Num;
+
+ Num = (UINT16) Handle;
+
+ ASSERT ((mHandle [Num / 8] & (~(1 << (Num % 8)))) != 0);
+ mHandle [Num / 8] &= (~(1 << (Num % 8)));
+}