2010-03-01 04:26:19 +01:00
|
|
|
/** @file
|
2008-08-21 09:56:01 +02:00
|
|
|
This file is for functins related to assign and free Framework HII handle number.
|
2008-08-20 16:17:24 +02:00
|
|
|
|
2010-04-24 11:48:54 +02:00
|
|
|
Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
|
|
|
|
This program and the accompanying materials
|
2008-08-20 16:17:24 +02:00
|
|
|
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};
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Initialize the Framework Hii Handle database.
|
|
|
|
|
|
|
|
**/
|
2008-08-20 16:17:24 +02:00
|
|
|
VOID
|
|
|
|
InitHiiHandleDatabase (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// FRAMEWORK_EFI_HII_HANDLE 0 is reserved.
|
|
|
|
// Set Bit 0 in mHandle[0] to 1.
|
|
|
|
//
|
|
|
|
mHandle[0] |= 1 << 0;
|
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
Allocate a new Framework HII handle.
|
|
|
|
|
|
|
|
@param Handle Returns the new Framework HII Handle assigned.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS A new Framework HII Handle is assigned.
|
|
|
|
@retval EFI_OUT_OF_RESOURCE The Framework HII Handle database is depleted.
|
2008-08-20 16:17:24 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
**/
|
2008-08-20 16:17:24 +02:00
|
|
|
EFI_STATUS
|
|
|
|
AllocateHiiHandle (
|
2008-11-26 12:02:31 +01:00
|
|
|
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
|
2008-08-20 16:17:24 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
for (Index = 0; Index < sizeof (mHandle) * 8; Index++) {
|
|
|
|
if ((mHandle[Index / 8] & (1 << (Index % 8))) == 0) {
|
2008-11-10 14:27:09 +01:00
|
|
|
mHandle[Index / 8] = (UINT8) (mHandle[Index / 8] | (1 << (Index % 8)));
|
2008-08-20 16:17:24 +02:00
|
|
|
*Handle = (FRAMEWORK_EFI_HII_HANDLE) Index;
|
|
|
|
ASSERT (*Handle != 0);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
Free Framework HII handle.
|
|
|
|
|
|
|
|
@param Handle The Framework HII Handle to be freed.
|
|
|
|
|
|
|
|
**/
|
2008-08-20 16:17:24 +02:00
|
|
|
VOID
|
|
|
|
FreeHiiHandle (
|
2008-11-26 12:02:31 +01:00
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle
|
2008-08-20 16:17:24 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT16 Num;
|
|
|
|
|
|
|
|
Num = (UINT16) Handle;
|
|
|
|
|
2008-09-05 03:19:01 +02:00
|
|
|
ASSERT ((mHandle [Num / 8] & (1 << (Num % 8))) != 0);
|
2008-11-10 14:27:09 +01:00
|
|
|
mHandle [Num / 8] = (UINT8) (mHandle [Num / 8] & (~(1 << (Num % 8))));
|
2008-08-20 16:17:24 +02:00
|
|
|
}
|