diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-01-21 14:33:26 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-01-21 14:33:26 +0000 |
commit | dc7b4a5c436c3190fca6607e77711c3246d7290a (patch) | |
tree | ecbc58331518112534a47dafd85e4f6a6756799a /IntelFrameworkPkg/Library/FrameworkHiiLib | |
parent | c03fbe30c1870c9f235eb101cba15e25c1fdd005 (diff) | |
download | edk2-platforms-dc7b4a5c436c3190fca6607e77711c3246d7290a.tar.xz |
UEFI HII: Merge UEFI HII support changes from branch.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4597 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkPkg/Library/FrameworkHiiLib')
-rw-r--r-- | IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c | 278 | ||||
-rw-r--r-- | IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf | 12 |
2 files changed, 274 insertions, 16 deletions
diff --git a/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c index 913b471c5a..1b4c0dd79a 100644 --- a/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c +++ b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c @@ -17,10 +17,67 @@ #include <FrameworkDxe.h>
+#include <Protocol/FrameworkHii.h>
+
#include <Library/FrameworkHiiLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+
+EFI_HII_PROTOCOL *mHii = NULL;
+
+EFI_STATUS
+EFIAPI
+FrameworkHiiLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (
+ &gEfiHiiProtocolGuid,
+ NULL,
+ (VOID **) &mHii
+ );
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (mHii != NULL);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_HII_PACKAGES *
+InternalPreparePackages (
+ IN UINTN NumberOfPackages,
+ IN CONST EFI_GUID *Guid OPTIONAL,
+ VA_LIST Marker
+ )
+{
+ EFI_HII_PACKAGES *HiiPackages;
+ VOID **Package;
+ UINTN Index;
+
+ ASSERT (NumberOfPackages > 0);
+
+ HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
+ 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 (Marker, VOID *);
+ Package++;
+ }
+
+ return HiiPackages;
+
+}
+
/**
This function allocates pool for an EFI_HII_PACKAGES structure
@@ -43,28 +100,219 @@ PreparePackages ( )
{
VA_LIST Args;
- EFI_HII_PACKAGES *HiiPackages;
- VOID **Package;
- UINTN Index;
- ASSERT (NumberOfPackages > 0);
+ VA_START (Args, Guid);
- HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
- ASSERT (HiiPackages != NULL);
+ return InternalPreparePackages (NumberOfPackages, Guid, Args);
+}
- HiiPackages->GuidId = (EFI_GUID *) Guid;
- HiiPackages->NumberOfPackages = NumberOfPackages;
- Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
- VA_START (Args, Guid);
+/**
+ This function allocates pool for an EFI_HII_PACKAGE_LIST structure
+ with additional space that is big enough to host all packages described by the variable
+ argument list of package pointers. The allocated structure is initialized using NumberOfPackages,
+ GuidId, and the variable length argument list of package pointers.
- for (Index = 0; Index < NumberOfPackages; Index++) {
- *Package = VA_ARG (Args, VOID *);
- Package++;
+ Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The
+ Handle to the newly registered Package List is returned throught HiiHandle.
+
+ @param NumberOfPackages The number of HII packages to register.
+ @param GuidId Package List GUID ID.
+ @param HiiHandle The ID used to retrieve the Package List later.
+ @param ... The variable argument list describing all HII Package.
+
+ @return
+ The allocated and initialized packages.
+
+**/
+
+EFI_STATUS
+EFIAPI
+HiiLibAddPackagesToHiiDatabase (
+ IN UINTN NumberOfPackages,
+ IN CONST EFI_GUID *GuidId,
+ IN EFI_HANDLE DriverHandle, OPTIONAL
+ OUT EFI_HII_HANDLE *HiiHandle, OPTIONAL
+ ...
+ )
+{
+ VA_LIST Args;
+ EFI_HII_PACKAGES *FrameworkHiiPacages;
+ FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle;
+ EFI_STATUS Status;
+
+
+ VA_START (Args, HiiHandle);
+ FrameworkHiiPacages = InternalPreparePackages (NumberOfPackages, GuidId, Args);
+
+ Status = mHii->NewPack (mHii, FrameworkHiiPacages, &FrameworkHiiHandle);
+ if (HiiHandle != NULL) {
+ if (EFI_ERROR (Status)) {
+ *HiiHandle = NULL;
+ } else {
+ *HiiHandle = (EFI_HII_HANDLE) (UINTN) FrameworkHiiHandle;
+ }
}
- VA_END (Args);
+ FreePool (FrameworkHiiPacages);
+
+ return Status;
+}
- return HiiPackages;
+EFI_STATUS
+EFIAPI
+HiiLibAddFontPackageToHiiDatabase (
+ IN UINTN FontSize,
+ IN CONST UINT8 *FontBinary,
+ IN CONST EFI_GUID *GuidId,
+ OUT EFI_HII_HANDLE *HiiHandle OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_FONT_PACK *FontPack;
+ UINT8 *Location;
+
+ FontPack = AllocateZeroPool (sizeof (EFI_HII_FONT_PACK) + FontSize);
+ ASSERT (FontPack != NULL);
+
+ FontPack->Header.Length = (UINT32) (sizeof (EFI_HII_FONT_PACK) + FontSize);
+ FontPack->Header.Type = EFI_HII_FONT;
+ FontPack->NumberOfNarrowGlyphs = (UINT16) (FontSize / sizeof (EFI_NARROW_GLYPH));
+
+ Location = (UINT8 *) (&FontPack->NumberOfWideGlyphs + sizeof (UINT8));
+ CopyMem (Location, FontBinary, FontSize);
+
+
+ //
+ // Register our Fonts into the global database
+ //
+ Status = HiiLibAddPackagesToHiiDatabase (1, NULL, HiiHandle, NULL, FontPack);
+ //
+ // Free the font database
+ //
+ FreePool (FontPack);
+ return Status;
}
+
+EFI_STATUS
+EFIAPI
+HiiLibRemovePackagesFromHiiDatabase (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+{
+ return mHii->RemovePack (mHii, (FRAMEWORK_EFI_HII_HANDLE) (UINTN) HiiHandle);
+}
+
+
+/**
+ This function adds the string into String Package of each language.
+
+ @param PackageList Handle of the package list where this string will
+ be added.
+ @param StringId On return, contains the new strings id, which is
+ unique within PackageList.
+ @param String Points to the new null-terminated string.
+
+ @retval EFI_SUCCESS The new string was added successfully.
+ @retval EFI_NOT_FOUND The specified PackageList could not be found in
+ database.
+ @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.
+ @retval EFI_INVALID_PARAMETER String is NULL or StringId is NULL is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiLibCreateString (
+ IN EFI_HII_HANDLE PackageList,
+ OUT EFI_STRING_ID *StringId,
+ IN CONST EFI_STRING String
+ )
+{
+ FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle;
+ EFI_STATUS Status;
+
+ FrameworkHiiHandle = (FRAMEWORK_EFI_HII_HANDLE) (UINTN) PackageList;
+ Status = mHii->NewString (
+ mHii,
+ NULL,
+ FrameworkHiiHandle,
+ StringId,
+ String
+ );
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+HiiLibUpdateString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ IN CONST EFI_STRING String
+ )
+{
+ FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle;
+ EFI_STATUS Status;
+
+ FrameworkHiiHandle = (FRAMEWORK_EFI_HII_HANDLE) (UINTN) PackageList;
+ Status = mHii->NewString (
+ mHii,
+ NULL,
+ FrameworkHiiHandle,
+ &StringId,
+ String
+ );
+
+ return Status;
+}
+
+//
+// Just use the UEFI prototype
+//
+EFI_STATUS
+EFIAPI
+HiiLibGetStringFromGuidId (
+ IN EFI_GUID *ProducerGuid,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+{
+ return EFI_SUCCESS;
+}
+
+//
+// Just use the UEFI prototype
+//
+EFI_STATUS
+EFIAPI
+HiiLibGetStringFromHandle (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+{
+ return EFI_SUCCESS;
+}
+
+//
+// Just use the UEFI prototype
+//
+EFI_STATUS
+EFIAPI
+HiiLibCreateHiiDriverHandle (
+ OUT EFI_HANDLE *DriverHandle
+ )
+{
+ //
+ // Driver
+ // This implementation does nothing as DriverHandle concept only
+ // applies to UEFI HII specification.
+ //
+
+ *DriverHandle = NULL;
+
+ return EFI_SUCCESS;
+}
+
diff --git a/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf index 98ee9f9ae2..d38275dd83 100644 --- a/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf +++ b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf @@ -20,10 +20,12 @@ FILE_GUID = 1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = FrameworkHiiLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+ LIBRARY_CLASS = FrameworkHiiLib,HiiLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
+ CONSTRUCTOR = FrameworkHiiLibConstructor
+
#
# The following information is for reference only and not required by the build tools.
@@ -41,4 +43,12 @@ [LibraryClasses]
MemoryAllocationLib
DebugLib
+ BaseMemoryLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiHiiProtocolGuid # ALWAYS_CONSUMED
+
+[Depex]
+ gEfiHiiProtocolGuid # ALWAYS_CONSUMED
|