2008-01-22 02:27:53 +01:00
|
|
|
/** @file
|
|
|
|
HII Library implementation that uses DXE protocols and services.
|
|
|
|
|
|
|
|
Copyright (c) 2006, Intel Corporation<BR>
|
|
|
|
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 <FrameworkDxe.h>
|
|
|
|
|
|
|
|
#include <Protocol/FrameworkHii.h>
|
|
|
|
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
|
|
|
|
EFI_HII_PROTOCOL *gHiiProtocol = NULL;
|
|
|
|
|
2008-04-09 11:07:37 +02:00
|
|
|
/**
|
|
|
|
The constructor function for HiiLibFramework library instance
|
|
|
|
|
|
|
|
The constructor function locates Hii protocol from protocol database.
|
|
|
|
It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
|
2008-01-22 02:27:53 +01:00
|
|
|
|
2008-04-09 11:07:37 +02:00
|
|
|
@param ImageHandle The firmware allocated handle for the EFI image.
|
|
|
|
@param SystemTable A pointer to the EFI System Table.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
|
|
|
|
|
|
|
**/
|
2008-01-22 02:27:53 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiLibFrameworkConstructor (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
2009-01-04 09:06:07 +01:00
|
|
|
EFI_STATUS Status;
|
2008-01-22 02:27:53 +01:00
|
|
|
|
|
|
|
Status = gBS->LocateProtocol (
|
|
|
|
&gEfiHiiProtocolGuid,
|
|
|
|
NULL,
|
2008-02-02 14:25:58 +01:00
|
|
|
(VOID **) &gHiiProtocol
|
2008-01-22 02:27:53 +01:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2009-01-04 09:06:07 +01:00
|
|
|
return Status;
|
2008-01-22 02:27:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function allocates pool for an EFI_HII_PACKAGES structure
|
|
|
|
with enough space for the variable argument list of package pointers.
|
|
|
|
The allocated structure is initialized using NumberOfPackages, Guid,
|
|
|
|
and the variable length argument list of package pointers.
|
|
|
|
|
|
|
|
@param NumberOfPackages The number of HII packages to prepare.
|
2008-04-22 07:52:01 +02:00
|
|
|
@param Guid Package GUID.
|
|
|
|
@param Args Package contents
|
2008-01-22 02:27:53 +01:00
|
|
|
|
2009-01-04 09:06:07 +01:00
|
|
|
@return The allocated and initialized packages.
|
2008-01-22 02:27:53 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_HII_PACKAGES *
|
|
|
|
InternalPreparePackages (
|
2009-01-04 09:06:07 +01:00
|
|
|
IN UINTN NumberOfPackages,
|
|
|
|
IN CONST EFI_GUID *Guid OPTIONAL,
|
|
|
|
IN VA_LIST Args
|
2008-01-22 02:27:53 +01:00
|
|
|
)
|
|
|
|
{
|
2009-01-04 09:06:07 +01:00
|
|
|
EFI_HII_PACKAGES *HiiPackages;
|
|
|
|
VOID **Package;
|
|
|
|
UINTN Index;
|
2008-01-22 02:27:53 +01:00
|
|
|
|
|
|
|
ASSERT (NumberOfPackages > 0);
|
|
|
|
|
2009-01-04 09:06:07 +01:00
|
|
|
HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
|
2008-01-22 02:27:53 +01:00
|
|
|
ASSERT (HiiPackages != NULL);
|
|
|
|
|
|
|
|
HiiPackages->GuidId = (EFI_GUID *) Guid;
|
|
|
|
HiiPackages->NumberOfPackages = NumberOfPackages;
|
|
|
|
Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
|
|
|
|
|
|
|
|
for (Index = 0; Index < NumberOfPackages; Index++) {
|
|
|
|
*Package = VA_ARG (Args, VOID *);
|
|
|
|
Package++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HiiPackages;
|
|
|
|
}
|
|
|
|
|
|
|
|
|