diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-02-02 13:11:49 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-02-02 13:11:49 +0000 |
commit | e52c5a9fdcc1663f98e1a1090c424c1606990650 (patch) | |
tree | 6bba76e4eed7ddbccb4c1d12258d8a86db81c797 /MdePkg | |
parent | 59ab6d02a98545df6b35178cce796af7ad56d0b9 (diff) | |
download | edk2-e52c5a9fdcc1663f98e1a1090c424c1606990650.tar.gz edk2-e52c5a9fdcc1663f98e1a1090c424c1606990650.tar.bz2 edk2-e52c5a9fdcc1663f98e1a1090c424c1606990650.zip |
1) Cleanup HiiLib, IfrSupportLib.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4661 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r-- | MdePkg/Include/Library/HiiLib.h | 365 | ||||
-rw-r--r-- | MdePkg/Include/Library/IfrSupportLib.h | 998 | ||||
-rw-r--r-- | MdePkg/Include/Uefi/UefiInternalFormRepresentation.h | 10 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/HiiLanguage.c | 136 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/HiiLib.c | 715 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/HiiLib.inf | 7 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/HiiString.c | 460 | ||||
-rw-r--r-- | MdePkg/Library/HiiLib/InternalHiiLib.h | 28 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/IfrSupportLib.inf | 74 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/IfrSupportLib.msa | 74 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/R8Lib.c | 241 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/R8Lib.h | 93 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/UefiIfrCommon.c | 47 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/UefiIfrForm.c | 759 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/UefiIfrLibraryInternal.h | 47 | ||||
-rw-r--r-- | MdePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c | 618 | ||||
-rw-r--r-- | MdePkg/MdePkg.dsc | 1 |
17 files changed, 3375 insertions, 1298 deletions
diff --git a/MdePkg/Include/Library/HiiLib.h b/MdePkg/Include/Library/HiiLib.h index dc557af31b..de6267bcf1 100644 --- a/MdePkg/Include/Library/HiiLib.h +++ b/MdePkg/Include/Library/HiiLib.h @@ -1,7 +1,7 @@ /** @file
Public include file for the HII Library
- Copyright (c) 2006, Intel Corporation
+ Copyright (c) 2007 - 2008, Intel Corporation
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
@@ -15,14 +15,37 @@ #ifndef __HII_LIB_H__
#define __HII_LIB_H__
-//#include <PiDxe.h>
-
//
// Limited buffer size recommended by RFC4646 (4.3. Length Considerations)
// (42 characters plus a NULL terminator)
//
#define RFC_3066_ENTRY_SIZE (42 + 1)
+#define ISO_639_2_ENTRY_SIZE 3
+
+/**
+ Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
+
+ If GuidId is NULL, then ASSERT.
+ If not enough resource to complete the operation, then ASSERT.
+
+ @param NumberOfPackages Number of packages.
+ @param GuidId Package GUID.
+ @param ... Variable argument list for packages to be assembled.
+
+ @return EFI_HII_PACKAGE_LIST_HEADER Pointer of EFI_HII_PACKAGE_LIST_HEADER. The function will ASSERT if system has
+ not enough resource to complete the operation.
+
+**/
+EFI_HII_PACKAGE_LIST_HEADER *
+EFIAPI
+HiiLibPreparePackageList (
+ IN UINTN NumberOfPackages,
+ IN CONST EFI_GUID *GuidId,
+ ...
+ )
+;
+
/**
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
@@ -32,23 +55,28 @@ 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.
+ If HiiHandle is NULL, then ASSERT.
+
@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 EFI_HANDLE Optional. If not NULL, the DriverHandle on which an instance of DEVICE_PATH_PROTOCOL is installed.
+ This DriverHandle uniquely defines the device that the added packages are associated with.
+ @param HiiHandle On output, the HiiHandle is update with the handle which can be used to retrieve the Package
+ List later. If the functions failed to add the package to the default HII database, this value will
+ be set to NULL.
@param ... The variable argument list describing all HII Package.
- @return
- The allocated and initialized packages.
+ @return EFI_SUCCESS If the packages are successfully added to the default HII database.
+ @return EFI_OUT_OF_RESOURCE Not enough resource to complete the operation.
**/
-
EFI_STATUS
EFIAPI
-HiiLibAddPackagesToHiiDatabase (
+HiiLibAddPackages (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
IN EFI_HANDLE DriverHandle, OPTIONAL
- OUT EFI_HII_HANDLE *HiiHandle, OPTIONAL
+ OUT EFI_HII_HANDLE *HiiHandle,
...
)
;
@@ -63,32 +91,46 @@ HiiLibAddFontPackageToHiiDatabase ( )
;
-EFI_STATUS
+/**
+ Removes a package list from the default HII database.
+
+ If HiiHandle is NULL, then ASSERT.
+ If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.
+
+ @param HiiHandle The handle that was previously registered to the data base that is requested for removal.
+ List later.
+
+ @return VOID
+
+**/
+VOID
EFIAPI
-HiiLibRemovePackagesFromHiiDatabase (
+HiiLibRemovePackages (
IN EFI_HII_HANDLE HiiHandle
)
;
/**
- This function adds the string into String Package of each language.
+ This function adds the string into String Package of each language
+ supported by the package list.
+
+ If String is NULL, then ASSERT.
+ If StringId is NULL, the ASSERT.
+ If PackageList could not be found in the default HII database, then ASSERT.
@param PackageList Handle of the package list where this string will
- be added.
+ be added.
@param StringId On return, contains the new strings id, which is
- unique within PackageList.
+ 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_SUCCESS The new string was added successfully.
@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 (
+HiiLibNewString (
IN EFI_HII_HANDLE PackageList,
OUT EFI_STRING_ID *StringId,
IN CONST EFI_STRING String
@@ -96,84 +138,301 @@ HiiLibCreateString ( ;
/**
- This function update the specified string in String Package of each language.
+ This function update the specified string in String Package of each language
+ supported by the package list.
+
+ If String is NULL, then ASSERT.
+ If PackageList could not be found in the default HII database, then ASSERT.
+ If StringId is not found in PackageList, then ASSERT.
@param PackageList Handle of the package list where this string will
- be added.
+ be added.
@param StringId Ths String Id to be updated.
@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
-HiiLibUpdateString (
+HiiLibSetString (
IN EFI_HII_HANDLE PackageList,
IN EFI_STRING_ID StringId,
IN CONST EFI_STRING String
)
;
+/**
+ This function try to retrieve string from String package of current language.
+ If fails, it try to retrieve string from String package of first language it support.
+
+ If String is NULL, then ASSERT.
+ If StringSize is NULL, then ASSERT.
+ If PackageList could not be found in the default HII database, then ASSERT.
+ If StringId is not found in PackageList, then ASSERT.
+
+ @param PackageList The package list in the HII database to search for
+ the specified string.
+ @param StringId The string's id, which is unique within
+ PackageList.
+ @param String Points to the new null-terminated string.
+ @param StringSize On entry, points to the size of the buffer pointed
+ to by String, in bytes. On return, points to the
+ length of the string, in bytes.
+
+ @retval EFI_SUCCESS The string was returned successfully.
+ @retval EFI_NOT_FOUND The string specified by StringId is not available.
+ @retval EFI_BUFFER_TOO_SMALL The buffer specified by StringLength is too small
+ to hold the string.
+ @retval EFI_INVALID_PARAMETER The String or StringSize was NULL.
+**/
-//
-// Just use the UEFI prototype
-//
EFI_STATUS
EFIAPI
-HiiLibGetStringFromGuidId (
- IN EFI_GUID *ProducerGuid,
+HiiLibGetString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING String,
+ IN OUT UINTN *StringSize
+ )
+;
+
+/**
+ Get string specified by StringId form the HiiHandle. The caller
+ is responsible to free the *String.
+
+ If String is NULL, then ASSERT.
+ If HiiHandle could not be found in the default HII database, then ASSERT.
+ If StringId is not found in PackageList, then ASSERT.
+
+ @param HiiHandle The HII handle of package list.
+ @param StringId The String ID.
+ @param String The output string.
+
+ @retval EFI_NOT_FOUND String is not found.
+ @retval EFI_SUCCESS Operation is successful.
+ @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
+ @retval EFI_INVALID_PARAMETER The String is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiLibGetStringFromHandle (
+ IN EFI_HII_HANDLE HiiHandle,
IN EFI_STRING_ID StringId,
OUT EFI_STRING *String
)
;
-//
-// This function is Implementation Specifc. HII_VENDOR_DEVICE_PATH
-// This should be moved to MdeModulepkg.
-//
+/**
+ Get the string given the StringId and String package Producer's Guid. The caller
+ is responsible to free the *String.
+
+ If PackageList with the matching ProducerGuid is not found, then ASSERT.
+ If PackageList with the matching ProducerGuid is found but no String is
+ specified by StringId is found, then ASSERT.
+
+ @param ProducerGuid The Guid of String package list.
+ @param StringId The String ID.
+ @param String The output string.
+
+ @retval EFI_SUCCESS Operation is successful.
+ @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
+
+**/
EFI_STATUS
EFIAPI
-HiiLibCreateHiiDriverHandle (
- OUT EFI_HANDLE *DriverHandle
+HiiLibGetStringFromToken (
+ IN EFI_GUID *ProducerGuid,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
)
;
+/**
+ Determines the handles that are currently active in the database.
+ It's the caller's responsibility to free handle buffer.
+
+ If HandleBufferLength is NULL, then ASSERT.
+ If HiiHandleBuffer is NULL, then ASSERT.
+
+ @param HiiDatabase A pointer to the EFI_HII_DATABASE_PROTOCOL
+ instance.
+ @param HandleBufferLength On input, a pointer to the length of the handle
+ buffer. On output, the length of the handle buffer
+ that is required for the handles found.
+ @param HiiHandleBuffer Pointer to an array of Hii Handles returned.
+
+ @retval EFI_SUCCESS Get an array of Hii Handles successfully.
+
+**/
EFI_STATUS
EFIAPI
-HiiLibDestroyHiiDriverHandle (
- IN EFI_HANDLE DriverHandle
+HiiLibGetHiiHandles (
+ IN OUT UINTN *HandleBufferLength,
+ OUT EFI_HII_HANDLE **HiiHandleBuffer
)
;
+/**
+ Extract Hii package list GUID for given HII handle.
+
+ If HiiHandle could not be found in the default HII database, then ASSERT.
+ If Guid is NULL, then ASSERT.
+
+ @param HiiHandle Hii handle
+ @param Guid Package list GUID
+ @retval EFI_SUCCESS Successfully extract GUID from Hii database.
+
+**/
EFI_STATUS
-HiiLibExtractClassFromHiiHandle (
+EFIAPI
+HiiLibExtractGuidFromHiiHandle (
IN EFI_HII_HANDLE Handle,
- OUT UINT16 *Class,
- OUT EFI_STRING_ID *FormSetTitle,
- OUT EFI_STRING_ID *FormSetHelp
+ OUT EFI_GUID *Guid
+ )
+;
+
+/**
+ Find HII Handle in the default HII database associated with given Device Path.
+
+ If DevicePath is NULL, then ASSERT.
+
+ @param DevicePath Device Path associated with the HII package list
+ handle.
+
+ @retval Handle HII package list Handle associated with the Device
+ Path.
+ @retval NULL Hii Package list handle is not found.
+
+**/
+EFI_HII_HANDLE
+EFIAPI
+HiiLibDevicePathToHiiHandle (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+;
+
+
+/**
+ Determine what is the current language setting. The space reserved for Lang
+ must be at least RFC_3066_ENTRY_SIZE bytes;
+
+ If Lang is NULL, then ASSERT.
+
+ @param Lang Pointer of system language. Lang will always be filled with
+ a valid RFC 3066 language string. If "PlatformLang" is not
+ set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang
+ is returned.
+
+ @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.
+ @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiLibGetCurrentLanguage (
+ OUT CHAR8 *Lang
)
-/*++
+;
-Routine Description:
- Extract formset class for given HII handle.
+/**
+ Get next language from language code list (with separator ';').
-Arguments:
- HiiHandle - Hii handle
- Class - Class of the formset
- FormSetTitle - Formset title string
- FormSetHelp - Formset help string
+ If LangCode is NULL, then ASSERT.
+ If Lang is NULL, then ASSERT.
-Returns:
- EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+ @param LangCode On input: point to first language in the list. On
+ output: point to next language in the list, or
+ NULL if no more language in the list.
+ @param Lang The first language in the list.
---*/
+**/
+VOID
+EFIAPI
+HiiLibGetNextLanguage (
+ IN OUT CHAR8 **LangCode,
+ OUT CHAR8 *Lang
+ )
+;
+
+/**
+ This function returns the list of supported languages, in the format specified
+ in UEFI specification Appendix M.
+
+ If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
+ If not enough resource to complete the operation, then ASSERT.
+
+ @param HiiHandle The HII package list handle.
+
+ @return The supported languages.
+
+**/
+CHAR8 *
+EFIAPI
+HiiLibGetSupportedLanguages (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+;
+
+/**
+ This function returns the number of supported languages on HiiHandle.
+
+ If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
+ If not enough resource to complete the operation, then ASSERT.
+
+ @param HiiHandle The HII package list handle.
+
+ @return The number of supported languages.
+
+**/
+UINT16
+EFIAPI
+HiiLibGetSupportedLanguageNumber (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+;
+
+/**
+ Convert language code from RFC3066 to ISO639-2.
+
+ If LanguageRfc3066 is NULL, then ASSERT.
+ If LanguageIso639 is NULL, then ASSERT.
+
+ @param LanguageRfc3066 RFC3066 language code.
+ @param LanguageIso639 ISO639-2 language code.
+
+ @retval EFI_SUCCESS Language code converted.
+ @retval EFI_NOT_FOUND Language code not found.
+
+**/
+EFI_STATUS
+EFIAPI
+ConvertRfc3066LanguageToIso639Language (
+ CHAR8 *LanguageRfc3066,
+ CHAR8 *LanguageIso639
+ )
+;
+
+/**
+ Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
+ be converted to "engfra".
+
+ If SupportedLanguages is NULL, then ASSERT.
+
+ @param SupportedLanguages The RFC3066 language list.
+
+ @return The ISO639-2 language list.
+
+**/
+CHAR8 *
+EFIAPI
+Rfc3066ToIso639 (
+ CHAR8 *SupportedLanguages
+ )
;
#endif
diff --git a/MdePkg/Include/Library/IfrSupportLib.h b/MdePkg/Include/Library/IfrSupportLib.h index 0b54a8eb9b..75c7f4785b 100644 --- a/MdePkg/Include/Library/IfrSupportLib.h +++ b/MdePkg/Include/Library/IfrSupportLib.h @@ -11,16 +11,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name:
- UefiIfrLibrary.h
+ IfrSupportLibrary.h
Abstract:
- The file contain all library function for Ifr Operations.
+ The file contain all library functions and definitions for IFR opcode creation and
+ related Form Browser utility Operations.
--*/
-#ifndef _IFRLIBRARY_H
-#define _IFRLIBRARY_H
+#ifndef _IFR_SUPPORT_LIBRARY_H
+#define _IFR_SUPPORT_LIBRARY_H
#include <Protocol/HiiFont.h>
@@ -34,8 +35,6 @@ Abstract: #include <Guid/GlobalVariable.h>
-#define IFR_LIB_DEFAULT_STRING_SIZE 0x200
-
//
// The architectural variable "Lang" and "LangCodes" are deprecated in UEFI
// specification. While, UEFI specification also states that these deprecated
@@ -94,50 +93,62 @@ typedef struct { } EFI_HII_UPDATE_DATA;
-//
-// Exported Library functions
-//
+/**
+ Create EFI_IFR_END_OP opcode.
+
+ If Data is NULL or Data->Data is NULL, then ASSERT.
+
+ @param Data Destination for the created opcode binary
+
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+
+**/
EFI_STATUS
+EFIAPI
CreateEndOpCode (
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_END_OP opcode.
+;
-Arguments:
- Data - Destination for the created opcode binary
+/**
+ Create EFI_IFR_DEFAULT_OP opcode.
-Returns:
- EFI_SUCCESS - Opcode create success
+ @param Value Value for the default
+ @param Type Type for the default
+ @param Data Destination for the created opcode binary
---*/
-;
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER The type is not valid.
+**/
EFI_STATUS
+EFIAPI
CreateDefaultOpCode (
IN EFI_IFR_TYPE_VALUE *Value,
IN UINT8 Type,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
+;
-Routine Description:
- Create EFI_IFR_DEFAULT_OP opcode.
+/**
+ Create EFI_IFR_ACTION_OP opcode.
-Arguments:
- Value - Value for the default
- Type - Type for the default
- Data - Destination for the created opcode binary
+ @param QuestionId Question ID
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param QuestionFlags Flags in Question Header
+ @param QuestionConfig String ID for configuration
+ @param Data Destination for the created opcode binary
-Returns:
- EFI_SUCCESS - Opcode create success
-
---*/
-;
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
+**/
EFI_STATUS
+EFIAPI
CreateActionOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_STRING_ID Prompt,
@@ -146,26 +157,23 @@ CreateActionOpCode ( IN EFI_STRING_ID QuestionConfig,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_ACTION_OP opcode.
-
-Arguments:
- QuestionId - Question ID
- Prompt - String ID for Prompt
- Help - String ID for Help
- QuestionFlags - Flags in Question Header
- QuestionConfig - String ID for configuration
- Data - Destination for the created opcode binary
+;
-Returns:
- EFI_SUCCESS - Opcode create success
+/**
+ Create EFI_IFR_SUBTITLE_OP opcode.
---*/
-;
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param Flags Subtitle opcode flags
+ @param Scope Subtitle Scope bit
+ @param Data Destination for the created opcode binary
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+
+**/
EFI_STATUS
+EFIAPI
CreateSubTitleOpCode (
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
@@ -173,49 +181,47 @@ CreateSubTitleOpCode ( IN UINT8 Scope,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
+;
-Routine Description:
- Create EFI_IFR_SUBTITLE_OP opcode.
+/**
+ Create EFI_IFR_TEXT_OP opcode.
-Arguments:
- Prompt - String ID for Prompt
- Help - String ID for Help
- Flags - Subtitle opcode flags
- Scope - Subtitle Scope bit
- Data - Destination for the created opcode binary
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param TextTwo String ID for text two
+ @param Data Destination for the created opcode binary
-Returns:
- EFI_SUCCESS - Opcode create success
-
---*/
-;
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+**/
EFI_STATUS
+EFIAPI
CreateTextOpCode (
IN EFI_STRING_ID Prompt,
IN EFI_STRING_ID Help,
IN EFI_STRING_ID TextTwo,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_TEXT_OP opcode.
+;
-Arguments:
- Prompt - String ID for Prompt
- Help - String ID for Help
- TextTwo - String ID for text two
- Data - Destination for the created opcode binary
+/**
+ Create EFI_IFR_REF_OP opcode.
-Returns:
- EFI_SUCCESS - Opcode create success
+ @param FormId Destination Form ID
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param QuestionFlags Flags in Question Header
+ @param QuestionId Question ID
+ @param Data Destination for the created opcode binary
---*/
-;
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
+**/
EFI_STATUS
+EFIAPI
CreateGotoOpCode (
IN EFI_FORM_ID FormId,
IN EFI_STRING_ID Prompt,
@@ -224,26 +230,22 @@ CreateGotoOpCode ( IN EFI_QUESTION_ID QuestionId,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_REF_OP opcode.
+;
-Arguments:
- FormId - Destination Form ID
- Prompt - String ID for Prompt
- Help - String ID for Help
- QuestionFlags - Flags in Question Header
- QuestionId - Question ID
- Data - Destination for the created opcode binary
+/**
+ Create EFI_IFR_ONE_OF_OPTION_OP opcode.
-Returns:
- EFI_SUCCESS - Opcode create success
+ @param QuestionId Question ID
+ @param OptionList The list of Options.
+ @param Type The data type.
+ @param Data Destination for the created opcode binary
---*/
-;
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+**/
EFI_STATUS
+EFIAPI
CreateOneOfOptionOpCode (
IN UINTN OptionCount,
IN IFR_OPTION *OptionsList,
@@ -252,7 +254,27 @@ CreateOneOfOptionOpCode ( )
;
+/**
+ Create EFI_IFR_ONE_OF_OP opcode.
+
+ @param QuestionId Question ID
+ @param VarStoreId Storage ID
+ @param VarOffset Offset in Storage
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param QuestionFlags Flags in Question Header
+ @param OneOfFlags Flags for oneof opcode
+ @param OptionsList List of options
+ @param OptionCount Number of options in option list
+ @param Data Destination for the created opcode binary
+
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
+
+**/
EFI_STATUS
+EFIAPI
CreateOneOfOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
@@ -265,30 +287,31 @@ CreateOneOfOpCode ( IN UINTN OptionCount,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_ONE_OF_OP opcode.
-
-Arguments:
- QuestionId - Question ID
- VarStoreId - Storage ID
- VarOffset - Offset in Storage
- Prompt - String ID for Prompt
- Help - String ID for Help
- QuestionFlags - Flags in Question Header
- OneOfFlags - Flags for oneof opcode
- OptionsList - List of options
- OptionCount - Number of options in option list
- Data - Destination for the created opcode binary
-
-Returns:
- EFI_SUCCESS - Opcode create success
-
---*/
;
+/**
+ Create EFI_IFR_ORDERED_LIST_OP opcode.
+
+ @param QuestionId Question ID
+ @param VarStoreId Storage ID
+ @param VarOffset Offset in Storage
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param QuestionFlags Flags in Question Header
+ @param Flags Flags for ordered list opcode
+ @param DataType Type for option value
+ @param MaxContainers Maximum count for options in this ordered list
+ @param OptionsList List of options
+ @param OptionCount Number of options in option list
+ @param Data Destination for the created opcode binary
+
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
+
+**/
EFI_STATUS
+EFIAPI
CreateOrderedListOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
@@ -303,32 +326,27 @@ CreateOrderedListOpCode ( IN UINTN OptionCount,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
+;
-Routine Description:
- Create EFI_IFR_ORDERED_LIST_OP opcode.
+/**
+ Create EFI_IFR_CHECKBOX_OP opcode.
-Arguments:
- QuestionId - Question ID
- VarStoreId - Storage ID
- VarOffset - Offset in Storage
- Prompt - String ID for Prompt
- Help - String ID for Help
- QuestionFlags - Flags in Question Header
- Flags - Flags for ordered list opcode
- DataType - Type for option value
- MaxContainers - Maximum count for options in this ordered list
- OptionsList - List of options
- OptionCount - Number of options in option list
- Data - Destination for the created opcode binary
-
-Returns:
- EFI_SUCCESS - Opcode create success
+ @param QuestionId Question ID
+ @param VarStoreId Storage ID
+ @param VarOffset Offset in Storage
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param QuestionFlags Flags in Question Header
+ @param CheckBoxFlags Flags for checkbox opcode
+ @param Data Destination for the created opcode binary
---*/
-;
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
+**/
EFI_STATUS
+EFIAPI
CreateCheckBoxOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
@@ -339,28 +357,31 @@ CreateCheckBoxOpCode ( IN UINT8 CheckBoxFlags,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_CHECKBOX_OP opcode.
-
-Arguments:
- QuestionId - Question ID
- VarStoreId - Storage ID
- VarOffset - Offset in Storage
- Prompt - String ID for Prompt
- Help - String ID for Help
- QuestionFlags - Flags in Question Header
- CheckBoxFlags - Flags for checkbox opcode
- Data - Destination for the created opcode binary
-
-Returns:
- EFI_SUCCESS - Opcode create success
-
---*/
;
+/**
+ Create EFI_IFR_NUMERIC_OP opcode.
+
+ @param QuestionId Question ID
+ @param VarStoreId Storage ID
+ @param VarOffset Offset in Storage
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param QuestionFlags Flags in Question Header
+ @param NumericFlags Flags for numeric opcode
+ @param Minimum Numeric minimum value
+ @param Maximum Numeric maximum value
+ @param Step Numeric step for edit
+ @param Default Numeric default value
+ @param Data Destination for the created opcode binary
+
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
+
+**/
EFI_STATUS
+EFIAPI
CreateNumericOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
@@ -375,32 +396,29 @@ CreateNumericOpCode ( IN UINT64 Default,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_NUMERIC_OP opcode.
-
-Arguments:
- QuestionId - Question ID
- VarStoreId - Storage ID
- VarOffset - Offset in Storage
- Prompt - String ID for Prompt
- Help - String ID for Help
- QuestionFlags - Flags in Question Header
- NumericFlags - Flags for numeric opcode
- Minimum - Numeric minimum value
- Maximum - Numeric maximum value
- Step - Numeric step for edit
- Default - Numeric default value
- Data - Destination for the created opcode binary
-
-Returns:
- EFI_SUCCESS - Opcode create success
-
---*/
;
+/**
+ Create EFI_IFR_STRING_OP opcode.
+
+ @param QuestionId Question ID
+ @param VarStoreId Storage ID
+ @param VarOffset Offset in Storage
+ @param Prompt String ID for Prompt
+ @param Help String ID for Help
+ @param QuestionFlags Flags in Question Header
+ @param StringFlags Flags for string opcode
+ @param MinSize String minimum length
+ @param MaxSize String maximum length
+ @param Data Destination for the created opcode binary
+
+ @retval EFI_SUCCESS Opcode create success
+ @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
+ @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
+
+**/
EFI_STATUS
+EFIAPI
CreateStringOpCode (
IN EFI_QUESTION_ID QuestionId,
IN EFI_VARSTORE_ID VarStoreId,
@@ -413,188 +431,71 @@ CreateStringOpCode ( IN UINT8 MaxSize,
IN OUT EFI_HII_UPDATE_DATA *Data
)
-/*++
-
-Routine Description:
- Create EFI_IFR_STRING_OP opcode.
-
-Arguments:
- QuestionId - Question ID
- VarStoreId - Storage ID
- VarOffset - Offset in Storage
- Prompt - String ID for Prompt
- Help - String ID for Help
- QuestionFlags - Flags in Question Header
- StringFlags - Flags for string opcode
- MinSize - String minimum length
- MaxSize - String maximum length
- Data - Destination for the created opcode binary
-
-Returns:
- EFI_SUCCESS - Opcode create success
-
---*/
;
-EFI_STATUS
-CreateBannerOpCode (
- IN EFI_STRING_ID Title,
- IN UINT16 LineNumber,
- IN UINT8 Alignment,
- IN OUT EFI_HII_UPDATE_DATA *Data
- )
-/*++
-
-Routine Description:
- Create GUIDed opcode for banner.
-
-Arguments:
- Title - String ID for title
- LineNumber - Line number for this banner
- Alignment - Alignment for this banner, left, center or right
- Data - Destination for the created opcode binary
-
-Returns:
- EFI_SUCCESS - Opcode create success
-
---*/
-;
-
-EFI_HII_PACKAGE_LIST_HEADER *
-PreparePackageList (
- IN UINTN NumberOfPackages,
- IN EFI_GUID *GuidId,
- ...
- )
-/*++
-
-Routine Description:
- Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
-
-Arguments:
- NumberOfPackages - Number of packages.
- GuidId - Package GUID.
-
-Returns:
- Pointer of EFI_HII_PACKAGE_LIST_HEADER.
-
---*/
-;
-
-EFI_HII_HANDLE
-DevicePathToHiiHandle (
- IN EFI_HII_DATABASE_PROTOCOL *HiiDatabase,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-/*++
-
-Routine Description:
- Find HII Handle associated with given Device Path.
-
-Arguments:
- HiiDatabase - Point to EFI_HII_DATABASE_PROTOCOL instance.
- DevicePath - Device Path associated with the HII package list handle.
-
-Returns:
- Handle - HII package list Handle associated with the Device Path.
- NULL - Hii Package list handle is not found.
-
---*/
-;
-
-EFI_STATUS
-ExtractDefault(
- IN VOID *Buffer,
- IN UINTN *BufferSize,
- UINTN Number,
- ...
- )
-/*++
-
- Routine Description:
- Configure the buffer accrording to ConfigBody strings.
-
- Arguments:
- DefaultId - the ID of default.
- Buffer - the start address of buffer.
- BufferSize - the size of buffer.
- Number - the number of the strings.
-
- Returns:
- EFI_BUFFER_TOO_SMALL - the BufferSize is too small to operate.
- EFI_INVALID_PARAMETER - Buffer is NULL or BufferSize is 0.
- EFI_SUCCESS - Operation successful.
-
---*/
-;
-
-EFI_STATUS
-ExtractGuidFromHiiHandle (
- IN EFI_HII_HANDLE Handle,
- OUT EFI_GUID *Guid
- )
-/*++
-
-Routine Description:
- Extract Hii package list GUID for given HII handle.
-
-Arguments:
- HiiHandle - Hii handle
- Guid - Package list GUID
+/**
+ Converts binary buffer to Unicode string in reversed byte order to BufToHexString().
-Returns:
- EFI_SUCCESS - Successfully extract GUID from Hii database.
+ @param Str String for output
+ @param Buffer Binary buffer.
+ @param BufferSize Size of the buffer in bytes.
---*/
-;
+ @retval EFI_SUCCESS The function completed successfully.
+**/
EFI_STATUS
+EFIAPI
BufferToHexString (
IN OUT CHAR16 *Str,
IN UINT8 *Buffer,
IN UINTN BufferSize
)
-/*++
-
-Routine Description:
- Converts binary buffer to Unicode string in reversed byte order to BufToHexString().
+;
-Arguments:
- Str - String for output
- Buffer - Binary buffer.
- BufferSize - Size of the buffer in bytes.
+/**
+ Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().
-Returns:
- EFI_SUCCESS - The function completed successfully.
+ @param Buffer Pointer to buffer that receives the data.
+ @param BufferSize Length in bytes of the buffer to hold converted
+ data. If routine return with EFI_SUCCESS,
+ containing length of converted data. If routine
+ return with EFI_BUFFER_TOO_SMALL, containg length
+ of buffer desired.
+ @param Str String to be converted from.
---*/
-;
+ @retval EFI_SUCCESS The function completed successfully.
+**/
EFI_STATUS
+EFIAPI
HexStringToBuffer (
IN OUT UINT8 *Buffer,
IN OUT UINTN *BufferSize,
IN CHAR16 *Str
)
-/*++
-
-Routine Description:
- Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().
-
-Arguments:
- Buffer - Pointer to buffer that receives the data.
- BufferSize - Length in bytes of the buffer to hold converted data.
- If routine return with EFI_SUCCESS, containing length of converted data.
- If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
- Str - String to be converted from.
-
-Returns:
- EFI_SUCCESS - The function completed successfully.
-
---*/
;
+/**
+ Construct <ConfigHdr> using routing information GUID/NAME/PATH.
+
+ @param ConfigHdr Pointer to the ConfigHdr string.
+ @param StrBufferLen On input: Length in bytes of buffer to hold the
+ ConfigHdr string. Includes tailing '\0' character.
+ On output: If return EFI_SUCCESS, containing
+ length of ConfigHdr string buffer. If return
+ EFI_BUFFER_TOO_SMALL, containg length of string
+ buffer desired.
+ @param Guid Routing information: GUID.
+ @param Name Routing information: NAME.
+ @param DriverHandle Driver handle which contains the routing
+ information: PATH.
+
+ @retval EFI_SUCCESS Routine success.
+ @retval EFI_BUFFER_TOO_SMALL The ConfigHdr string buffer is too small.
+
+**/
EFI_STATUS
+EFIAPI
ConstructConfigHdr (
IN OUT CHAR16 *ConfigHdr,
IN OUT UINTN *StrBufferLen,
@@ -602,104 +503,77 @@ ConstructConfigHdr ( IN CHAR16 *Name, OPTIONAL
IN EFI_HANDLE *DriverHandle
)
-/*++
-Routine Description:
- Construct <ConfigHdr> using routing information GUID/NAME/PATH.
+;
-Arguments:
- ConfigHdr - Pointer to the ConfigHdr string.
- StrBufferLen - On input: Length in bytes of buffer to hold the ConfigHdr string. Includes tailing '\0' character.
- On output:
- If return EFI_SUCCESS, containing length of ConfigHdr string buffer.
- If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
- Guid - Routing information: GUID.
- Name - Routing information: NAME.
- DriverHandle - Driver handle which contains the routing information: PATH.
+/**
+ Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
-Returns:
- EFI_SUCCESS - Routine success.
- EFI_BUFFER_TOO_SMALL - The ConfigHdr string buffer is too small.
+ @param String The string to be searched in.
+ @param Offset Offset in BlockName.
+ @param Width Width in BlockName.
---*/
-;
+ @retval TRUE Block name found.
+ @retval FALSE Block name not found.
+**/
BOOLEAN
+EFIAPI
FindBlockName (
IN OUT CHAR16 *String,
UINTN Offset,
UINTN Width
)
-/*++
-
-Routine Description:
- Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
+;
-Arguments:
- String - The string to be searched in.
- Offset - Offset in BlockName.
- Width - Width in BlockName.
+/**
+ This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
-Returns:
- TRUE - Block name found.
- FALSE - Block name not found.
+ @param VariableGuid An optional field to indicate the target variable
+ GUID name to use.
+ @param VariableName An optional field to indicate the target
+ human-readable variable name.
+ @param BufferSize On input: Length in bytes of buffer to hold
+ retrived data. On output: If return
+ EFI_BUFFER_TOO_SMALL, containg length of buffer
+ desired.
+ @param Buffer Buffer to hold retrived data.
---*/
-;
+ @retval EFI_SUCCESS Routine success.
+ @retval EFI_BUFFER_TOO_SMALL The intput buffer is too small.
+**/
EFI_STATUS
+EFIAPI
GetBrowserData (
EFI_GUID *VariableGuid, OPTIONAL
CHAR16 *VariableName, OPTIONAL
UINTN *BufferSize,
UINT8 *Buffer
)
-/*++
-
-Routine Description:
- This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
-
-Arguments:
- VariableGuid - An optional field to indicate the target variable GUID name to use.
- VariableName - An optional field to indicate the target human-readable variable name.
- BufferSize - On input: Length in bytes of buffer to hold retrived data.
- On output:
- If return EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
- Buffer - Buffer to hold retrived data.
-
-Returns:
- EFI_SUCCESS - Routine success.
- EFI_BUFFER_TOO_SMALL - The intput buffer is too small.
-
---*/
;
-EFI_STATUS
-GetHiiHandles (
- IN OUT UINTN *HandleBufferLength,
- OUT EFI_HII_HANDLE **HiiHandleBuffer
- )
-/*++
-
-Routine Description:
- Determines the handles that are currently active in the database.
- It's the caller's responsibility to free handle buffer.
-
-Arguments:
- HiiDatabase - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
- HandleBufferLength - On input, a pointer to the length of the handle buffer. On output,
- the length of the handle buffer that is required for the handles found.
- HiiHandleBuffer - Pointer to an array of Hii Handles returned.
-
-Returns:
- EFI_SUCCESS - Get an array of Hii Handles successfully.
- EFI_INVALID_PARAMETER - Hii is NULL.
- EFI_NOT_FOUND - Database not found.
-
---*/
-;
+/**
+ This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
+ @param VariableGuid An optional field to indicate the target variable
+ GUID name to use.
+ @param VariableName An optional field to indicate the target
+ human-readable variable name.
+ @param BufferSize Length in bytes of buffer to hold retrived data.
+ @param Buffer Buffer to hold retrived data.
+ @param RequestElement An optional field to specify which part of the
+ buffer data will be send back to Browser. If NULL,
+ the whole buffer of data will be committed to
+ Browser. <RequestElement> ::=
+ &OFFSET=<Number>&WIDTH=<Number>*
+
+ @retval EFI_SUCCESS Routine success.
+ @retval Other Updating Browser uncommitted data failed.
+
+**/
EFI_STATUS
+EFIAPI
SetBrowserData (
EFI_GUID *VariableGuid, OPTIONAL
CHAR16 *VariableName, OPTIONAL
@@ -707,325 +581,31 @@ SetBrowserData ( UINT8 *Buffer,
CHAR16 *RequestElement OPTIONAL
)
-/*++
-
-Routine Description:
- This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
-
-Arguments:
- VariableGuid - An optional field to indicate the target variable GUID name to use.
- VariableName - An optional field to indicate the target human-readable variable name.
- BufferSize - Length in bytes of buffer to hold retrived data.
- Buffer - Buffer to hold retrived data.
- RequestElement - An optional field to specify which part of the buffer data
- will be send back to Browser. If NULL, the whole buffer of
- data will be committed to Browser.
- <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*
-
-Returns:
- EFI_SUCCESS - Routine success.
- Other - Updating Browser uncommitted data failed.
-
---*/
-;
-
-EFI_STATUS
-ConvertRfc3066LanguageToIso639Language (
- CHAR8 *LanguageRfc3066,
- CHAR8 *LanguageIso639
- )
-/*++
-
-Routine Description:
- Convert language code from RFC3066 to ISO639-2.
-
-Arguments:
- LanguageRfc3066 - RFC3066 language code.
- LanguageIso639 - ISO639-2 language code.
-
-Returns:
- EFI_SUCCESS - Language code converted.
- EFI_NOT_FOUND - Language code not found.
-
---*/
-;
-
-CHAR8 *
-Rfc3066ToIso639 (
- CHAR8 *SupportedLanguages
- )
-/*++
-
-Routine Description:
- Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
- be converted to "engfra".
-
-Arguments:
- SupportedLanguages - The RFC3066 language list.
-
-Returns:
- The ISO639-2 language list.
-
---*/
;
-EFI_STATUS
-GetCurrentLanguage (
- OUT CHAR8 *Lang
- )
-/*++
-
-Routine Description:
- Determine what is the current language setting
-
-Arguments:
- Lang - Pointer of system language
-
-Returns:
- Status code
-
---*/
-;
-
-VOID
-GetNextLanguage (
- IN OUT CHAR8 **LangCode,
- OUT CHAR8 *Lang
- )
-/*++
-
-Routine Description:
- Get next language from language code list.
-
-Arguments:
- LangCode - The language code.
- Lang - Returned language.
-
-Returns:
- None.
-
---*/
-;
-
-CHAR8 *
-GetSupportedLanguages (
- IN EFI_HII_HANDLE HiiHandle
- )
-/*++
-
-Routine Description:
- This function returns the list of supported languages, in the format specified
- in UEFI specification Appendix M.
-
-Arguments:
- HiiHandle - The HII package list handle.
-
-Returns:
- The supported languages.
-
---*/
-;
-
-UINT16
-GetSupportedLanguageNumber (
- IN EFI_HII_HANDLE HiiHandle
- )
-/*++
-
-Routine Description:
- This function returns the number of supported languages
-
-Arguments:
- HiiHandle - The HII package list handle.
-
-Returns:
- The number of supported languages.
-
---*/
-;
-
-EFI_STATUS
-GetStringFromHandle (
- IN EFI_HII_HANDLE HiiHandle,
- IN EFI_STRING_ID StringId,
- OUT EFI_STRING *String
- )
-/*++
-
-Routine Description:
- Get string specified by StringId form the HiiHandle.
-
-Arguments:
- HiiHandle - The HII handle of package list.
- StringId - The String ID.
- String - The output string.
-
-Returns:
- EFI_NOT_FOUND - String is not found.
- EFI_SUCCESS - Operation is successful.
- EFI_OUT_OF_RESOURCES - There is not enought memory in the system.
- EFI_INVALID_PARAMETER - The String is NULL.
-
---*/
-;
-
-EFI_STATUS
-GetStringFromToken (
- IN EFI_GUID *ProducerGuid,
- IN EFI_STRING_ID StringId,
- OUT EFI_STRING *String
- )
-/*++
-
-Routine Description:
- Get the string given the StringId and String package Producer's Guid.
-
-Arguments:
- ProducerGuid - The Guid of String package list.
- StringId - The String ID.
- String - The output string.
-
-Returns:
- EFI_NOT_FOUND - String is not found.
- EFI_SUCCESS - Operation is successful.
- EFI_OUT_OF_RESOURCES - There is not enought memory in the system.
-
---*/
-;
-
-EFI_STATUS
-IfrLibNewString (
- IN EFI_HII_HANDLE PackageList,
- OUT EFI_STRING_ID *StringId,
- IN CONST EFI_STRING String
- )
-/*++
-
- Routine Description:
- This function adds the string into String Package of each language.
-
- Arguments:
- PackageList - Handle of the package list where this string will be added.
- StringId - On return, contains the new strings id, which is unique within PackageList.
- String - Points to the new null-terminated string.
-
- Returns:
- EFI_SUCCESS - The new string was added successfully.
- EFI_NOT_FOUND - The specified PackageList could not be found in database.
- EFI_OUT_OF_RESOURCES - Could not add the string due to lack of resources.
- EFI_INVALID_PARAMETER - String is NULL or StringId is NULL is NULL.
-
---*/
-;
-
-EFI_STATUS
-IfrLibGetString (
- IN EFI_HII_HANDLE PackageList,
- IN EFI_STRING_ID StringId,
- OUT EFI_STRING String,
- IN OUT UINTN *StringSize
- )
-/*++
-
- Routine Description:
- This function try to retrieve string from String package of current language.
- If fail, it try to retrieve string from String package of first language it support.
-
- Arguments:
- PackageList - The package list in the HII database to search for the specified string.
- StringId - The string's id, which is unique within PackageList.
- String - Points to the new null-terminated string.
- StringSize - On entry, points to the size of the buffer pointed to by String, in bytes. On return,
- points to the length of the string, in bytes.
-
- Returns:
- EFI_SUCCESS - The string was returned successfully.
- EFI_NOT_FOUND - The string specified by StringId is not available.
- EFI_BUFFER_TOO_SMALL - The buffer specified by StringLength is too small to hold the string.
- EFI_INVALID_PARAMETER - The String or StringSize was NULL.
-
---*/
-;
-
-EFI_STATUS
-IfrLibSetString (
- IN EFI_HII_HANDLE PackageList,
- IN EFI_STRING_ID StringId,
- IN CONST EFI_STRING String
- )
-/*++
-
- Routine Description:
- This function updates the string in String package of current language.
+/**
+ Draw a dialog and return the selected key.
- Arguments:
- PackageList - The package list containing the strings.
- StringId - The string's id, which is unique within PackageList.
- String - Points to the new null-terminated string.
+ @param NumberOfLines The number of lines for the dialog box
+ @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
+ @param String Pointer to the first string in the list
+ @param ... A series of (quantity == NumberOfLines) text
+ strings which will be used to construct the dialog
+ box
- Returns:
- EFI_SUCCESS - The string was updated successfully.
- EFI_NOT_FOUND - The string specified by StringId is not in the database.
- EFI_INVALID_PARAMETER - The String was NULL.
- EFI_OUT_OF_RESOURCES - The system is out of resources to accomplish the task.
+ @retval EFI_SUCCESS Displayed dialog and received user interaction
+ @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
---*/
-;
+**/
EFI_STATUS
+EFIAPI
IfrLibCreatePopUp (
IN UINTN NumberOfLines,
OUT EFI_INPUT_KEY *KeyValue,
IN CHAR16 *String,
...
)
-/*++
-
-Routine Description:
- Draw a dialog and return the selected key.
-
-Arguments:
- NumberOfLines - The number of lines for the dialog box
- KeyValue - The EFI_KEY value returned if HotKey is TRUE..
- String - Pointer to the first string in the list
- ... - A series of (quantity == NumberOfLines) text strings which
- will be used to construct the dialog box
-
-Returns:
- EFI_SUCCESS - Displayed dialog and received user interaction
- EFI_INVALID_PARAMETER - One of the parameters was invalid.
-
---*/
;
-EFI_STATUS
-IfrLibUpdateForm (
- IN EFI_HII_HANDLE Handle,
- IN EFI_GUID *FormSetGuid, OPTIONAL
- IN EFI_FORM_ID FormId,
- IN UINT16 Label,
- IN BOOLEAN Insert,
- IN EFI_HII_UPDATE_DATA *Data
- )
-/*++
-
-Routine Description:
- This function allows the caller to update a form that has
- previously been registered with the EFI HII database.
-
-Arguments:
- Handle - Hii Handle
- FormSetGuid - The formset should be updated.
- FormId - The form should be updated.
- Label - Update information starting immediately after this label in the IFR
- Insert - If TRUE and Data is not NULL, insert data after Label.
- If FALSE, replace opcodes between two labels with Data.
- Data - The adding data; If NULL, remove opcodes between two Label.
-
-Returns:
- EFI_SUCCESS - Update success.
- Other - Update fail.
-
---*/
-;
#endif
diff --git a/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h b/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h index d13421d0db..dd7247fe8d 100644 --- a/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h +++ b/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h @@ -1488,4 +1488,14 @@ typedef struct { +//
+// References to string tokens must use this macro to enable scanning for
+// token usages.
+//
+//
+// STRING_TOKEN is not defined in UEFI specification. But it is placed
+// here for the easy access by C files and VFR source files.
+//
+#define STRING_TOKEN(t) t
+
#endif
diff --git a/MdePkg/Library/HiiLib/HiiLanguage.c b/MdePkg/Library/HiiLib/HiiLanguage.c new file mode 100644 index 0000000000..9ef3a3e9ed --- /dev/null +++ b/MdePkg/Library/HiiLib/HiiLanguage.c @@ -0,0 +1,136 @@ +/** @file
+ Language related HII Library implementation.
+
+ 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 "InternalHiiLib.h"
+
+EFI_STATUS
+EFIAPI
+HiiLibGetCurrentLanguage (
+ OUT CHAR8 *Lang
+ )
+{
+ EFI_STATUS Status;
+ UINTN Size;
+
+ ASSERT (Lang != NULL);
+
+ //
+ // Get current language setting
+ //
+ Size = RFC_3066_ENTRY_SIZE;
+ Status = gRT->GetVariable (
+ L"PlatformLang",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &Size,
+ Lang
+ );
+
+ if (EFI_ERROR (Status)) {
+ AsciiStrCpy (Lang, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang));
+ }
+
+ return Status;
+}
+
+
+VOID
+EFIAPI
+HiiLibGetNextLanguage (
+ IN OUT CHAR8 **LangCode,
+ OUT CHAR8 *Lang
+ )
+{
+ UINTN Index;
+ CHAR8 *StringPtr;
+
+ ASSERT (LangCode != NULL);
+ ASSERT (Lang != NULL);
+
+ Index = 0;
+ StringPtr = *LangCode;
+ while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
+ Index++;
+ }
+
+ CopyMem (Lang, StringPtr, Index);
+ Lang[Index] = 0;
+
+ if (StringPtr[Index] == ';') {
+ Index++;
+ }
+ *LangCode = StringPtr + Index;
+}
+
+
+CHAR8 *
+EFIAPI
+HiiLibGetSupportedLanguages (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ CHAR8 *LanguageString;
+
+ ASSERT (HiiHandle != NULL);
+ ASSERT (IsHiiHandleRegistered (HiiHandle));
+ //
+ // Collect current supported Languages for given HII handle
+ //
+ BufferSize = 0x1000;
+ LanguageString = AllocatePool (BufferSize);
+ Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gBS->FreePool (LanguageString);
+ LanguageString = AllocatePool (BufferSize);
+ Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
+ }
+
+ if (EFI_ERROR (Status)) {
+ LanguageString = NULL;
+ }
+
+ return LanguageString;
+}
+
+
+UINT16
+EFIAPI
+HiiLibGetSupportedLanguageNumber (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+{
+ CHAR8 *Languages;
+ CHAR8 *LanguageString;
+ UINT16 LangNumber;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+
+ Languages = HiiLibGetSupportedLanguages (HiiHandle);
+ if (Languages == NULL) {
+ return 0;
+ }
+
+ LangNumber = 0;
+ LanguageString = Languages;
+ while (*LanguageString != 0) {
+ HiiLibGetNextLanguage (&LanguageString, Lang);
+ LangNumber++;
+ }
+ gBS->FreePool (Languages);
+
+ return LangNumber;
+}
diff --git a/MdePkg/Library/HiiLib/HiiLib.c b/MdePkg/Library/HiiLib/HiiLib.c index ef86f5da24..e2153f307d 100644 --- a/MdePkg/Library/HiiLib/HiiLib.c +++ b/MdePkg/Library/HiiLib/HiiLib.c @@ -12,59 +12,22 @@ **/
-
-#include <PiDxe.h>
-
-#include <Protocol/HiiDatabase.h>
-#include <Protocol/HiiString.h>
-#include <Protocol/DevicePath.h>
-
-#include <Guid/GlobalVariable.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/HiiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/PcdLib.h>
-
-#include <MdeModuleHii.h>
-
#include "InternalHiiLib.h"
-
EFI_HII_DATABASE_PROTOCOL *mHiiDatabaseProt;
EFI_HII_STRING_PROTOCOL *mHiiStringProt;
-//
-// Hii vendor device path template
-//
-HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {
- {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),
- (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)
- }
- },
- EFI_IFR_TIANO_GUID
- },
- 0
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- END_DEVICE_PATH_LENGTH
- }
- }
-};
+/**
+ The constructor function of Hii Library.
+
+ The constructor function caches the value of default HII protocol instances.
+ @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.
+
+**/
EFI_STATUS
EFIAPI
UefiHiiLibConstructor (
@@ -93,166 +56,6 @@ UefiHiiLibConstructor ( return EFI_SUCCESS;
}
-EFI_STATUS
-HiiLibGetCurrentLanguage (
- OUT CHAR8 *Lang
- )
-/*++
-
-Routine Description:
- Determine what is the current language setting
-
-Arguments:
- Lang - Pointer of system language
-
-Returns:
- Status code
-
---*/
-{
- EFI_STATUS Status;
- UINTN Size;
-
- //
- // Get current language setting
- //
- Size = RFC_3066_ENTRY_SIZE;
- Status = gRT->GetVariable (
- L"PlatformLang",
- &gEfiGlobalVariableGuid,
- NULL,
- &Size,
- Lang
- );
-
- if (EFI_ERROR (Status)) {
- AsciiStrCpy (Lang, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang));
- }
-
- return Status;
-}
-
-VOID
-HiiLibGetNextLanguage (
- IN OUT CHAR8 **LangCode,
- OUT CHAR8 *Lang
- )
-/*++
-
-Routine Description:
- Get next language from language code list (with separator ';').
-
-Arguments:
- LangCode - On input: point to first language in the list. On output: point to
- next language in the list, or NULL if no more language in the list.
- Lang - The first language in the list.
-
-Returns:
- None.
-
---*/
-{
- UINTN Index;
- CHAR8 *StringPtr;
-
- if (LangCode == NULL || *LangCode == NULL) {
- *Lang = 0;
- return;
- }
-
- Index = 0;
- StringPtr = *LangCode;
- while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
- Index++;
- }
-
- CopyMem (Lang, StringPtr, Index);
- Lang[Index] = 0;
-
- if (StringPtr[Index] == ';') {
- Index++;
- }
- *LangCode = StringPtr + Index;
-}
-
-CHAR8 *
-HiiLibGetSupportedLanguages (
- IN EFI_HII_HANDLE HiiHandle
- )
-/*++
-
-Routine Description:
- This function returns the list of supported languages, in the format specified
- in UEFI specification Appendix M.
-
-Arguments:
- HiiHandle - The HII package list handle.
-
-Returns:
- The supported languages.
-
---*/
-{
- EFI_STATUS Status;
- UINTN BufferSize;
- CHAR8 *LanguageString;
-
- //
- // Collect current supported Languages for given HII handle
- //
- BufferSize = 0x1000;
- LanguageString = AllocatePool (BufferSize);
- Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- gBS->FreePool (LanguageString);
- LanguageString = AllocatePool (BufferSize);
- Status = mHiiStringProt->GetLanguages (mHiiStringProt, HiiHandle, LanguageString, &BufferSize);
- }
-
- if (EFI_ERROR (Status)) {
- LanguageString = NULL;
- }
-
- return LanguageString;
-}
-
-UINT16
-HiiLibGetSupportedLanguageNumber (
- IN EFI_HII_HANDLE HiiHandle
- )
-/*++
-
-Routine Description:
- This function returns the number of supported languages
-
-Arguments:
- HiiHandle - The HII package list handle.
-
-Returns:
- The number of supported languages.
-
---*/
-{
- CHAR8 *Languages;
- CHAR8 *LanguageString;
- UINT16 LangNumber;
- CHAR8 Lang[RFC_3066_ENTRY_SIZE];
-
- Languages = HiiLibGetSupportedLanguages (HiiHandle);
- if (Languages == NULL) {
- return 0;
- }
-
- LangNumber = 0;
- LanguageString = Languages;
- while (*LanguageString != 0) {
- HiiLibGetNextLanguage (&LanguageString, Lang);
- LangNumber++;
- }
- gBS->FreePool (Languages);
-
- return LangNumber;
-}
EFI_HII_PACKAGE_LIST_HEADER *
@@ -318,23 +121,12 @@ HiiLibPreparePackageList ( IN CONST EFI_GUID *GuidId,
...
)
-/*++
-
-Routine Description:
- Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
-
-Arguments:
- NumberOfPackages - Number of packages.
- GuidId - Package GUID.
-
-Returns:
- Pointer of EFI_HII_PACKAGE_LIST_HEADER.
-
---*/
{
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
VA_LIST Marker;
+ ASSERT (GuidId != NULL);
+
VA_START (Marker, GuidId);
PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Marker);
VA_END (Marker);
@@ -343,28 +135,9 @@ Returns: }
-/**
- 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.
-
- 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 (
+HiiLibAddPackages (
IN UINTN NumberOfPackages,
IN CONST EFI_GUID *GuidId,
IN EFI_HANDLE DriverHandle, OPTIONAL
@@ -376,6 +149,7 @@ HiiLibAddPackagesToHiiDatabase ( EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
EFI_STATUS Status;
+ ASSERT (HiiHandle != NULL);
VA_START (Args, HiiHandle);
PackageListHeader = InternalHiiLibPreparePackages (NumberOfPackages, GuidId, Args);
@@ -410,7 +184,7 @@ HiiLibAddFontPackageToHiiDatabase ( UINT8 *Package;
//
- // Add 4 bytes to the header for entire length for PreparePackageList use only.
+ // Add 4 bytes to the header for entire length for HiiLibPreparePackageList use only.
// Looks ugly. Might be updated when font tool is ready.
//
PackageLength = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR) + FontSize + 4;
@@ -439,361 +213,238 @@ HiiLibAddFontPackageToHiiDatabase ( return EFI_SUCCESS;
}
-EFI_STATUS
+VOID
EFIAPI
-HiiLibRemovePackagesFromHiiDatabase (
+HiiLibRemovePackages (
IN EFI_HII_HANDLE HiiHandle
)
{
- return mHiiDatabaseProt->RemovePackageList (mHiiDatabaseProt, HiiHandle);
+ EFI_STATUS Status;
+
+ ASSERT (HiiHandle != NULL);
+ Status = mHiiDatabaseProt->RemovePackageList (mHiiDatabaseProt, HiiHandle);
+ ASSERT_EFI_ERROR (Status);
}
+
EFI_STATUS
EFIAPI
-HiiLibCreateString (
- IN EFI_HII_HANDLE PackageList,
- OUT EFI_STRING_ID *StringId,
- IN CONST EFI_STRING String
+HiiLibGetHiiHandles (
+ IN OUT UINTN *HandleBufferLength,
+ OUT EFI_HII_HANDLE **HiiHandleBuffer
)
{
+ UINTN BufferLength;
EFI_STATUS Status;
- CHAR8 *Languages;
- CHAR8 *LangStrings;
- CHAR8 Lang[RFC_3066_ENTRY_SIZE];
-
- Status = EFI_SUCCESS;
- Languages = HiiLibGetSupportedLanguages (PackageList);
+ ASSERT (HandleBufferLength != NULL);
+ ASSERT (HiiHandleBuffer != NULL);
- LangStrings = Languages;
- while (*LangStrings != 0) {
- HiiLibGetNextLanguage (&LangStrings, Lang);
+ BufferLength = 0;
- Status = mHiiStringProt->NewString (
- mHiiStringProt,
- PackageList,
- StringId,
- Lang,
+ //
+ // Try to find the actual buffer size for HiiHandle Buffer.
+ //
+ Status = mHiiDatabaseProt->ListPackageLists (
+ mHiiDatabaseProt,
+ EFI_HII_PACKAGE_TYPE_ALL,
NULL,
- String,
- NULL
+ &BufferLength,
+ *HiiHandleBuffer
);
- if (EFI_ERROR (Status)) {
- break;
- }
- }
-
- FreePool (Languages);
-
- return Status;
-
-}
-
-EFI_STATUS
-EFIAPI
-HiiLibUpdateString (
- IN EFI_HII_HANDLE PackageList,
- IN EFI_STRING_ID StringId,
- IN CONST EFI_STRING String
- )
-{
- EFI_STATUS Status;
- CHAR8 *Languages;
- CHAR8 *LangStrings;
- CHAR8 Lang[RFC_3066_ENTRY_SIZE];
- Status = EFI_SUCCESS;
-
- Languages = HiiLibGetSupportedLanguages (PackageList);
-
- LangStrings = Languages;
- while (*LangStrings != 0) {
- HiiLibGetNextLanguage (&LangStrings, Lang);
-
- Status = mHiiStringProt->SetString (
- mHiiStringProt,
- PackageList,
- StringId,
- Lang,
- String,
- NULL
- );
- if (EFI_ERROR (Status)) {
- break;
- }
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ *HiiHandleBuffer = AllocateZeroPool (BufferLength);
+ Status = mHiiDatabaseProt->ListPackageLists (
+ mHiiDatabaseProt,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &BufferLength,
+ *HiiHandleBuffer
+ );
+ //
+ // we should not fail here.
+ //
+ ASSERT_EFI_ERROR (Status);
}
- FreePool (Languages);
+ *HandleBufferLength = BufferLength;
return Status;
}
-// //
-// //////////////////////////////////////////////////
-// //
-
-//
-// This function is Implementation Specifc. HII_VENDOR_DEVICE_PATH
-// This should be moved to MdeModulepkg.
-//
EFI_STATUS
EFIAPI
-HiiLibCreateHiiDriverHandle (
- OUT EFI_HANDLE *DriverHandle
+HiiLibExtractGuidFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT EFI_GUID *Guid
)
{
EFI_STATUS Status;
- HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;
- UINT64 MonotonicCount;
+ UINTN BufferSize;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
- VendorDevicePath = AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);
- if (VendorDevicePath == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
+ ASSERT (Guid != NULL);
- gBS->GetNextMonotonicCount (&MonotonicCount);
- VendorDevicePath->MonotonicCount = (UINT32) MonotonicCount;
+ //
+ // Get HII PackageList
+ //
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = mHiiDatabaseProt->ExportPackageLists (mHiiDatabaseProt, Handle, &BufferSize, HiiPackageList);
+ ASSERT (Status != EFI_NOT_FOUND);
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = AllocatePool (BufferSize);
+ ASSERT (HiiPackageList != NULL);
- *DriverHandle = NULL;
- Status = gBS->InstallProtocolInterface (
- DriverHandle,
- &gEfiDevicePathProtocolGuid,
- EFI_NATIVE_INTERFACE,
- VendorDevicePath
- );
- if (EFI_ERROR (Status)) {
- return Status;
+ Status = mHiiDatabaseProt->ExportPackageLists (mHiiDatabaseProt, Handle, &BufferSize, HiiPackageList);
}
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-HiiLibDestroyHiiDriverHandle (
- IN EFI_HANDLE DriverHandle
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- Status = gBS->HandleProtocol (
- DriverHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
- );
if (EFI_ERROR (Status)) {
return Status;
}
- Status = gBS->UninstallProtocolInterface (
- DriverHandle,
- &gEfiDevicePathProtocolGuid,
- DevicePath
- );
-
- return Status;
-}
-
-EFI_STATUS
-HiiLibExtractDefault(
- IN VOID *Buffer,
- IN UINTN *BufferSize,
- UINTN Number,
- ...
- )
-/*++
-
- Routine Description:
-
- Configure the buffer accrording to ConfigBody strings.
-
- Arguments:
- DefaultId - the ID of default.
- Buffer - the start address of buffer.
- BufferSize - the size of buffer.
- Number - the number of the strings.
-
- Returns:
- EFI_BUFFER_TOO_SMALL - the BufferSize is too small to operate.
- EFI_INVALID_PARAMETER - Buffer is NULL or BufferSize is 0.
- EFI_SUCCESS - Operation successful.
-
---*/
-{
- VA_LIST Args;
- UINTN Index;
- UINT32 TotalLen;
- UINT8 *BufCfgArray;
- UINT8 *BufferPos;
- UINT16 Offset;
- UINT16 Width;
- UINT8 *Value;
-
- if ((Buffer == NULL) || (BufferSize == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Offset = 0;
- Width = 0;
- Value = NULL;
-
- VA_START (Args, Number);
- for (Index = 0; Index < Number; Index++) {
- BufCfgArray = (UINT8 *) VA_ARG (Args, VOID *);
- CopyMem (&TotalLen, BufCfgArray, sizeof (UINT32));
- BufferPos = BufCfgArray + sizeof (UINT32);
-
- while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {
- CopyMem (&Offset, BufferPos, sizeof (UINT16));
- BufferPos += sizeof (UINT16);
- CopyMem (&Width, BufferPos, sizeof (UINT16));
- BufferPos += sizeof (UINT16);
- Value = BufferPos;
- BufferPos += Width;
-
- if ((UINTN)(Offset + Width) > *BufferSize) {
- return EFI_BUFFER_TOO_SMALL;
- }
-
- CopyMem ((UINT8 *)Buffer + Offset, Value, Width);
- }
- }
- VA_END (Args);
+ //
+ // Extract GUID
+ //
+ CopyMem (Guid, &HiiPackageList->PackageListGuid, sizeof (EFI_GUID));
- *BufferSize = (UINTN)Offset;
+ gBS->FreePool (HiiPackageList);
return EFI_SUCCESS;
}
-
-STATIC EFI_GUID mIfrVendorGuid = EFI_IFR_TIANO_GUID;
-
-EFI_STATUS
-HiiLibExtractClassFromHiiHandle (
- IN EFI_HII_HANDLE Handle,
- OUT UINT16 *Class,
- OUT EFI_STRING_ID *FormSetTitle,
- OUT EFI_STRING_ID *FormSetHelp
+EFI_HII_HANDLE
+EFIAPI
+HiiLibDevicePathToHiiHandle (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
-/*++
-
-Routine Description:
- Extract formset class for given HII handle.
-
-Arguments:
- HiiHandle - Hii handle
- Class - Class of the formset
- FormSetTitle - Formset title string
- FormSetHelp - Formset help string
-
-Returns:
- EFI_SUCCESS - Successfully extract Class for specified Hii handle.
-
---*/
{
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
- UINT8 *Package;
- UINT8 *OpCodeData;
- UINT32 Offset;
- UINT32 Offset2;
- UINT32 PackageListLength;
- EFI_HII_PACKAGE_HEADER PackageHeader;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
+ UINTN BufferSize;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_HANDLE *Handles;
+ EFI_HANDLE Handle;
+ UINTN Size;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_HANDLE *HiiHandles;
+ EFI_HII_HANDLE HiiHandle;
- *Class = EFI_NON_DEVICE_CLASS;
- *FormSetTitle = 0;
- *FormSetHelp = 0;
+ ASSERT (DevicePath != NULL);
//
- // Locate HII Database protocol
+ // Locate Device Path Protocol handle buffer
//
- Status = gBS->LocateProtocol (
- &gEfiHiiDatabaseProtocolGuid,
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDevicePathProtocolGuid,
NULL,
- (VOID **) &HiiDatabase
+ &HandleCount,
+ &Handles
);
if (EFI_ERROR (Status)) {
- return Status;
+ return NULL;
}
//
- // Get HII PackageList
+ // Search Driver Handle by Device Path
//
- BufferSize = 0;
- HiiPackageList = NULL;
- Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HiiPackageList = AllocatePool (BufferSize);
- ASSERT (HiiPackageList != NULL);
-
- Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ DriverHandle = NULL;
+ BufferSize = GetDevicePathSize (DevicePath);
+ for(Index = 0; Index < HandleCount; Index++) {
+ Handle = Handles[Index];
+ gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &TmpDevicePath);
+
+ //
+ // Check whether DevicePath match
+ //
+ Size = GetDevicePathSize (TmpDevicePath);
+ if ((Size == BufferSize) && CompareMem (DevicePath, TmpDevicePath, Size) == 0) {
+ DriverHandle = Handle;
+ break;
+ }
}
- if (EFI_ERROR (Status)) {
- return Status;
+ gBS->FreePool (Handles);
+
+ if (DriverHandle == NULL) {
+ return NULL;
}
//
- // Get Form package from this HII package List
+ // Retrieve all Hii Handles from HII database
//
- Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
- Offset2 = 0;
- CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+ BufferSize = 0x1000;
+ HiiHandles = AllocatePool (BufferSize);
+ ASSERT (HiiHandles != NULL);
+ Status = mHiiDatabaseProt->ListPackageLists (
+ mHiiDatabaseProt,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &BufferSize,
+ HiiHandles
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gBS->FreePool (HiiHandles);
+ HiiHandles = AllocatePool (BufferSize);
+ ASSERT (HiiHandles != NULL);
+
+ Status = mHiiDatabaseProt->ListPackageLists (
+ mHiiDatabaseProt,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &BufferSize,
+ HiiHandles
+ );
+ }
- while (Offset < PackageListLength) {
- Package = ((UINT8 *) HiiPackageList) + Offset;
- CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (HiiHandles);
+ return NULL;
+ }
- if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
- //
- // Search Class Opcode in this Form Package
- //
- Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
- while (Offset2 < PackageHeader.Length) {
- OpCodeData = Package + Offset2;
-
- if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
- //
- // Find FormSet OpCode
- //
- CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
- CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
- }
-
- if ((((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_GUID_OP) &&
- CompareGuid (&mIfrVendorGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER))) &&
- (((EFI_IFR_GUID_CLASS *) OpCodeData)->ExtendOpCode == EFI_IFR_EXTEND_OP_CLASS)
- ) {
- //
- // Find GUIDed Class OpCode
- //
- CopyMem (Class, &((EFI_IFR_GUID_CLASS *) OpCodeData)->Class, sizeof (UINT16));
-
- //
- // Till now, we ought to have found the formset Opcode
- //
- break;
- }
-
- Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
- }
-
- if (Offset2 < PackageHeader.Length) {
- //
- // Target formset found
- //
- break;
- }
+ //
+ // Search Hii Handle by Driver Handle
+ //
+ HiiHandle = NULL;
+ HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = mHiiDatabaseProt->GetPackageListHandle (
+ mHiiDatabaseProt,
+ HiiHandles[Index],
+ &Handle
+ );
+ if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
+ HiiHandle = HiiHandles[Index];
+ break;
}
-
- Offset += PackageHeader.Length;
}
- gBS->FreePool (HiiPackageList);
+ gBS->FreePool (HiiHandles);
+ return HiiHandle;
+}
- return EFI_SUCCESS;
+BOOLEAN
+IsHiiHandleRegistered (
+ EFI_HII_HANDLE HiiHandle
+ )
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+
+ ASSERT (HiiHandle != NULL);
+
+ HiiPackageList = NULL;
+ BufferSize = 0;
+ Status = mHiiDatabaseProt->ExportPackageLists (
+ mHiiDatabaseProt,
+ HiiHandle,
+ &BufferSize,
+ HiiPackageList
+ );
+
+ return (BOOLEAN) (Status == EFI_BUFFER_TOO_SMALL);
}
diff --git a/MdePkg/Library/HiiLib/HiiLib.inf b/MdePkg/Library/HiiLib/HiiLib.inf index ddff1c8004..30a1657984 100644 --- a/MdePkg/Library/HiiLib/HiiLib.inf +++ b/MdePkg/Library/HiiLib/HiiLib.inf @@ -32,20 +32,19 @@ [Sources.common]
HiiLib.c
+ HiiString.c
+ HiiLanguage.c
[Packages]
MdePkg/MdePkg.dec
- #BugBug: This package dependency will be re-evaluated when the code become functional and stable.
- # : HiiLibCreateHiiDriverHandle depends on HII_VENDOR_DEVICE_PATH which is defined by this
- # : specification only.
- MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
MemoryAllocationLib
DebugLib
PcdLib
UefiRuntimeServicesTableLib
+ DevicePathLib
[Protocols]
gEfiHiiDatabaseProtocolGuid # ALWAYS_CONSUMED
diff --git a/MdePkg/Library/HiiLib/HiiString.c b/MdePkg/Library/HiiLib/HiiString.c new file mode 100644 index 0000000000..b28a955d81 --- /dev/null +++ b/MdePkg/Library/HiiLib/HiiString.c @@ -0,0 +1,460 @@ +/** @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 "InternalHiiLib.h"
+EFI_STATUS
+EFIAPI
+HiiLibNewString (
+ IN EFI_HII_HANDLE PackageList,
+ OUT EFI_STRING_ID *StringId,
+ IN CONST EFI_STRING String
+ )
+{
+ EFI_STATUS Status;
+ CHAR8 *Languages;
+ CHAR8 *LangStrings;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+
+ ASSERT (String != NULL);
+ ASSERT (StringId != NULL);
+
+ Status = EFI_SUCCESS;
+
+ Languages = HiiLibGetSupportedLanguages (PackageList);
+
+ LangStrings = Languages;
+ while (*LangStrings != 0) {
+ HiiLibGetNextLanguage (&LangStrings, Lang);
+
+ Status = mHiiStringProt->NewString (
+ mHiiStringProt,
+ PackageList,
+ StringId,
+ Lang,
+ NULL,
+ String,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ }
+
+ FreePool (Languages);
+
+ return Status;
+
+}
+
+EFI_STATUS
+EFIAPI
+HiiLibSetString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ IN CONST EFI_STRING String
+ )
+{
+ EFI_STATUS Status;
+ CHAR8 *Languages;
+ CHAR8 *LangStrings;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+
+ ASSERT (IsHiiHandleRegistered (PackageList));
+
+ Status = EFI_SUCCESS;
+
+ Languages = HiiLibGetSupportedLanguages (PackageList);
+ ASSERT (Languages != NULL);
+
+ LangStrings = Languages;
+ while (*LangStrings != 0) {
+ HiiLibGetNextLanguage (&LangStrings, Lang);
+
+ Status = mHiiStringProt->SetString (
+ mHiiStringProt,
+ PackageList,
+ StringId,
+ Lang,
+ String,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ }
+
+ FreePool (Languages);
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+HiiLibGetStringFromToken (
+ IN EFI_GUID *ProducerGuid,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN HandleBufferLen;
+ EFI_HII_HANDLE *HiiHandleBuffer;
+ EFI_GUID Guid;
+
+ Status = HiiLibGetHiiHandles (&HandleBufferLen, &HiiHandleBuffer);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+ for (Index = 0; Index < (HandleBufferLen / sizeof (EFI_HII_HANDLE)); Index++) {
+ Status = HiiLibExtractGuidFromHiiHandle (HiiHandleBuffer[Index], &Guid);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+ if (CompareGuid (&Guid, ProducerGuid) == TRUE) {
+ break;
+ }
+ }
+
+ if (Index >= (HandleBufferLen / sizeof (EFI_HII_HANDLE))) {
+ //
+ // If PackageList with the matching ProducerGuid is not found, then ASSERT.
+ //
+ ASSERT (FALSE);
+ Status = EFI_NOT_FOUND;
+ goto Out;
+ }
+
+ Status = HiiLibGetStringFromHandle (HiiHandleBuffer[Index], StringId, String);
+
+Out:
+ if (HiiHandleBuffer != NULL) {
+ gBS->FreePool (HiiHandleBuffer);
+ }
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+HiiLibGetString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING String,
+ IN OUT UINTN *StringSize
+ )
+{
+ EFI_STATUS Status;
+ CHAR8 *Languages;
+ CHAR8 *LangStrings;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+ CHAR8 CurrentLang[RFC_3066_ENTRY_SIZE];
+
+ ASSERT (String != NULL);
+ ASSERT (StringSize != NULL);
+ ASSERT (IsHiiHandleRegistered (PackageList));
+
+ HiiLibGetCurrentLanguage (CurrentLang);
+
+ Status = mHiiStringProt->GetString (
+ mHiiStringProt,
+ CurrentLang,
+ PackageList,
+ StringId,
+ String,
+ StringSize,
+ NULL
+ );
+
+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
+ Languages = HiiLibGetSupportedLanguages (PackageList);
+ ASSERT (Languages != NULL);
+
+ LangStrings = Languages;
+ HiiLibGetNextLanguage (&LangStrings, Lang);
+ gBS->FreePool (Languages);
+
+ Status = mHiiStringProt->GetString (
+ mHiiStringProt,
+ Lang,
+ PackageList,
+ StringId,
+ String,
+ StringSize,
+ NULL
+ );
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+HiiLibGetStringFromHandle (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+{
+ EFI_STATUS Status;
+ UINTN StringSize;
+
+ ASSERT (String != NULL);
+
+ StringSize = HII_LIB_DEFAULT_STRING_SIZE;
+ *String = AllocateZeroPool (StringSize);
+ if (*String == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = HiiLibGetString (HiiHandle, StringId, *String, &StringSize);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gBS->FreePool (*String);
+ *String = AllocateZeroPool (StringSize);
+ if (*String == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Status = HiiLibGetString (HiiHandle, StringId, *String, &StringSize);
+ }
+
+ return Status;
+}
+
+
+
+//
+// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes
+// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.
+// The last 2 CHAR8 values are the ISO 639-1 code.
+//
+CHAR8 Iso639ToRfc3066ConversionTable[] =
+"\
+aaraa\
+abkab\
+afraf\
+amham\
+araar\
+asmas\
+aymay\
+azeaz\
+bakba\
+belbe\
+benbn\
+bihbh\
+bisbi\
+bodbo\
+brebr\
+bulbg\
+catca\
+cescs\
+corkw\
+cosco\
+cymcy\
+danda\
+deude\
+dzodz\
+ellel\
+engen\
+epoeo\
+estet\
+euseu\
+faofo\
+fasfa\
+fijfj\
+finfi\
+frafr\
+fryfy\
+gaiga\
+gdhgd\
+glggl\
+grngn\
+gujgu\
+hauha\
+hebhe\
+hinhi\
+hrvhr\
+hunhu\
+hyehy\
+ikuiu\
+ileie\
+inaia\
+indid\
+ipkik\
+islis\
+itait\
+jawjw\
+jpnja\
+kalkl\
+kankn\
+kasks\
+katka\
+kazkk\
+khmkm\
+kinrw\
+kirky\
+korko\
+kurku\
+laolo\
+latla\
+lavlv\
+linln\
+litlt\
+ltzlb\
+malml\
+marmr\
+mkdmk\
+mlgmg\
+mltmt\
+molmo\
+monmn\
+mrimi\
+msams\
+myamy\
+nauna\
+nepne\
+nldnl\
+norno\
+ocioc\
+ormom\
+panpa\
+polpl\
+porpt\
+pusps\
+quequ\
+rohrm\
+ronro\
+runrn\
+rusru\
+sagsg\
+sansa\
+sinsi\
+slksk\
+slvsl\
+smise\
+smosm\
+snasn\
+sndsd\
+somso\
+sotst\
+spaes\
+sqisq\
+srpsr\
+sswss\
+sunsu\
+swasw\
+swesv\
+tamta\
+tattt\
+telte\
+tgktg\
+tgltl\
+thath\
+tsnts\
+tuktk\
+twitw\
+uigug\
+ukruk\
+urdur\
+uzbuz\
+vievi\
+volvo\
+wolwo\
+xhoxh\
+yidyi\
+zhaza\
+zhozh\
+zulzu\
+";
+
+
+/**
+ Convert language code from RFC3066 to ISO639-2.
+
+ @param LanguageRfc3066 RFC3066 language code.
+ @param LanguageIso639 ISO639-2 language code.
+
+ @retval EFI_SUCCESS Language code converted.
+ @retval EFI_NOT_FOUND Language code not found.
+
+**/
+EFI_STATUS
+EFIAPI
+ConvertRfc3066LanguageToIso639Language (
+ CHAR8 *LanguageRfc3066,
+ CHAR8 *LanguageIso639
+ )
+{
+ UINTN Index;
+
+ if ((LanguageRfc3066[2] != '-') && (LanguageRfc3066[2] != 0)) {
+ CopyMem (LanguageIso639, LanguageRfc3066, 3);
+ return EFI_SUCCESS;
+ }
+
+ for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {
+ if (CompareMem (LanguageRfc3066, &Iso639ToRfc3066ConversionTable[Index + 3], 2) == 0) {
+ CopyMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3);
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+/**
+ Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
+ be converted to "engfra".
+
+ @param SupportedLanguages The RFC3066 language list.
+
+ @return The ISO639-2 language list.
+
+**/
+CHAR8 *
+EFIAPI
+Rfc3066ToIso639 (
+ CHAR8 *SupportedLanguages
+ )
+{
+ CHAR8 *Languages;
+ CHAR8 *ReturnValue;
+ CHAR8 *LangCodes;
+ CHAR8 LangRfc3066[RFC_3066_ENTRY_SIZE];
+ CHAR8 LangIso639[ISO_639_2_ENTRY_SIZE];
+ EFI_STATUS Status;
+
+ ReturnValue = AllocateZeroPool (AsciiStrSize (SupportedLanguages));
+ if (ReturnValue == NULL) {
+ return ReturnValue;
+ }
+
+ Languages = ReturnValue;
+ LangCodes = SupportedLanguages;
+ while (*LangCodes != 0) {
+ HiiLibGetNextLanguage (&LangCodes, LangRfc3066);
+
+ Status = ConvertRfc3066LanguageToIso639Language (LangRfc3066, LangIso639);
+ if (!EFI_ERROR (Status)) {
+ CopyMem (Languages, LangIso639, 3);
+ Languages = Languages + 3;
+ }
+ }
+
+ return ReturnValue;
+}
+
+
diff --git a/MdePkg/Library/HiiLib/InternalHiiLib.h b/MdePkg/Library/HiiLib/InternalHiiLib.h index 78540a4431..0303fa9968 100644 --- a/MdePkg/Library/HiiLib/InternalHiiLib.h +++ b/MdePkg/Library/HiiLib/InternalHiiLib.h @@ -15,6 +15,34 @@ #ifndef __INTERNAL_HII_LIB_H__
#define __INTERNAL_HII_LIB_H__
+#include <PiDxe.h>
+#include <Protocol/HiiDatabase.h>
+#include <Protocol/HiiString.h>
+#include <Protocol/DevicePath.h>
+
+#include <Guid/GlobalVariable.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HiiLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/PcdLib.h>
+#include <Library/DevicePathLib.h>
+
+#define HII_LIB_DEFAULT_STRING_SIZE 0x200
+
+
+extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabaseProt;
+extern EFI_HII_STRING_PROTOCOL *mHiiStringProt;
+
+BOOLEAN
+IsHiiHandleRegistered (
+ EFI_HII_HANDLE HiiHandle
+ )
+;
#endif
diff --git a/MdePkg/Library/IfrSupportLib/IfrSupportLib.inf b/MdePkg/Library/IfrSupportLib/IfrSupportLib.inf new file mode 100644 index 0000000000..a8d5df4c95 --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/IfrSupportLib.inf @@ -0,0 +1,74 @@ +#/** @file
+# Component name for module UefiEfiIfrSupportLib
+#
+# FIX ME!
+# Copyright (c) 2007, Intel Corporation. All rights reserved.
+#
+# 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.
+#
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = IfrSupportLib
+ FILE_GUID = bf38668e-e231-4baa-99e4-8c0e4c35dca6
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = IfrSupportLib
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+
+ CONSTRUCTOR = IfrSupportLibConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources.common]
+ UefiIfrCommon.c
+ UefiIfrForm.c
+ UefiIfrLibraryInternal.h
+ UefiIfrOpCodeCreation.c
+ R8Lib.h
+ R8Lib.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+
+[LibraryClasses]
+ MemoryAllocationLib
+ DevicePathLib
+ BaseLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ BaseMemoryLib
+ DebugLib
+ PcdLib
+
+[Guids]
+ gEfiGlobalVariableGuid # ALWAYS_CONSUMED
+
+[Protocols]
+ gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiHiiDatabaseProtocolGuid
+ gEfiHiiStringProtocolGuid
+ gEfiHiiConfigRoutingProtocolGuid
+ gEfiFormBrowser2ProtocolGuid
+
+[Depex]
+ gEfiHiiDatabaseProtocolGuid AND gEfiHiiStringProtocolGuid
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
+
\ No newline at end of file diff --git a/MdePkg/Library/IfrSupportLib/IfrSupportLib.msa b/MdePkg/Library/IfrSupportLib/IfrSupportLib.msa new file mode 100644 index 0000000000..dc9d665a14 --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/IfrSupportLib.msa @@ -0,0 +1,74 @@ +<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <MsaHeader>
+ <ModuleName>UefiEfiIfrSupportLib</ModuleName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <GuidValue>bf38668e-e231-4baa-99e4-8c0e4c35dca6</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Component name for module UefiEfiIfrSupportLib</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2007, Intel Corporation. All rights reserved.</Copyright>
+ <License>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.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>UefiEfiIfrSupportLib</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseMemoryLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiRuntimeServicesTableLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiBootServicesTableLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DevicePathLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>MemoryAllocationLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>R8Lib.c</Filename>
+ <Filename>R8Lib.h</Filename>
+ <Filename>UefiIfrString.c</Filename>
+ <Filename>UefiIfrOpCodeCreation.c</Filename>
+ <Filename>UefiIfrLibraryInternal.h</Filename>
+ <Filename>UefiIfrForm.c</Filename>
+ <Filename>UefiIfrCommon.c</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ </PackageDependencies>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">
+ <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
+ </Protocol>
+ </Protocols>
+ <Guids>
+ <GuidCNames Usage="ALWAYS_CONSUMED">
+ <GuidCName>gEfiGlobalVariableGuid</GuidCName>
+ </GuidCNames>
+ </Guids>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ </Externs>
+</ModuleSurfaceArea>
\ No newline at end of file diff --git a/MdePkg/Library/IfrSupportLib/R8Lib.c b/MdePkg/Library/IfrSupportLib/R8Lib.c new file mode 100644 index 0000000000..634bdb682d --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/R8Lib.c @@ -0,0 +1,241 @@ +/**@file + Copyright (c) 2007, Intel Corporation + + 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 "UefiIfrLibraryInternal.h" + + +CHAR16 +InternalNibbleToHexChar ( + IN UINT8 Nibble + ) +/*++ + + Routine Description: + Converts the low nibble of a byte to hex unicode character. + + Arguments: + Nibble - lower nibble of a byte. + + Returns: + Hex unicode character. + +--*/ +{ + Nibble &= 0x0F; + if (Nibble <= 0x9) { + return (CHAR16)(Nibble + L'0'); + } + + return (CHAR16)(Nibble - 0xA + L'A'); +} + + +/** + Converts binary buffer to Unicode string. + At a minimum, any blob of data could be represented as a hex string. + + @param Str Pointer to the string. + @param HexStringBufferLength Length in bytes of buffer to hold the hex string. + Includes tailing '\0' character. If routine return + with EFI_SUCCESS, containing length of hex string + buffer. If routine return with + EFI_BUFFER_TOO_SMALL, containg length of hex + string buffer desired. + @param Buf Buffer to be converted from. + @param Len Length in bytes of the buffer to be converted. + + @retval EFI_SUCCESS Routine success. + @retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small. + +**/ +EFI_STATUS +R8_BufToHexString ( + IN OUT CHAR16 *Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ) +{ + // + // Porting Guide: + // This library interface is simply obsolete. + // Include the source code to user code. + // + UINTN Idx; + UINT8 Byte; + UINTN StrLen; + + // + // Make sure string is either passed or allocate enough. + // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer. + // Plus the Unicode termination character. + // + StrLen = Len * 2; + if (StrLen > ((*HexStringBufferLength) - 1)) { + *HexStringBufferLength = StrLen + 1; + return EFI_BUFFER_TOO_SMALL; + } + + *HexStringBufferLength = StrLen + 1; + // + // Ends the string. + // + Str[StrLen] = L'\0'; + + for (Idx = 0; Idx < Len; Idx++) { + + Byte = Buf[Idx]; + Str[StrLen - 1 - Idx * 2] = InternalNibbleToHexChar (Byte); + Str[StrLen - 2 - Idx * 2] = InternalNibbleToHexChar ((UINT8)(Byte >> 4)); + } + + return EFI_SUCCESS; +} + + + + +/** + Converts Unicode string to binary buffer. + The conversion may be partial. + The first character in the string that is not hex digit stops the conversion. + At a minimum, any blob of data could be represented as a hex string. + + @param Buf Pointer to buffer that receives the data. + @param Len Length in bytes of the buffer to hold converted + data. If routine return with EFI_SUCCESS, + containing length of converted data. If routine + return with EFI_BUFFER_TOO_SMALL, containg length + of buffer desired. + @param Str String to be converted from. + @param ConvertedStrLen Length of the Hex String consumed. + + @retval EFI_SUCCESS Routine Success. + @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data. + +**/ +EFI_STATUS +R8_HexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ) +{ + // + // Porting Guide: + // This library interface is simply obsolete. + // Include the source code to user code. + // + + UINTN HexCnt; + UINTN Idx; + UINTN BufferLength; + UINT8 Digit; + UINT8 Byte; + + // + // Find out how many hex characters the string has. + // + for (Idx = 0, HexCnt = 0; R8_IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++); + + if (HexCnt == 0) { + *Len = 0; + return EFI_SUCCESS; + } + // + // Two Unicode characters make up 1 buffer byte. Round up. + // + BufferLength = (HexCnt + 1) / 2; + + // + // Test if buffer is passed enough. + // + if (BufferLength > (*Len)) { + *Len = BufferLength; + return EFI_BUFFER_TOO_SMALL; + } + + *Len = BufferLength; + + for (Idx = 0; Idx < HexCnt; Idx++) { + + R8_IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]); + + // + // For odd charaters, write the lower nibble for each buffer byte, + // and for even characters, the upper nibble. + // + if ((Idx & 1) == 0) { + Byte = Digit; + } else { + Byte = Buf[Idx / 2]; + Byte &= 0x0F; + Byte = (UINT8) (Byte | Digit << 4); + } + + Buf[Idx / 2] = Byte; + } + + if (ConvertedStrLen != NULL) { + *ConvertedStrLen = HexCnt; + } + + return EFI_SUCCESS; +} + + +/** + Determines if a Unicode character is a hexadecimal digit. + The test is case insensitive. + + @param Digit Pointer to byte that receives the value of the hex + character. + @param Char Unicode character to test. + + @retval TRUE If the character is a hexadecimal digit. + @retval FALSE Otherwise. + +**/ +BOOLEAN +R8_IsHexDigit ( + OUT UINT8 *Digit, + IN CHAR16 Char + ) +{ + // + // Porting Guide: + // This library interface is simply obsolete. + // Include the source code to user code. + // + + if ((Char >= L'0') && (Char <= L'9')) { + *Digit = (UINT8) (Char - L'0'); + return TRUE; + } + + if ((Char >= L'A') && (Char <= L'F')) { + *Digit = (UINT8) (Char - L'A' + 0x0A); + return TRUE; + } + + if ((Char >= L'a') && (Char <= L'f')) { + *Digit = (UINT8) (Char - L'a' + 0x0A); + return TRUE; + } + + return FALSE; +} + + diff --git a/MdePkg/Library/IfrSupportLib/R8Lib.h b/MdePkg/Library/IfrSupportLib/R8Lib.h new file mode 100644 index 0000000000..ca9b93989e --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/R8Lib.h @@ -0,0 +1,93 @@ +/**@file + Copyright (c) 2007, Intel Corporation + + 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. + + +**/ + + + +/** + Converts binary buffer to Unicode string. + At a minimum, any blob of data could be represented as a hex string. + + @param Str Pointer to the string. + @param HexStringBufferLength Length in bytes of buffer to hold the hex string. + Includes tailing '\0' character. If routine return + with EFI_SUCCESS, containing length of hex string + buffer. If routine return with + EFI_BUFFER_TOO_SMALL, containg length of hex + string buffer desired. + @param Buf Buffer to be converted from. + @param Len Length in bytes of the buffer to be converted. + + @retval EFI_SUCCESS Routine success. + @retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small. + +**/ +EFI_STATUS +R8_BufToHexString ( + IN OUT CHAR16 *Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ) +; + + + + +/** + Converts Unicode string to binary buffer. + The conversion may be partial. + The first character in the string that is not hex digit stops the conversion. + At a minimum, any blob of data could be represented as a hex string. + + @param Buf Pointer to buffer that receives the data. + @param Len Length in bytes of the buffer to hold converted + data. If routine return with EFI_SUCCESS, + containing length of converted data. If routine + return with EFI_BUFFER_TOO_SMALL, containg length + of buffer desired. + @param Str String to be converted from. + @param ConvertedStrLen Length of the Hex String consumed. + + @retval EFI_SUCCESS Routine Success. + @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data. + +**/ +EFI_STATUS +R8_HexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ) +; + +/** + Determines if a Unicode character is a hexadecimal digit. + The test is case insensitive. + + @param Digit Pointer to byte that receives the value of the hex + character. + @param Char Unicode character to test. + + @retval TRUE If the character is a hexadecimal digit. + @retval FALSE Otherwise. + +**/ +BOOLEAN +R8_IsHexDigit ( + OUT UINT8 *Digit, + IN CHAR16 Char + ) +; + diff --git a/MdePkg/Library/IfrSupportLib/UefiIfrCommon.c b/MdePkg/Library/IfrSupportLib/UefiIfrCommon.c new file mode 100644 index 0000000000..958400fc51 --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/UefiIfrCommon.c @@ -0,0 +1,47 @@ +/** @file + +Copyright (c) 2007, Intel Corporation +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. + +Module Name: + + UefiIfrCommon.c + +Abstract: + + Common Library Routines to assist handle HII elements. + + +**/ + +#include "UefiIfrLibraryInternal.h" + +EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase; +EFI_HII_STRING_PROTOCOL *gIfrLibHiiString; + + +EFI_STATUS +EFIAPI +IfrSupportLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gIfrLibHiiDatabase); + ASSERT_EFI_ERROR (Status); + + Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gIfrLibHiiString); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + + diff --git a/MdePkg/Library/IfrSupportLib/UefiIfrForm.c b/MdePkg/Library/IfrSupportLib/UefiIfrForm.c new file mode 100644 index 0000000000..10ca13c3d7 --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/UefiIfrForm.c @@ -0,0 +1,759 @@ +/** @file + +Copyright (c) 2007, Intel Corporation +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. + +Module Name: + + UefiIfrForm.c + +Abstract: + + Common Library Routines to assist handle HII elements. + + +**/ + +#include "UefiIfrLibraryInternal.h" + +// +// Fake <ConfigHdr> +// +UINT16 mFakeConfigHdr[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=0"; + +STATIC +EFI_STATUS +GetPackageDataFromPackageList ( + IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList, + IN UINT32 PackageIndex, + OUT UINT32 *BufferLen, + OUT EFI_HII_PACKAGE_HEADER **Buffer + ) +{ + UINT32 Index; + EFI_HII_PACKAGE_HEADER *Package; + UINT32 Offset; + UINT32 PackageListLength; + EFI_HII_PACKAGE_HEADER PackageHeader = {0, 0}; + + ASSERT(HiiPackageList != NULL); + + if ((BufferLen == NULL) || (Buffer == NULL)) { + return EFI_INVALID_PARAMETER; + } + + Package = NULL; + Index = 0; + Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER); + CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32)); + while (Offset < PackageListLength) { + Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset); + CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER)); + if (Index == PackageIndex) { + break; + } + Offset += PackageHeader.Length; + Index++; + } + if (Offset >= PackageListLength) { + // + // no package found in this Package List + // + return EFI_NOT_FOUND; + } + + *BufferLen = PackageHeader.Length; + *Buffer = Package; + return EFI_SUCCESS; +} + + +/** + Draw a dialog and return the selected key. + + @param NumberOfLines The number of lines for the dialog box + @param KeyValue The EFI_KEY value returned if HotKey is TRUE.. + @param String Pointer to the first string in the list + @param ... A series of (quantity == NumberOfLines) text + strings which will be used to construct the dialog + box + + @retval EFI_SUCCESS Displayed dialog and received user interaction + @retval EFI_INVALID_PARAMETER One of the parameters was invalid. + +**/ +EFI_STATUS +EFIAPI +IfrLibCreatePopUp ( + IN UINTN NumberOfLines, + OUT EFI_INPUT_KEY *KeyValue, + IN CHAR16 *String, + ... + ) +{ + UINTN Index; + UINTN Count; + UINTN Start; + UINTN Top; + CHAR16 *StringPtr; + UINTN LeftColumn; + UINTN RightColumn; + UINTN TopRow; + UINTN BottomRow; + UINTN DimensionsWidth; + UINTN DimensionsHeight; + VA_LIST Marker; + EFI_INPUT_KEY Key; + UINTN LargestString; + CHAR16 *StackString; + EFI_STATUS Status; + UINTN StringLen; + CHAR16 *LineBuffer; + CHAR16 **StringArray; + EFI_EVENT TimerEvent; + EFI_EVENT WaitList[2]; + UINTN CurrentAttribute; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut; + + if ((KeyValue == NULL) || (String == NULL)) { + return EFI_INVALID_PARAMETER; + } + + TopRow = 0; + BottomRow = 0; + LeftColumn = 0; + RightColumn = 0; + + ConOut = gST->ConOut; + ConOut->QueryMode (ConOut, ConOut->Mode->Mode, &RightColumn, &BottomRow); + + DimensionsWidth = RightColumn - LeftColumn; + DimensionsHeight = BottomRow - TopRow; + + CurrentAttribute = ConOut->Mode->Attribute; + + LineBuffer = AllocateZeroPool (DimensionsWidth * sizeof (CHAR16)); + ASSERT (LineBuffer != NULL); + + // + // Determine the largest string in the dialog box + // Notice we are starting with 1 since String is the first string + // + StringArray = AllocateZeroPool (NumberOfLines * sizeof (CHAR16 *)); + LargestString = StrLen (String); + StringArray[0] = String; + + VA_START (Marker, String); + for (Index = 1; Index < NumberOfLines; Index++) { + StackString = VA_ARG (Marker, CHAR16 *); + + if (StackString == NULL) { + return EFI_INVALID_PARAMETER; + } + + StringArray[Index] = StackString; + StringLen = StrLen (StackString); + if (StringLen > LargestString) { + LargestString = StringLen; + } + } + + if ((LargestString + 2) > DimensionsWidth) { + LargestString = DimensionsWidth - 2; + } + + // + // Subtract the PopUp width from total Columns, allow for one space extra on + // each end plus a border. + // + Start = (DimensionsWidth - LargestString - 2) / 2 + LeftColumn + 1; + + Top = ((DimensionsHeight - NumberOfLines - 2) / 2) + TopRow - 1; + + // + // Disable cursor + // + ConOut->EnableCursor (ConOut, FALSE); + ConOut->SetAttribute (ConOut, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); + + StringPtr = &LineBuffer[0]; + *StringPtr++ = BOXDRAW_DOWN_RIGHT; + for (Index = 0; Index < LargestString; Index++) { + *StringPtr++ = BOXDRAW_HORIZONTAL; + } + *StringPtr++ = BOXDRAW_DOWN_LEFT; + *StringPtr = L'\0'; + + ConOut->SetCursorPosition (ConOut, Start, Top); + ConOut->OutputString (ConOut, LineBuffer); + + for (Index = 0; Index < NumberOfLines; Index++) { + StringPtr = &LineBuffer[0]; + *StringPtr++ = BOXDRAW_VERTICAL; + + for (Count = 0; Count < LargestString; Count++) { + StringPtr[Count] = L' '; + } + + StringLen = StrLen (StringArray[Index]); + if (StringLen > LargestString) { + StringLen = LargestString; + } + CopyMem ( + StringPtr + ((LargestString - StringLen) / 2), + StringArray[Index], + StringLen * sizeof (CHAR16) + ); + StringPtr += LargestString; + + *StringPtr++ = BOXDRAW_VERTICAL; + *StringPtr = L'\0'; + + ConOut->SetCursorPosition (ConOut, Start, Top + 1 + Index); + ConOut->OutputString (ConOut, LineBuffer); + } + + StringPtr = &LineBuffer[0]; + *StringPtr++ = BOXDRAW_UP_RIGHT; + for (Index = 0; Index < LargestString; Index++) { + *StringPtr++ = BOXDRAW_HORIZONTAL; + } + *StringPtr++ = BOXDRAW_UP_LEFT; + *StringPtr = L'\0'; + + ConOut->SetCursorPosition (ConOut, Start, Top + NumberOfLines + 1); + ConOut->OutputString (ConOut, LineBuffer); + + do { + Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent); + + // + // Set a timer event of 1 second expiration + // + gBS->SetTimer ( + TimerEvent, + TimerRelative, + 10000000 + ); + + // + // Wait for the keystroke event or the timer + // + WaitList[0] = gST->ConIn->WaitForKey; + WaitList[1] = TimerEvent; + Status = gBS->WaitForEvent (2, WaitList, &Index); + + // + // Check for the timer expiration + // + if (!EFI_ERROR (Status) && Index == 1) { + Status = EFI_TIMEOUT; + } + + gBS->CloseEvent (TimerEvent); + } while (Status == EFI_TIMEOUT); + + Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); + CopyMem (KeyValue, &Key, sizeof (EFI_INPUT_KEY)); + + ConOut->SetAttribute (ConOut, CurrentAttribute); + ConOut->EnableCursor (ConOut, TRUE); + + return Status; +} + + +/** + Swap bytes in the buffer. + + @param Buffer Binary buffer. + @param BufferSize Size of the buffer in bytes. + + @return None. + +**/ +STATIC +VOID +SwapBuffer ( + IN OUT UINT8 *Buffer, + IN UINTN BufferSize + ) +{ + UINTN Index; + UINT8 Temp; + UINTN SwapCount; + + SwapCount = (BufferSize - 1) / 2; + for (Index = 0; Index < SwapCount; Index++) { + Temp = Buffer[Index]; + Buffer[Index] = Buffer[BufferSize - 1 - Index]; + Buffer[BufferSize - 1 - Index] = Temp; + } +} + + +/** + Converts binary buffer to Unicode string in reversed byte order from R8_BufToHexString(). + + @param Str String for output + @param Buffer Binary buffer. + @param BufferSize Size of the buffer in bytes. + + @retval EFI_SUCCESS The function completed successfully. + +**/ +EFI_STATUS +EFIAPI +BufferToHexString ( + IN OUT CHAR16 *Str, + IN UINT8 *Buffer, + IN UINTN BufferSize + ) +{ + EFI_STATUS Status; + UINT8 *NewBuffer; + UINTN StrBufferLen; + + NewBuffer = AllocateCopyPool (BufferSize, Buffer); + SwapBuffer (NewBuffer, BufferSize); + + StrBufferLen = (BufferSize + 1) * sizeof (CHAR16); + Status = R8_BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize); + + gBS->FreePool (NewBuffer); + + return Status; +} + + +/** + Converts Hex String to binary buffer in reversed byte order from R8_HexStringToBuf(). + + @param Buffer Pointer to buffer that receives the data. + @param BufferSize Length in bytes of the buffer to hold converted + data. If routine return with EFI_SUCCESS, + containing length of converted data. If routine + return with EFI_BUFFER_TOO_SMALL, containg length + of buffer desired. + @param Str String to be converted from. + + @retval EFI_SUCCESS The function completed successfully. + +**/ +EFI_STATUS +EFIAPI +HexStringToBuffer ( + IN OUT UINT8 *Buffer, + IN OUT UINTN *BufferSize, + IN CHAR16 *Str + ) +{ + EFI_STATUS Status; + UINTN ConvertedStrLen; + + ConvertedStrLen = 0; + Status = R8_HexStringToBuf (Buffer, BufferSize, Str, &ConvertedStrLen); + if (!EFI_ERROR (Status)) { + SwapBuffer (Buffer, ConvertedStrLen); + } + + return Status; +} + + +/** + Construct <ConfigHdr> using routing information GUID/NAME/PATH. + + @param ConfigHdr Pointer to the ConfigHdr string. + @param StrBufferLen On input: Length in bytes of buffer to hold the + ConfigHdr string. Includes tailing '\0' character. + On output: If return EFI_SUCCESS, containing + length of ConfigHdr string buffer. If return + EFI_BUFFER_TOO_SMALL, containg length of string + buffer desired. + @param Guid Routing information: GUID. + @param Name Routing information: NAME. + @param DriverHandle Driver handle which contains the routing + information: PATH. + + @retval EFI_SUCCESS Routine success. + @retval EFI_BUFFER_TOO_SMALL The ConfigHdr string buffer is too small. + +**/ +EFI_STATUS +EFIAPI +ConstructConfigHdr ( + IN OUT CHAR16 *ConfigHdr, + IN OUT UINTN *StrBufferLen, + IN EFI_GUID *Guid, + IN CHAR16 *Name, OPTIONAL + IN EFI_HANDLE *DriverHandle + ) +{ + EFI_STATUS Status; + UINTN NameStrLen; + UINTN DevicePathSize; + UINTN BufferSize; + CHAR16 *StrPtr; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + if (Name == NULL) { + // + // There will be no "NAME" in <ConfigHdr> for Name/Value storage + // + NameStrLen = 0; + } else { + // + // For buffer storage + // + NameStrLen = StrLen (Name); + } + + // + // Retrieve DevicePath Protocol associated with this HiiPackageList + // + Status = gBS->HandleProtocol ( + DriverHandle, + &gEfiDevicePathProtocolGuid, + (VOID **) &DevicePath + ); + if (EFI_ERROR (Status)) { + return Status; + } + + DevicePathSize = GetDevicePathSize (DevicePath); + + // + // GUID=<HexCh>32&NAME=<Alpha>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL> + // | 5 | 32 | 6 | NameStrLen | 6 | DevicePathStrLen | + // + BufferSize = (5 + 32 + 6 + NameStrLen + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16); + if (*StrBufferLen < BufferSize) { + *StrBufferLen = BufferSize; + return EFI_BUFFER_TOO_SMALL; + } + + *StrBufferLen = BufferSize; + + StrPtr = ConfigHdr; + + StrCpy (StrPtr, L"GUID="); + StrPtr += 5; + BufferToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID)); + StrPtr += 32; + + StrCpy (StrPtr, L"&NAME="); + StrPtr += 6; + if (Name != NULL) { + StrCpy (StrPtr, Name); + StrPtr += NameStrLen; + } + + StrCpy (StrPtr, L"&PATH="); + StrPtr += 6; + BufferToHexString (StrPtr, (UINT8 *) DevicePath, DevicePathSize); + + return EFI_SUCCESS; +} + + +/** + Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string. + + @param String The string to be searched in. + @param Offset Offset in BlockName. + @param Width Width in BlockName. + + @retval TRUE Block name found. + @retval FALSE Block name not found. + +**/ +BOOLEAN +FindBlockName ( + IN OUT CHAR16 *String, + UINTN Offset, + UINTN Width + ) +{ + EFI_STATUS Status; + UINTN Data; + UINTN BufferSize; + UINTN ConvertedStrLen; + + while ((String = StrStr (String, L"&OFFSET=")) != NULL) { + // + // Skip '&OFFSET=' + // + String = String + 8; + + Data = 0; + BufferSize = sizeof (UINTN); + Status = R8_HexStringToBuf ((UINT8 *) &Data, &BufferSize, String, &ConvertedStrLen); + if (EFI_ERROR (Status)) { + return FALSE; + } + String = String + ConvertedStrLen; + + if (Data != Offset) { + continue; + } + + if (StrnCmp (String, L"&WIDTH=", 7) != 0) { + return FALSE; + } + String = String + 7; + + Data = 0; + BufferSize = sizeof (UINTN); + Status = R8_HexStringToBuf ((UINT8 *) &Data, &BufferSize, String, &ConvertedStrLen); + if (EFI_ERROR (Status)) { + return FALSE; + } + if (Data == Width) { + return TRUE; + } + + String = String + ConvertedStrLen; + } + + return FALSE; +} + + +/** + This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser. + + @param VariableGuid An optional field to indicate the target variable + GUID name to use. + @param VariableName An optional field to indicate the target + human-readable variable name. + @param BufferSize On input: Length in bytes of buffer to hold + retrived data. On output: If return + EFI_BUFFER_TOO_SMALL, containg length of buffer + desired. + @param Buffer Buffer to hold retrived data. + + @retval EFI_SUCCESS Routine success. + @retval EFI_BUFFER_TOO_SMALL The intput buffer is too small. + +**/ +EFI_STATUS +EFIAPI +GetBrowserData ( + EFI_GUID *VariableGuid, OPTIONAL + CHAR16 *VariableName, OPTIONAL + UINTN *BufferSize, + UINT8 *Buffer + ) +{ + EFI_STATUS Status; + CHAR16 *ConfigHdr; + CHAR16 *ConfigResp; + CHAR16 *StringPtr; + UINTN HeaderLen; + UINTN BufferLen; + CHAR16 *Progress; + EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + // + // Locate protocols for use + // + Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Retrive formset storage data from Form Browser + // + ConfigHdr = mFakeConfigHdr; + HeaderLen = StrLen (ConfigHdr); + + BufferLen = 0x4000; + ConfigResp = AllocateZeroPool (BufferLen + HeaderLen); + + StringPtr = ConfigResp + HeaderLen; + *StringPtr = L'&'; + StringPtr++; + + Status = FormBrowser2->BrowserCallback ( + FormBrowser2, + &BufferLen, + StringPtr, + TRUE, + VariableGuid, + VariableName + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + gBS->FreePool (ConfigResp); + ConfigResp = AllocateZeroPool (BufferLen + HeaderLen); + + StringPtr = ConfigResp + HeaderLen; + *StringPtr = L'&'; + StringPtr++; + + Status = FormBrowser2->BrowserCallback ( + FormBrowser2, + &BufferLen, + StringPtr, + TRUE, + VariableGuid, + VariableName + ); + } + if (EFI_ERROR (Status)) { + gBS->FreePool (ConfigResp); + return Status; + } + CopyMem (ConfigResp, ConfigHdr, HeaderLen * sizeof (UINT16)); + + // + // Convert <ConfigResp> to buffer data + // + Status = HiiConfigRouting->ConfigToBlock ( + HiiConfigRouting, + ConfigResp, + Buffer, + BufferSize, + &Progress + ); + gBS->FreePool (ConfigResp); + + return Status; +} + + +/** + This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser. + + @param VariableGuid An optional field to indicate the target variable + GUID name to use. + @param VariableName An optional field to indicate the target + human-readable variable name. + @param BufferSize Length in bytes of buffer to hold retrived data. + @param Buffer Buffer to hold retrived data. + @param RequestElement An optional field to specify which part of the + buffer data will be send back to Browser. If NULL, + the whole buffer of data will be committed to + Browser. <RequestElement> ::= + &OFFSET=<Number>&WIDTH=<Number>* + + @retval EFI_SUCCESS Routine success. + @retval Other Updating Browser uncommitted data failed. + +**/ +EFI_STATUS +EFIAPI +SetBrowserData ( + EFI_GUID *VariableGuid, OPTIONAL + CHAR16 *VariableName, OPTIONAL + UINTN BufferSize, + UINT8 *Buffer, + CHAR16 *RequestElement OPTIONAL + ) +{ + EFI_STATUS Status; + CHAR16 *ConfigHdr; + CHAR16 *ConfigResp; + CHAR16 *StringPtr; + UINTN HeaderLen; + UINTN BufferLen; + CHAR16 *Progress; + EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + CHAR16 BlockName[33]; + CHAR16 *ConfigRequest; + CHAR16 *Request; + + // + // Locate protocols for use + // + Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Prepare <ConfigRequest> + // + ConfigHdr = mFakeConfigHdr; + HeaderLen = StrLen (ConfigHdr); + + if (RequestElement == NULL) { + // + // RequestElement not specified, use "&OFFSET=0&WIDTH=<BufferSize>" as <BlockName> + // + BlockName[0] = L'\0'; + StrCpy (BlockName, L"&OFFSET=0&WIDTH="); + + // + // String lenghth of L"&OFFSET=0&WIDTH=" is 16 + // + StringPtr = BlockName + 16; + BufferLen = sizeof (BlockName) - (16 * sizeof (CHAR16)); + R8_BufToHexString (StringPtr, &BufferLen, (UINT8 *) &BufferSize, sizeof (UINTN)); + + Request = BlockName; + } else { + Request = RequestElement; + } + + BufferLen = HeaderLen * sizeof (CHAR16) + StrSize (Request); + ConfigRequest = AllocateZeroPool (BufferLen); + + CopyMem (ConfigRequest, ConfigHdr, HeaderLen * sizeof (CHAR16)); + StringPtr = ConfigRequest + HeaderLen; + StrCpy (StringPtr, Request); + + // + // Convert buffer to <ConfigResp> + // + Status = HiiConfigRouting->BlockToConfig ( + HiiConfigRouting, + ConfigRequest, + Buffer, + BufferSize, + &ConfigResp, + &Progress + ); + if (EFI_ERROR (Status)) { + gBS->FreePool (ConfigResp); + return Status; + } + + // + // Skip <ConfigHdr> and '&' + // + StringPtr = ConfigResp + HeaderLen + 1; + + // + // Change uncommitted data in Browser + // + Status = FormBrowser2->BrowserCallback ( + FormBrowser2, + &BufferSize, + StringPtr, + FALSE, + NULL, + NULL + ); + gBS->FreePool (ConfigResp); + return Status; +} diff --git a/MdePkg/Library/IfrSupportLib/UefiIfrLibraryInternal.h b/MdePkg/Library/IfrSupportLib/UefiIfrLibraryInternal.h new file mode 100644 index 0000000000..dd41c7aea3 --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/UefiIfrLibraryInternal.h @@ -0,0 +1,47 @@ +/** @file + +Copyright (c) 2007, Intel Corporation +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. + +Module Name: + + UefiIfrLibraryInternal + +Abstract: + + The file contain all library function for Ifr Operations. + + +**/ + +#ifndef _IFRLIBRARY_INTERNAL_H +#define _IFRLIBRARY_INTERNAL_H + + +#include <PiDxe.h> + +#include <Guid/GlobalVariable.h> +#include <Protocol/DevicePath.h> + +#include <Library/DebugLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/BaseLib.h> +#include <Library/DevicePathLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/IfrSupportLib.h> +#include <Library/HiiLib.h> +#include <Library/PcdLib.h> + +//#include <MdeModuleHii.h> + +#include "R8Lib.h" + +#endif diff --git a/MdePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c b/MdePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c new file mode 100644 index 0000000000..f2f82e06db --- /dev/null +++ b/MdePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c @@ -0,0 +1,618 @@ +/** @file + +Copyright (c) 2007, Intel Corporation +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. + +Module Name: + + UefiIfrOpCodeCreation.c + +Abstract: + + Library Routines to create IFR independent of string data - assume tokens already exist + Primarily to be used for exporting op-codes at a label in pre-defined forms. + +Revision History: + + +**/ + +#include "UefiIfrLibraryInternal.h" + +STATIC +BOOLEAN +IsValidQuestionFlags ( + IN UINT8 Flags + ) +{ + return (BOOLEAN) ((Flags & (~QUESTION_FLAGS)) ? FALSE : TRUE); +} + +STATIC +BOOLEAN +IsValidValueType ( + IN UINT8 Type + ) +{ + return (BOOLEAN) ((Type <= EFI_IFR_TYPE_OTHER) ? TRUE : FALSE); +} + +STATIC +BOOLEAN +IsValidNumricFlags ( + IN UINT8 Flags + ) +{ + if (Flags & ~(EFI_IFR_NUMERIC_SIZE | EFI_IFR_DISPLAY)) { + return FALSE; + } + + if ((Flags & EFI_IFR_DISPLAY) > EFI_IFR_DISPLAY_UINT_HEX) { + return FALSE; + } + + return TRUE; +} + +STATIC +BOOLEAN +IsValidCheckboxFlags ( + IN UINT8 Flags + ) +{ + return (BOOLEAN) ((Flags <= EFI_IFR_CHECKBOX_DEFAULT_MFG) ? TRUE : FALSE); +} + +EFI_STATUS +EFIAPI +CreateEndOpCode ( + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_END End; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (Data->Offset + sizeof (EFI_IFR_END) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + End.Header.Length = sizeof (EFI_IFR_END); + End.Header.OpCode = EFI_IFR_END_OP; + End.Header.Scope = 0; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &End, sizeof (EFI_IFR_END)); + Data->Offset += sizeof (EFI_IFR_END); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateDefaultOpCode ( + IN EFI_IFR_TYPE_VALUE *Value, + IN UINT8 Type, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_DEFAULT Default; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if ((Value == NULL) || !IsValidValueType (Type)) { + return EFI_INVALID_PARAMETER; + } + + if (Data->Offset + sizeof (EFI_IFR_DEFAULT) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + Default.Header.OpCode = EFI_IFR_DEFAULT_OP; + Default.Header.Length = sizeof (EFI_IFR_DEFAULT); + Default.Header.Scope = 0; + Default.Type = Type; + Default.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; + CopyMem (&Default.Value, Value, sizeof(EFI_IFR_TYPE_VALUE)); + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &Default, sizeof (EFI_IFR_DEFAULT)); + Data->Offset += sizeof (EFI_IFR_DEFAULT); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateActionOpCode ( + IN EFI_QUESTION_ID QuestionId, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN EFI_STRING_ID QuestionConfig, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_ACTION Action; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (!IsValidQuestionFlags (QuestionFlags)) { + return EFI_INVALID_PARAMETER; + } + + if (Data->Offset + sizeof (EFI_IFR_ACTION) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + Action.Header.OpCode = EFI_IFR_ACTION_OP; + Action.Header.Length = sizeof (EFI_IFR_ACTION); + Action.Header.Scope = 0; + Action.Question.QuestionId = QuestionId; + Action.Question.Header.Prompt = Prompt; + Action.Question.Header.Help = Help; + Action.Question.VarStoreId = INVALID_VARSTORE_ID; + Action.Question.Flags = QuestionFlags; + Action.QuestionConfig = QuestionConfig; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &Action, sizeof (EFI_IFR_ACTION)); + Data->Offset += sizeof (EFI_IFR_ACTION); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateSubTitleOpCode ( + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 Flags, + IN UINT8 Scope, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_SUBTITLE Subtitle; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (Data->Offset + sizeof (EFI_IFR_SUBTITLE) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP; + Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE); + Subtitle.Header.Scope = Scope; + Subtitle.Statement.Prompt = Prompt; + Subtitle.Statement.Help = Help; + Subtitle.Flags = Flags; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE)); + Data->Offset += sizeof (EFI_IFR_SUBTITLE); + + return EFI_SUCCESS; +} + + +EFI_STATUS +EFIAPI +CreateTextOpCode ( + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN EFI_STRING_ID TextTwo, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_TEXT Text; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (Data->Offset + sizeof (EFI_IFR_TEXT) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + Text.Header.OpCode = EFI_IFR_TEXT_OP; + Text.Header.Length = sizeof (EFI_IFR_TEXT); + Text.Header.Scope = 0; + Text.Statement.Prompt = Prompt; + Text.Statement.Help = Help; + Text.TextTwo = TextTwo; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &Text, sizeof (EFI_IFR_TEXT)); + Data->Offset += sizeof (EFI_IFR_TEXT); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateGotoOpCode ( + IN EFI_FORM_ID FormId, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN EFI_QUESTION_ID QuestionId, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_REF Goto; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (!IsValidQuestionFlags (QuestionFlags)) { + return EFI_INVALID_PARAMETER; + } + + if (Data->Offset + sizeof (EFI_IFR_REF) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + Goto.Header.OpCode = EFI_IFR_REF_OP; + Goto.Header.Length = sizeof (EFI_IFR_REF); + Goto.Header.Scope = 0; + Goto.Question.Header.Prompt = Prompt; + Goto.Question.Header.Help = Help; + Goto.Question.VarStoreId = INVALID_VARSTORE_ID; + Goto.Question.QuestionId = QuestionId; + Goto.Question.Flags = QuestionFlags; + Goto.FormId = FormId; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &Goto, sizeof (EFI_IFR_REF)); + Data->Offset += sizeof (EFI_IFR_REF); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateOneOfOptionOpCode ( + IN UINTN OptionCount, + IN IFR_OPTION *OptionsList, + IN UINT8 Type, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + UINTN Index; + UINT8 *LocalBuffer; + EFI_IFR_ONE_OF_OPTION OneOfOption; + + ASSERT (Data != NULL && Data->Data != NULL); + + if ((OptionCount != 0) && (OptionsList == NULL)) { + return EFI_INVALID_PARAMETER; + } + + if (Data->Offset + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + for (Index = 0; Index < OptionCount; Index++) { + OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + OneOfOption.Header.Scope = 0; + + OneOfOption.Option = OptionsList[Index].StringToken; + OneOfOption.Value = OptionsList[Index].Value; + OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG)); + OneOfOption.Type = Type; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION)); + Data->Offset += sizeof (EFI_IFR_ONE_OF_OPTION); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateOneOfOpCode ( + IN EFI_QUESTION_ID QuestionId, + IN EFI_VARSTORE_ID VarStoreId, + IN UINT16 VarOffset, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN UINT8 OneOfFlags, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + UINTN Length; + EFI_IFR_ONE_OF OneOf; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (!IsValidNumricFlags (OneOfFlags) || + !IsValidQuestionFlags (QuestionFlags) || + ((OptionCount != 0) && (OptionsList == NULL))) { + return EFI_INVALID_PARAMETER; + } + + Length = sizeof (EFI_IFR_ONE_OF) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END); + if (Data->Offset + Length > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP; + OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF); + OneOf.Header.Scope = 1; + OneOf.Question.Header.Prompt = Prompt; + OneOf.Question.Header.Help = Help; + OneOf.Question.QuestionId = QuestionId; + OneOf.Question.VarStoreId = VarStoreId; + OneOf.Question.VarStoreInfo.VarOffset = VarOffset; + OneOf.Question.Flags = QuestionFlags; + OneOf.Flags = OneOfFlags; + ZeroMem ((VOID *) &OneOf.data, sizeof (MINMAXSTEP_DATA)); + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF)); + Data->Offset += sizeof (EFI_IFR_ONE_OF); + + CreateOneOfOptionOpCode (OptionCount, OptionsList, (UINT8) (OneOfFlags & EFI_IFR_NUMERIC_SIZE), Data); + + CreateEndOpCode (Data); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateOrderedListOpCode ( + IN EFI_QUESTION_ID QuestionId, + IN EFI_VARSTORE_ID VarStoreId, + IN UINT16 VarOffset, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN UINT8 OrderedListFlags, + IN UINT8 DataType, + IN UINT8 MaxContainers, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + UINTN Length; + EFI_IFR_ORDERED_LIST OrderedList; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (!IsValidQuestionFlags (QuestionFlags) || + ((OptionCount != 0) && (OptionsList == NULL))) { + return EFI_INVALID_PARAMETER; + } + + if ((OrderedListFlags != 0) && + (OrderedListFlags != EFI_IFR_UNIQUE_SET) && + (OrderedListFlags != EFI_IFR_NO_EMPTY_SET)) { + return EFI_INVALID_PARAMETER; + } + + Length = sizeof (EFI_IFR_ORDERED_LIST) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END); + if (Data->Offset + Length > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP; + OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST); + OrderedList.Header.Scope = 1; + OrderedList.Question.Header.Prompt = Prompt; + OrderedList.Question.Header.Help = Help; + OrderedList.Question.QuestionId = QuestionId; + OrderedList.Question.VarStoreId = VarStoreId; + OrderedList.Question.VarStoreInfo.VarOffset = VarOffset; + OrderedList.Question.Flags = QuestionFlags; + OrderedList.MaxContainers = MaxContainers; + OrderedList.Flags = OrderedListFlags; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST)); + Data->Offset += sizeof (EFI_IFR_ORDERED_LIST); + + CreateOneOfOptionOpCode (OptionCount, OptionsList, DataType, Data); + + CreateEndOpCode (Data); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateCheckBoxOpCode ( + IN EFI_QUESTION_ID QuestionId, + IN EFI_VARSTORE_ID VarStoreId, + IN UINT16 VarOffset, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN UINT8 CheckBoxFlags, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_CHECKBOX CheckBox; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (!IsValidQuestionFlags (QuestionFlags) || !IsValidCheckboxFlags (CheckBoxFlags)) { + return EFI_INVALID_PARAMETER; + } + + if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP; + CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX); + CheckBox.Header.Scope = 0; + CheckBox.Question.QuestionId = QuestionId; + CheckBox.Question.VarStoreId = VarStoreId; + CheckBox.Question.VarStoreInfo.VarOffset = VarOffset; + CheckBox.Question.Header.Prompt = Prompt; + CheckBox.Question.Header.Help = Help; + CheckBox.Question.Flags = QuestionFlags; + CheckBox.Flags = CheckBoxFlags; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX)); + Data->Offset += sizeof (EFI_IFR_CHECKBOX); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateNumericOpCode ( + IN EFI_QUESTION_ID QuestionId, + IN EFI_VARSTORE_ID VarStoreId, + IN UINT16 VarOffset, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN UINT8 NumericFlags, + IN UINT64 Minimum, + IN UINT64 Maximum, + IN UINT64 Step, + IN UINT64 Default, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_STATUS Status; + EFI_IFR_NUMERIC Numeric; + MINMAXSTEP_DATA MinMaxStep; + EFI_IFR_TYPE_VALUE DefaultValue; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (!IsValidQuestionFlags (QuestionFlags) || !IsValidNumricFlags (NumericFlags)) { + return EFI_INVALID_PARAMETER; + } + + if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP; + Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC); + Numeric.Header.Scope = 1; + Numeric.Question.QuestionId = QuestionId; + Numeric.Question.VarStoreId = VarStoreId; + Numeric.Question.VarStoreInfo.VarOffset = VarOffset; + Numeric.Question.Header.Prompt = Prompt; + Numeric.Question.Header.Help = Help; + Numeric.Question.Flags = QuestionFlags; + Numeric.Flags = NumericFlags; + + switch (NumericFlags & EFI_IFR_NUMERIC_SIZE) { + case EFI_IFR_NUMERIC_SIZE_1: + MinMaxStep.u8.MinValue = (UINT8) Minimum; + MinMaxStep.u8.MaxValue = (UINT8) Maximum; + MinMaxStep.u8.Step = (UINT8) Step; + break; + + case EFI_IFR_NUMERIC_SIZE_2: + MinMaxStep.u16.MinValue = (UINT16) Minimum; + MinMaxStep.u16.MaxValue = (UINT16) Maximum; + MinMaxStep.u16.Step = (UINT16) Step; + break; + + case EFI_IFR_NUMERIC_SIZE_4: + MinMaxStep.u32.MinValue = (UINT32) Minimum; + MinMaxStep.u32.MaxValue = (UINT32) Maximum; + MinMaxStep.u32.Step = (UINT32) Step; + break; + + case EFI_IFR_NUMERIC_SIZE_8: + MinMaxStep.u64.MinValue = Minimum; + MinMaxStep.u64.MaxValue = Maximum; + MinMaxStep.u64.Step = Step; + break; + } + + CopyMem (&Numeric.data, &MinMaxStep, sizeof (MINMAXSTEP_DATA)); + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC)); + Data->Offset += sizeof (EFI_IFR_NUMERIC); + + DefaultValue.u64 = Default; + Status = CreateDefaultOpCode (&DefaultValue, (UINT8) (NumericFlags & EFI_IFR_NUMERIC_SIZE), Data); + if (EFI_ERROR(Status)) { + return Status; + } + + CreateEndOpCode (Data); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CreateStringOpCode ( + IN EFI_QUESTION_ID QuestionId, + IN EFI_VARSTORE_ID VarStoreId, + IN UINT16 VarOffset, + IN EFI_STRING_ID Prompt, + IN EFI_STRING_ID Help, + IN UINT8 QuestionFlags, + IN UINT8 StringFlags, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN OUT EFI_HII_UPDATE_DATA *Data + ) +{ + EFI_IFR_STRING String; + UINT8 *LocalBuffer; + + ASSERT (Data != NULL && Data->Data != NULL); + + if (!IsValidQuestionFlags (QuestionFlags) || (StringFlags & (~EFI_IFR_STRING_MULTI_LINE))) { + return EFI_INVALID_PARAMETER; + } + + if (Data->Offset + sizeof (EFI_IFR_STRING) > Data->BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + String.Header.OpCode = EFI_IFR_STRING_OP; + String.Header.Length = sizeof (EFI_IFR_STRING); + String.Header.Scope = 0; + String.Question.Header.Prompt = Prompt; + String.Question.Header.Help = Help; + String.Question.QuestionId = QuestionId; + String.Question.VarStoreId = VarStoreId; + String.Question.VarStoreInfo.VarOffset = VarOffset; + String.Question.Flags = QuestionFlags; + String.MinSize = MinSize; + String.MaxSize = MaxSize; + String.Flags = StringFlags; + + LocalBuffer = (UINT8 *) Data->Data + Data->Offset; + CopyMem (LocalBuffer, &String, sizeof (EFI_IFR_STRING)); + Data->Offset += sizeof (EFI_IFR_STRING); + + return EFI_SUCCESS; +} + + diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index 1a6f16270a..c43cd5cd25 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -77,6 +77,7 @@ MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
MdePkg/Library/DxeSmbusLib/DxeSmbusLib.inf
MdePkg/Library/HiiLib/HiiLib.inf
+ MdePkg/Library/IfrSupportLib/IfrSupportLib.inf
MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
MdePkg/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf
MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
|