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.
18 #include <FrameworkDxe.h>
20 #include <Protocol/FrameworkHii.h>
23 #include <Library/FrameworkHiiLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/MemoryAllocationLib.h>
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <Library/BaseMemoryLib.h>
29 EFI_HII_PROTOCOL
*mHii
= NULL
;
33 FrameworkHiiLibConstructor (
34 IN EFI_HANDLE ImageHandle
,
35 IN EFI_SYSTEM_TABLE
*SystemTable
40 Status
= gBS
->LocateProtocol (
45 ASSERT_EFI_ERROR (Status
);
46 ASSERT (mHii
!= NULL
);
53 InternalPreparePackages (
54 IN UINTN NumberOfPackages
,
55 IN CONST EFI_GUID
*Guid OPTIONAL
,
59 EFI_HII_PACKAGES
*HiiPackages
;
63 ASSERT (NumberOfPackages
> 0);
65 HiiPackages
= AllocateZeroPool (sizeof (EFI_HII_PACKAGES
) + NumberOfPackages
* sizeof (VOID
*));
66 ASSERT (HiiPackages
!= NULL
);
68 HiiPackages
->GuidId
= (EFI_GUID
*) Guid
;
69 HiiPackages
->NumberOfPackages
= NumberOfPackages
;
70 Package
= (VOID
**) (((UINT8
*) HiiPackages
) + sizeof (EFI_HII_PACKAGES
));
72 for (Index
= 0; Index
< NumberOfPackages
; Index
++) {
73 *Package
= VA_ARG (Marker
, VOID
*);
83 This function allocates pool for an EFI_HII_PACKAGES structure
84 with enough space for the variable argument list of package pointers.
85 The allocated structure is initialized using NumberOfPackages, Guid,
86 and the variable length argument list of package pointers.
88 @param NumberOfPackages The number of HII packages to prepare.
89 @param Guid Package GUID.
91 @return The allocated and initialized packages.
97 IN UINTN NumberOfPackages
,
98 IN CONST EFI_GUID
*Guid OPTIONAL
,
104 VA_START (Args
, Guid
);
106 return InternalPreparePackages (NumberOfPackages
, Guid
, Args
);
111 This function allocates pool for an EFI_HII_PACKAGE_LIST structure
112 with additional space that is big enough to host all packages described by the variable
113 argument list of package pointers. The allocated structure is initialized using NumberOfPackages,
114 GuidId, and the variable length argument list of package pointers.
116 Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The
117 Handle to the newly registered Package List is returned throught HiiHandle.
119 @param NumberOfPackages The number of HII packages to register.
120 @param GuidId Package List GUID ID.
121 @param HiiHandle The ID used to retrieve the Package List later.
122 @param ... The variable argument list describing all HII Package.
125 The allocated and initialized packages.
132 IN UINTN NumberOfPackages
,
133 IN CONST EFI_GUID
*GuidId
,
134 IN EFI_HANDLE DriverHandle
, OPTIONAL
135 OUT EFI_HII_HANDLE
*HiiHandle
, OPTIONAL
140 EFI_HII_PACKAGES
*FrameworkHiiPacages
;
141 FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
;
145 VA_START (Args
, HiiHandle
);
146 FrameworkHiiPacages
= InternalPreparePackages (NumberOfPackages
, GuidId
, Args
);
148 Status
= mHii
->NewPack (mHii
, FrameworkHiiPacages
, &FrameworkHiiHandle
);
149 if (HiiHandle
!= NULL
) {
150 if (EFI_ERROR (Status
)) {
153 *HiiHandle
= (EFI_HII_HANDLE
) (UINTN
) FrameworkHiiHandle
;
157 FreePool (FrameworkHiiPacages
);
164 HiiLibRemovePackages (
165 IN EFI_HII_HANDLE HiiHandle
170 Status
= mHii
->RemovePack (mHii
, (FRAMEWORK_EFI_HII_HANDLE
) (UINTN
) HiiHandle
);
171 ASSERT_EFI_ERROR (Status
);
176 This function adds the string into String Package of each language.
178 @param PackageList Handle of the package list where this string will
180 @param StringId On return, contains the new strings id, which is
181 unique within PackageList.
182 @param String Points to the new null-terminated string.
184 @retval EFI_SUCCESS The new string was added successfully.
185 @retval EFI_NOT_FOUND The specified PackageList could not be found in
187 @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.
188 @retval EFI_INVALID_PARAMETER String is NULL or StringId is NULL is NULL.
194 IN EFI_HII_HANDLE PackageList
,
195 OUT EFI_STRING_ID
*StringId
,
196 IN CONST EFI_STRING String
199 FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
;
202 FrameworkHiiHandle
= (FRAMEWORK_EFI_HII_HANDLE
) (UINTN
) PackageList
;
203 Status
= mHii
->NewString (
218 IN EFI_HII_HANDLE PackageList
,
219 IN EFI_STRING_ID StringId
,
220 IN CONST EFI_STRING String
223 FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
;
226 FrameworkHiiHandle
= (FRAMEWORK_EFI_HII_HANDLE
) (UINTN
) PackageList
;
227 Status
= mHii
->NewString (
239 // Just use the UEFI prototype
243 HiiLibGetStringFromToken (
244 IN EFI_GUID
*ProducerGuid
,
245 IN EFI_STRING_ID StringId
,
246 OUT EFI_STRING
*String
253 // Just use the UEFI prototype
257 HiiLibGetStringFromHandle (
258 IN EFI_HII_HANDLE PackageList
,
259 IN EFI_STRING_ID StringId
,
260 OUT EFI_STRING
*String
267 // Just use the UEFI prototype
271 HiiLibCreateHiiDriverHandle (
272 OUT EFI_HANDLE
*DriverHandle
277 // This implementation does nothing as DriverHandle concept only
278 // applies to UEFI HII specification.
281 *DriverHandle
= NULL
;