2 HII Library implementation that uses DXE protocols and services.
4 Copyright (c) 2006, Intel Corporation<BR>
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
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.
16 #include <FrameworkDxe.h>
19 #include <Protocol/FrameworkHii.h>
21 #include <Library/HiiLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/MemoryAllocationLib.h>
26 EFI_HII_PROTOCOL
*gHiiProtocol
= NULL
;
29 The constructor function for HiiLibFramework library instance
31 The constructor function locates Hii protocol from protocol database.
32 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
34 @param ImageHandle The firmware allocated handle for the EFI image.
35 @param SystemTable A pointer to the EFI System Table.
37 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
42 HiiLibFrameworkConstructor (
43 IN EFI_HANDLE ImageHandle
,
44 IN EFI_SYSTEM_TABLE
*SystemTable
49 Status
= gBS
->LocateProtocol (
52 (VOID
**) &gHiiProtocol
54 ASSERT_EFI_ERROR (Status
);
61 This function allocates pool for an EFI_HII_PACKAGES structure
62 with enough space for the variable argument list of package pointers.
63 The allocated structure is initialized using NumberOfPackages, Guid,
64 and the variable length argument list of package pointers.
66 @param NumberOfPackages The number of HII packages to prepare.
67 @param Guid Package GUID.
69 @return The allocated and initialized packages.
73 InternalPreparePackages (
74 IN UINTN NumberOfPackages
,
75 IN CONST EFI_GUID
*Guid OPTIONAL
,
79 EFI_HII_PACKAGES
*HiiPackages
;
83 ASSERT (NumberOfPackages
> 0);
85 HiiPackages
= AllocateZeroPool (sizeof (EFI_HII_PACKAGES
) + NumberOfPackages
* sizeof (VOID
*));
86 ASSERT (HiiPackages
!= NULL
);
88 HiiPackages
->GuidId
= (EFI_GUID
*) Guid
;
89 HiiPackages
->NumberOfPackages
= NumberOfPackages
;
90 Package
= (VOID
**) (((UINT8
*) HiiPackages
) + sizeof (EFI_HII_PACKAGES
));
92 for (Index
= 0; Index
< NumberOfPackages
; Index
++) {
93 *Package
= VA_ARG (Args
, VOID
*);
103 PrepareAndCreateNewPackages (
104 IN UINTN NumberOfPackages
,
105 IN CONST EFI_GUID
*GuidId
,
106 OUT VOID
**HiiHandle
, //Framework is FRAMEWORK_HII_HANDLE; UEFI is EFI_HII_HANDLE;
107 // C:\D\Work\Tiano\Tiano_Main_Trunk\TIANO\Platform\IntelEpg\SR870BN4\MemorySubClassDriver\DualChannelDdr\MemorySubClass.c make use of this output value
112 EFI_HII_PACKAGES
*PackageList
;
114 FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
;
117 VA_START (Args
, HiiHandle
);
118 PackageList
= InternalPreparePackages (NumberOfPackages
, GuidId
, Args
);
121 Status
= gHiiProtocol
->NewPack (gHiiProtocol
, PackageList
, &FrameworkHiiHandle
);
122 *HiiHandle
= (VOID
*) (UINTN
) FrameworkHiiHandle
;