From: klu2 Date: Mon, 22 Oct 2007 09:36:00 +0000 (+0000) Subject: Update following library class/Protocol for puting 'Framework' as prefix X-Git-Tag: edk2-stable201903~21838 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=8e5b17b25e91ffa293c1cbcb30e1c6997c6bdecd Update following library class/Protocol for puting 'Framework' as prefix FrameworkHii FrameworkFormBrowser FrameworkFormCallback FrameworkIfrSupportLib git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4196 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc index 7f98ec5d2f..af1486b2c6 100644 --- a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc +++ b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc @@ -80,8 +80,8 @@ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf - IfrSupportLibFramework|IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf + FrameworkIfrSupportLib|IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.inf PciIncompatibleDeviceSupportLib|IntelFrameworkModulePkg/Library/PciIncompatibleDeviceSupportLib/PciIncompatibleDeviceSupportLib.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf GraphicsLib|IntelFrameworkModulePkg/Library/GraphicsLib/GraphicsLib.inf @@ -98,8 +98,8 @@ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf - IfrSupportLibFramework|IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf + FrameworkIfrSupportLib|IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf ################################################################################ diff --git a/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c b/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c index 50eb1f56bc..5ab779a6a3 100644 --- a/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c +++ b/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c @@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include +#include #include diff --git a/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSample.h b/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSample.h index e32927d7a7..fbf93ece95 100644 --- a/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -20,8 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include -#include -#include +#include +#include #include #include @@ -29,10 +29,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include +#include #include #include -#include +#include #include "NVDataStruc.h" diff --git a/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf index 2a552838b0..aff2ae4695 100644 --- a/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf +++ b/IntelFrameworkModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf @@ -46,10 +46,10 @@ [LibraryClasses] - HiiLibFramework + FrameworkHiiLib MemoryAllocationLib BaseMemoryLib - IfrSupportLibFramework + FrameworkIfrSupportLib PrintLib BaseLib UefiDriverEntryPoint diff --git a/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.h b/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.h index 077a0cccdc..1498f3cc9e 100644 --- a/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.h +++ b/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.h @@ -21,8 +21,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include -#include +#include +#include #include #include @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include +#include // // HII Database Global data diff --git a/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.inf b/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.inf index a106feb14e..3e8c6d57f0 100644 --- a/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.inf +++ b/IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/HiiDatabase.inf @@ -46,7 +46,7 @@ IntelFrameworkPkg/IntelFrameworkPkg.dec [LibraryClasses] - IfrSupportLibFramework + FrameworkIfrSupportLib UefiRuntimeServicesTableLib UefiBootServicesTableLib BaseMemoryLib diff --git a/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/Setup.h b/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/Setup.h index bc26a5905d..098077776f 100644 --- a/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -18,9 +18,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include -#include -#include -#include +#include +#include +#include #include #include @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include +#include #include diff --git a/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/SetupBrowser.inf b/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/SetupBrowser.inf index 2b811953e1..f01b83d757 100644 --- a/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/SetupBrowser.inf +++ b/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/SetupBrowser.inf @@ -54,7 +54,7 @@ [LibraryClasses] GraphicsLib - HiiLibFramework + FrameworkHiiLib UefiRuntimeServicesTableLib UefiBootServicesTableLib PrintLib diff --git a/IntelFrameworkPkg/Include/Library/FrameworkHiiLib.h b/IntelFrameworkPkg/Include/Library/FrameworkHiiLib.h new file mode 100644 index 0000000000..d2d74336a0 --- /dev/null +++ b/IntelFrameworkPkg/Include/Library/FrameworkHiiLib.h @@ -0,0 +1,46 @@ +/** @file + Public include file for the HII Library + + Copyright (c) 2006, 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: HiiLib.h + +**/ + +#ifndef __HII_LIB_H__ +#define __HII_LIB_H__ + +#include + +/** + This function allocates pool for an EFI_HII_PACKAGES structure + with enough space for the variable argument list of package pointers. + The allocated structure is initialized using NumberOfPackages, Guid, + and the variable length argument list of package pointers. + + @param NumberOfPackages The number of HII packages to prepare. + @param Guid Package GUID. + + @return + The allocated and initialized packages. + +**/ +EFI_HII_PACKAGES * +EFIAPI +PreparePackages ( + IN UINTN NumberOfPackages, + IN CONST EFI_GUID *Guid OPTIONAL, + ... + ) +; + + + +#endif diff --git a/IntelFrameworkPkg/Include/Library/FrameworkIfrSupportLib.h b/IntelFrameworkPkg/Include/Library/FrameworkIfrSupportLib.h new file mode 100644 index 0000000000..d2a1ff5ee4 --- /dev/null +++ b/IntelFrameworkPkg/Include/Library/FrameworkIfrSupportLib.h @@ -0,0 +1,1270 @@ +/*++ + +Copyright (c) 2006, 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: + + IfrSupportLib.h + +Abstract: + + The file contain all library function for Ifr Operations. + +--*/ + +#ifndef _IFRSUPPORTLIBRARY_H +#define _IFRSUPPORTLIBRARY_H + +#define DEFAULT_FORM_BUFFER_SIZE 0xFFFF +#define DEFAULT_STRING_BUFFER_SIZE 0xFFFF + +#pragma pack(1) +typedef struct { + CHAR16 *OptionString; // Passed in string to generate a token for in a truly dynamic form creation + STRING_REF StringToken; // This is used when creating a single op-code without generating a StringToken (have one already) + UINT16 Value; + UINT8 Flags; + UINT16 Key; +} IFR_OPTION; +#pragma pack() + +EFI_STATUS +GetCurrentLanguage ( + OUT CHAR16 *Lang + ) +/*++ + +Routine Description: + + Determine what is the current language setting + +Arguments: + + Lang - Pointer of system language + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +AddString ( + IN VOID *StringBuffer, + IN CHAR16 *Language, + IN CHAR16 *String, + IN OUT STRING_REF *StringToken + ) +/*++ + +Routine Description: + + Add a string to the incoming buffer and return the token and offset data + +Arguments: + + StringBuffer - The incoming buffer + + Language - Currrent language + + String - The string to be added + + StringToken - The index where the string placed + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - String successfully added to the incoming buffer + +--*/ +; + +EFI_STATUS +AddOpCode ( + IN VOID *FormBuffer, + IN OUT VOID *OpCodeData + ) +/*++ + +Routine Description: + + Add op-code data to the FormBuffer + +Arguments: + + FormBuffer - Form buffer to be inserted to + + OpCodeData - Op-code data to be inserted + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Op-code data successfully inserted + +--*/ +; + +EFI_STATUS +CreateFormSet ( + IN CHAR16 *FormSetTitle, + IN EFI_GUID *Guid, + IN UINT8 Class, + IN UINT8 SubClass, + IN OUT VOID **FormBuffer, + IN OUT VOID **StringBuffer + ) +/*++ + +Routine Description: + + Create a formset + +Arguments: + + FormSetTitle - Title of formset + + Guid - Guid of formset + + Class - Class of formset + + SubClass - Sub class of formset + + FormBuffer - Pointer of the formset created + + StringBuffer - Pointer of FormSetTitile string created + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Formset successfully created + +--*/ +; + +EFI_STATUS +CreateForm ( + IN CHAR16 *FormTitle, + IN UINT16 FormId, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a form + +Arguments: + + FormTitle - Title of the form + + FormId - Id of the form + + FormBuffer - Pointer of the form created + + StringBuffer - Pointer of FormTitil string created + +Returns: + + EFI_SUCCESS - Form successfully created + +--*/ +; + +EFI_STATUS +CreateSubTitle ( + IN CHAR16 *SubTitle, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle + +Arguments: + + SubTitle - Sub title to be created + + FormBuffer - Where this subtitle to add to + + StringBuffer - String buffer created for subtitle + +Returns: + + EFI_SUCCESS - Subtitle successfully created + +--*/ +; + +EFI_STATUS +CreateText ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN CHAR16 *String3, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a line of text + +Arguments: + + String - First string of the text + + String2 - Second string of the text + + String3 - Help string of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - The form where this text adds to + + StringBuffer - String buffer created for String, String2 and String3 + +Returns: + + EFI_SUCCESS - Text successfully created + +--*/ +; + +EFI_STATUS +CreateGoto ( + IN UINT16 FormId, + IN CHAR16 *Prompt, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink + +Arguments: + + FormId - Form ID of the hyperlink + + Prompt - Prompt of the hyperlink + + FormBuffer - The form where this hyperlink adds to + + StringBuffer - String buffer created for Prompt + +Returns: + + EFI_SUCCESS - Hyperlink successfully created + +--*/ +; + +EFI_STATUS +CreateOneOf ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + Prompt - Prompt of the one-of box + + Help - Help of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - The form where this one-of box adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - One-Of box successfully created. + +--*/ +; + +EFI_STATUS +CreateOrderedList ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + Prompt - Prompt of the ordered list + + Help - Help of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - The form where this ordered list adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_SUCCESS - Ordered list successfully created. + +--*/ +; + +EFI_STATUS +CreateCheckBox ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 Flags, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a checkbox + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + Prompt - Prompt of the check box + + Help - Help of the check box + + Flags - Flags of the check box + + FormBuffer - The form where this check box adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 1 + + EFI_SUCCESS - Check box successfully created + +--*/ +; + +EFI_STATUS +CreateNumeric ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a numeric + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + Prompt - Prompt of the numeric + + Help - Help of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - The form where this numeric adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - Numeric is successfully created + +--*/ +; + +EFI_STATUS +CreateString ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a string + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + Prompt - Prompt of the string + + Help - Help of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - The form where this string adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_SUCCESS - String successfully created. + +--*/ +; + +EFI_STATUS +ExtractDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + IN OUT UINT16 *ImageLength, + OUT UINT8 *DefaultImage, + OUT EFI_GUID *Guid + ) +/*++ + +Routine Description: + + Extract information pertaining to the HiiHandle + +Arguments: + + HiiHandle - Hii handle + + ImageLength - For input, length of DefaultImage; + For output, length of actually required + + DefaultImage - Image buffer prepared by caller + + Guid - Guid information about the form + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength + + EFI_SUCCESS - Successfully extract data from Hii database. + + +--*/ +; + +EFI_HII_HANDLE +FindHiiHandle ( + IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL + IN EFI_GUID *Guid + ) +/*++ + +Routine Description: + Finds HII handle for given pack GUID previously registered with the HII. + +Arguments: + HiiProtocol - pointer to pointer to HII protocol interface. + If NULL, the interface will be found but not returned. + If it points to NULL, the interface will be found and + written back to the pointer that is pointed to. + Guid - The GUID of the pack that registered with the HII. + +Returns: + Handle to the HII pack previously registered by the memory driver. + +--*/ +; + +EFI_STATUS +CreateSubTitleOpCode ( + IN STRING_REF StringToken, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - StringToken of the subtitle + + FormBuffer - Output of subtitle as a form + +Returns: + + EFI_SUCCESS - Subtitle created to be a form + +--*/ +; + +EFI_STATUS +CreateTextOpCode ( + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN STRING_REF StringTokenThree, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a Text opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - First string token of the text + + StringTokenTwo - Second string token of the text + + StringTokenThree - Help string token of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - Output of text as a form + +Returns: + + EFI_SUCCESS - Text created to be a form + +--*/ +; + +EFI_STATUS +CreateGotoOpCode ( + IN UINT16 FormId, + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + FormId - Form ID of the hyperlink + + StringToken - Prompt string token of the hyperlink + + StringTokenTwo - Help string token of the hyperlink + + Flags - Flags of the hyperlink + + Key - Key of the hyperlink + + FormBuffer - Output of hyperlink as a form + +Returns: + + EFI_SUCCESS - Hyperlink created to be a form + +--*/ +; + +EFI_STATUS +CreateOneOfOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a one-of opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + PromptToken - Prompt string token of the one-of box + + HelpToken - Help string token of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - Output of One-Of box as a form + +Returns: + + EFI_SUCCESS - One-Of box created to be a form + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +; + +EFI_STATUS +CreateOrderedListOpCode ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a ordered list opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + PromptToken - Prompt string token of the ordered list + + HelpToken - Help string token of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - Output of ordered list as a form + +Returns: + + EFI_SUCCESS - Ordered list created to be a form + +--*/ +; + +EFI_STATUS +CreateCheckBoxOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a checkbox opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + PromptToken - Prompt string token of the check box + + HelpToken - Help string token of the check box + + Flags - Flags of the check box + + Key - Key of the check box + + FormBuffer - Output of the check box as a form + +Returns: + + EFI_SUCCESS - Checkbox created to be a form + + EFI_DEVICE_ERROR - DataWidth > 1 + +--*/ +; + +EFI_STATUS +CreateNumericOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + PromptToken - Prompt string token of the numeric + + HelpToken - Help string token of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value of the numeric + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - Output of the numeric as a form + +Returns: + + EFI_SUCCESS - The numeric created to be a form. + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +; + +EFI_STATUS +CreateStringOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + PromptToken - Prompt token of the string + + HelpToken - Help token of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - Output of the string as a form + +Returns: + + EFI_SUCCESS - String created to be a form. + +--*/ +; + +EFI_STATUS +ValidateDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + OUT BOOLEAN *Results + ) +/*++ + +Routine Description: + + Validate that the data associated with the HiiHandle in NVRAM is within + the reasonable parameters for that FormSet. Values for strings and passwords + are not verified due to their not having the equivalent of valid range settings. + +Arguments: + + HiiHandle - Handle of the HII database entry to query + + Results - If return Status is EFI_SUCCESS, Results provides valid data + TRUE = NVRAM Data is within parameters + FALSE = NVRAM Data is NOT within parameters + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Data successfully validated +--*/ +; + +EFI_STATUS +CreateBannerOpCode ( + IN UINT16 Title, + IN UINT16 LineNumber, + IN UINT8 Alignment, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a banner opcode. This is primarily used by the FrontPage implementation from BDS. + +Arguments: + + Title - Title of the banner + + LineNumber - LineNumber of the banner + + Alignment - Alignment of the banner + + FormBuffer - Output of banner as a form + +Returns: + + EFI_SUCCESS - Banner created to be a form. + +--*/ +; + +VOID +EfiLibHiiVariablePackGetMap ( + IN EFI_HII_VARIABLE_PACK *Pack, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, OPTIONAL + OUT UINTN *Size OPTIONAL + ) +/*++ + +Routine Description: + + Extracts a variable form a Pack. + +Arguments: + + Pack - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + VOID. + +--*/ +; + +UINTN +EfiLibHiiVariablePackListGetMapCnt ( + IN EFI_HII_VARIABLE_PACK_LIST *List + ) +/*++ + +Routine Description: + + Finds a count of the variables/maps in the List. + +Arguments: + + List - List of variables + +Returns: + + Number of Map in the variable pack list. + +--*/ +; + +typedef VOID (EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK) ( + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINT16 Id, + IN VOID *Var, + IN UINTN Size + ) +/*++ + +Routine Description: + + type definition for the callback to be + used with EfiLibHiiVariablePackListForEachVar(). + +Arguments: + + Id - Variable/Map ID + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + VOID + +--*/ +; + +VOID +EfiLibHiiVariablePackListForEachVar ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback + ) +/*++ + +Routine Description: + + Will iterate all variable/maps as appearing + in List and for each, it will call the Callback. + +Arguments: + + List - List of variables + Callback - Routine to be called for each iterated variable. + +Returns: + + VOID + +--*/ +; + +EFI_STATUS +EfiLibHiiVariablePackListGetMapByIdx ( + IN UINTN Idx, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + Finds a variable form List given + the order number as appears in the List. + +Arguments: + + Idx - The index of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ +; + +EFI_STATUS +EfiLibHiiVariablePackListGetMapById ( + IN UINT16 Id, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + Finds a variable form List given the + order number as appears in the List. + +Arguments: + + Id - The ID of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ +; + +EFI_STATUS +EfiLibHiiVariablePackListGetMap ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + OUT UINT16 *Id, + OUT VOID **Var, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID. + +Arguments: + + List - List of variables + Name - Name of the variable/map to be found + Guid - GUID of the variable/map to be found + Var - Pointer to the variable/map found + Size - Size of the variable/map in bytes found + +Returns: + + EFI_SUCCESS - variable is found, OUT parameters are valid + EFI_NOT_FOUND - variable is not found, OUT parameters are not valid + +--*/ +; + +EFI_STATUS +EfiLibHiiVariableRetrieveFromNv ( + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID **Var + ) +/*++ + +Routine Description: + Finds out if a variable of specific Name/Guid/Size exists in NV. + If it does, it will retrieve it into the Var. + +Arguments: + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into buffer pointed by this pointer. + If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer. +Returns: + EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +; + +//// +//// Variable override support. +//// + +EFI_STATUS +EfiLibHiiVariableOverrideIfSuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the Name ends with specified Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride", + the Suffix matches the end of Name, so the variable will be loaded from NV + provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the Name should end with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_INVALID_PARAMETER - The name of the variable does not end with . + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +; + +EFI_STATUS +EfiLibHiiVariableOverrideBySuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the NV contains the same variable with Name is appended with Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetup", + the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride" + will be loaded from NV provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the variable will be appended with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. + +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +; + +#endif diff --git a/IntelFrameworkPkg/Include/Library/HiiLibFramework.h b/IntelFrameworkPkg/Include/Library/HiiLibFramework.h deleted file mode 100644 index 91453e99ea..0000000000 --- a/IntelFrameworkPkg/Include/Library/HiiLibFramework.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - Public include file for the HII Library - - Copyright (c) 2006, 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: HiiLib.h - -**/ - -#ifndef __HII_LIB_H__ -#define __HII_LIB_H__ - -#include - -/** - This function allocates pool for an EFI_HII_PACKAGES structure - with enough space for the variable argument list of package pointers. - The allocated structure is initialized using NumberOfPackages, Guid, - and the variable length argument list of package pointers. - - @param NumberOfPackages The number of HII packages to prepare. - @param Guid Package GUID. - - @return - The allocated and initialized packages. - -**/ -EFI_HII_PACKAGES * -EFIAPI -PreparePackages ( - IN UINTN NumberOfPackages, - IN CONST EFI_GUID *Guid OPTIONAL, - ... - ) -; - - - -#endif diff --git a/IntelFrameworkPkg/Include/Library/IfrSupportLibFramework.h b/IntelFrameworkPkg/Include/Library/IfrSupportLibFramework.h deleted file mode 100644 index d2a1ff5ee4..0000000000 --- a/IntelFrameworkPkg/Include/Library/IfrSupportLibFramework.h +++ /dev/null @@ -1,1270 +0,0 @@ -/*++ - -Copyright (c) 2006, 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: - - IfrSupportLib.h - -Abstract: - - The file contain all library function for Ifr Operations. - ---*/ - -#ifndef _IFRSUPPORTLIBRARY_H -#define _IFRSUPPORTLIBRARY_H - -#define DEFAULT_FORM_BUFFER_SIZE 0xFFFF -#define DEFAULT_STRING_BUFFER_SIZE 0xFFFF - -#pragma pack(1) -typedef struct { - CHAR16 *OptionString; // Passed in string to generate a token for in a truly dynamic form creation - STRING_REF StringToken; // This is used when creating a single op-code without generating a StringToken (have one already) - UINT16 Value; - UINT8 Flags; - UINT16 Key; -} IFR_OPTION; -#pragma pack() - -EFI_STATUS -GetCurrentLanguage ( - OUT CHAR16 *Lang - ) -/*++ - -Routine Description: - - Determine what is the current language setting - -Arguments: - - Lang - Pointer of system language - -Returns: - - Status code - ---*/ -; - -EFI_STATUS -AddString ( - IN VOID *StringBuffer, - IN CHAR16 *Language, - IN CHAR16 *String, - IN OUT STRING_REF *StringToken - ) -/*++ - -Routine Description: - - Add a string to the incoming buffer and return the token and offset data - -Arguments: - - StringBuffer - The incoming buffer - - Language - Currrent language - - String - The string to be added - - StringToken - The index where the string placed - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - String successfully added to the incoming buffer - ---*/ -; - -EFI_STATUS -AddOpCode ( - IN VOID *FormBuffer, - IN OUT VOID *OpCodeData - ) -/*++ - -Routine Description: - - Add op-code data to the FormBuffer - -Arguments: - - FormBuffer - Form buffer to be inserted to - - OpCodeData - Op-code data to be inserted - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - Op-code data successfully inserted - ---*/ -; - -EFI_STATUS -CreateFormSet ( - IN CHAR16 *FormSetTitle, - IN EFI_GUID *Guid, - IN UINT8 Class, - IN UINT8 SubClass, - IN OUT VOID **FormBuffer, - IN OUT VOID **StringBuffer - ) -/*++ - -Routine Description: - - Create a formset - -Arguments: - - FormSetTitle - Title of formset - - Guid - Guid of formset - - Class - Class of formset - - SubClass - Sub class of formset - - FormBuffer - Pointer of the formset created - - StringBuffer - Pointer of FormSetTitile string created - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - Formset successfully created - ---*/ -; - -EFI_STATUS -CreateForm ( - IN CHAR16 *FormTitle, - IN UINT16 FormId, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a form - -Arguments: - - FormTitle - Title of the form - - FormId - Id of the form - - FormBuffer - Pointer of the form created - - StringBuffer - Pointer of FormTitil string created - -Returns: - - EFI_SUCCESS - Form successfully created - ---*/ -; - -EFI_STATUS -CreateSubTitle ( - IN CHAR16 *SubTitle, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a SubTitle - -Arguments: - - SubTitle - Sub title to be created - - FormBuffer - Where this subtitle to add to - - StringBuffer - String buffer created for subtitle - -Returns: - - EFI_SUCCESS - Subtitle successfully created - ---*/ -; - -EFI_STATUS -CreateText ( - IN CHAR16 *String, - IN CHAR16 *String2, - IN CHAR16 *String3, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a line of text - -Arguments: - - String - First string of the text - - String2 - Second string of the text - - String3 - Help string of the text - - Flags - Flag of the text - - Key - Key of the text - - FormBuffer - The form where this text adds to - - StringBuffer - String buffer created for String, String2 and String3 - -Returns: - - EFI_SUCCESS - Text successfully created - ---*/ -; - -EFI_STATUS -CreateGoto ( - IN UINT16 FormId, - IN CHAR16 *Prompt, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a hyperlink - -Arguments: - - FormId - Form ID of the hyperlink - - Prompt - Prompt of the hyperlink - - FormBuffer - The form where this hyperlink adds to - - StringBuffer - String buffer created for Prompt - -Returns: - - EFI_SUCCESS - Hyperlink successfully created - ---*/ -; - -EFI_STATUS -CreateOneOf ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a one-of question with a set of options to choose from. The - OptionsList is a pointer to a null-terminated list of option descriptions. - -Arguments: - - QuestionId - Question ID of the one-of box - - DataWidth - DataWidth of the one-of box - - Prompt - Prompt of the one-of box - - Help - Help of the one-of box - - OptionsList - Each string in it is an option of the one-of box - - OptionCount - Option string count - - FormBuffer - The form where this one-of box adds to - - StringBuffer - String buffer created for Prompt, Help and Option strings - -Returns: - - EFI_DEVICE_ERROR - DataWidth > 2 - - EFI_SUCCESS - One-Of box successfully created. - ---*/ -; - -EFI_STATUS -CreateOrderedList ( - IN UINT16 QuestionId, - IN UINT8 MaxEntries, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a one-of question with a set of options to choose from. The - OptionsList is a pointer to a null-terminated list of option descriptions. - -Arguments: - - QuestionId - Question ID of the ordered list - - MaxEntries - MaxEntries of the ordered list - - Prompt - Prompt of the ordered list - - Help - Help of the ordered list - - OptionsList - Each string in it is an option of the ordered list - - OptionCount - Option string count - - FormBuffer - The form where this ordered list adds to - - StringBuffer - String buffer created for Prompt, Help and Option strings - -Returns: - - EFI_SUCCESS - Ordered list successfully created. - ---*/ -; - -EFI_STATUS -CreateCheckBox ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN UINT8 Flags, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a checkbox - -Arguments: - - QuestionId - Question ID of the check box - - DataWidth - DataWidth of the check box - - Prompt - Prompt of the check box - - Help - Help of the check box - - Flags - Flags of the check box - - FormBuffer - The form where this check box adds to - - StringBuffer - String buffer created for Prompt and Help. - -Returns: - - EFI_DEVICE_ERROR - DataWidth > 1 - - EFI_SUCCESS - Check box successfully created - ---*/ -; - -EFI_STATUS -CreateNumeric ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN UINT16 Minimum, - IN UINT16 Maximum, - IN UINT16 Step, - IN UINT16 Default, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a numeric - -Arguments: - - QuestionId - Question ID of the numeric - - DataWidth - DataWidth of the numeric - - Prompt - Prompt of the numeric - - Help - Help of the numeric - - Minimum - Minumun boundary of the numeric - - Maximum - Maximum boundary of the numeric - - Step - Step of the numeric - - Default - Default value - - Flags - Flags of the numeric - - Key - Key of the numeric - - FormBuffer - The form where this numeric adds to - - StringBuffer - String buffer created for Prompt and Help. - -Returns: - - EFI_DEVICE_ERROR - DataWidth > 2 - - EFI_SUCCESS - Numeric is successfully created - ---*/ -; - -EFI_STATUS -CreateString ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN UINT8 MinSize, - IN UINT8 MaxSize, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a string - -Arguments: - - QuestionId - Question ID of the string - - DataWidth - DataWidth of the string - - Prompt - Prompt of the string - - Help - Help of the string - - MinSize - Min size boundary of the string - - MaxSize - Max size boundary of the string - - Flags - Flags of the string - - Key - Key of the string - - FormBuffer - The form where this string adds to - - StringBuffer - String buffer created for Prompt and Help. - -Returns: - - EFI_SUCCESS - String successfully created. - ---*/ -; - -EFI_STATUS -ExtractDataFromHiiHandle ( - IN EFI_HII_HANDLE HiiHandle, - IN OUT UINT16 *ImageLength, - OUT UINT8 *DefaultImage, - OUT EFI_GUID *Guid - ) -/*++ - -Routine Description: - - Extract information pertaining to the HiiHandle - -Arguments: - - HiiHandle - Hii handle - - ImageLength - For input, length of DefaultImage; - For output, length of actually required - - DefaultImage - Image buffer prepared by caller - - Guid - Guid information about the form - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength - - EFI_SUCCESS - Successfully extract data from Hii database. - - ---*/ -; - -EFI_HII_HANDLE -FindHiiHandle ( - IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL - IN EFI_GUID *Guid - ) -/*++ - -Routine Description: - Finds HII handle for given pack GUID previously registered with the HII. - -Arguments: - HiiProtocol - pointer to pointer to HII protocol interface. - If NULL, the interface will be found but not returned. - If it points to NULL, the interface will be found and - written back to the pointer that is pointed to. - Guid - The GUID of the pack that registered with the HII. - -Returns: - Handle to the HII pack previously registered by the memory driver. - ---*/ -; - -EFI_STATUS -CreateSubTitleOpCode ( - IN STRING_REF StringToken, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a SubTitle opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - StringToken - StringToken of the subtitle - - FormBuffer - Output of subtitle as a form - -Returns: - - EFI_SUCCESS - Subtitle created to be a form - ---*/ -; - -EFI_STATUS -CreateTextOpCode ( - IN STRING_REF StringToken, - IN STRING_REF StringTokenTwo, - IN STRING_REF StringTokenThree, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a Text opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - StringToken - First string token of the text - - StringTokenTwo - Second string token of the text - - StringTokenThree - Help string token of the text - - Flags - Flag of the text - - Key - Key of the text - - FormBuffer - Output of text as a form - -Returns: - - EFI_SUCCESS - Text created to be a form - ---*/ -; - -EFI_STATUS -CreateGotoOpCode ( - IN UINT16 FormId, - IN STRING_REF StringToken, - IN STRING_REF StringTokenTwo, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a hyperlink opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - FormId - Form ID of the hyperlink - - StringToken - Prompt string token of the hyperlink - - StringTokenTwo - Help string token of the hyperlink - - Flags - Flags of the hyperlink - - Key - Key of the hyperlink - - FormBuffer - Output of hyperlink as a form - -Returns: - - EFI_SUCCESS - Hyperlink created to be a form - ---*/ -; - -EFI_STATUS -CreateOneOfOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a one-of opcode with a set of option op-codes to choose from independent of string creation. - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - - OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken - has been filled in since this routine will not generate StringToken values. - -Arguments: - - QuestionId - Question ID of the one-of box - - DataWidth - DataWidth of the one-of box - - PromptToken - Prompt string token of the one-of box - - HelpToken - Help string token of the one-of box - - OptionsList - Each string in it is an option of the one-of box - - OptionCount - Option string count - - FormBuffer - Output of One-Of box as a form - -Returns: - - EFI_SUCCESS - One-Of box created to be a form - - EFI_DEVICE_ERROR - DataWidth > 2 - ---*/ -; - -EFI_STATUS -CreateOrderedListOpCode ( - IN UINT16 QuestionId, - IN UINT8 MaxEntries, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a ordered list opcode with a set of option op-codes to choose from independent of string creation. - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - - OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken - has been filled in since this routine will not generate StringToken values. - -Arguments: - - QuestionId - Question ID of the ordered list - - MaxEntries - MaxEntries of the ordered list - - PromptToken - Prompt string token of the ordered list - - HelpToken - Help string token of the ordered list - - OptionsList - Each string in it is an option of the ordered list - - OptionCount - Option string count - - FormBuffer - Output of ordered list as a form - -Returns: - - EFI_SUCCESS - Ordered list created to be a form - ---*/ -; - -EFI_STATUS -CreateCheckBoxOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a checkbox opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - QuestionId - Question ID of the check box - - DataWidth - DataWidth of the check box - - PromptToken - Prompt string token of the check box - - HelpToken - Help string token of the check box - - Flags - Flags of the check box - - Key - Key of the check box - - FormBuffer - Output of the check box as a form - -Returns: - - EFI_SUCCESS - Checkbox created to be a form - - EFI_DEVICE_ERROR - DataWidth > 1 - ---*/ -; - -EFI_STATUS -CreateNumericOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN UINT16 Minimum, - IN UINT16 Maximum, - IN UINT16 Step, - IN UINT16 Default, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a numeric opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - QuestionId - Question ID of the numeric - - DataWidth - DataWidth of the numeric - - PromptToken - Prompt string token of the numeric - - HelpToken - Help string token of the numeric - - Minimum - Minumun boundary of the numeric - - Maximum - Maximum boundary of the numeric - - Step - Step of the numeric - - Default - Default value of the numeric - - Flags - Flags of the numeric - - Key - Key of the numeric - - FormBuffer - Output of the numeric as a form - -Returns: - - EFI_SUCCESS - The numeric created to be a form. - - EFI_DEVICE_ERROR - DataWidth > 2 - ---*/ -; - -EFI_STATUS -CreateStringOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN UINT8 MinSize, - IN UINT8 MaxSize, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a numeric opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - QuestionId - Question ID of the string - - DataWidth - DataWidth of the string - - PromptToken - Prompt token of the string - - HelpToken - Help token of the string - - MinSize - Min size boundary of the string - - MaxSize - Max size boundary of the string - - Flags - Flags of the string - - Key - Key of the string - - FormBuffer - Output of the string as a form - -Returns: - - EFI_SUCCESS - String created to be a form. - ---*/ -; - -EFI_STATUS -ValidateDataFromHiiHandle ( - IN EFI_HII_HANDLE HiiHandle, - OUT BOOLEAN *Results - ) -/*++ - -Routine Description: - - Validate that the data associated with the HiiHandle in NVRAM is within - the reasonable parameters for that FormSet. Values for strings and passwords - are not verified due to their not having the equivalent of valid range settings. - -Arguments: - - HiiHandle - Handle of the HII database entry to query - - Results - If return Status is EFI_SUCCESS, Results provides valid data - TRUE = NVRAM Data is within parameters - FALSE = NVRAM Data is NOT within parameters - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - Data successfully validated ---*/ -; - -EFI_STATUS -CreateBannerOpCode ( - IN UINT16 Title, - IN UINT16 LineNumber, - IN UINT8 Alignment, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a banner opcode. This is primarily used by the FrontPage implementation from BDS. - -Arguments: - - Title - Title of the banner - - LineNumber - LineNumber of the banner - - Alignment - Alignment of the banner - - FormBuffer - Output of banner as a form - -Returns: - - EFI_SUCCESS - Banner created to be a form. - ---*/ -; - -VOID -EfiLibHiiVariablePackGetMap ( - IN EFI_HII_VARIABLE_PACK *Pack, - OUT CHAR16 **Name, OPTIONAL - OUT EFI_GUID **Guid, OPTIONAL - OUT UINT16 *Id, OPTIONAL - OUT VOID **Var, OPTIONAL - OUT UINTN *Size OPTIONAL - ) -/*++ - -Routine Description: - - Extracts a variable form a Pack. - -Arguments: - - Pack - List of variables - Name - Name of the variable/map - Guid - GUID of the variable/map - Var - Pointer to the variable/map - Size - Size of the variable/map in bytes - -Returns: - - VOID. - ---*/ -; - -UINTN -EfiLibHiiVariablePackListGetMapCnt ( - IN EFI_HII_VARIABLE_PACK_LIST *List - ) -/*++ - -Routine Description: - - Finds a count of the variables/maps in the List. - -Arguments: - - List - List of variables - -Returns: - - Number of Map in the variable pack list. - ---*/ -; - -typedef VOID (EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK) ( - IN CHAR16 *Name, - IN EFI_GUID *Guid, - IN UINT16 Id, - IN VOID *Var, - IN UINTN Size - ) -/*++ - -Routine Description: - - type definition for the callback to be - used with EfiLibHiiVariablePackListForEachVar(). - -Arguments: - - Id - Variable/Map ID - Name - Name of the variable/map - Guid - GUID of the variable/map - Var - Pointer to the variable/map - Size - Size of the variable/map in bytes - -Returns: - - VOID - ---*/ -; - -VOID -EfiLibHiiVariablePackListForEachVar ( - IN EFI_HII_VARIABLE_PACK_LIST *List, - IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback - ) -/*++ - -Routine Description: - - Will iterate all variable/maps as appearing - in List and for each, it will call the Callback. - -Arguments: - - List - List of variables - Callback - Routine to be called for each iterated variable. - -Returns: - - VOID - ---*/ -; - -EFI_STATUS -EfiLibHiiVariablePackListGetMapByIdx ( - IN UINTN Idx, - IN EFI_HII_VARIABLE_PACK_LIST *List, - OUT CHAR16 **Name, OPTIONAL - OUT EFI_GUID **Guid, OPTIONAL - OUT UINT16 *Id, OPTIONAL - OUT VOID **Var, - OUT UINTN *Size - ) -/*++ - -Routine Description: - - Finds a variable form List given - the order number as appears in the List. - -Arguments: - - Idx - The index of the variable/map to retrieve - List - List of variables - Name - Name of the variable/map - Guid - GUID of the variable/map - Var - Pointer to the variable/map - Size - Size of the variable/map in bytes - -Returns: - - EFI_SUCCESS - Variable is found, OUT parameters are valid - EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid - ---*/ -; - -EFI_STATUS -EfiLibHiiVariablePackListGetMapById ( - IN UINT16 Id, - IN EFI_HII_VARIABLE_PACK_LIST *List, - OUT CHAR16 **Name, OPTIONAL - OUT EFI_GUID **Guid, OPTIONAL - OUT VOID **Var, - OUT UINTN *Size - ) -/*++ - -Routine Description: - - Finds a variable form List given the - order number as appears in the List. - -Arguments: - - Id - The ID of the variable/map to retrieve - List - List of variables - Name - Name of the variable/map - Guid - GUID of the variable/map - Var - Pointer to the variable/map - Size - Size of the variable/map in bytes - -Returns: - - EFI_SUCCESS - Variable is found, OUT parameters are valid - EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid - ---*/ -; - -EFI_STATUS -EfiLibHiiVariablePackListGetMap ( - IN EFI_HII_VARIABLE_PACK_LIST *List, - IN CHAR16 *Name, - IN EFI_GUID *Guid, - OUT UINT16 *Id, - OUT VOID **Var, - OUT UINTN *Size - ) -/*++ - -Routine Description: - - Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID. - -Arguments: - - List - List of variables - Name - Name of the variable/map to be found - Guid - GUID of the variable/map to be found - Var - Pointer to the variable/map found - Size - Size of the variable/map in bytes found - -Returns: - - EFI_SUCCESS - variable is found, OUT parameters are valid - EFI_NOT_FOUND - variable is not found, OUT parameters are not valid - ---*/ -; - -EFI_STATUS -EfiLibHiiVariableRetrieveFromNv ( - IN CHAR16 *Name, - IN EFI_GUID *Guid, - IN UINTN Size, - OUT VOID **Var - ) -/*++ - -Routine Description: - Finds out if a variable of specific Name/Guid/Size exists in NV. - If it does, it will retrieve it into the Var. - -Arguments: - Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. - Var - Variable will be retrieved into buffer pointed by this pointer. - If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer. -Returns: - EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var. - EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. - EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. - ---*/ -; - -//// -//// Variable override support. -//// - -EFI_STATUS -EfiLibHiiVariableOverrideIfSuffix ( - IN CHAR16 *Suffix, - IN CHAR16 *Name, - IN EFI_GUID *Guid, - IN UINTN Size, - OUT VOID *Var - ) -/*++ - -Routine Description: - Overrrides the variable with NV data if found. - But it only does it if the Name ends with specified Suffix. - For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride", - the Suffix matches the end of Name, so the variable will be loaded from NV - provided the variable exists and the GUID and Size matches. - -Arguments: - Suffix - Suffix the Name should end with. - Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. - Var - Variable will be retrieved into this buffer. - Caller is responsible for providing storage of exactly Size size in bytes. -Returns: - EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. - EFI_INVALID_PARAMETER - The name of the variable does not end with . - EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. - EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. - ---*/ -; - -EFI_STATUS -EfiLibHiiVariableOverrideBySuffix ( - IN CHAR16 *Suffix, - IN CHAR16 *Name, - IN EFI_GUID *Guid, - IN UINTN Size, - OUT VOID *Var - ) -/*++ - -Routine Description: - Overrrides the variable with NV data if found. - But it only does it if the NV contains the same variable with Name is appended with Suffix. - For example, if Suffix="MyOverride" and the Name="XyzSetup", - the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride" - will be loaded from NV provided the variable exists and the GUID and Size matches. - -Arguments: - Suffix - Suffix the variable will be appended with. - Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. - Var - Variable will be retrieved into this buffer. - Caller is responsible for providing storage of exactly Size size in bytes. - -Returns: - EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. - EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. - EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. - ---*/ -; - -#endif diff --git a/IntelFrameworkPkg/Include/Protocol/FormBrowserFramework.h b/IntelFrameworkPkg/Include/Protocol/FormBrowserFramework.h deleted file mode 100644 index 74b9b4b5ae..0000000000 --- a/IntelFrameworkPkg/Include/Protocol/FormBrowserFramework.h +++ /dev/null @@ -1,162 +0,0 @@ -/** @file - The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI - Configuration Driver. This will allow the caller to direct the - configuration driver to use either the HII database or use the passed - in packet of data. This will also allow the caller to post messages - into the configuration drivers internal mailbox. - - Copyright (c) 2006, 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: FrameworkFormBrowser.h - - @par Revision Reference: - This protocol is defined in HII spec 0.92. - -**/ - -#ifndef __FRAMEWORK_FORM_BROWSER_H__ -#define __FRAMEWORK_FORM_BROWSER_H__ - -#include - - -#define EFI_FORM_BROWSER_PROTOCOL_GUID \ - { \ - 0xe5a1333e, 0xe1b4, 0x4d55, {0xce, 0xeb, 0x35, 0xc3, 0xef, 0x13, 0x34, 0x43 } \ - } - -typedef struct _EFI_FORM_BROWSER_PROTOCOL EFI_FORM_BROWSER_PROTOCOL; - -typedef struct { - UINT32 Length; - UINT16 Type; - UINT8 Data[1]; -} EFI_HII_PACKET; - -typedef struct { - EFI_HII_IFR_PACK *IfrData; - EFI_HII_STRING_PACK *StringData; -} EFI_IFR_PACKET; - -typedef struct { - UINTN LeftColumn; - UINTN RightColumn; - UINTN TopRow; - UINTN BottomRow; -} EFI_SCREEN_DESCRIPTOR; - -/** - Provides direction to the configuration driver whether to use the HII - database or a passed-in set of data. This function also establishes a - pointer to the calling driver's callback interface. - - @param This A pointer to the EFI_FORM_BROWSER_PROTOCOL instance. - @param UseDatabase Determines whether the HII database is to be - used to gather information. If the value is FALSE, the configuration - driver will get the information provided in the passed-in Packet parameters. - @param Handle A pointer to an array of HII handles to display. This value - should correspond to the value of the HII form package that is required to - be displayed. - @param HandleCount The number of handles in the array specified by Handle. - @param Packet A pointer to a set of data containing pointers to IFR - and/or string data. - @param CallbackHandle The handle to the driver's callback interface. - This parameter is used only when the UseDatabase parameter is FALSE - and an application wants to register a callback with the browser - @param NvMapOverride This buffer is used only when there is no NV variable - to define the current settings and the caller needs to provide to the browser - the current settings for the "fake" NV variable. - @param ScreenDimensions Allows the browser to be called so that it occupies - a portion of the physical screen instead of dynamically determining the - screen dimensions. - @param ResetRequired This BOOLEAN value will tell the caller if a reset - is required based on the data that might have been changed. The ResetRequired - parameter is primarily applicable for configuration applications, and is an - optional parameter. - - @retval EFI_SUCCESS The function completed successfully - @retval EFI_NOT_FOUND The variable was not found. - @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. - DataSize has been updated with the size needed to complete the request. - @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. - @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SEND_FORM) ( - IN EFI_FORM_BROWSER_PROTOCOL *This, - IN BOOLEAN UseDatabase, - IN EFI_HII_HANDLE *Handle, - IN UINTN HandleCount, - IN EFI_IFR_PACKET *Packet, OPTIONAL - IN EFI_HANDLE CallbackHandle, OPTIONAL - IN UINT8 *NvMapOverride, OPTIONAL - IN EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL - OUT BOOLEAN *ResetRequired OPTIONAL - ); - -/** - Routine used to abstract a generic dialog interface and return the selected - key or string. - - @param NumberOfLines The number of lines for the dialog box. - @param HotKey Defines whether a single character is parsed (TRUE) - and returned in KeyValue or if a string is returned in StringBuffer. - @param MaximumStringSize The maximum size in bytes of a typed-in string. - Because each character is a CHAR16, the minimum string returned is two bytes. - @param StringBuffer The passed-in pointer to the buffer that will hold - the typed in string if HotKey is FALSE. - @param KeyValue The EFI_INPUT_KEY value returned if HotKey is TRUE. - @param String The pointer to the first string in the list of strings - that comprise the dialog box. - @param ... A series of NumberOfLines text strings that will be used - to construct the dialog box. - - @retval EFI_SUCCESS The dialog was displayed and user interaction was received. - @retval EFI_DEVICE_ERROR The user typed in an ESC character to exit the routine. - @retval EFI_INVALID_PARAMETER One of the parameters was invalid - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_CREATE_POP_UP) ( - IN UINTN NumberOfLines, - IN BOOLEAN HotKey, - IN UINTN MaximumStringSize, - OUT CHAR16 *StringBuffer, - OUT EFI_INPUT_KEY *KeyValue, - IN CHAR16 *String, - ... - ); - -/** - @par Protocol Description: - The EFI_FORM_BROWSER_PROTOCOL is the interface to call for drivers to - leverage the EFI configuration driver interface. - - @param SendForm - Provides direction to the configuration driver whether to use the HII - database or to use a passed-in set of data. This functions also establishes - a pointer to the calling driver's callback interface. - - @param CreatePopUp - Routine used to abstract a generic dialog interface and return the - selected key or string. - -**/ -struct _EFI_FORM_BROWSER_PROTOCOL { - EFI_SEND_FORM SendForm; - EFI_CREATE_POP_UP CreatePopUp; -}; - -extern EFI_GUID gEfiFormBrowserProtocolGuid; - -#endif diff --git a/IntelFrameworkPkg/Include/Protocol/FormCallbackFramework.h b/IntelFrameworkPkg/Include/Protocol/FormCallbackFramework.h deleted file mode 100644 index 708eabcb10..0000000000 --- a/IntelFrameworkPkg/Include/Protocol/FormCallbackFramework.h +++ /dev/null @@ -1,211 +0,0 @@ -/** @file - The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom - NV storage devices as well as communication of user selections in a more - interactive environment. This protocol should be published by hardware - specific drivers which want to export access to custom hardware storage or - publish IFR which has a requirement to call back the original driver. - - Copyright (c) 2006, 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: FormCallbackFramework.h - - @par Revision Reference: - This protocol is defined in HII spec 0.92. - -**/ - -#ifndef __FORM_CALLBACK_H__ -#define __FORM_CALLBACK_H__ - -#include - -#include -#include - -#define EFI_FORM_CALLBACK_PROTOCOL_GUID \ - { \ - 0xf3e4543d, 0xcf35, 0x6cef, {0x35, 0xc4, 0x4f, 0xe6, 0x34, 0x4d, 0xfc, 0x54 } \ - } - -// -// Forward reference for pure ANSI compatability -// -typedef struct _EFI_FORM_CALLBACK_PROTOCOL EFI_FORM_CALLBACK_PROTOCOL; - - -#define RESET_REQUIRED 1 // Flags setting to signify that the callback operation resulted in an eventual -// reset to be done upon exit of the browser -// -#define EXIT_REQUIRED 2 // Flags setting to signify that after the processing of the callback results - exit the browser -#define SAVE_REQUIRED 4 // Flags setting to signify that after the processing of the callback results - save the NV data -#define NV_CHANGED 8 // Flags setting to signify that after the processing of the callback results - turn the NV flag on -#define NV_NOT_CHANGED 16 // Flags setting to signify that after the processing of the callback results - turn the NV flag off -#pragma pack(1) -typedef struct { - UINT8 OpCode; // Likely a string, numeric, or one-of - UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet - UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback - VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately - // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value - // If the OpCode is a String type - Data is a CHAR16[x] type - // If the OpCode is a Checkbox type - Data is a UINT8 value - // If the OpCode is a NV Access type - Data is a EFI_IFR_NV_DATA structure - // -} EFI_IFR_DATA_ENTRY; - -typedef struct { - VOID *NvRamMap; // If the flag of the op-code specified retrieval of a copy of the NVRAM map, - // this is a pointer to a buffer copy - // - UINT32 EntryCount; // How many EFI_IFR_DATA_ENTRY entries - // - // EFI_IFR_DATA_ENTRY Data[1]; // The in-line Data entries. - // -} EFI_IFR_DATA_ARRAY; - - -typedef union { - EFI_IFR_DATA_ARRAY DataArray; // Primarily used by those who call back to their drivers and use HII as a repository - EFI_IFR_PACKET DataPacket; // Primarily used by those which do not use HII as a repository - CHAR16 *String; // If returning an error - fill the string with null-terminated contents -} EFI_HII_CALLBACK_PACKET; - -typedef struct { - EFI_IFR_OP_HEADER Header; - UINT16 QuestionId; // Offset into the map - UINT8 StorageWidth; // Width of the value - // - // CHAR8 Data[1]; // The Data itself - // -} EFI_IFR_NV_DATA; - -#pragma pack() -// -// The following types are currently defined: -// -/** - Returns the value of a variable. - - @param This A pointer to the EFI_FORM_CALLBACK_PROTOCOL instance. - @param VariableName A NULL-terminated Unicode string that is the - name of the vendor's variable. - @param VendorGuid A unique identifier for the vendor. - @param Attributes If not NULL, a pointer to the memory location to - return the attribute's bit-mask for the variable. - @param DataSize The size in bytes of the Buffer. A size of zero causes - the variable to be deleted. - @param Buffer The buffer to return the contents of the variable. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_NOT_FOUND The variable was not found. - @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. - DataSize has been updated with the size needed to complete the request. - @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. - @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_NV_READ) ( - IN EFI_FORM_CALLBACK_PROTOCOL *This, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - OUT UINT32 *Attributes OPTIONAL, - IN OUT UINTN *DataSize, - OUT VOID *Buffer - ); - -/** - Sets the value of a variable. - - @param This A pointer to the EFI_FORM_CALLBACK_PROTOCOL instance. - @param VariableName A NULL-terminated Unicode string that is the - name of the vendor's variable. Each VariableName is unique for each VendorGuid. - @param VendorGuid A unique identifier for the vendor. - @param Attributes Attributes bit-mask to set for the variable. - @param DataSize The size in bytes of the Buffer. A size of zero causes - the variable to be deleted. - @param Buffer The buffer containing the contents of the variable. - @param ResetRequired Returns a value from the driver that abstracts - this information and will enable a system to know if a system reset - is required to achieve the configuration changes being enabled through - this function. - - @retval EFI_SUCCESS The firmware has successfully stored the variable and - its data as defined by the Attributes. - @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold - the variable and its data. - @retval EFI_INVALID_PARAMETER An invalid combination of Attributes bits - was supplied, or the DataSize exceeds the maximum allowed. - @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_NV_WRITE) ( - IN EFI_FORM_CALLBACK_PROTOCOL *This, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Buffer, - OUT BOOLEAN *ResetRequired - ); - -/** - This function is called to provide results data to the driver. - - @param This A pointer to the EFI_FORM_CALLBACK_PROTOCOL instance. - @param KeyValue A unique value which is sent to the original exporting - driver so that it can identify the type of data to expect. The format of - the data tends to vary based on the opcode that generated the callback. - @param Data A pointer to the data being sent to the original exporting driver. - @param Packet A pointer to a packet of information which a driver passes - back to the browser. - - @return Status Code - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_FORM_CALLBACK) ( - IN EFI_FORM_CALLBACK_PROTOCOL *This, - IN UINT16 KeyValue, - IN EFI_IFR_DATA_ARRAY *Data, - OUT EFI_HII_CALLBACK_PACKET **Packet - ); - -/** - @par Protocol Description: - The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to - custom NVS devices as well as communication of user selections in a more - interactive environment. This protocol should be published by hardware-specific - drivers that want to export access to custom hardware storage or publish IFR - that has a requirement to call back the original driver. - - @param NvRead - The read operation to access the NV data serviced by a hardware-specific driver. - - @param NvWrite - The write operation to access the NV data serviced by a hardware-specific driver. - - @param Callback - The function that is called from the configuration browser to communicate key value pairs. - -**/ -struct _EFI_FORM_CALLBACK_PROTOCOL { - EFI_NV_READ NvRead; - EFI_NV_WRITE NvWrite; - EFI_FORM_CALLBACK Callback; -}; - -extern EFI_GUID gEfiFormCallbackProtocolGuid; - -#endif diff --git a/IntelFrameworkPkg/Include/Protocol/FrameworkFormBrowser.h b/IntelFrameworkPkg/Include/Protocol/FrameworkFormBrowser.h new file mode 100644 index 0000000000..867a5b79bd --- /dev/null +++ b/IntelFrameworkPkg/Include/Protocol/FrameworkFormBrowser.h @@ -0,0 +1,162 @@ +/** @file + The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI + Configuration Driver. This will allow the caller to direct the + configuration driver to use either the HII database or use the passed + in packet of data. This will also allow the caller to post messages + into the configuration drivers internal mailbox. + + Copyright (c) 2006, 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: FrameworkFormBrowser.h + + @par Revision Reference: + This protocol is defined in HII spec 0.92. + +**/ + +#ifndef __FRAMEWORK_FORM_BROWSER_H__ +#define __FRAMEWORK_FORM_BROWSER_H__ + +#include + + +#define EFI_FORM_BROWSER_PROTOCOL_GUID \ + { \ + 0xe5a1333e, 0xe1b4, 0x4d55, {0xce, 0xeb, 0x35, 0xc3, 0xef, 0x13, 0x34, 0x43 } \ + } + +typedef struct _EFI_FORM_BROWSER_PROTOCOL EFI_FORM_BROWSER_PROTOCOL; + +typedef struct { + UINT32 Length; + UINT16 Type; + UINT8 Data[1]; +} EFI_HII_PACKET; + +typedef struct { + EFI_HII_IFR_PACK *IfrData; + EFI_HII_STRING_PACK *StringData; +} EFI_IFR_PACKET; + +typedef struct { + UINTN LeftColumn; + UINTN RightColumn; + UINTN TopRow; + UINTN BottomRow; +} EFI_SCREEN_DESCRIPTOR; + +/** + Provides direction to the configuration driver whether to use the HII + database or a passed-in set of data. This function also establishes a + pointer to the calling driver's callback interface. + + @param This A pointer to the EFI_FORM_BROWSER_PROTOCOL instance. + @param UseDatabase Determines whether the HII database is to be + used to gather information. If the value is FALSE, the configuration + driver will get the information provided in the passed-in Packet parameters. + @param Handle A pointer to an array of HII handles to display. This value + should correspond to the value of the HII form package that is required to + be displayed. + @param HandleCount The number of handles in the array specified by Handle. + @param Packet A pointer to a set of data containing pointers to IFR + and/or string data. + @param CallbackHandle The handle to the driver's callback interface. + This parameter is used only when the UseDatabase parameter is FALSE + and an application wants to register a callback with the browser + @param NvMapOverride This buffer is used only when there is no NV variable + to define the current settings and the caller needs to provide to the browser + the current settings for the "fake" NV variable. + @param ScreenDimensions Allows the browser to be called so that it occupies + a portion of the physical screen instead of dynamically determining the + screen dimensions. + @param ResetRequired This BOOLEAN value will tell the caller if a reset + is required based on the data that might have been changed. The ResetRequired + parameter is primarily applicable for configuration applications, and is an + optional parameter. + + @retval EFI_SUCCESS The function completed successfully + @retval EFI_NOT_FOUND The variable was not found. + @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. + DataSize has been updated with the size needed to complete the request. + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. + @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SEND_FORM) ( + IN EFI_FORM_BROWSER_PROTOCOL *This, + IN BOOLEAN UseDatabase, + IN EFI_HII_HANDLE *Handle, + IN UINTN HandleCount, + IN EFI_IFR_PACKET *Packet, OPTIONAL + IN EFI_HANDLE CallbackHandle, OPTIONAL + IN UINT8 *NvMapOverride, OPTIONAL + IN EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL + OUT BOOLEAN *ResetRequired OPTIONAL + ); + +/** + Routine used to abstract a generic dialog interface and return the selected + key or string. + + @param NumberOfLines The number of lines for the dialog box. + @param HotKey Defines whether a single character is parsed (TRUE) + and returned in KeyValue or if a string is returned in StringBuffer. + @param MaximumStringSize The maximum size in bytes of a typed-in string. + Because each character is a CHAR16, the minimum string returned is two bytes. + @param StringBuffer The passed-in pointer to the buffer that will hold + the typed in string if HotKey is FALSE. + @param KeyValue The EFI_INPUT_KEY value returned if HotKey is TRUE. + @param String The pointer to the first string in the list of strings + that comprise the dialog box. + @param ... A series of NumberOfLines text strings that will be used + to construct the dialog box. + + @retval EFI_SUCCESS The dialog was displayed and user interaction was received. + @retval EFI_DEVICE_ERROR The user typed in an ESC character to exit the routine. + @retval EFI_INVALID_PARAMETER One of the parameters was invalid + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_CREATE_POP_UP) ( + IN UINTN NumberOfLines, + IN BOOLEAN HotKey, + IN UINTN MaximumStringSize, + OUT CHAR16 *StringBuffer, + OUT EFI_INPUT_KEY *KeyValue, + IN CHAR16 *String, + ... + ); + +/** + @par Protocol Description: + The EFI_FORM_BROWSER_PROTOCOL is the interface to call for drivers to + leverage the EFI configuration driver interface. + + @param SendForm + Provides direction to the configuration driver whether to use the HII + database or to use a passed-in set of data. This functions also establishes + a pointer to the calling driver's callback interface. + + @param CreatePopUp + Routine used to abstract a generic dialog interface and return the + selected key or string. + +**/ +struct _EFI_FORM_BROWSER_PROTOCOL { + EFI_SEND_FORM SendForm; + EFI_CREATE_POP_UP CreatePopUp; +}; + +extern EFI_GUID gEfiFormBrowserProtocolGuid; + +#endif diff --git a/IntelFrameworkPkg/Include/Protocol/FrameworkFormCallback.h b/IntelFrameworkPkg/Include/Protocol/FrameworkFormCallback.h new file mode 100644 index 0000000000..12aed7dc90 --- /dev/null +++ b/IntelFrameworkPkg/Include/Protocol/FrameworkFormCallback.h @@ -0,0 +1,211 @@ +/** @file + The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom + NV storage devices as well as communication of user selections in a more + interactive environment. This protocol should be published by hardware + specific drivers which want to export access to custom hardware storage or + publish IFR which has a requirement to call back the original driver. + + Copyright (c) 2006, 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: FrameworkFormCallback.h + + @par Revision Reference: + This protocol is defined in HII spec 0.92. + +**/ + +#ifndef __FORM_CALLBACK_H__ +#define __FORM_CALLBACK_H__ + +#include + +#include +#include + +#define EFI_FORM_CALLBACK_PROTOCOL_GUID \ + { \ + 0xf3e4543d, 0xcf35, 0x6cef, {0x35, 0xc4, 0x4f, 0xe6, 0x34, 0x4d, 0xfc, 0x54 } \ + } + +// +// Forward reference for pure ANSI compatability +// +typedef struct _EFI_FORM_CALLBACK_PROTOCOL EFI_FORM_CALLBACK_PROTOCOL; + + +#define RESET_REQUIRED 1 // Flags setting to signify that the callback operation resulted in an eventual +// reset to be done upon exit of the browser +// +#define EXIT_REQUIRED 2 // Flags setting to signify that after the processing of the callback results - exit the browser +#define SAVE_REQUIRED 4 // Flags setting to signify that after the processing of the callback results - save the NV data +#define NV_CHANGED 8 // Flags setting to signify that after the processing of the callback results - turn the NV flag on +#define NV_NOT_CHANGED 16 // Flags setting to signify that after the processing of the callback results - turn the NV flag off +#pragma pack(1) +typedef struct { + UINT8 OpCode; // Likely a string, numeric, or one-of + UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet + UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback + VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately + // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value + // If the OpCode is a String type - Data is a CHAR16[x] type + // If the OpCode is a Checkbox type - Data is a UINT8 value + // If the OpCode is a NV Access type - Data is a EFI_IFR_NV_DATA structure + // +} EFI_IFR_DATA_ENTRY; + +typedef struct { + VOID *NvRamMap; // If the flag of the op-code specified retrieval of a copy of the NVRAM map, + // this is a pointer to a buffer copy + // + UINT32 EntryCount; // How many EFI_IFR_DATA_ENTRY entries + // + // EFI_IFR_DATA_ENTRY Data[1]; // The in-line Data entries. + // +} EFI_IFR_DATA_ARRAY; + + +typedef union { + EFI_IFR_DATA_ARRAY DataArray; // Primarily used by those who call back to their drivers and use HII as a repository + EFI_IFR_PACKET DataPacket; // Primarily used by those which do not use HII as a repository + CHAR16 *String; // If returning an error - fill the string with null-terminated contents +} EFI_HII_CALLBACK_PACKET; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // Offset into the map + UINT8 StorageWidth; // Width of the value + // + // CHAR8 Data[1]; // The Data itself + // +} EFI_IFR_NV_DATA; + +#pragma pack() +// +// The following types are currently defined: +// +/** + Returns the value of a variable. + + @param This A pointer to the EFI_FORM_CALLBACK_PROTOCOL instance. + @param VariableName A NULL-terminated Unicode string that is the + name of the vendor's variable. + @param VendorGuid A unique identifier for the vendor. + @param Attributes If not NULL, a pointer to the memory location to + return the attribute's bit-mask for the variable. + @param DataSize The size in bytes of the Buffer. A size of zero causes + the variable to be deleted. + @param Buffer The buffer to return the contents of the variable. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_NOT_FOUND The variable was not found. + @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. + DataSize has been updated with the size needed to complete the request. + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. + @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_NV_READ) ( + IN EFI_FORM_CALLBACK_PROTOCOL *This, + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Buffer + ); + +/** + Sets the value of a variable. + + @param This A pointer to the EFI_FORM_CALLBACK_PROTOCOL instance. + @param VariableName A NULL-terminated Unicode string that is the + name of the vendor's variable. Each VariableName is unique for each VendorGuid. + @param VendorGuid A unique identifier for the vendor. + @param Attributes Attributes bit-mask to set for the variable. + @param DataSize The size in bytes of the Buffer. A size of zero causes + the variable to be deleted. + @param Buffer The buffer containing the contents of the variable. + @param ResetRequired Returns a value from the driver that abstracts + this information and will enable a system to know if a system reset + is required to achieve the configuration changes being enabled through + this function. + + @retval EFI_SUCCESS The firmware has successfully stored the variable and + its data as defined by the Attributes. + @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold + the variable and its data. + @retval EFI_INVALID_PARAMETER An invalid combination of Attributes bits + was supplied, or the DataSize exceeds the maximum allowed. + @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_NV_WRITE) ( + IN EFI_FORM_CALLBACK_PROTOCOL *This, + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Buffer, + OUT BOOLEAN *ResetRequired + ); + +/** + This function is called to provide results data to the driver. + + @param This A pointer to the EFI_FORM_CALLBACK_PROTOCOL instance. + @param KeyValue A unique value which is sent to the original exporting + driver so that it can identify the type of data to expect. The format of + the data tends to vary based on the opcode that generated the callback. + @param Data A pointer to the data being sent to the original exporting driver. + @param Packet A pointer to a packet of information which a driver passes + back to the browser. + + @return Status Code + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_FORM_CALLBACK) ( + IN EFI_FORM_CALLBACK_PROTOCOL *This, + IN UINT16 KeyValue, + IN EFI_IFR_DATA_ARRAY *Data, + OUT EFI_HII_CALLBACK_PACKET **Packet + ); + +/** + @par Protocol Description: + The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to + custom NVS devices as well as communication of user selections in a more + interactive environment. This protocol should be published by hardware-specific + drivers that want to export access to custom hardware storage or publish IFR + that has a requirement to call back the original driver. + + @param NvRead + The read operation to access the NV data serviced by a hardware-specific driver. + + @param NvWrite + The write operation to access the NV data serviced by a hardware-specific driver. + + @param Callback + The function that is called from the configuration browser to communicate key value pairs. + +**/ +struct _EFI_FORM_CALLBACK_PROTOCOL { + EFI_NV_READ NvRead; + EFI_NV_WRITE NvWrite; + EFI_FORM_CALLBACK Callback; +}; + +extern EFI_GUID gEfiFormCallbackProtocolGuid; + +#endif diff --git a/IntelFrameworkPkg/Include/Protocol/FrameworkHii.h b/IntelFrameworkPkg/Include/Protocol/FrameworkHii.h new file mode 100644 index 0000000000..32e66ed45d --- /dev/null +++ b/IntelFrameworkPkg/Include/Protocol/FrameworkHii.h @@ -0,0 +1,951 @@ +/** @file + This file defines the Human Interface Infrastructure protocol which will + be used by resources which want to publish IFR/Font/String data and have it + collected by the Configuration engine. + + 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: FrameworkHii.h + + @par Revision Reference: + This protocol is defined in HII spec 0.92. + +**/ + +#ifndef _FRAMEWORK_HII_H_ +#define _FRAMEWORK_HII_H_ + +#include + +// +// To get EFI_GRAPHICS_OUTPUT_BLT_PIXEL, +// is defined in MdePkg/Protocol/GraphicsOutput.h +// +#include + +#define EFI_HII_PROTOCOL_GUID \ + { \ + 0xd7ad636e, 0xb997, 0x459b, {0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 0xe1} \ + } + +// BugBug: +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// If UGA goes away we need to put this some place. I'm not sure where? +// +//typedef struct { +// UINT8 Blue; +// UINT8 Green; +// UINT8 Red; +// UINT8 Reserved; +//} EFI_UGA_PIXEL; + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// + +typedef struct _EFI_HII_PROTOCOL EFI_HII_PROTOCOL; + +// +// Global definition +// +#define NARROW_CHAR 0xFFF0 +#define WIDE_CHAR 0xFFF1 +#define NON_BREAKING_CHAR 0xFFF2 +#define GLYPH_WIDTH 8 +#define GLYPH_HEIGHT 19 + +#define EFI_HII_FONT 1 +#define EFI_HII_STRING 2 +#define EFI_HII_IFR 3 +#define EFI_HII_KEYBOARD 4 +#define EFI_HII_HANDLES 5 +#define EFI_HII_VARIABLE 6 +#define EFI_HII_DEVICE_PATH 7 + + +// References to string tokens must use this macro to enable scanning for +// token usages. +// +#define STRING_TOKEN(t) t + +// +// The following types are currently defined: +// EFI_FROM_ID has been defined in UEFI spec. +// +typedef UINT16 EFI_FORM_LABEL; + +#pragma pack(1) + +typedef struct { + UINT32 Length; + UINT16 Type; +} EFI_HII_PACK_HEADER; + +// +// A form list consists of a large variety of structure +// possibilities so to represent the binary blob of data +// associated with a package of forms, we will assume a +// pointer to a self-describing data buffer. +// +typedef struct { + EFI_HII_PACK_HEADER Header; +} EFI_HII_IFR_PACK; + +typedef struct { + EFI_HII_PACK_HEADER Header; // Must be filled in + EFI_HANDLE ImageHandle; // Must be filled in + EFI_HANDLE DeviceHandle; // Optional + EFI_HANDLE ControllerHandle; // Optional + EFI_HANDLE CallbackHandle; // Optional + EFI_HANDLE COBExportHandle; // Optional +} EFI_HII_HANDLE_PACK; + +// +// ******************************************************** +// EFI_VARIABLE_CONTENTS +// ******************************************************** +// +typedef struct { + EFI_HII_PACK_HEADER Header; + EFI_GUID VariableGuid; + UINT32 VariableNameLength; + UINT16 VariableId; + // + // CHAR16 VariableName[]; //Null-terminated + // +} EFI_HII_VARIABLE_PACK; + +// +// ******************************************************** +// EFI_DEVICE_PATH_PACK +// ******************************************************** +// +typedef struct { + EFI_HII_PACK_HEADER Header; + // + // EFI_DEVICE_PATH DevicePath[]; + // +} EFI_HII_DEVICE_PATH_PACK; + +// +// ******************************************************** +// EFI_HII_DATA_TABLE +// ******************************************************** +// +typedef struct { + EFI_HII_HANDLE HiiHandle; + EFI_GUID PackageGuid; + UINT32 DataTableSize; + UINT32 IfrDataOffset; + UINT32 StringDataOffset; + UINT32 VariableDataOffset; + UINT32 DevicePathOffset; + UINT32 NumberOfVariableData; + UINT32 NumberOfLanguages; + // + // EFI_HII_DEVICE_PATH_PACK DevicePath[]; + // EFI_HII_VARIABLE_PACK VariableData[]; + // EFI_HII_IFR_PACK IfrData; + // EFI_HII_STRING_PACK StringData[]; + // +} EFI_HII_DATA_TABLE; + +// +// ******************************************************** +// EFI_HII_EXPORT_TABLE +// ******************************************************** +// +typedef struct { + UINT32 NumberOfHiiDataTables; + EFI_GUID Revision; + // + // EFI_HII_DATA_TABLE HiiDataTable[]; + // +} EFI_HII_EXPORT_TABLE; + +typedef struct { + BOOLEAN FormSetUpdate; // If TRUE, next variable is significant + EFI_PHYSICAL_ADDRESS FormCallbackHandle; // If not 0, will update Formset with this info + BOOLEAN FormUpdate; // If TRUE, next variable is significant + UINT16 FormValue; // specify which form is to be updated if FormUpdate value is TRUE. + STRING_REF FormTitle; // If not 0, will update Form with this info + UINT16 DataCount; // The number of Data entries in this structure + UINT8 *Data; // An array of 1+ op-codes, specified by DataCount +} EFI_HII_UPDATE_DATA; + +// +// String attributes +// +#define LANG_RIGHT_TO_LEFT 0x00000001 + +// +// A string package is used to localize strings to a particular +// language. The package is associated with a particular driver +// or set of drivers. Tools are used to associate tokens with +// string references in forms and in programs. These tokens are +// language agnostic. When paired with a language pack (directly +// or indirectly), the string token resolves into an actual +// UNICODE string. The NumStringPointers determines how many +// StringPointers (offset values) there are as well as the total +// number of Strings that are defined. +// +typedef struct { + EFI_HII_PACK_HEADER Header; + RELOFST LanguageNameString; + RELOFST PrintableLanguageName; + UINT32 NumStringPointers; + UINT32 Attributes; + // + // RELOFST StringPointers[]; + // EFI_STRING Strings[]; + // +} EFI_HII_STRING_PACK; + +// +// Glyph Attributes +// +#define EFI_GLYPH_NON_SPACING 1 +#define EFI_GLYPH_WIDE 2 + +typedef struct { + CHAR16 UnicodeWeight; + UINT8 Attributes; + UINT8 GlyphCol1[GLYPH_HEIGHT]; +} EFI_NARROW_GLYPH; + +typedef struct { + CHAR16 UnicodeWeight; + UINT8 Attributes; + UINT8 GlyphCol1[GLYPH_HEIGHT]; + UINT8 GlyphCol2[GLYPH_HEIGHT]; + UINT8 Pad[3]; +} EFI_WIDE_GLYPH; + +// +// A font list consists of a font header followed by a series +// of glyph structures. Note that fonts are not language specific. +// +typedef struct { + EFI_HII_PACK_HEADER Header; + UINT16 NumberOfNarrowGlyphs; + UINT16 NumberOfWideGlyphs; +} EFI_HII_FONT_PACK; + +// +// The IfrData in the EFI_HII_IFR_PACK structure definition +// is variable length, and not really part of the header. To +// simplify from code the size of the header, define an +// identical structure that does not include the IfrData field. +// Then use sizeof() this new structure to determine the +// actual size of the header. +// +typedef struct { + EFI_HII_PACK_HEADER Header; +} EFI_HII_IFR_PACK_HEADER; + +// +// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER; +// +typedef enum { + EfiKeyLCtrl, + EfiKeyA0, + EfiKeyLAlt, + EfiKeySpaceBar, + EfiKeyA2, + EfiKeyA3, + EfiKeyA4, + EfiKeyRCtrl, + EfiKeyLeftArrow, + EfiKeyDownArrow, + EfiKeyRightArrow, + EfiKeyZero, + EfiKeyPeriod, + EfiKeyEnter, + EfiKeyLShift, + EfiKeyB0, + EfiKeyB1, + EfiKeyB2, + EfiKeyB3, + EfiKeyB4, + EfiKeyB5, + EfiKeyB6, + EfiKeyB7, + EfiKeyB8, + EfiKeyB9, + EfiKeyB10, + EfiKeyRshift, + EfiKeyUpArrow, + EfiKeyOne, + EfiKeyTwo, + EfiKeyThree, + EfiKeyCapsLock, + EfiKeyC1, + EfiKeyC2, + EfiKeyC3, + EfiKeyC4, + EfiKeyC5, + EfiKeyC6, + EfiKeyC7, + EfiKeyC8, + EfiKeyC9, + EfiKeyC10, + EfiKeyC11, + EfiKeyC12, + EfiKeyFour, + EfiKeyFive, + EfiKeySix, + EfiKeyPlus, + EfiKeyTab, + EfiKeyD1, + EfiKeyD2, + EfiKeyD3, + EfiKeyD4, + EfiKeyD5, + EfiKeyD6, + EfiKeyD7, + EfiKeyD8, + EfiKeyD9, + EfiKeyD10, + EfiKeyD11, + EfiKeyD12, + EfiKeyD13, + EfiKeyDel, + EfiKeyEnd, + EfiKeyPgDn, + EfiKeySeven, + EfiKeyEight, + EfiKeyNine, + EfiKeyE0, + EfiKeyE1, + EfiKeyE2, + EfiKeyE3, + EfiKeyE4, + EfiKeyE5, + EfiKeyE6, + EfiKeyE7, + EfiKeyE8, + EfiKeyE9, + EfiKeyE10, + EfiKeyE11, + EfiKeyE12, + EfiKeyBackSpace, + EfiKeyIns, + EfiKeyHome, + EfiKeyPgUp, + EfiKeyNLck, + EfiKeySlash, + EfiKeyAsterisk, + EfiKeyMinus, + EfiKeyEsc, + EfiKeyF1, + EfiKeyF2, + EfiKeyF3, + EfiKeyF4, + EfiKeyF5, + EfiKeyF6, + EfiKeyF7, + EfiKeyF8, + EfiKeyF9, + EfiKeyF10, + EfiKeyF11, + EfiKeyF12, + EfiKeyPrint, + EfiKeySLck, + EfiKeyPause +} EFI_KEY; + +typedef struct { + EFI_KEY Key; + CHAR16 Unicode; + CHAR16 ShiftedUnicode; + CHAR16 AltGrUnicode; + CHAR16 ShiftedAltGrUnicode; + UINT16 Modifier; +} EFI_KEY_DESCRIPTOR; + +// +// This structure allows a sparse set of keys to be redefined +// or a complete redefinition of the keyboard layout. Most +// keyboards have a lot of commonality in their layouts, therefore +// only defining those keys that need to change from the default +// minimizes the passed in information. +// +// Additionally, when an update occurs, the active keyboard layout +// will be switched to the newly updated keyboard layout. This +// allows for situations that when a keyboard layout driver is +// loaded as part of system initialization, the system will default +// the keyboard behavior to the new layout. +// +// Each call to update the keyboard mapping should contain the +// complete set of key descriptors to be updated, since every +// call to the HII which contains an EFI_HII_KEYBOARD_PACK will +// wipe the previous set of overrides. A call to +// +typedef struct { + EFI_HII_PACK_HEADER Header; + EFI_KEY_DESCRIPTOR *Descriptor; + UINT8 DescriptorCount; +} EFI_HII_KEYBOARD_PACK; + +// +// The EFI_HII_PACKAGES can contain different types of packages just +// after the structure as inline data. +// +typedef struct { + UINTN NumberOfPackages; + EFI_GUID *GuidId; + // + // EFI_HII_HANDLE_PACK *HandlePack; // Only one pack. + // EFI_HII_IFR_PACK *IfrPack; // Only one pack. + // EFI_HII_FONT_PACK *FontPack[]; // Multiple packs ok + // EFI_HII_STRING_PACK *StringPack[]; // Multiple packs ok + // EFI_HII_KEYBOARD_PACK *KeyboardPack[]; // Multiple packs ok + // +} EFI_HII_PACKAGES; + +typedef struct _EFI_HII_VARIABLE_PACK_LIST { + struct _EFI_HII_VARIABLE_PACK_LIST *NextVariablePack; + EFI_HII_VARIABLE_PACK *VariablePack; +} EFI_HII_VARIABLE_PACK_LIST; + + +#pragma pack() + +/** + Registers the various packs that are passed in via the Packages parameter. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Packages A pointer to an EFI_HII_PACKAGES package instance. + @param Handle A pointer to the EFI_HII_HANDLE instance. + + @retval EFI_SUCCESS Data was extracted from Packages, the database + was updated with the data, and Handle returned successfully. + @retval EFI_INVALID_PARAMETER The content of Packages was invalid. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_NEW_PACK) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_PACKAGES *Packages, + OUT EFI_HII_HANDLE *Handle + ); + +/** + Removes a package from the HII database. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle that was registered to the data that is requested + for removal. + + @retval EFI_SUCCESS The data associated with the Handle was removed + from the HII database. + @retval EFI_INVALID_PARAMETER The Handle was not valid. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_REMOVE_PACK) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle + ); + +/** + Determines the handles that are currently active in the database. + + @param This A pointer to the EFI_HII_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 Handle An array of EFI_HII_HANDLE instances returned. + + @retval EFI_SUCCESS Handle was updated successfully. + @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates + that Handle is too small to support the number of handles. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_FIND_HANDLES) ( + IN EFI_HII_PROTOCOL *This, + IN OUT UINT16 *HandleBufferLength, + OUT EFI_HII_HANDLE *Handle + ); + +/** + Exports the contents of the database into a buffer. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle An EFI_HII_HANDLE that corresponds to the desired + handle to export. If the value is 0, the entire database will be exported. + In either case, the data will be exported in a format described by the + structure definition of EFI_HII_EXPORT_TABLE. + @param BufferSize + On input, a pointer to the length of the buffer. On output, the length + of the buffer that is required for the export data. + @param Buffer A pointer to a buffer that will contain the results of the export function. + + @retval EFI_SUCCESS The buffer was successfully filled with BufferSize amount of data. + @retval EFI_BUFFER_TOO_SMALL The value in BufferSize was too small to contain the export data. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_EXPORT) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + +/** + Remove any new strings that were added after the initial string export + for this handle. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle on which the string resides. + + @retval EFI_SUCCESS Remove strings from the handle successfully. + @retval EFI_INVALID_PARAMETER The Handle was unknown. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_RESET_STRINGS) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle + ); + +/** + Tests if all of the characters in a string have corresponding font characters. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param StringToTest A pointer to a Unicode string. + @param FirstMissing A pointer to an index into the string. On input, + the index of the first character in the StringToTest to examine. On exit, + the index of the first character encountered for which a glyph is unavailable. + If all glyphs in the string are available, the index is the index of the + terminator of the string. + @param GlyphBufferSize A pointer to a value. On output, if the function + returns EFI_SUCCESS, it contains the amount of memory that is required to + store the string's glyph equivalent. + + @retval EFI_SUCCESS All glyphs are available. Note that an empty string + always returns this value. + @retval EFI_NOT_FOUND A glyph was not found for a character. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_TEST_STRING) ( + IN EFI_HII_PROTOCOL *This, + IN CHAR16 *StringToTest, + IN OUT UINT32 *FirstMissing, + OUT UINT32 *GlyphBufferSize + ); + +/** + Translates a Unicode character into the corresponding font glyph. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Source A pointer to a Unicode string. + @param Index On input, the offset into the string from which to fetch + the character.On successful completion, the index is updated to the first + character past the character(s) making up the just extracted glyph. + @param GlyphBuffer Pointer to an array where the glyphs corresponding + to the characters in the source may be stored. GlyphBuffer is assumed + to be wide enough to accept a wide glyph character. + @param BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by + this value is filled with the length of the glyph in pixels. It is unchanged + if the call was unsuccessful. + @param InternalStatus The cell pointed to by this parameter must be + initialized to zero prior to invoking the call the first time for any string. + + @retval EFI_SUCCESS It worked. + @retval EFI_NOT_FOUND A glyph for a character was not found. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_GLYPH) ( + IN EFI_HII_PROTOCOL *This, + IN CHAR16 *Source, + IN OUT UINT16 *Index, + OUT UINT8 **GlyphBuffer, + OUT UINT16 *BitWidth, + IN OUT UINT32 *InternalStatus + ); + +/** + Translates a glyph into the format required for input to the Universal + Graphics Adapter (UGA) Block Transfer (BLT) routines. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param GlyphBuffer A pointer to the buffer that contains glyph data. + @param Foreground The foreground setting requested to be used for the + generated BltBuffer data. + @param Background The background setting requested to be used for the + generated BltBuffer data. + @param Count The entry in the BltBuffer upon which to act. + @param Width The width in bits of the glyph being converted. + @param Height The height in bits of the glyph being converted + @param BltBuffer A pointer to the buffer that contains the data that is + ready to be used by the UGA BLT routines. + + @retval EFI_SUCCESS It worked. + @retval EFI_NOT_FOUND A glyph for a character was not found. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GLYPH_TO_BLT) ( + IN EFI_HII_PROTOCOL *This, + IN UINT8 *GlyphBuffer, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background, + IN UINTN Count, + IN UINTN Width, + IN UINTN Height, + IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer + ); + +/** + Allows a new string to be added to an already existing string package. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Pointer to a NULL-terminated string containing a single ISO 639-2 + language identifier, indicating the language in which the string is translated. + @param Handle The handle of the language pack to which the string is to be added. + @param Reference The identifier of the string to be added. If the reference + value is zero, then the string will be assigned a new identifier on that + handle for the language specified. Otherwise, the string will be updated + with the NewString Value. + @param NewString The string to be added. + + @retval EFI_SUCCESS The string was effectively registered. + @retval EFI_INVALID_PARAMETER The Handle was unknown. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_NEW_STRING) ( + IN EFI_HII_PROTOCOL *This, + IN CHAR16 *Language, + IN EFI_HII_HANDLE Handle, + IN OUT STRING_REF *Reference, + IN CHAR16 *NewString + ); + +/** + Allows a program to determine the primary languages that are supported + on a given handle. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle on which the strings reside. + @param LanguageString A string allocated by GetPrimaryLanguages() that + contains a list of all primary languages registered on the handle. + + @retval EFI_SUCCESS LanguageString was correctly returned. + @retval EFI_INVALID_PARAMETER The Handle was unknown. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + OUT EFI_STRING *LanguageString + ); + +/** + Allows a program to determine which secondary languages are supported + on a given handle for a given primary language. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle on which the strings reside. + @param PrimaryLanguage Pointer to a NULL-terminated string containing a single + ISO 639-2 language identifier, indicating the primary language. + @param LanguageString A string allocated by GetSecondaryLanguages() + containing a list of all secondary languages registered on the handle. + + @retval EFI_SUCCESS LanguageString was correctly returned. + @retval EFI_INVALID_PARAMETER The Handle was unknown. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN CHAR16 *PrimaryLanguage, + OUT EFI_STRING *LanguageString + ); + +/** + Extracts a string from a package already registered with the EFI HII database. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle on which the string resides. + @param Token The string token assigned to the string. + @param Raw If TRUE, the string is returned unedited in the internal + storage format described above. If false, the string returned is edited + by replacing with and by removing special characters such + as the prefix. + @param LanguageString Pointer to a NULL-terminated string containing a + single ISO 639-2 language identifier, indicating the language to print. + If the LanguageString is empty (starts with a NULL), the default system + language will be used to determine the language. + @param BufferLength Length of the StringBuffer. + @param StringBuffer The buffer designed to receive the characters in the string. + + @retval EFI_SUCCESS StringBuffer is filled with a NULL-terminated string. + @retval EFI_INVALID_PARAMETER The handle or string token is unknown. + @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough to + allow the entire string to be stored. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_STRING) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN STRING_REF Token, + IN BOOLEAN Raw, + IN CHAR16 *LanguageString, + IN OUT UINTN *BufferLength, + OUT EFI_STRING StringBuffer + ); + +/** + Allows a program to extract a part of a string of not more than a given width. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle on which the string resides. + @param Token The string token assigned to the string. + @param Index On input, the offset into the string where the line is to start. + On output, the index is updated to point to beyond the last character returned + in the call. + @param LineWidth The maximum width of the line in units of narrow glyphs. + @param LanguageString Pointer to a NULL-terminated string containing a + single ISO 639-2 language identifier, indicating the language to print. + @param BufferLength Pointer to the length of the StringBuffer. + @param StringBuffer The buffer designed to receive the characters in the string. + + @retval EFI_SUCCESS StringBuffer filled with characters that will fit on the line. + @retval EFI_NOT_FOUND The font glyph for at least one of the characters in + the string is not in the font database. + @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough + to allow the entire string to be stored. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_LINE) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN STRING_REF Token, + IN OUT UINT16 *Index, + IN UINT16 LineWidth, + IN CHAR16 *LanguageString, + IN OUT UINT16 *BufferLength, + OUT EFI_STRING StringBuffer + ); + +/** + Allows a program to extract a form or form package that has previously + been registered with the HII database. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle Handle on which the form resides. + @param FormId The ID of the form to return. If the ID is zero, + the entire form package is returned. + @param BufferLength On input, the length of the Buffer. On output, + the length of the returned buffer, + @param Buffer The buffer designed to receive the form(s). + + @retval EFI_SUCCESS Buffer filled with the requested forms. BufferLength + was updated. + @retval EFI_INVALID_PARAMETER The handle is unknown. + @retval EFI_NOT_FOUND A form on the requested handle cannot be found with + the requested FormId. + @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough + to allow the form to be stored. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_FORMS) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN EFI_FORM_ID FormId, + IN OUT UINTN *BufferLength, + OUT UINT8 *Buffer + ); + +/** + Extracts the defaults that are associated with a given handle in the HII database. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The HII handle from which will have default data retrieved. + @param DefaultMask The mask used to specify some type of default override when extracting + the default image data. + @param VariablePackList A indirect pointer to the first entry of a link list with + type EFI_HII_VARIABLE_PACK_LIST. + + @retval EFI_SUCCESS The VariablePackList was populated with the appropriate + default setting data. + @retval EFI_NOT_FOUND The IFR does not have any explicit or default map(s). + @retval EFI_INVALID_PARAMETER The HII database entry associated with Handle + contain invalid data. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN UINTN DefaultMask, + OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList + ); + +/** + Allows the caller to update a form or form package that has previously been + registered with the EFI HII database. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle Handle of the package where the form to be updated resides. + @param Label The label inside the form package where the update is to take place. + @param AddData If TRUE, adding data at a given Label; otherwise, + if FALSE, removing data at a given Label. + @param Data The buffer containing the new tags to insert after the Label + + @retval EFI_SUCCESS The form was updated with the new tags. + @retval EFI_INVALID_PARAMETER The buffer for the buffer length does not + contain an integral number of tags. + @retval EFI_NOT_FOUND The Handle, Label, or FormId was not found. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_UPDATE_FORM) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN EFI_FORM_LABEL Label, + IN BOOLEAN AddData, + IN EFI_HII_UPDATE_DATA *Data + ); + +/** + Retrieves the current keyboard layout. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param DescriptorCount A pointer to the number of Descriptor entries being + described in the keyboard layout being retrieved. + @param Descriptor A pointer to a buffer containing an array of EFI_KEY_DESCRIPTOR + entries. Each entry will reflect the definition of a specific physical key. + + @retval EFI_SUCCESS The keyboard layout was retrieved successfully. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) ( + IN EFI_HII_PROTOCOL *This, + OUT UINT16 *DescriptorCount, + OUT EFI_KEY_DESCRIPTOR *Descriptor + ); + +/** + @par Protocol Description: + The HII Protocol manages the HII database, which is a repository for data + having to do with fonts, strings, forms, keyboards, and other future human + interface items. + + @param NewPack + Extracts the various packs from a package list. + + @param RemovePack + Removes a package from the HII database. + + @param FindHandles + Determines the handles that are currently active in the database. + + @param ExportDatabase + Export the entire contents of the database to a buffer. + + @param TestString + Tests if all of the characters in a string have corresponding font characters. + + @param GetGlyph + Translates a Unicode character into the corresponding font glyph. + + @param GlyphToBlt + Converts a glyph value into a format that is ready for a UGA BLT command. + + @param NewString + Allows a new string to be added to an already existing string package. + + @param GetPrimaryLanguages + Allows a program to determine the primary languages that are supported + on a given handle. + + @param GetSecondaryLanguages + Allows a program to determine which secondary languages are supported + on a given handle for a given primary language. + + @param GetString + Extracts a string from a package that is already registered with the + EFI HII database. + + @param ResetString + Remove any new strings that were added after the initial string export + for this handle. + + @param GetLine + Allows a program to extract a part of a string of not more than a given width. + + @param GetForms + Allows a program to extract a form or form package that has been previously registered. + + @param GetDefaultImage + Allows a program to extract the nonvolatile image that represents the default storage image. + + @param UpdateForm + Allows a program to update a previously registered form. + + @param GetKeyboardLayout + Allows a program to extract the current keyboard layout. + +**/ +struct _EFI_HII_PROTOCOL { + EFI_HII_NEW_PACK NewPack; + EFI_HII_REMOVE_PACK RemovePack; + EFI_HII_FIND_HANDLES FindHandles; + EFI_HII_EXPORT ExportDatabase; + + EFI_HII_TEST_STRING TestString; + EFI_HII_GET_GLYPH GetGlyph; + EFI_HII_GLYPH_TO_BLT GlyphToBlt; + + EFI_HII_NEW_STRING NewString; + EFI_HII_GET_PRI_LANGUAGES GetPrimaryLanguages; + EFI_HII_GET_SEC_LANGUAGES GetSecondaryLanguages; + EFI_HII_GET_STRING GetString; + EFI_HII_RESET_STRINGS ResetStrings; + EFI_HII_GET_LINE GetLine; + EFI_HII_GET_FORMS GetForms; + EFI_HII_GET_DEFAULT_IMAGE GetDefaultImage; + EFI_HII_UPDATE_FORM UpdateForm; + + EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout; +}; + +extern EFI_GUID gEfiHiiProtocolGuid; + +#endif diff --git a/IntelFrameworkPkg/Include/Protocol/HiiFramework.h b/IntelFrameworkPkg/Include/Protocol/HiiFramework.h deleted file mode 100644 index d138ad8a95..0000000000 --- a/IntelFrameworkPkg/Include/Protocol/HiiFramework.h +++ /dev/null @@ -1,951 +0,0 @@ -/** @file - This file defines the Human Interface Infrastructure protocol which will - be used by resources which want to publish IFR/Font/String data and have it - collected by the Configuration engine. - - 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: HiiFramework.h - - @par Revision Reference: - This protocol is defined in HII spec 0.92. - -**/ - -#ifndef _FRAMEWORK_HII_H_ -#define _FRAMEWORK_HII_H_ - -#include - -// -// To get EFI_GRAPHICS_OUTPUT_BLT_PIXEL, -// is defined in MdePkg/Protocol/GraphicsOutput.h -// -#include - -#define EFI_HII_PROTOCOL_GUID \ - { \ - 0xd7ad636e, 0xb997, 0x459b, {0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 0xe1} \ - } - -// BugBug: -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// If UGA goes away we need to put this some place. I'm not sure where? -// -//typedef struct { -// UINT8 Blue; -// UINT8 Green; -// UINT8 Red; -// UINT8 Reserved; -//} EFI_UGA_PIXEL; - -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// - -typedef struct _EFI_HII_PROTOCOL EFI_HII_PROTOCOL; - -// -// Global definition -// -#define NARROW_CHAR 0xFFF0 -#define WIDE_CHAR 0xFFF1 -#define NON_BREAKING_CHAR 0xFFF2 -#define GLYPH_WIDTH 8 -#define GLYPH_HEIGHT 19 - -#define EFI_HII_FONT 1 -#define EFI_HII_STRING 2 -#define EFI_HII_IFR 3 -#define EFI_HII_KEYBOARD 4 -#define EFI_HII_HANDLES 5 -#define EFI_HII_VARIABLE 6 -#define EFI_HII_DEVICE_PATH 7 - - -// References to string tokens must use this macro to enable scanning for -// token usages. -// -#define STRING_TOKEN(t) t - -// -// The following types are currently defined: -// EFI_FROM_ID has been defined in UEFI spec. -// -typedef UINT16 EFI_FORM_LABEL; - -#pragma pack(1) - -typedef struct { - UINT32 Length; - UINT16 Type; -} EFI_HII_PACK_HEADER; - -// -// A form list consists of a large variety of structure -// possibilities so to represent the binary blob of data -// associated with a package of forms, we will assume a -// pointer to a self-describing data buffer. -// -typedef struct { - EFI_HII_PACK_HEADER Header; -} EFI_HII_IFR_PACK; - -typedef struct { - EFI_HII_PACK_HEADER Header; // Must be filled in - EFI_HANDLE ImageHandle; // Must be filled in - EFI_HANDLE DeviceHandle; // Optional - EFI_HANDLE ControllerHandle; // Optional - EFI_HANDLE CallbackHandle; // Optional - EFI_HANDLE COBExportHandle; // Optional -} EFI_HII_HANDLE_PACK; - -// -// ******************************************************** -// EFI_VARIABLE_CONTENTS -// ******************************************************** -// -typedef struct { - EFI_HII_PACK_HEADER Header; - EFI_GUID VariableGuid; - UINT32 VariableNameLength; - UINT16 VariableId; - // - // CHAR16 VariableName[]; //Null-terminated - // -} EFI_HII_VARIABLE_PACK; - -// -// ******************************************************** -// EFI_DEVICE_PATH_PACK -// ******************************************************** -// -typedef struct { - EFI_HII_PACK_HEADER Header; - // - // EFI_DEVICE_PATH DevicePath[]; - // -} EFI_HII_DEVICE_PATH_PACK; - -// -// ******************************************************** -// EFI_HII_DATA_TABLE -// ******************************************************** -// -typedef struct { - EFI_HII_HANDLE HiiHandle; - EFI_GUID PackageGuid; - UINT32 DataTableSize; - UINT32 IfrDataOffset; - UINT32 StringDataOffset; - UINT32 VariableDataOffset; - UINT32 DevicePathOffset; - UINT32 NumberOfVariableData; - UINT32 NumberOfLanguages; - // - // EFI_HII_DEVICE_PATH_PACK DevicePath[]; - // EFI_HII_VARIABLE_PACK VariableData[]; - // EFI_HII_IFR_PACK IfrData; - // EFI_HII_STRING_PACK StringData[]; - // -} EFI_HII_DATA_TABLE; - -// -// ******************************************************** -// EFI_HII_EXPORT_TABLE -// ******************************************************** -// -typedef struct { - UINT32 NumberOfHiiDataTables; - EFI_GUID Revision; - // - // EFI_HII_DATA_TABLE HiiDataTable[]; - // -} EFI_HII_EXPORT_TABLE; - -typedef struct { - BOOLEAN FormSetUpdate; // If TRUE, next variable is significant - EFI_PHYSICAL_ADDRESS FormCallbackHandle; // If not 0, will update Formset with this info - BOOLEAN FormUpdate; // If TRUE, next variable is significant - UINT16 FormValue; // specify which form is to be updated if FormUpdate value is TRUE. - STRING_REF FormTitle; // If not 0, will update Form with this info - UINT16 DataCount; // The number of Data entries in this structure - UINT8 *Data; // An array of 1+ op-codes, specified by DataCount -} EFI_HII_UPDATE_DATA; - -// -// String attributes -// -#define LANG_RIGHT_TO_LEFT 0x00000001 - -// -// A string package is used to localize strings to a particular -// language. The package is associated with a particular driver -// or set of drivers. Tools are used to associate tokens with -// string references in forms and in programs. These tokens are -// language agnostic. When paired with a language pack (directly -// or indirectly), the string token resolves into an actual -// UNICODE string. The NumStringPointers determines how many -// StringPointers (offset values) there are as well as the total -// number of Strings that are defined. -// -typedef struct { - EFI_HII_PACK_HEADER Header; - RELOFST LanguageNameString; - RELOFST PrintableLanguageName; - UINT32 NumStringPointers; - UINT32 Attributes; - // - // RELOFST StringPointers[]; - // EFI_STRING Strings[]; - // -} EFI_HII_STRING_PACK; - -// -// Glyph Attributes -// -#define EFI_GLYPH_NON_SPACING 1 -#define EFI_GLYPH_WIDE 2 - -typedef struct { - CHAR16 UnicodeWeight; - UINT8 Attributes; - UINT8 GlyphCol1[GLYPH_HEIGHT]; -} EFI_NARROW_GLYPH; - -typedef struct { - CHAR16 UnicodeWeight; - UINT8 Attributes; - UINT8 GlyphCol1[GLYPH_HEIGHT]; - UINT8 GlyphCol2[GLYPH_HEIGHT]; - UINT8 Pad[3]; -} EFI_WIDE_GLYPH; - -// -// A font list consists of a font header followed by a series -// of glyph structures. Note that fonts are not language specific. -// -typedef struct { - EFI_HII_PACK_HEADER Header; - UINT16 NumberOfNarrowGlyphs; - UINT16 NumberOfWideGlyphs; -} EFI_HII_FONT_PACK; - -// -// The IfrData in the EFI_HII_IFR_PACK structure definition -// is variable length, and not really part of the header. To -// simplify from code the size of the header, define an -// identical structure that does not include the IfrData field. -// Then use sizeof() this new structure to determine the -// actual size of the header. -// -typedef struct { - EFI_HII_PACK_HEADER Header; -} EFI_HII_IFR_PACK_HEADER; - -// -// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER; -// -typedef enum { - EfiKeyLCtrl, - EfiKeyA0, - EfiKeyLAlt, - EfiKeySpaceBar, - EfiKeyA2, - EfiKeyA3, - EfiKeyA4, - EfiKeyRCtrl, - EfiKeyLeftArrow, - EfiKeyDownArrow, - EfiKeyRightArrow, - EfiKeyZero, - EfiKeyPeriod, - EfiKeyEnter, - EfiKeyLShift, - EfiKeyB0, - EfiKeyB1, - EfiKeyB2, - EfiKeyB3, - EfiKeyB4, - EfiKeyB5, - EfiKeyB6, - EfiKeyB7, - EfiKeyB8, - EfiKeyB9, - EfiKeyB10, - EfiKeyRshift, - EfiKeyUpArrow, - EfiKeyOne, - EfiKeyTwo, - EfiKeyThree, - EfiKeyCapsLock, - EfiKeyC1, - EfiKeyC2, - EfiKeyC3, - EfiKeyC4, - EfiKeyC5, - EfiKeyC6, - EfiKeyC7, - EfiKeyC8, - EfiKeyC9, - EfiKeyC10, - EfiKeyC11, - EfiKeyC12, - EfiKeyFour, - EfiKeyFive, - EfiKeySix, - EfiKeyPlus, - EfiKeyTab, - EfiKeyD1, - EfiKeyD2, - EfiKeyD3, - EfiKeyD4, - EfiKeyD5, - EfiKeyD6, - EfiKeyD7, - EfiKeyD8, - EfiKeyD9, - EfiKeyD10, - EfiKeyD11, - EfiKeyD12, - EfiKeyD13, - EfiKeyDel, - EfiKeyEnd, - EfiKeyPgDn, - EfiKeySeven, - EfiKeyEight, - EfiKeyNine, - EfiKeyE0, - EfiKeyE1, - EfiKeyE2, - EfiKeyE3, - EfiKeyE4, - EfiKeyE5, - EfiKeyE6, - EfiKeyE7, - EfiKeyE8, - EfiKeyE9, - EfiKeyE10, - EfiKeyE11, - EfiKeyE12, - EfiKeyBackSpace, - EfiKeyIns, - EfiKeyHome, - EfiKeyPgUp, - EfiKeyNLck, - EfiKeySlash, - EfiKeyAsterisk, - EfiKeyMinus, - EfiKeyEsc, - EfiKeyF1, - EfiKeyF2, - EfiKeyF3, - EfiKeyF4, - EfiKeyF5, - EfiKeyF6, - EfiKeyF7, - EfiKeyF8, - EfiKeyF9, - EfiKeyF10, - EfiKeyF11, - EfiKeyF12, - EfiKeyPrint, - EfiKeySLck, - EfiKeyPause -} EFI_KEY; - -typedef struct { - EFI_KEY Key; - CHAR16 Unicode; - CHAR16 ShiftedUnicode; - CHAR16 AltGrUnicode; - CHAR16 ShiftedAltGrUnicode; - UINT16 Modifier; -} EFI_KEY_DESCRIPTOR; - -// -// This structure allows a sparse set of keys to be redefined -// or a complete redefinition of the keyboard layout. Most -// keyboards have a lot of commonality in their layouts, therefore -// only defining those keys that need to change from the default -// minimizes the passed in information. -// -// Additionally, when an update occurs, the active keyboard layout -// will be switched to the newly updated keyboard layout. This -// allows for situations that when a keyboard layout driver is -// loaded as part of system initialization, the system will default -// the keyboard behavior to the new layout. -// -// Each call to update the keyboard mapping should contain the -// complete set of key descriptors to be updated, since every -// call to the HII which contains an EFI_HII_KEYBOARD_PACK will -// wipe the previous set of overrides. A call to -// -typedef struct { - EFI_HII_PACK_HEADER Header; - EFI_KEY_DESCRIPTOR *Descriptor; - UINT8 DescriptorCount; -} EFI_HII_KEYBOARD_PACK; - -// -// The EFI_HII_PACKAGES can contain different types of packages just -// after the structure as inline data. -// -typedef struct { - UINTN NumberOfPackages; - EFI_GUID *GuidId; - // - // EFI_HII_HANDLE_PACK *HandlePack; // Only one pack. - // EFI_HII_IFR_PACK *IfrPack; // Only one pack. - // EFI_HII_FONT_PACK *FontPack[]; // Multiple packs ok - // EFI_HII_STRING_PACK *StringPack[]; // Multiple packs ok - // EFI_HII_KEYBOARD_PACK *KeyboardPack[]; // Multiple packs ok - // -} EFI_HII_PACKAGES; - -typedef struct _EFI_HII_VARIABLE_PACK_LIST { - struct _EFI_HII_VARIABLE_PACK_LIST *NextVariablePack; - EFI_HII_VARIABLE_PACK *VariablePack; -} EFI_HII_VARIABLE_PACK_LIST; - - -#pragma pack() - -/** - Registers the various packs that are passed in via the Packages parameter. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Packages A pointer to an EFI_HII_PACKAGES package instance. - @param Handle A pointer to the EFI_HII_HANDLE instance. - - @retval EFI_SUCCESS Data was extracted from Packages, the database - was updated with the data, and Handle returned successfully. - @retval EFI_INVALID_PARAMETER The content of Packages was invalid. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_NEW_PACK) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_PACKAGES *Packages, - OUT EFI_HII_HANDLE *Handle - ); - -/** - Removes a package from the HII database. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle The handle that was registered to the data that is requested - for removal. - - @retval EFI_SUCCESS The data associated with the Handle was removed - from the HII database. - @retval EFI_INVALID_PARAMETER The Handle was not valid. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_REMOVE_PACK) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle - ); - -/** - Determines the handles that are currently active in the database. - - @param This A pointer to the EFI_HII_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 Handle An array of EFI_HII_HANDLE instances returned. - - @retval EFI_SUCCESS Handle was updated successfully. - @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates - that Handle is too small to support the number of handles. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_FIND_HANDLES) ( - IN EFI_HII_PROTOCOL *This, - IN OUT UINT16 *HandleBufferLength, - OUT EFI_HII_HANDLE *Handle - ); - -/** - Exports the contents of the database into a buffer. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle An EFI_HII_HANDLE that corresponds to the desired - handle to export. If the value is 0, the entire database will be exported. - In either case, the data will be exported in a format described by the - structure definition of EFI_HII_EXPORT_TABLE. - @param BufferSize - On input, a pointer to the length of the buffer. On output, the length - of the buffer that is required for the export data. - @param Buffer A pointer to a buffer that will contain the results of the export function. - - @retval EFI_SUCCESS The buffer was successfully filled with BufferSize amount of data. - @retval EFI_BUFFER_TOO_SMALL The value in BufferSize was too small to contain the export data. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_EXPORT) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ); - -/** - Remove any new strings that were added after the initial string export - for this handle. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle The handle on which the string resides. - - @retval EFI_SUCCESS Remove strings from the handle successfully. - @retval EFI_INVALID_PARAMETER The Handle was unknown. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_RESET_STRINGS) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle - ); - -/** - Tests if all of the characters in a string have corresponding font characters. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param StringToTest A pointer to a Unicode string. - @param FirstMissing A pointer to an index into the string. On input, - the index of the first character in the StringToTest to examine. On exit, - the index of the first character encountered for which a glyph is unavailable. - If all glyphs in the string are available, the index is the index of the - terminator of the string. - @param GlyphBufferSize A pointer to a value. On output, if the function - returns EFI_SUCCESS, it contains the amount of memory that is required to - store the string's glyph equivalent. - - @retval EFI_SUCCESS All glyphs are available. Note that an empty string - always returns this value. - @retval EFI_NOT_FOUND A glyph was not found for a character. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_TEST_STRING) ( - IN EFI_HII_PROTOCOL *This, - IN CHAR16 *StringToTest, - IN OUT UINT32 *FirstMissing, - OUT UINT32 *GlyphBufferSize - ); - -/** - Translates a Unicode character into the corresponding font glyph. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Source A pointer to a Unicode string. - @param Index On input, the offset into the string from which to fetch - the character.On successful completion, the index is updated to the first - character past the character(s) making up the just extracted glyph. - @param GlyphBuffer Pointer to an array where the glyphs corresponding - to the characters in the source may be stored. GlyphBuffer is assumed - to be wide enough to accept a wide glyph character. - @param BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by - this value is filled with the length of the glyph in pixels. It is unchanged - if the call was unsuccessful. - @param InternalStatus The cell pointed to by this parameter must be - initialized to zero prior to invoking the call the first time for any string. - - @retval EFI_SUCCESS It worked. - @retval EFI_NOT_FOUND A glyph for a character was not found. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_GLYPH) ( - IN EFI_HII_PROTOCOL *This, - IN CHAR16 *Source, - IN OUT UINT16 *Index, - OUT UINT8 **GlyphBuffer, - OUT UINT16 *BitWidth, - IN OUT UINT32 *InternalStatus - ); - -/** - Translates a glyph into the format required for input to the Universal - Graphics Adapter (UGA) Block Transfer (BLT) routines. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param GlyphBuffer A pointer to the buffer that contains glyph data. - @param Foreground The foreground setting requested to be used for the - generated BltBuffer data. - @param Background The background setting requested to be used for the - generated BltBuffer data. - @param Count The entry in the BltBuffer upon which to act. - @param Width The width in bits of the glyph being converted. - @param Height The height in bits of the glyph being converted - @param BltBuffer A pointer to the buffer that contains the data that is - ready to be used by the UGA BLT routines. - - @retval EFI_SUCCESS It worked. - @retval EFI_NOT_FOUND A glyph for a character was not found. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GLYPH_TO_BLT) ( - IN EFI_HII_PROTOCOL *This, - IN UINT8 *GlyphBuffer, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background, - IN UINTN Count, - IN UINTN Width, - IN UINTN Height, - IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer - ); - -/** - Allows a new string to be added to an already existing string package. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Pointer to a NULL-terminated string containing a single ISO 639-2 - language identifier, indicating the language in which the string is translated. - @param Handle The handle of the language pack to which the string is to be added. - @param Reference The identifier of the string to be added. If the reference - value is zero, then the string will be assigned a new identifier on that - handle for the language specified. Otherwise, the string will be updated - with the NewString Value. - @param NewString The string to be added. - - @retval EFI_SUCCESS The string was effectively registered. - @retval EFI_INVALID_PARAMETER The Handle was unknown. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_NEW_STRING) ( - IN EFI_HII_PROTOCOL *This, - IN CHAR16 *Language, - IN EFI_HII_HANDLE Handle, - IN OUT STRING_REF *Reference, - IN CHAR16 *NewString - ); - -/** - Allows a program to determine the primary languages that are supported - on a given handle. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle The handle on which the strings reside. - @param LanguageString A string allocated by GetPrimaryLanguages() that - contains a list of all primary languages registered on the handle. - - @retval EFI_SUCCESS LanguageString was correctly returned. - @retval EFI_INVALID_PARAMETER The Handle was unknown. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - OUT EFI_STRING *LanguageString - ); - -/** - Allows a program to determine which secondary languages are supported - on a given handle for a given primary language. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle The handle on which the strings reside. - @param PrimaryLanguage Pointer to a NULL-terminated string containing a single - ISO 639-2 language identifier, indicating the primary language. - @param LanguageString A string allocated by GetSecondaryLanguages() - containing a list of all secondary languages registered on the handle. - - @retval EFI_SUCCESS LanguageString was correctly returned. - @retval EFI_INVALID_PARAMETER The Handle was unknown. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - IN CHAR16 *PrimaryLanguage, - OUT EFI_STRING *LanguageString - ); - -/** - Extracts a string from a package already registered with the EFI HII database. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle The handle on which the string resides. - @param Token The string token assigned to the string. - @param Raw If TRUE, the string is returned unedited in the internal - storage format described above. If false, the string returned is edited - by replacing with and by removing special characters such - as the prefix. - @param LanguageString Pointer to a NULL-terminated string containing a - single ISO 639-2 language identifier, indicating the language to print. - If the LanguageString is empty (starts with a NULL), the default system - language will be used to determine the language. - @param BufferLength Length of the StringBuffer. - @param StringBuffer The buffer designed to receive the characters in the string. - - @retval EFI_SUCCESS StringBuffer is filled with a NULL-terminated string. - @retval EFI_INVALID_PARAMETER The handle or string token is unknown. - @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough to - allow the entire string to be stored. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_STRING) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - IN STRING_REF Token, - IN BOOLEAN Raw, - IN CHAR16 *LanguageString, - IN OUT UINTN *BufferLength, - OUT EFI_STRING StringBuffer - ); - -/** - Allows a program to extract a part of a string of not more than a given width. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle The handle on which the string resides. - @param Token The string token assigned to the string. - @param Index On input, the offset into the string where the line is to start. - On output, the index is updated to point to beyond the last character returned - in the call. - @param LineWidth The maximum width of the line in units of narrow glyphs. - @param LanguageString Pointer to a NULL-terminated string containing a - single ISO 639-2 language identifier, indicating the language to print. - @param BufferLength Pointer to the length of the StringBuffer. - @param StringBuffer The buffer designed to receive the characters in the string. - - @retval EFI_SUCCESS StringBuffer filled with characters that will fit on the line. - @retval EFI_NOT_FOUND The font glyph for at least one of the characters in - the string is not in the font database. - @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough - to allow the entire string to be stored. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_LINE) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - IN STRING_REF Token, - IN OUT UINT16 *Index, - IN UINT16 LineWidth, - IN CHAR16 *LanguageString, - IN OUT UINT16 *BufferLength, - OUT EFI_STRING StringBuffer - ); - -/** - Allows a program to extract a form or form package that has previously - been registered with the HII database. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle Handle on which the form resides. - @param FormId The ID of the form to return. If the ID is zero, - the entire form package is returned. - @param BufferLength On input, the length of the Buffer. On output, - the length of the returned buffer, - @param Buffer The buffer designed to receive the form(s). - - @retval EFI_SUCCESS Buffer filled with the requested forms. BufferLength - was updated. - @retval EFI_INVALID_PARAMETER The handle is unknown. - @retval EFI_NOT_FOUND A form on the requested handle cannot be found with - the requested FormId. - @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough - to allow the form to be stored. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_FORMS) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - IN EFI_FORM_ID FormId, - IN OUT UINTN *BufferLength, - OUT UINT8 *Buffer - ); - -/** - Extracts the defaults that are associated with a given handle in the HII database. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle The HII handle from which will have default data retrieved. - @param DefaultMask The mask used to specify some type of default override when extracting - the default image data. - @param VariablePackList A indirect pointer to the first entry of a link list with - type EFI_HII_VARIABLE_PACK_LIST. - - @retval EFI_SUCCESS The VariablePackList was populated with the appropriate - default setting data. - @retval EFI_NOT_FOUND The IFR does not have any explicit or default map(s). - @retval EFI_INVALID_PARAMETER The HII database entry associated with Handle - contain invalid data. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - IN UINTN DefaultMask, - OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList - ); - -/** - Allows the caller to update a form or form package that has previously been - registered with the EFI HII database. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param Handle Handle of the package where the form to be updated resides. - @param Label The label inside the form package where the update is to take place. - @param AddData If TRUE, adding data at a given Label; otherwise, - if FALSE, removing data at a given Label. - @param Data The buffer containing the new tags to insert after the Label - - @retval EFI_SUCCESS The form was updated with the new tags. - @retval EFI_INVALID_PARAMETER The buffer for the buffer length does not - contain an integral number of tags. - @retval EFI_NOT_FOUND The Handle, Label, or FormId was not found. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_UPDATE_FORM) ( - IN EFI_HII_PROTOCOL *This, - IN EFI_HII_HANDLE Handle, - IN EFI_FORM_LABEL Label, - IN BOOLEAN AddData, - IN EFI_HII_UPDATE_DATA *Data - ); - -/** - Retrieves the current keyboard layout. - - @param This A pointer to the EFI_HII_PROTOCOL instance. - @param DescriptorCount A pointer to the number of Descriptor entries being - described in the keyboard layout being retrieved. - @param Descriptor A pointer to a buffer containing an array of EFI_KEY_DESCRIPTOR - entries. Each entry will reflect the definition of a specific physical key. - - @retval EFI_SUCCESS The keyboard layout was retrieved successfully. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) ( - IN EFI_HII_PROTOCOL *This, - OUT UINT16 *DescriptorCount, - OUT EFI_KEY_DESCRIPTOR *Descriptor - ); - -/** - @par Protocol Description: - The HII Protocol manages the HII database, which is a repository for data - having to do with fonts, strings, forms, keyboards, and other future human - interface items. - - @param NewPack - Extracts the various packs from a package list. - - @param RemovePack - Removes a package from the HII database. - - @param FindHandles - Determines the handles that are currently active in the database. - - @param ExportDatabase - Export the entire contents of the database to a buffer. - - @param TestString - Tests if all of the characters in a string have corresponding font characters. - - @param GetGlyph - Translates a Unicode character into the corresponding font glyph. - - @param GlyphToBlt - Converts a glyph value into a format that is ready for a UGA BLT command. - - @param NewString - Allows a new string to be added to an already existing string package. - - @param GetPrimaryLanguages - Allows a program to determine the primary languages that are supported - on a given handle. - - @param GetSecondaryLanguages - Allows a program to determine which secondary languages are supported - on a given handle for a given primary language. - - @param GetString - Extracts a string from a package that is already registered with the - EFI HII database. - - @param ResetString - Remove any new strings that were added after the initial string export - for this handle. - - @param GetLine - Allows a program to extract a part of a string of not more than a given width. - - @param GetForms - Allows a program to extract a form or form package that has been previously registered. - - @param GetDefaultImage - Allows a program to extract the nonvolatile image that represents the default storage image. - - @param UpdateForm - Allows a program to update a previously registered form. - - @param GetKeyboardLayout - Allows a program to extract the current keyboard layout. - -**/ -struct _EFI_HII_PROTOCOL { - EFI_HII_NEW_PACK NewPack; - EFI_HII_REMOVE_PACK RemovePack; - EFI_HII_FIND_HANDLES FindHandles; - EFI_HII_EXPORT ExportDatabase; - - EFI_HII_TEST_STRING TestString; - EFI_HII_GET_GLYPH GetGlyph; - EFI_HII_GLYPH_TO_BLT GlyphToBlt; - - EFI_HII_NEW_STRING NewString; - EFI_HII_GET_PRI_LANGUAGES GetPrimaryLanguages; - EFI_HII_GET_SEC_LANGUAGES GetSecondaryLanguages; - EFI_HII_GET_STRING GetString; - EFI_HII_RESET_STRINGS ResetStrings; - EFI_HII_GET_LINE GetLine; - EFI_HII_GET_FORMS GetForms; - EFI_HII_GET_DEFAULT_IMAGE GetDefaultImage; - EFI_HII_UPDATE_FORM UpdateForm; - - EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout; -}; - -extern EFI_GUID gEfiHiiProtocolGuid; - -#endif diff --git a/IntelFrameworkPkg/IntelFrameworkPkg.dec b/IntelFrameworkPkg/IntelFrameworkPkg.dec index 1a3a5b2076..e3e823108c 100644 --- a/IntelFrameworkPkg/IntelFrameworkPkg.dec +++ b/IntelFrameworkPkg/IntelFrameworkPkg.dec @@ -24,8 +24,8 @@ Include # Root include for the package [LibraryClasses.common] - HiiLibFramework|Include/Library/HiiLibFramework.h - IfrSupportLibFramework|Include/Library/IfrSupportLibFramework.h + FrameworkHiiLib|Include/Library/FrameworkHiiLib.h + FrameworkIfrSupportLib|Include/Library/FrameworkIfrSupportLib.h SmmLib|Include/Library/SmmLib.h [Guids.common] diff --git a/IntelFrameworkPkg/IntelFrameworkPkg.dsc b/IntelFrameworkPkg/IntelFrameworkPkg.dsc index fa20b026f0..be7a5bce1a 100644 --- a/IntelFrameworkPkg/IntelFrameworkPkg.dsc +++ b/IntelFrameworkPkg/IntelFrameworkPkg.dsc @@ -58,8 +58,8 @@ ################################################################################ [Components.common] IntelFrameworkPkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf - IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.inf + IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DxeSmmDriverEntryPoint.inf - IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf - IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf + IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf + IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.inf IntelFrameworkPkg/Library/PeiSmbusLibSmbusPpi/PeiSmbusLibSmbusPpi.inf diff --git a/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c new file mode 100644 index 0000000000..913b471c5a --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c @@ -0,0 +1,70 @@ +/** @file + HII Library implementation that uses DXE protocols and services. + + Copyright (c) 2006, 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: HiiLib.c + +**/ + + +#include + + +#include +#include +#include + +/** + This function allocates pool for an EFI_HII_PACKAGES structure + with enough space for the variable argument list of package pointers. + The allocated structure is initialized using NumberOfPackages, Guid, + and the variable length argument list of package pointers. + + @param NumberOfPackages The number of HII packages to prepare. + @param Guid Package GUID. + + @return The allocated and initialized packages. + +**/ +EFI_HII_PACKAGES * +EFIAPI +PreparePackages ( + IN UINTN NumberOfPackages, + IN CONST EFI_GUID *Guid OPTIONAL, + ... + ) +{ + VA_LIST Args; + EFI_HII_PACKAGES *HiiPackages; + VOID **Package; + UINTN Index; + + ASSERT (NumberOfPackages > 0); + + HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *)); + ASSERT (HiiPackages != NULL); + + HiiPackages->GuidId = (EFI_GUID *) Guid; + HiiPackages->NumberOfPackages = NumberOfPackages; + Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES)); + + VA_START (Args, Guid); + + for (Index = 0; Index < NumberOfPackages; Index++) { + *Package = VA_ARG (Args, VOID *); + Package++; + } + + VA_END (Args); + + return HiiPackages; + +} diff --git a/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf new file mode 100644 index 0000000000..98ee9f9ae2 --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf @@ -0,0 +1,44 @@ +#/** @file +# Library instance for HII common routines. +# +# This library instance implements the common HII routines. +# Copyright (c) 2006, 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. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = FrameworkHiiLib + FILE_GUID = 1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = FrameworkHiiLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources.common] + HiiLib.c + +[Packages] + MdePkg/MdePkg.dec + IntelFrameworkPkg/IntelFrameworkPkg.dec + +[LibraryClasses] + MemoryAllocationLib + DebugLib + diff --git a/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.msa b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.msa new file mode 100644 index 0000000000..67e1f0d7f1 --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.msa @@ -0,0 +1,45 @@ + + + + HiiLibFramework + DXE_DRIVER + 1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c + 1.0 + Library instance for HII common routines. + This library instance implements the common HII routines. + Copyright (c) 2006, 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. + FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 + + + IA32 X64 IPF EBC + false + HiiLibFramework + + + + HiiLib + + + DebugLib + + + MemoryAllocationLib + + + + HiiLib.c + + + + + + EFI_SPECIFICATION_VERSION 0x00020000 + EDK_RELEASE_VERSION 0x00020000 + + \ No newline at end of file diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrCommon.c b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrCommon.c new file mode 100644 index 0000000000..d9894c4e6c --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrCommon.c @@ -0,0 +1,1005 @@ +/*++ +Copyright (c) 2006, 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: + IfrCommon.c + +Abstract: + + Common Library Routines to assist in IFR creation on-the-fly + +Revision History: + +--*/ + +// +// Include common header file for this module. +// +#include "IfrSupportLibInternal.h" + +EFI_STATUS +EFIAPI +IfrLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return EFI_SUCCESS; +} + +EFI_STATUS +GetCurrentLanguage ( + OUT CHAR16 *Lang + ) +/*++ + +Routine Description: + + Determine what is the current language setting + +Arguments: + + Lang - Pointer of system language + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + UINTN Size; + UINTN Index; + CHAR8 Language[4]; + + // + // Getting the system language and placing it into our Global Data + // + Size = sizeof (Language); + + Status = gRT->GetVariable ( + (CHAR16 *) L"Lang", + &gEfiGlobalVariableGuid, + NULL, + &Size, + Language + ); + + if (EFI_ERROR (Status)) { + AsciiStrCpy (Language, "eng"); + } + + for (Index = 0; Index < 3; Index++) { + // + // Bitwise AND ascii value with 0xDF yields an uppercase value. + // Sign extend into a unicode value + // + Lang[Index] = (CHAR16) (Language[Index] & 0xDF); + } + + // + // Null-terminate the value + // + Lang[3] = (CHAR16) 0; + + return Status; +} + + +EFI_STATUS +AddString ( + IN VOID *StringBuffer, + IN CHAR16 *Language, + IN CHAR16 *String, + IN OUT STRING_REF *StringToken + ) +/*++ + +Routine Description: + + Add a string to the incoming buffer and return the token and offset data + +Arguments: + + StringBuffer - The incoming buffer + + Language - Currrent language + + String - The string to be added + + StringToken - The index where the string placed + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - String successfully added to the incoming buffer + +--*/ +{ + EFI_HII_STRING_PACK *StringPack; + EFI_HII_STRING_PACK *StringPackBuffer; + VOID *NewBuffer; + RELOFST *PackSource; + RELOFST *PackDestination; + UINT8 *Source; + UINT8 *Destination; + UINTN Index; + BOOLEAN Finished; + UINTN SizeofLanguage; + UINTN SizeofString; + + StringPack = (EFI_HII_STRING_PACK *) StringBuffer; + Finished = FALSE; + + // + // Pre-allocate a buffer sufficient for us to work on. + // We will use it as a destination scratch pad to build data on + // and when complete shift the data back to the original buffer + // + NewBuffer = AllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE); + if (NewBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + StringPackBuffer = (EFI_HII_STRING_PACK *) NewBuffer; + + // + // StringPack is terminated with a length 0 entry + // + for (; StringPack->Header.Length != 0;) { + // + // If this stringpack's language is same as CurrentLanguage, use it + // + if (CompareMem ((VOID *) ((CHAR8 *) (StringPack) + StringPack->LanguageNameString), Language, 3) == 0) { + // + // We have some data in this string pack, copy the string package up to the string data + // + CopyMem (&StringPackBuffer->Header, &StringPack->Header, sizeof (StringPack)); + + // + // These are references in the structure to tokens, need to increase them by the space occupied by an additional StringPointer + // + StringPackBuffer->LanguageNameString = (UINT16) (StringPackBuffer->LanguageNameString + (UINT16) sizeof (RELOFST)); + StringPackBuffer->PrintableLanguageName = (UINT16) (StringPackBuffer->PrintableLanguageName + (UINT16) sizeof (RELOFST)); + + PackSource = (RELOFST *) (StringPack + 1); + PackDestination = (RELOFST *) (StringPackBuffer + 1); + for (Index = 0; PackSource[Index] != 0x0000; Index++) { + // + // Copy the stringpointers from old to new buffer + // remember that we are adding a string, so the string offsets will all go up by sizeof (RELOFST) + // + PackDestination[Index] = (UINT16) (PackDestination[Index] + sizeof (RELOFST)); + } + + // + // Add a new stringpointer in the new buffer since we are adding a string. Null terminate it + // + PackDestination[Index] = (UINT16)(PackDestination[Index-1] + + StrSize((CHAR16 *)((CHAR8 *)(StringPack) + PackSource[Index-1]))); + PackDestination[Index + 1] = (UINT16) 0; + + // + // Index is the token value for the new string + // + *StringToken = (UINT16) Index; + + // + // Source now points to the beginning of the old buffer strings + // Destination now points to the beginning of the new buffer strings + // + Source = (UINT8 *) &PackSource[Index + 1]; + Destination = (UINT8 *) &PackDestination[Index + 2]; + + // + // This should copy all the strings from the old buffer to the new buffer + // + for (; Index != 0; Index--) { + // + // Copy Source string to destination buffer + // + StrCpy ((CHAR16 *) Destination, (CHAR16 *) Source); + + // + // Adjust the source/destination to the next string location + // + Destination = Destination + StrSize ((CHAR16 *) Source); + Source = Source + StrSize ((CHAR16 *) Source); + } + + // + // This copies the new string to the destination buffer + // + StrCpy ((CHAR16 *) Destination, (CHAR16 *) String); + + // + // Adjust the size of the changed string pack by adding the size of the new string + // along with the size of the additional offset entry for the new string + // + StringPackBuffer->Header.Length = (UINT32) ((UINTN) StringPackBuffer->Header.Length + StrSize (String) + sizeof (RELOFST)); + + // + // Advance the buffers to point to the next spots. + // + StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPackBuffer->Header.Length); + StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length); + Finished = TRUE; + continue; + } + // + // This isn't the language of the stringpack we were asked to add a string to + // so we need to copy it to the new buffer. + // + CopyMem (&StringPackBuffer->Header, &StringPack->Header, StringPack->Header.Length); + + // + // Advance the buffers to point to the next spots. + // + StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPack->Header.Length); + StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length); + } + + // + // If we didn't copy the new data to a stringpack yet + // + if (!Finished) { + PackDestination = (RELOFST *) (StringPackBuffer + 1); + // + // Pointing to a new string pack location + // + SizeofLanguage = StrSize (Language); + SizeofString = StrSize (String); + StringPackBuffer->Header.Length = (UINT32) + ( + sizeof (EFI_HII_STRING_PACK) - + sizeof (EFI_STRING) + + sizeof (RELOFST) + + sizeof (RELOFST) + + SizeofLanguage + + SizeofString + ); + StringPackBuffer->Header.Type = EFI_HII_STRING; + StringPackBuffer->LanguageNameString = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); + StringPackBuffer->PrintableLanguageName = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); + StringPackBuffer->Attributes = 0; + PackDestination[0] = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); + PackDestination[1] = (UINT16) (PackDestination[0] + StrSize (Language)); + PackDestination[2] = (UINT16) 0; + + // + // The first string location will be set to destination. The minimum number of strings + // associated with a stringpack will always be token 0 stored as the languagename (e.g. ENG, SPA, etc) + // and token 1 as the new string being added and and null entry for the stringpointers + // + Destination = (UINT8 *) &PackDestination[3]; + + // + // Copy the language name string to the new buffer + // + StrCpy ((CHAR16 *) Destination, Language); + + // + // Advance the destination to the new empty spot + // + Destination = Destination + StrSize (Language); + + // + // Copy the string to the new buffer + // + StrCpy ((CHAR16 *) Destination, String); + + // + // Since we are starting with a new string pack - we know the new string is token 1 + // + *StringToken = (UINT16) 1; + } + + // + // Zero out the original buffer and copy the updated data in the new buffer to the old buffer + // + ZeroMem (StringBuffer, DEFAULT_STRING_BUFFER_SIZE); + CopyMem (StringBuffer, NewBuffer, DEFAULT_STRING_BUFFER_SIZE); + + // + // Free the newly created buffer since we don't need it anymore + // + gBS->FreePool (NewBuffer); + return EFI_SUCCESS; +} + + +EFI_STATUS +AddOpCode ( + IN VOID *FormBuffer, + IN OUT VOID *OpCodeData + ) +/*++ + +Routine Description: + + Add op-code data to the FormBuffer + +Arguments: + + FormBuffer - Form buffer to be inserted to + + OpCodeData - Op-code data to be inserted + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Op-code data successfully inserted + +--*/ +{ + EFI_HII_PACK_HEADER *NewBuffer; + UINT8 *Source; + UINT8 *Destination; + + // + // Pre-allocate a buffer sufficient for us to work on. + // We will use it as a destination scratch pad to build data on + // and when complete shift the data back to the original buffer + // + NewBuffer = AllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE); + if (NewBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Source = (UINT8 *) FormBuffer; + Destination = (UINT8 *) NewBuffer; + + // + // Copy the IFR Package header to the new buffer + // + CopyMem (Destination, Source, sizeof (EFI_HII_PACK_HEADER)); + + // + // Advance Source and Destination to next op-code + // + Source = Source + sizeof (EFI_HII_PACK_HEADER); + Destination = Destination + sizeof (EFI_HII_PACK_HEADER); + + // + // Copy data to the new buffer until we run into the end_form + // + for (; ((EFI_IFR_OP_HEADER *) Source)->OpCode != EFI_IFR_END_FORM_OP;) { + // + // If the this opcode is an end_form_set we better be creating and endform + // Nonetheless, we will add data before the end_form_set. This also provides + // for interesting behavior in the code we will run, but has no bad side-effects + // since we will possibly do a 0 byte copy in this particular end-case. + // + if (((EFI_IFR_OP_HEADER *) Source)->OpCode == EFI_IFR_END_FORM_SET_OP) { + break; + } + + // + // Copy data to new buffer + // + CopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); + + // + // Adjust Source/Destination to next op-code location + // + Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + } + + // + // Prior to the end_form is where we insert the new op-code data + // + CopyMem (Destination, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length); + Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) OpCodeData)->Length; + + NewBuffer->Length = (UINT32) (NewBuffer->Length + (UINT32) (((EFI_IFR_OP_HEADER *) OpCodeData)->Length)); + + // + // Copy end-form data to new buffer + // + CopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); + + // + // Adjust Source/Destination to next op-code location + // + Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + + // + // Copy end-formset data to new buffer + // + CopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); + + // + // Zero out the original buffer and copy the updated data in the new buffer to the old buffer + // + ZeroMem (FormBuffer, DEFAULT_FORM_BUFFER_SIZE); + CopyMem (FormBuffer, NewBuffer, DEFAULT_FORM_BUFFER_SIZE); + + // + // Free the newly created buffer since we don't need it anymore + // + gBS->FreePool (NewBuffer); + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +GetHiiInterface ( + OUT EFI_HII_PROTOCOL **Hii + ) +/*++ + +Routine Description: + + Get the HII protocol interface + +Arguments: + + Hii - HII protocol interface + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + + // + // There should only be one HII protocol + // + Status = gBS->LocateProtocol ( + &gEfiHiiProtocolGuid, + NULL, + (VOID **) Hii + ); + + return Status;; +} + + +EFI_STATUS +ExtractDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + IN OUT UINT16 *ImageLength, + OUT UINT8 *DefaultImage, + OUT EFI_GUID *Guid + ) +/*++ + +Routine Description: + + Extract information pertaining to the HiiHandle + +Arguments: + + HiiHandle - Hii handle + + ImageLength - For input, length of DefaultImage; + For output, length of actually required + + DefaultImage - Image buffer prepared by caller + + Guid - Guid information about the form + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength + + EFI_SUCCESS - Successfully extract data from Hii database. + + +--*/ +{ + EFI_STATUS Status; + EFI_HII_PROTOCOL *Hii; + UINTN DataLength; + UINT8 *RawData; + UINT8 *OldData; + UINTN Index; + UINTN Temp; + UINTN SizeOfNvStore; + UINTN CachedStart; + + DataLength = DEFAULT_FORM_BUFFER_SIZE; + SizeOfNvStore = 0; + CachedStart = 0; + + Status = GetHiiInterface (&Hii); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Allocate space for retrieval of IFR data + // + RawData = AllocateZeroPool (DataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData); + + if (EFI_ERROR (Status)) { + gBS->FreePool (RawData); + + // + // Allocate space for retrieval of IFR data + // + RawData = AllocateZeroPool (DataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData); + } + + OldData = RawData; + + // + // Point RawData to the beginning of the form data + // + RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER)); + + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_FORM_SET_OP: + // + // Copy the GUID information from this handle + // + CopyMem (Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID)); + break; + + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_CHECKBOX_OP: + case EFI_IFR_NUMERIC_OP: + case EFI_IFR_DATE_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_PASSWORD_OP: + case EFI_IFR_STRING_OP: + // + // Remember, multiple op-codes may reference the same item, so let's keep a running + // marker of what the highest QuestionId that wasn't zero length. This will accurately + // maintain the Size of the NvStore + // + if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) { + Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + if (SizeOfNvStore < Temp) { + SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + } + } + } + + Index = RawData[Index + 1] + Index; + } + + // + // Return an error if buffer is too small + // + if (SizeOfNvStore > *ImageLength) { + gBS->FreePool (OldData); + *ImageLength = (UINT16) SizeOfNvStore; + return EFI_BUFFER_TOO_SMALL; + } + + if (DefaultImage != NULL) { + ZeroMem (DefaultImage, SizeOfNvStore); + } + + // + // Copy the default image information to the user's buffer + // + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_ONE_OF_OP: + CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId; + break; + + case EFI_IFR_ONE_OF_OPTION_OP: + if (((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Flags & EFI_IFR_FLAG_DEFAULT) { + CopyMem (&DefaultImage[CachedStart], &((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value, 2); + } + break; + + case EFI_IFR_CHECKBOX_OP: + DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId] = ((EFI_IFR_CHECKBOX *) &RawData[Index])->Flags; + break; + + case EFI_IFR_NUMERIC_OP: + CopyMem ( + &DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId], + &((EFI_IFR_NUMERIC *) &RawData[Index])->Default, + 2 + ); + break; + + } + + Index = RawData[Index + 1] + Index; + } + + *ImageLength = (UINT16) SizeOfNvStore; + + // + // Free our temporary repository of form data + // + gBS->FreePool (OldData); + + return EFI_SUCCESS; +} + + +EFI_HII_HANDLE +FindHiiHandle ( + IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL + IN EFI_GUID *Guid + ) +/*++ + +Routine Description: + Finds HII handle for given pack GUID previously registered with the HII. + +Arguments: + HiiProtocol - pointer to pointer to HII protocol interface. + If NULL, the interface will be found but not returned. + If it points to NULL, the interface will be found and + written back to the pointer that is pointed to. + Guid - The GUID of the pack that registered with the HII. + +Returns: + Handle to the HII pack previously registered by the memory driver. + +--*/ +{ + EFI_STATUS Status; + + EFI_HII_HANDLE *HiiHandleBuffer; + EFI_HII_HANDLE HiiHandle; + UINT16 HiiHandleBufferLength; + UINT32 NumberOfHiiHandles; + EFI_GUID HiiGuid; + EFI_HII_PROTOCOL *HiiProt; + UINT32 Index; + UINT16 Length; + + HiiHandle = 0; + if ((HiiProtocol != NULL) && (*HiiProtocol != NULL)) { + // + // The protocol has been passed in + // + HiiProt = *HiiProtocol; + } else { + gBS->LocateProtocol ( + &gEfiHiiProtocolGuid, + NULL, + (VOID **) &HiiProt + ); + if (HiiProt == NULL) { + return HiiHandle; + } + + if (HiiProtocol != NULL) { + // + // Return back the HII protocol for the caller as promissed + // + *HiiProtocol = HiiProt; + } + } + // + // Allocate buffer + // + HiiHandleBufferLength = 10; + HiiHandleBuffer = AllocatePool (HiiHandleBufferLength); + ASSERT (HiiHandleBuffer != NULL); + + // + // Get the Handles of the packages that were registered with Hii + // + Status = HiiProt->FindHandles ( + HiiProt, + &HiiHandleBufferLength, + HiiHandleBuffer + ); + + // + // Get a bigger bugffer if this one is to small, and try again + // + if (Status == EFI_BUFFER_TOO_SMALL) { + + gBS->FreePool (HiiHandleBuffer); + + HiiHandleBuffer = AllocatePool (HiiHandleBufferLength); + ASSERT (HiiHandleBuffer != NULL); + + Status = HiiProt->FindHandles ( + HiiProt, + &HiiHandleBufferLength, + HiiHandleBuffer + ); + } + + if (EFI_ERROR (Status)) { + goto lbl_exit; + } + + NumberOfHiiHandles = HiiHandleBufferLength / sizeof (EFI_HII_HANDLE); + + // + // Iterate Hii handles and look for the one that matches our Guid + // + for (Index = 0; Index < NumberOfHiiHandles; Index++) { + + Length = 0; + ExtractDataFromHiiHandle (HiiHandleBuffer[Index], &Length, NULL, &HiiGuid); + + if (CompareGuid (&HiiGuid, Guid)) { + + HiiHandle = HiiHandleBuffer[Index]; + break; + } + } + +lbl_exit: + gBS->FreePool (HiiHandleBuffer); + return HiiHandle; +} + + +EFI_STATUS +ValidateDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + OUT BOOLEAN *Results + ) +/*++ + +Routine Description: + + Validate that the data associated with the HiiHandle in NVRAM is within + the reasonable parameters for that FormSet. Values for strings and passwords + are not verified due to their not having the equivalent of valid range settings. + +Arguments: + + HiiHandle - Handle of the HII database entry to query + + Results - If return Status is EFI_SUCCESS, Results provides valid data + TRUE = NVRAM Data is within parameters + FALSE = NVRAM Data is NOT within parameters + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Data successfully validated +--*/ +{ + EFI_STATUS Status; + EFI_HII_PROTOCOL *Hii; + EFI_GUID Guid; + UINT8 *RawData; + UINT8 *OldData; + UINTN RawDataLength; + UINT8 *VariableData; + UINTN Index; + UINTN Temp; + UINTN SizeOfNvStore; + UINTN CachedStart; + BOOLEAN GotMatch; + + RawDataLength = DEFAULT_FORM_BUFFER_SIZE; + SizeOfNvStore = 0; + CachedStart = 0; + GotMatch = FALSE; + *Results = TRUE; + + Status = GetHiiInterface (&Hii); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Allocate space for retrieval of IFR data + // + RawData = AllocateZeroPool (RawDataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData); + + if (EFI_ERROR (Status)) { + gBS->FreePool (RawData); + + // + // Allocate space for retrieval of IFR data + // + RawData = AllocateZeroPool (RawDataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData); + } + + OldData = RawData; + + // + // Point RawData to the beginning of the form data + // + RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER)); + + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + if (RawData[Index] == EFI_IFR_FORM_SET_OP) { + CopyMem (&Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID)); + break; + } + + Index = RawData[Index + 1] + Index; + } + + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_FORM_SET_OP: + break; + + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_CHECKBOX_OP: + case EFI_IFR_NUMERIC_OP: + case EFI_IFR_DATE_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_PASSWORD_OP: + case EFI_IFR_STRING_OP: + // + // Remember, multiple op-codes may reference the same item, so let's keep a running + // marker of what the highest QuestionId that wasn't zero length. This will accurately + // maintain the Size of the NvStore + // + if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) { + Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + if (SizeOfNvStore < Temp) { + SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + } + } + } + + Index = RawData[Index + 1] + Index; + } + + // + // Allocate memory for our File Form Tags + // + VariableData = AllocateZeroPool (SizeOfNvStore); + if (VariableData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = gRT->GetVariable ( + (CHAR16 *) L"Setup", + &Guid, + NULL, + &SizeOfNvStore, + (VOID *) VariableData + ); + + if (EFI_ERROR (Status)) { + + // + // If there is a variable that exists already and it is larger than what we calculated the + // storage needs to be, we must assume the variable size from GetVariable is correct and not + // allow the truncation of the variable. It is very possible that the user who created the IFR + // we are cracking is not referring to a variable that was in a previous map, however we cannot + // allow it's truncation. + // + if (Status == EFI_BUFFER_TOO_SMALL) { + // + // Free the buffer that was allocated that was too small + // + gBS->FreePool (VariableData); + + VariableData = AllocatePool (SizeOfNvStore); + if (VariableData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = gRT->GetVariable ( + (CHAR16 *) L"Setup", + &Guid, + NULL, + &SizeOfNvStore, + (VOID *) VariableData + ); + } + } + + // + // Walk through the form and see that the variable data it refers to is ok. + // This allows for the possibility of stale (obsoleted) data in the variable + // can be overlooked without causing an error + // + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_ONE_OF_OP: + // + // A one_of has no data, its the option that does - cache the storage Id + // + CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId; + break; + + case EFI_IFR_ONE_OF_OPTION_OP: + // + // A one_of_option can be any value + // + if (VariableData[CachedStart] == ((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value) { + GotMatch = TRUE; + } + break; + + case EFI_IFR_END_ONE_OF_OP: + // + // At this point lets make sure that the data value in the NVRAM matches one of the options + // + if (!GotMatch) { + *Results = FALSE; + return EFI_SUCCESS; + } + break; + + case EFI_IFR_CHECKBOX_OP: + // + // A checkbox is a boolean, so 0 and 1 are valid + // Remember, QuestionId corresponds to the offset location of the data in the variable + // + if (VariableData[((EFI_IFR_CHECKBOX *) &RawData[Index])->QuestionId] > 1) { + *Results = FALSE; + return EFI_SUCCESS; + } + break; + + case EFI_IFR_NUMERIC_OP: + if ((VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] < ((EFI_IFR_NUMERIC *)&RawData[Index])->Minimum) || + (VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] > ((EFI_IFR_NUMERIC *)&RawData[Index])->Maximum)) { + *Results = FALSE; + return EFI_SUCCESS; + } + break; + + } + + Index = RawData[Index + 1] + Index; + } + + // + // Free our temporary repository of form data + // + gBS->FreePool (OldData); + gBS->FreePool (VariableData); + + return EFI_SUCCESS; +} + diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrOnTheFly.c b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrOnTheFly.c new file mode 100644 index 0000000000..e9ab48246c --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrOnTheFly.c @@ -0,0 +1,977 @@ +/*++ +Copyright (c) 2006, 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: + IfrOnTheFly.c + +Abstract: + + Library Routines to create IFR on-the-fly + +Revision History: + +--*/ + +// +// Include common header file for this module. +// +#include "IfrSupportLibInternal.h" + +EFI_STATUS +CreateFormSet ( + IN CHAR16 *FormSetTitle, + IN EFI_GUID *Guid, + IN UINT8 Class, + IN UINT8 SubClass, + IN OUT VOID **FormBuffer, + IN OUT VOID **StringBuffer + ) +/*++ + +Routine Description: + + Create a formset + +Arguments: + + FormSetTitle - Title of formset + + Guid - Guid of formset + + Class - Class of formset + + SubClass - Sub class of formset + + FormBuffer - Pointer of the formset created + + StringBuffer - Pointer of FormSetTitile string created + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Formset successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_HII_IFR_PACK IfrPack; + EFI_IFR_FORM_SET FormSet; + EFI_IFR_END_FORM_SET EndFormSet; + UINT8 *Destination; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Pre-allocate a buffer sufficient for us to work from. + // + FormBuffer = AllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE); + if (FormBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Pre-allocate a buffer sufficient for us to work from. + // + StringBuffer = AllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE); + if (StringBuffer == NULL) { + gBS->FreePool (FormBuffer); + return EFI_OUT_OF_RESOURCES; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add the FormSetTitle to the string buffer and get the StringToken + // + Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Initialize the Ifr Package header data + // + IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (EFI_IFR_FORM_SET) + sizeof (EFI_IFR_END_FORM_SET); + IfrPack.Header.Type = EFI_HII_IFR; + + // + // Initialize FormSet with the appropriate information + // + FormSet.Header.OpCode = EFI_IFR_FORM_SET_OP; + FormSet.Header.Length = sizeof (EFI_IFR_FORM_SET); + FormSet.FormSetTitle = StringToken; + FormSet.Class = Class; + FormSet.SubClass = SubClass; + CopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID)); + + // + // Initialize the end formset data + // + EndFormSet.Header.Length = sizeof (EFI_IFR_END_FORM_SET); + EndFormSet.Header.OpCode = EFI_IFR_END_FORM_SET_OP; + + Destination = (UINT8 *) *FormBuffer; + + // + // Copy the formset/endformset data to the form buffer + // + CopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER)); + + Destination = Destination + sizeof (EFI_HII_PACK_HEADER); + + CopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET)); + + Destination = Destination + sizeof (EFI_IFR_FORM_SET); + + CopyMem (Destination, &EndFormSet, sizeof (EFI_IFR_END_FORM_SET)); + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateForm ( + IN CHAR16 *FormTitle, + IN UINT16 FormId, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a form + +Arguments: + + FormTitle - Title of the form + + FormId - Id of the form + + FormBuffer - Pointer of the form created + + StringBuffer - Pointer of FormTitil string created + +Returns: + + EFI_SUCCESS - Form successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_FORM Form; + EFI_IFR_END_FORM EndForm; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Form.Header.OpCode = EFI_IFR_FORM_OP; + Form.Header.Length = sizeof (EFI_IFR_FORM); + Form.FormId = FormId; + Form.FormTitle = StringToken; + + Status = AddOpCode (FormBuffer, &Form); + + if (EFI_ERROR (Status)) { + return Status; + } + + EndForm.Header.OpCode = EFI_IFR_END_FORM_OP; + EndForm.Header.Length = sizeof (EFI_IFR_END_FORM); + + Status = AddOpCode (FormBuffer, &EndForm); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateSubTitle ( + IN CHAR16 *SubTitle, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle + +Arguments: + + SubTitle - Sub title to be created + + FormBuffer - Where this subtitle to add to + + StringBuffer - String buffer created for subtitle + +Returns: + + EFI_SUCCESS - Subtitle successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_SUBTITLE Subtitle; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP; + Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE); + Subtitle.SubTitle = StringToken; + + Status = AddOpCode (FormBuffer, &Subtitle); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateText ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN CHAR16 *String3, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a line of text + +Arguments: + + String - First string of the text + + String2 - Second string of the text + + String3 - Help string of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - The form where this text adds to + + StringBuffer - String buffer created for String, String2 and String3 + +Returns: + + EFI_SUCCESS - Text successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_TEXT Text; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Text.Header.OpCode = EFI_IFR_TEXT_OP; + Text.Header.Length = sizeof (EFI_IFR_TEXT); + Text.Text = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Text.TextTwo = StringToken; + + Text.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + Text.Key = Key; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Text.Help = StringToken; + + Status = AddOpCode (FormBuffer, &Text); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateGoto ( + IN UINT16 FormId, + IN CHAR16 *Prompt, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink + +Arguments: + + FormId - Form ID of the hyperlink + + Prompt - Prompt of the hyperlink + + FormBuffer - The form where this hyperlink adds to + + StringBuffer - String buffer created for Prompt + +Returns: + + EFI_SUCCESS - Hyperlink successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_REF Hyperlink; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Hyperlink.Header.OpCode = EFI_IFR_REF_OP; + Hyperlink.Header.Length = sizeof (EFI_IFR_REF); + Hyperlink.FormId = FormId; + Hyperlink.Prompt = StringToken; + + Status = AddOpCode (FormBuffer, &Hyperlink); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateOneOf ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + Prompt - Prompt of the one-of box + + Help - Help of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - The form where this one-of box adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - One-Of box successfully created. + +--*/ +{ + EFI_STATUS Status; + UINTN Index; + EFI_IFR_ONE_OF OneOf; + EFI_IFR_ONE_OF_OPTION OneOfOption; + EFI_IFR_END_ONE_OF EndOneOf; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // We do not create op-code storage widths for one-of in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP; + OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF); + OneOf.QuestionId = QuestionId; + OneOf.Width = DataWidth; + OneOf.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OneOf.Help = StringToken; + + Status = AddOpCode (FormBuffer, &OneOf); + + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < OptionCount; Index++) { + OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + + // + // Add string and get token back + // + Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken); + + OneOfOption.Option = StringToken; + OneOfOption.Value = OptionsList[Index].Value; + OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED); + OneOfOption.Key = OptionsList[Index].Key; + + Status = AddOpCode (FormBuffer, &OneOfOption); + + if (EFI_ERROR (Status)) { + return Status; + } + } + + EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + Status = AddOpCode (FormBuffer, &EndOneOf); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateOrderedList ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + Prompt - Prompt of the ordered list + + Help - Help of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - The form where this ordered list adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_SUCCESS - Ordered list successfully created. + +--*/ +{ + EFI_STATUS Status; + UINTN Index; + EFI_IFR_ORDERED_LIST OrderedList; + EFI_IFR_ONE_OF_OPTION OrderedListOption; + EFI_IFR_END_ONE_OF EndOrderedList; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP; + OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST); + OrderedList.QuestionId = QuestionId; + OrderedList.MaxEntries = MaxEntries; + OrderedList.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OrderedList.Help = StringToken; + + Status = AddOpCode (FormBuffer, &OrderedList); + + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < OptionCount; Index++) { + OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + + // + // Add string and get token back + // + Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken); + + OrderedListOption.Option = StringToken; + OrderedListOption.Value = OptionsList[Index].Value; + OrderedListOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED); + OrderedListOption.Key = OptionsList[Index].Key; + + Status = AddOpCode (FormBuffer, &OrderedListOption); + + if (EFI_ERROR (Status)) { + return Status; + } + } + + EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + Status = AddOpCode (FormBuffer, &EndOrderedList); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateCheckBox ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 Flags, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a checkbox + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + Prompt - Prompt of the check box + + Help - Help of the check box + + Flags - Flags of the check box + + FormBuffer - The form where this check box adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 1 + + EFI_SUCCESS - Check box successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_CHECKBOX CheckBox; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // We do not create op-code storage widths for checkbox in excess of 8 bits for now + // + if (DataWidth > 1) { + return EFI_DEVICE_ERROR; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP; + CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX); + CheckBox.QuestionId = QuestionId; + CheckBox.Width = DataWidth; + CheckBox.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + CheckBox.Help = StringToken; + CheckBox.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + + Status = AddOpCode (FormBuffer, &CheckBox); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateNumeric ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a numeric + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + Prompt - Prompt of the numeric + + Help - Help of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - The form where this numeric adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - Numeric is successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_NUMERIC Numeric; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // We do not create op-code storage widths for numerics in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP; + Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC); + Numeric.QuestionId = QuestionId; + Numeric.Width = DataWidth; + Numeric.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Numeric.Help = StringToken; + Numeric.Minimum = Minimum; + Numeric.Maximum = Maximum; + Numeric.Step = Step; + Numeric.Default = Default; + Numeric.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + Numeric.Key = Key; + + Status = AddOpCode (FormBuffer, &Numeric); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateString ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a string + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + Prompt - Prompt of the string + + Help - Help of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - The form where this string adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_SUCCESS - String successfully created. + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_STRING String; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + String.Header.OpCode = EFI_IFR_STRING_OP; + String.Header.Length = sizeof (EFI_IFR_STRING); + String.QuestionId = QuestionId; + String.Width = DataWidth; + String.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + String.Help = StringToken; + String.MinSize = MinSize; + String.MaxSize = MaxSize; + String.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + String.Key = Key; + + Status = AddOpCode (FormBuffer, &String); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrOpCodeCreation.c b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrOpCodeCreation.c new file mode 100644 index 0000000000..05b123887c --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrOpCodeCreation.c @@ -0,0 +1,618 @@ +/*++ +Copyright (c) 2006, 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: + IfrOpCodeCreation.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 common header file for this module. +// +#include "IfrSupportLibInternal.h" + +EFI_STATUS +CreateSubTitleOpCode ( + IN STRING_REF StringToken, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - StringToken of the subtitle + + FormBuffer - Output of subtitle as a form + +Returns: + + EFI_SUCCESS - Subtitle created to be a form + +--*/ +{ + EFI_IFR_SUBTITLE Subtitle; + + Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP; + Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE); + Subtitle.SubTitle = StringToken; + + CopyMem (FormBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE)); + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateTextOpCode ( + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN STRING_REF StringTokenThree, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a Text opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - First string token of the text + + StringTokenTwo - Second string token of the text + + StringTokenThree - Help string token of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - Output of text as a form + +Returns: + + EFI_SUCCESS - Text created to be a form + +--*/ +{ + EFI_IFR_TEXT Text; + + Text.Header.OpCode = EFI_IFR_TEXT_OP; + Text.Header.Length = sizeof (EFI_IFR_TEXT); + Text.Text = StringToken; + + Text.TextTwo = StringTokenTwo; + Text.Help = StringTokenThree; + Text.Flags = Flags; + Text.Key = Key; + + CopyMem (FormBuffer, &Text, sizeof (EFI_IFR_TEXT)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateGotoOpCode ( + IN UINT16 FormId, + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + FormId - Form ID of the hyperlink + + StringToken - Prompt string token of the hyperlink + + StringTokenTwo - Help string token of the hyperlink + + Flags - Flags of the hyperlink + + Key - Key of the hyperlink + + FormBuffer - Output of hyperlink as a form + +Returns: + + EFI_SUCCESS - Hyperlink created to be a form + +--*/ +{ + EFI_IFR_REF Hyperlink; + + Hyperlink.Header.OpCode = EFI_IFR_REF_OP; + Hyperlink.Header.Length = sizeof (EFI_IFR_REF); + Hyperlink.FormId = FormId; + Hyperlink.Prompt = StringToken; + Hyperlink.Help = StringTokenTwo; + Hyperlink.Key = Key; + Hyperlink.Flags = Flags; + + CopyMem (FormBuffer, &Hyperlink, sizeof (EFI_IFR_REF)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateOneOfOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a one-of opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + PromptToken - Prompt string token of the one-of box + + HelpToken - Help string token of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - Output of One-Of box as a form + +Returns: + + EFI_SUCCESS - One-Of box created to be a form + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +{ + UINTN Index; + EFI_IFR_ONE_OF OneOf; + EFI_IFR_ONE_OF_OPTION OneOfOption; + EFI_IFR_END_ONE_OF EndOneOf; + UINT8 *LocalBuffer; + + // + // We do not create op-code storage widths for one-of in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP; + OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF); + OneOf.QuestionId = QuestionId; + OneOf.Width = DataWidth; + OneOf.Prompt = PromptToken; + + OneOf.Help = HelpToken; + + LocalBuffer = (UINT8 *) FormBuffer; + + CopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF)); + + LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF)); + + 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.Option = OptionsList[Index].StringToken; + OneOfOption.Value = OptionsList[Index].Value; + OneOfOption.Flags = OptionsList[Index].Flags; + OneOfOption.Key = OptionsList[Index].Key; + + CopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION)); + + LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION)); + } + + EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + CopyMem (LocalBuffer, &EndOneOf, sizeof (EFI_IFR_END_ONE_OF)); + + LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF)); + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateOrderedListOpCode ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a ordered list opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + PromptToken - Prompt string token of the ordered list + + HelpToken - Help string token of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - Output of ordered list as a form + +Returns: + + EFI_SUCCESS - Ordered list created to be a form + +--*/ +{ + UINTN Index; + EFI_IFR_ORDERED_LIST OrderedList; + EFI_IFR_ONE_OF_OPTION OrderedListOption; + EFI_IFR_END_ONE_OF EndOrderedList; + UINT8 *LocalBuffer; + + OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP; + OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST); + OrderedList.QuestionId = QuestionId; + OrderedList.MaxEntries = MaxEntries; + OrderedList.Prompt = PromptToken; + + OrderedList.Help = HelpToken; + + LocalBuffer = (UINT8 *) FormBuffer; + + CopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST)); + + LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ORDERED_LIST)); + + for (Index = 0; Index < OptionCount; Index++) { + OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + + OrderedListOption.Option = OptionsList[Index].StringToken; + OrderedListOption.Value = OptionsList[Index].Value; + OrderedListOption.Flags = OptionsList[Index].Flags; + OrderedListOption.Key = OptionsList[Index].Key; + + CopyMem (LocalBuffer, &OrderedListOption, sizeof (EFI_IFR_ONE_OF_OPTION)); + + LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION)); + } + + EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + CopyMem (LocalBuffer, &EndOrderedList, sizeof (EFI_IFR_END_ONE_OF)); + + LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF)); + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateCheckBoxOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a checkbox opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + PromptToken - Prompt string token of the check box + + HelpToken - Help string token of the check box + + Flags - Flags of the check box + + Key - Key of the check box + + FormBuffer - Output of the check box as a form + +Returns: + + EFI_SUCCESS - Checkbox created to be a form + + EFI_DEVICE_ERROR - DataWidth > 1 + +--*/ +{ + EFI_IFR_CHECKBOX CheckBox; + + // + // We do not create op-code storage widths for checkbox in excess of 8 bits for now + // + if (DataWidth > 1) { + return EFI_DEVICE_ERROR; + } + + CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP; + CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX); + CheckBox.QuestionId = QuestionId; + CheckBox.Width = DataWidth; + CheckBox.Prompt = PromptToken; + + CheckBox.Help = HelpToken; + CheckBox.Flags = Flags; + CheckBox.Key = Key; + + CopyMem (FormBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateNumericOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + PromptToken - Prompt string token of the numeric + + HelpToken - Help string token of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value of the numeric + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - Output of the numeric as a form + +Returns: + + EFI_SUCCESS - The numeric created to be a form. + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +{ + EFI_IFR_NUMERIC Numeric; + + // + // We do not create op-code storage widths for numerics in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP; + Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC); + Numeric.QuestionId = QuestionId; + Numeric.Width = DataWidth; + Numeric.Prompt = PromptToken; + + Numeric.Help = HelpToken; + Numeric.Minimum = Minimum; + Numeric.Maximum = Maximum; + Numeric.Step = Step; + Numeric.Default = Default; + Numeric.Flags = Flags; + Numeric.Key = Key; + + CopyMem (FormBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateStringOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + PromptToken - Prompt token of the string + + HelpToken - Help token of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - Output of the string as a form + +Returns: + + EFI_SUCCESS - String created to be a form. + +--*/ +{ + EFI_IFR_STRING String; + + String.Header.OpCode = EFI_IFR_STRING_OP; + String.Header.Length = sizeof (EFI_IFR_STRING); + String.QuestionId = QuestionId; + String.Width = DataWidth; + String.Prompt = PromptToken; + + String.Help = HelpToken; + String.MinSize = MinSize; + String.MaxSize = MaxSize; + String.Flags = Flags; + String.Key = Key; + + CopyMem (FormBuffer, &String, sizeof (EFI_IFR_STRING)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateBannerOpCode ( + IN UINT16 Title, + IN UINT16 LineNumber, + IN UINT8 Alignment, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a banner opcode. This is primarily used by the FrontPage implementation from BDS. + +Arguments: + + Title - Title of the banner + + LineNumber - LineNumber of the banner + + Alignment - Alignment of the banner + + FormBuffer - Output of banner as a form + +Returns: + + EFI_SUCCESS - Banner created to be a form. + +--*/ +{ + EFI_IFR_BANNER Banner; + + Banner.Header.OpCode = EFI_IFR_BANNER_OP; + Banner.Header.Length = sizeof (EFI_IFR_BANNER); + CopyMem (&Banner.Title, &Title, sizeof (UINT16)); + CopyMem (&Banner.LineNumber, &LineNumber, sizeof (UINT16)); + Banner.Alignment = Alignment; + + CopyMem (FormBuffer, &Banner, sizeof (EFI_IFR_BANNER)); + + return EFI_SUCCESS; +} diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.inf b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.inf new file mode 100644 index 0000000000..fa0069897c --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.inf @@ -0,0 +1,66 @@ +#/** @file +# EDK Internal Form Refresentation Support Library Instance. +# +# The library instance provides common library routines help in +# IFR creation on-the-fly, HII variable access, HII database access, multi language supports. +# Copyright (c) 2006 - 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. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = FrameworkIfrSupportLib + FILE_GUID = ea55bada-d488-427b-9d2d-227e0aaa3707 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = FrameworkIfrSupportLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + CONSTRUCTOR = IfrLibConstruct + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# +# Variable Guid C Name: gLanGuid Variable Name: L"Lan" +# + +[Sources.common] + IfrVariable.c + IfrOpCodeCreation.c + IfrOnTheFly.c + IfrCommon.c + IfrSupportLibInternal.h + + +[Packages] + MdePkg/MdePkg.dec + IntelFrameworkPkg/IntelFrameworkPkg.dec + + +[LibraryClasses] + UefiRuntimeServicesTableLib + UefiBootServicesTableLib + MemoryAllocationLib + BaseMemoryLib + BaseLib + DebugLib + + +[Guids] + gEfiGlobalVariableGuid # ALWAYS_CONSUMED + + +[Protocols] + gEfiHiiProtocolGuid # PROTOCOL ALWAYS_CONSUMED + diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.msa b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.msa new file mode 100644 index 0000000000..87f4f7411a --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.msa @@ -0,0 +1,81 @@ + + + + EdkIfrSupportLib + DXE_DRIVER + ea55bada-d488-427b-9d2d-227e0aaa3707 + 1.0 + EDK Internal Form Refresentation Support Library Instance. + The library instance provides common library routines help in + IFR creation on-the-fly, HII variable access, HII database access, multi language supports. + Copyright (c) 2006 - 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. + FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 + + + IA32 X64 IPF EBC + false + EdkIfrSupportLib + + + + EdkIfrSupportLib + + + DebugLib + + + BaseLib + + + BaseMemoryLib + + + MemoryAllocationLib + + + UefiBootServicesTableLib + + + UefiRuntimeServicesTableLib + + + + IfrCommon.c + IfrOnTheFly.c + IfrOpCodeCreation.c + IfrVariable.c + + + + + + + + gEfiHiiProtocolGuid + + + + + 0x004C 0x0061 0x006E + gLanGuid + + + + + gEfiGlobalVariableGuid + + + + EFI_SPECIFICATION_VERSION 0x00020000 + EDK_RELEASE_VERSION 0x00020000 + + IfrLibConstruct + + + \ No newline at end of file diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLibInternal.h b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLibInternal.h new file mode 100644 index 0000000000..033b3969da --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLibInternal.h @@ -0,0 +1,33 @@ +/**@file + Common header file shared by all source files. + + This file includes package header files, library classes and protocol, PPI & GUID definitions. + + Copyright (c) 2006 - 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. +**/ + +#ifndef __IFRSUPPORT_LIB_INTERNAL_H_ +#define __IFRSUPPORT_LIB_INTERNAL_H_ + + + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrVariable.c b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrVariable.c new file mode 100644 index 0000000000..04aa4dcd9b --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrVariable.c @@ -0,0 +1,493 @@ +/*++ + +Copyright (c) 2006, 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: + IfrVariable.c + +Abstract: + Variable/Map manipulations routines + +--*/ + +// +// Include common header file for this module. +// +#include "IfrSupportLibInternal.h" + +VOID +EfiLibHiiVariablePackGetMap ( + IN EFI_HII_VARIABLE_PACK *Pack, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, OPTIONAL + OUT UINTN *Size OPTIONAL + ) +/*++ + +Routine Description: + + Extracts a variable form a Pack. + +Arguments: + + Pack - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + VOID + +--*/ +{ + if (NULL != Name) { + *Name = (VOID *) (Pack + 1); + } + + if (NULL != Guid) { + *Guid = (EFI_GUID *)(UINTN)&Pack->VariableGuid; + } + + + if (NULL != Id) { + *Id = Pack->VariableId; + } + + if (NULL != Var) { + *Var = (VOID *) ((CHAR8 *) (Pack + 1) + Pack->VariableNameLength); + } + + if (NULL != Size) { + *Size = Pack->Header.Length - sizeof (*Pack) - Pack->VariableNameLength; + } +} + + +UINTN +EfiLibHiiVariablePackListGetMapCnt ( + IN EFI_HII_VARIABLE_PACK_LIST *List + ) + +/*++ + +Routine Description: + + Finds a count of the variables/maps in the List. + +Arguments: + + List - List of variables + +Returns: + + UINTN - The number of map count. + +--*/ + +{ + UINTN Cnt = 0; + while (NULL != List) { + Cnt++; + List = List->NextVariablePack; + } + return Cnt; +} + + +VOID +EfiLibHiiVariablePackListForEachVar ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback + ) +/*++ + +Routine Description: + + Will iterate all variable/maps as appearing + in List and for each, it will call the Callback. + +Arguments: + + List - List of variables + Callback - Routine to be called for each iterated variable. + +Returns: + + VOID + +--*/ + +{ + CHAR16 *MapName; + EFI_GUID *MapGuid; + UINT16 MapId; + VOID *Map; + UINTN MapSize; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + // + // call the callback + // + Callback (MapName, MapGuid, MapId, Map, MapSize); + List = List->NextVariablePack; + } +} + + +EFI_STATUS +EfiLibHiiVariablePackListGetMapByIdx ( + IN UINTN Idx, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) + +/*++ + +Routine Description: + + Finds a variable form List given + the order number as appears in the List. + +Arguments: + + Idx - The index of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ +{ + CHAR16 *MapName; + EFI_GUID *MapGuid; + UINT16 MapId; + VOID *Map; + UINTN MapSize; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + if (0 == Idx--) { + *Var = Map; + *Size = MapSize; + + if (NULL != Name) { + *Name = MapName; + } + + if (NULL != Guid) { + *Guid = MapGuid; + } + + if (NULL != Id) { + *Id = MapId; + } + + return EFI_SUCCESS; // Map found + } + List = List->NextVariablePack; + } + // + // If here, the map is not found + // + return EFI_NOT_FOUND; +} + + +EFI_STATUS +EfiLibHiiVariablePackListGetMapById ( + IN UINT16 Id, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) + +/*++ + +Routine Description: + + Finds a variable form List given the + order number as appears in the List. + +Arguments: + + Id - The ID of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ + +{ + CHAR16 *MapName; + EFI_GUID *MapGuid; + UINT16 MapId; + VOID *Map; + UINTN MapSize; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + if (MapId == Id) { + *Var = Map; + *Size = MapSize; + if (NULL != Name) { + *Name = MapName; + } + if (NULL != Guid) { + *Guid = MapGuid; + } + // + // Map found + // + return EFI_SUCCESS; + } + List = List->NextVariablePack; + } + // + // If here, the map is not found + // + return EFI_NOT_FOUND; +} + + +EFI_STATUS +EfiLibHiiVariablePackListGetMap ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + OUT UINT16 *Id, + OUT VOID **Var, + OUT UINTN *Size + ) + +/*++ + +Routine Description: + + Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID. + +Arguments: + + List - List of variables + Name - Name of the variable/map to be found + Guid - GUID of the variable/map to be found + Var - Pointer to the variable/map found + Size - Size of the variable/map in bytes found + +Returns: + + EFI_SUCCESS - variable is found, OUT parameters are valid + EFI_NOT_FOUND - variable is not found, OUT parameters are not valid + +--*/ + +{ + VOID *Map; + UINTN MapSize; + UINT16 MapId; + CHAR16 *MapName; + EFI_GUID *MapGuid; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + if ((0 == StrCmp (Name, MapName)) && CompareGuid (Guid, MapGuid)) { + *Id = MapId; + *Var = Map; + *Size = MapSize; + return EFI_SUCCESS; + } + List = List->NextVariablePack; + } + // + // If here, the map is not found + // + return EFI_NOT_FOUND; +} + +EFI_STATUS +EfiLibHiiVariableRetrieveFromNv ( + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID **Var + ) +/*++ + +Routine Description: + Finds out if a variable of specific Name/Guid/Size exists in NV. + If it does, it will retrieve it into the Var. + +Arguments: + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into buffer pointed by this pointer. + If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer. +Returns: + EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +{ + EFI_STATUS Status; + UINTN SizeNv; + + // + // Test for existence of the variable. + // + SizeNv = 0; + Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, NULL); + if (EFI_BUFFER_TOO_SMALL != Status) { + ASSERT (EFI_SUCCESS != Status); + return EFI_NOT_FOUND; + } + if (SizeNv != Size) { + // + // The variable is considered corrupt, as it has different size from expected. + // + return EFI_LOAD_ERROR; + } + + if (NULL == *Var) { + *Var = AllocatePool (Size); + ASSERT (NULL != *Var); + } + SizeNv = Size; + // + // Final read into the Var + // + Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, *Var); + // + // No tolerance for random failures. Such behavior is undetermined and not validated. + // + ASSERT_EFI_ERROR (Status); + ASSERT (SizeNv == Size); + return EFI_SUCCESS; +} + + + +EFI_STATUS +EfiLibHiiVariableOverrideIfSuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the Name ends with specified Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride", + the Suffix matches the end of Name, so the variable will be loaded from NV + provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the Name should end with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_INVALID_PARAMETER - The name of the variable does not end with . + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +{ + UINTN StrLength; + UINTN StrLenSuffix; + + StrLength = StrLen (Name); + StrLenSuffix = StrLen (Suffix); + if ((StrLength <= StrLenSuffix) || (0 != StrCmp (Suffix, &Name[StrLength - StrLenSuffix]))) { + // + // Not ending with . + // + return EFI_INVALID_PARAMETER; + } + return EfiLibHiiVariableRetrieveFromNv (Name, Guid, Size, &Var); +} + +EFI_STATUS +EfiLibHiiVariableOverrideBySuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the NV contains the same variable with Name is appended with Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetup", + the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride" + will be loaded from NV provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the variable will be appended with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. + +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +{ + EFI_STATUS Status; + CHAR16 *NameSuffixed; + UINTN NameLength; + UINTN SuffixLength; + + // + // enough to concatenate both strings. + // + NameLength = StrLen (Name); + SuffixLength = StrLen (Suffix); + NameSuffixed = AllocateZeroPool ((NameLength + SuffixLength + 1) * sizeof (CHAR16)); + + StrCpy (NameSuffixed, Name); + StrCat (NameSuffixed, Suffix); + + Status = EfiLibHiiVariableRetrieveFromNv (NameSuffixed, Guid, Size, &Var); + gBS->FreePool (NameSuffixed); + + return Status; +} + diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c new file mode 100644 index 0000000000..8baacaf8d4 --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/Console.c @@ -0,0 +1,282 @@ +/** @file + Mde UEFI library functions. + + 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: Console.c + +**/ + +#include "FrameworkUefiLib.h" + +typedef struct { + CHAR16 WChar; + UINT32 Width; +} UNICODE_WIDTH_ENTRY; + +UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = { + // + // General script area + // + {(CHAR16)0x1FFF, 1}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all narrow glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x007F, 1}, // C0 controls and basic Latin. 0x0000-0x007F + {(CHAR16)0x00FF, 1}, // C1 controls and Latin-1 support. 0x0080-0x00FF + {(CHAR16)0x017F, 1}, // Latin extended-A. 0x0100-0x017F + {(CHAR16)0x024F, 1}, // Latin extended-B. 0x0180-0x024F + {(CHAR16)0x02AF, 1}, // IPA extensions. 0x0250-0x02AF + {(CHAR16)0x02FF, 1}, // Spacing modifier letters. 0x02B0-0x02FF + {(CHAR16)0x036F, 1}, // Combining diacritical marks. 0x0300-0x036F + {(CHAR16)0x03FF, 1}, // Greek. 0x0370-0x03FF + {(CHAR16)0x04FF, 1}, // Cyrillic. 0x0400-0x04FF + {(CHAR16)0x052F, 0}, // Unassigned. As Armenian in ver3.0. 0x0500-0x052F + {(CHAR16)0x058F, 1}, // Armenian. 0x0530-0x058F + {(CHAR16)0x05FF, 1}, // Hebrew. 0x0590-0x05FF + {(CHAR16)0x06FF, 1}, // Arabic. 0x0600-0x06FF + {(CHAR16)0x08FF, 0}, // Unassigned. 0x0700-0x08FF + {(CHAR16)0x097F, 1}, // Devanagari. 0x0900-0x097F + {(CHAR16)0x09FF, 1}, // Bengali. 0x0980-0x09FF + {(CHAR16)0x0A7F, 1}, // Gurmukhi. 0x0A00-0x0A7F + {(CHAR16)0x0AFF, 1}, // Gujarati. 0x0A80-0x0AFF + {(CHAR16)0x0B7F, 1}, // Oriya. 0x0B00-0x0B7F + {(CHAR16)0x0BFF, 1}, // Tamil. (See page 7-92). 0x0B80-0x0BFF + {(CHAR16)0x0C7F, 1}, // Telugu. 0x0C00-0x0C7F + {(CHAR16)0x0CFF, 1}, // Kannada. (See page 7-100). 0x0C80-0x0CFF + {(CHAR16)0x0D7F, 1}, // Malayalam (See page 7-104). 0x0D00-0x0D7F + {(CHAR16)0x0DFF, 0}, // Unassigned. 0x0D80-0x0DFF + {(CHAR16)0x0E7F, 1}, // Thai. 0x0E00-0x0E7F + {(CHAR16)0x0EFF, 1}, // Lao. 0x0E80-0x0EFF + {(CHAR16)0x0FBF, 1}, // Tibetan. 0x0F00-0x0FBF + {(CHAR16)0x109F, 0}, // Unassigned. 0x0FC0-0x109F + {(CHAR16)0x10FF, 1}, // Georgian. 0x10A0-0x10FF + {(CHAR16)0x11FF, 1}, // Hangul Jamo. 0x1100-0x11FF + {(CHAR16)0x1DFF, 0}, // Unassigned. 0x1200-0x1DFF + {(CHAR16)0x1EFF, 1}, // Latin extended additional. 0x1E00-0x1EFF + {(CHAR16)0x1FFF, 1}, // Greek extended. 0x1F00-0x1FFF + * + */ + + // + // Symbol area + // + {(CHAR16)0x2FFF, 1}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all narrow glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x206F, 1}, // General punctuation. (See page7-154). 0x200-0x206F + {(CHAR16)0x209F, 1}, // Superscripts and subscripts. 0x2070-0x209F + {(CHAR16)0x20CF, 1}, // Currency symbols. 0x20A0-0x20CF + {(CHAR16)0x20FF, 1}, // Combining diacritical marks for symbols. 0x20D0-0x20FF + {(CHAR16)0x214F, 1}, // Letterlike sympbols. 0x2100-0x214F + {(CHAR16)0x218F, 1}, // Number forms. 0x2150-0x218F + {(CHAR16)0x21FF, 1}, // Arrows. 0x2190-0x21FF + {(CHAR16)0x22FF, 1}, // Mathematical operators. 0x2200-0x22FF + {(CHAR16)0x23FF, 1}, // Miscellaneous technical. 0x2300-0x23FF + {(CHAR16)0x243F, 1}, // Control pictures. 0x2400-0x243F + {(CHAR16)0x245F, 1}, // Optical character recognition. 0x2440-0x245F + {(CHAR16)0x24FF, 1}, // Enclosed alphanumerics. 0x2460-0x24FF + {(CHAR16)0x257F, 1}, // Box drawing. 0x2500-0x257F + {(CHAR16)0x259F, 1}, // Block elements. 0x2580-0x259F + {(CHAR16)0x25FF, 1}, // Geometric shapes. 0x25A0-0x25FF + {(CHAR16)0x26FF, 1}, // Miscellaneous symbols. 0x2600-0x26FF + {(CHAR16)0x27BF, 1}, // Dingbats. 0x2700-0x27BF + {(CHAR16)0x2FFF, 0}, // Reserved. 0x27C0-0x2FFF + * + */ + + // + // CJK phonetics and symbol area + // + {(CHAR16)0x33FF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x303F, 2}, // CJK symbols and punctuation. 0x3000-0x303F + {(CHAR16)0x309F, 2}, // Hiragana. 0x3040-0x309F + {(CHAR16)0x30FF, 2}, // Katakana. 0x30A0-0x30FF + {(CHAR16)0x312F, 2}, // Bopomofo. 0x3100-0x312F + {(CHAR16)0x318F, 2}, // Hangul compatibility jamo. 0x3130-0x318F + {(CHAR16)0x319F, 2}, // Kanbun. 0x3190-0x319F + {(CHAR16)0x31FF, 0}, // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF + {(CHAR16)0x32FF, 2}, // Enclosed CJK letters and months. 0x3200-0x32FF + {(CHAR16)0x33FF, 2}, // CJK compatibility. 0x3300-0x33FF + * + */ + + // + // CJK ideograph area + // + {(CHAR16)0x9FFF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x4DFF, 0}, // Reserved. 0x3400-0x4DBF as CJK unified ideographs + // extension A in ver3.0. 0x3400-0x4DFF + {(CHAR16)0x9FFF, 2}, // CJK unified ideographs. 0x4E00-0x9FFF + * + */ + + // + // Reserved + // + {(CHAR16)0xABFF, 0}, // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0 + // as Yi radicals in ver3.0. 0xA000-0xABFF + // + // Hangul syllables + // + {(CHAR16)0xD7FF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0xD7A3, 2}, // Hangul syllables. 0xAC00-0xD7A3 + {(CHAR16)0xD7FF, 0}, // Reserved. 0xD7A3-0xD7FF + * + */ + + // + // Surrogates area + // + {(CHAR16)0xDFFF, 0}, // Surrogates, not used now. 0xD800-0xDFFF + + // + // Private use area + // + {(CHAR16)0xF8FF, 0}, // Private use area. 0xE000-0xF8FF + + // + // Compatibility area and specials + // + {(CHAR16)0xFAFF, 2}, // CJK compatibility ideographs. 0xF900-0xFAFF + {(CHAR16)0xFB4F, 1}, // Alphabetic presentation forms. 0xFB00-0xFB4F + {(CHAR16)0xFDFF, 1}, // Arabic presentation forms-A. 0xFB50-0xFDFF + {(CHAR16)0xFE1F, 0}, // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F + {(CHAR16)0xFE2F, 1}, // Combining half marks. 0xFE20-0xFE2F + {(CHAR16)0xFE4F, 2}, // CJK compatibility forms. 0xFE30-0xFE4F + {(CHAR16)0xFE6F, 1}, // Small Form Variants. 0xFE50-0xFE6F + {(CHAR16)0xFEFF, 1}, // Arabic presentation forms-B. 0xFE70-0xFEFF + {(CHAR16)0xFFEF, 1}, // Half width and full width forms. 0xFF00-0xFFEF + {(CHAR16)0xFFFF, 0}, // Speicials. 0xFFF0-0xFFFF +}; + +/** + This function computes and returns the width of the Unicode character + specified by UnicodeChar. + + @param UnicodeChar A Unicode character. + + @retval 0 The width if UnicodeChar could not be determined. + @retval 1 UnicodeChar is a narrow glyph. + @retval 2 UnicodeChar is a wide glyph. + +**/ +UINTN +EFIAPI +GetGlyphWidth ( + IN CHAR16 UnicodeChar + ) +{ + UINTN Index; + UINTN Low; + UINTN High; + UNICODE_WIDTH_ENTRY *Item; + + Item = NULL; + Low = 0; + High = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1; + while (Low <= High) { + Index = (Low + High) >> 1; + Item = &(mUnicodeWidthTable[Index]); + if (Index == 0) { + if (UnicodeChar <= Item->WChar) { + break; + } + + return 0; + } + + if (UnicodeChar > Item->WChar) { + Low = Index + 1; + } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) { + High = Index - 1; + } else { + // + // Index - 1 < UnicodeChar <= Index. Found + // + break; + } + } + + if (Low <= High) { + return Item->Width; + } + + return 0; +} + +/** + This function computes and returns the display length of + the Null-terminated Unicode string specified by String. + If String is NULL, then 0 is returned. + If any of the widths of the Unicode characters in String + can not be determined, then 0 is returned. + + @param String A pointer to a Null-terminated Unicode string. + + @return The display length of the Null-terminated Unicode string specified by String. + +**/ +UINTN +EFIAPI +UnicodeStringDisplayLength ( + IN CONST CHAR16 *String + ) +{ + UINTN Length; + UINTN Width; + + if (String == NULL) { + return 0; + } + + Length = 0; + while (*String != 0) { + Width = GetGlyphWidth (*String); + if (Width == 0) { + return 0; + } + + Length += Width; + String++; + } + + return Length; +} diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.h b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.h new file mode 100644 index 0000000000..89d4633a48 --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.h @@ -0,0 +1,44 @@ +/** @file + Header file to include header files common to all source files in + FrameworkUefiLib. + + 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: FrameworkUefiLib.h + +**/ + +#ifndef _UEFI_LIB_FRAMEWORK_H_ +#define _UEFI_LIB_FRAMEWORK_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf new file mode 100644 index 0000000000..a7a29bbd4b --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf @@ -0,0 +1,80 @@ +#/** @file +# Component description file for the entry point to a EFIDXE Drivers +# +# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification +# +# Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the oldconflicts with library functions and supporting implementations of the old +# (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as it contains DXE enum extensions for EFI event services. +# Copyright (c) 2006, 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. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = FrameworkUefiLib + FILE_GUID = B2F0D71A-A39F-4094-854B-0C6BA6910CCE + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = UefiLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources.common] + UefiLibPrint.c + UefiNotTiano.c + Console.c + UefiLib.c + UefiDriverModel.c + +[Packages] + MdePkg/MdePkg.dec + IntelFrameworkPkg/IntelFrameworkPkg.dec + + +[LibraryClasses] + PrintLib + PcdLib + MemoryAllocationLib + DebugLib + BaseMemoryLib + BaseLib + UefiBootServicesTableLib + +[Protocols] + gEfiDriverBindingProtocolGuid # ALWAYS_CONSUMED + gEfiComponentNameProtocolGuid # SOMETIMES_CONSUMED + gEfiComponentName2ProtocolGuid # SOMETIMES_CONSUMED + gEfiDriverConfigurationProtocolGuid # SOMETIMES_CONSUMED + gEfiDriverDiagnosticsProtocolGuid # SOMETIMES_CONSUMED + gEfiDriverDiagnostics2ProtocolGuid # SOMETIMES_CONSUMED + gEfiFirmwareVolume2ProtocolGuid # ALWAYS_CONSUMED + +[Guids] + gEfiFrameworkDevicePathGuid # ALWAYS_CONSUMED + gEfiEventReadyToBootGuid # ALWAYS_CONSUMED + gEfiEventLegacyBootGuid # ALWAYS_CONSUMED + + +[Pcd.common] + gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize + +[FeaturePcd.common] + gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable + gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable + gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable + gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.msa b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.msa new file mode 100644 index 0000000000..49866165f7 --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.msa @@ -0,0 +1,84 @@ + + + + UefiLib + DXE_DRIVER + B2F0D71A-A39F-4094-854B-0C6BA6910CCE + 1.0 + Component description file for the entry point to a EFIDXE Drivers + Library to abstract Framework extensions that conflict with UEFI 2.0 Specification + + Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the oldconflicts with library functions and supporting implementations of the old + (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as it contains DXE enum extensions for EFI event services. + Copyright (c) 2006, 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. + FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 + + + IA32 X64 IPF EBC + false + UefiLib + + + + UefiLib + + + UefiBootServicesTableLib + + + BaseLib + + + BaseMemoryLib + + + DebugLib + + + MemoryAllocationLib + + + PcdLib + + + PrintLib + + + + UefiLib.c + Console.c + UefiNotTiano.c + UefiLibPrint.c + + + + + + + gEfiEventLegacyBootGuid + + + gEfiEventReadyToBootGuid + + + gEfiFrameworkDevicePathGuid + + + + EFI_SPECIFICATION_VERSION 0x00020000 + EDK_RELEASE_VERSION 0x00020000 + + + + PcdUefiLibMaxPrintBufferSize + gEfiMdePkgTokenSpaceGuid + This PCD is used by UefiLib APIs, which are Print, ErrorPrint, AsciiPrint, AsciiErrorPrint. If the length of the formatted Unicode or ASCII string is greater than PcdUefiLibMaxPrintBufferSize, then only the first (PcdUefiLibMaxPrintBufferSize / Sizeof(CHAR16)) Unicode characters or PcdUefiLibMaxPrintBufferSize Ascii characters are sent to the respective console. + + + \ No newline at end of file diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c new file mode 100644 index 0000000000..c26599a37f --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiDriverModel.c @@ -0,0 +1,667 @@ +/** @file + Library functions that abstract driver model protocols + installation. + + Copyright (c) 2006 - 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 "FrameworkUefiLib.h" + +/** + Intialize a driver by installing the Driver Binding Protocol onto the driver's + DriverBindingHandle. This is typically the same as the driver's ImageHandle, but + it can be different if the driver produces multiple DriverBinding Protocols. + If the Drvier Binding Protocol interface is NULL, then ASSERT (). + If the installation fails, then ASSERT (). + + @param ImageHandle The image handle of the driver. + @param SystemTable The EFI System Table that was passed to the driver's entry point. + @param DriverBinding A Driver Binding Protocol instance that this driver is producing. + @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + + @retval EFI_SUCCESS The protocol installation is completed successfully. + @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). + +**/ +EFI_STATUS +EFIAPI +EfiLibInstallDriverBinding ( + IN CONST EFI_HANDLE ImageHandle, + IN CONST EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle + ) +{ + EFI_STATUS Status; + + ASSERT (NULL != DriverBinding); + + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + NULL + ); + // + // ASSERT if the call to InstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + // + // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol + // + DriverBinding->ImageHandle = ImageHandle; + DriverBinding->DriverBindingHandle = DriverBindingHandle; + + return Status; +} + + +/** + Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name, + Driver Configure and Driver Diagnostic Protocols onto the driver's DriverBindingHandle. This is + typically the same as the driver's ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. + If the Drvier Binding Protocol interface is NULL, then ASSERT (). + If the installation fails, then ASSERT (). + + @param ImageHandle The image handle of the driver. + @param SystemTable The EFI System Table that was passed to the driver's entry point. + @param DriverBinding A Driver Binding Protocol instance that this driver is producing. + @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + @param ComponentName A Component Name Protocol instance that this driver is producing. + @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing. + @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing. + + @retval EFI_SUCCESS The protocol installation is completed successfully. + @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). + +**/ +EFI_STATUS +EFIAPI +EfiLibInstallAllDriverProtocols ( + IN CONST EFI_HANDLE ImageHandle, + IN CONST EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle, + IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL + IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL + IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL + ) +{ + EFI_STATUS Status; + + ASSERT (NULL != DriverBinding); + + if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { + if (DriverConfiguration == NULL) { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + NULL + ); + } + } else { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + NULL + ); + } + } + } else { + if (DriverConfiguration == NULL) { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } + } else { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } + } + } + + // + // ASSERT if the call to InstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + // + // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol + // + DriverBinding->ImageHandle = ImageHandle; + DriverBinding->DriverBindingHandle = DriverBindingHandle; + + return Status; +} + + + +/** + Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name, + Component Name 2 onto the driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple DriverBinding Protocols. + If the Drvier Binding Protocol interface is NULL, then ASSERT (). + If the installation fails, then ASSERT (). + + @param ImageHandle The image handle of the driver. + @param SystemTable The EFI System Table that was passed to the driver's entry point. + @param DriverBinding A Driver Binding Protocol instance that this driver is producing. + @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + @param ComponentName A Component Name Protocol instance that this driver is producing. + @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing. + + @retval EFI_SUCCESS The protocol installation is completed successfully. + @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). + +**/ +EFI_STATUS +EFIAPI +EfiLibInstallDriverBindingComponentName2 ( + IN CONST EFI_HANDLE ImageHandle, + IN CONST EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle, + IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL + IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL + ) +{ + EFI_STATUS Status; + + ASSERT (NULL != DriverBinding); + + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + NULL + ); + } + } + // + // ASSERT if the call to InstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + // + // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol + // + DriverBinding->ImageHandle = ImageHandle; + DriverBinding->DriverBindingHandle = DriverBindingHandle; + + return Status; +} + + + +/** + Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name, + Component Name 2, Driver Configure, Driver Diagnostic and Driver Diagnostic 2 Protocols onto the driver's + DriverBindingHandle. This is typically the same as the driver's ImageHandle, but it can be different if + the driver produces multiple DriverBinding Protocols. + If the Drvier Binding Protocol interface is NULL, then ASSERT (). + If the installation fails, then ASSERT (). + + @param ImageHandle The image handle of the driver. + @param SystemTable The EFI System Table that was passed to the driver's entry point. + @param DriverBinding A Driver Binding Protocol instance that this driver is producing. + @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + @param ComponentName A Component Name Protocol instance that this driver is producing. + @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing. + @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing. + @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing. + @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing. + + @retval EFI_SUCCESS The protocol installation is completed successfully. + @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). + +**/ +EFI_STATUS +EFIAPI +EfiLibInstallAllDriverProtocols2 ( + IN CONST EFI_HANDLE ImageHandle, + IN CONST EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle, + IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL + IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL + IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL + IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL + IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL + ) +{ + EFI_STATUS Status; + + ASSERT (NULL != DriverBinding); + + if (DriverConfiguration == NULL) { + if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { + if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + NULL + ); + } + } + } else { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } + } + } else { + if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } + } + } else { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } + } + } + } else { + if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { + if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + NULL + ); + } + } + } else { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } + } + } else { + if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + NULL + ); + } + } + } else { + if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } else { + if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, DriverBinding, + &gEfiComponentNameProtocolGuid, ComponentName, + &gEfiComponentName2ProtocolGuid, ComponentName2, + &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, + &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, + NULL + ); + } + } + } + } + } + + // + // ASSERT if the call to InstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + // + // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol + // + DriverBinding->ImageHandle = ImageHandle; + DriverBinding->DriverBindingHandle = DriverBindingHandle; + + return Status; +} + + diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c new file mode 100644 index 0000000000..af88f6353d --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c @@ -0,0 +1,813 @@ +/** @file + Mde UEFI library functions. + + Copyright (c) 2006 - 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: UefiLib.c + +**/ + +#include "FrameworkUefiLib.h" + +/** + Compare whether two names of languages are identical. + + @param Language1 Name of language 1. + @param Language2 Name of language 2. + + @retval TRUE Language 1 and language 2 are the same. + @retval FALSE Language 1 and language 2 are not the same. + +**/ +STATIC +BOOLEAN +CompareIso639LanguageCode ( + IN CONST CHAR8 *Language1, + IN CONST CHAR8 *Language2 + ) +{ + UINT32 Name1; + UINT32 Name2; + + Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1); + Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2); + + return (BOOLEAN) (Name1 == Name2); +} + +/** + This function searches the list of configuration tables stored in the EFI System + Table for a table with a GUID that matches TableGuid. If a match is found, + then a pointer to the configuration table is returned in Table, and EFI_SUCCESS + is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. + + @param TableGuid Pointer to table's GUID type.. + @param Table Pointer to the table associated with TableGuid in the EFI System Table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. + +**/ +EFI_STATUS +EFIAPI +EfiGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ) +{ + EFI_SYSTEM_TABLE *SystemTable; + UINTN Index; + + ASSERT (TableGuid != NULL); + ASSERT (Table != NULL); + + SystemTable = gST; + *Table = NULL; + for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { + if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) { + *Table = SystemTable->ConfigurationTable[Index].VendorTable; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +/** + This function causes the notification function to be executed for every protocol + of type ProtocolGuid instance that exists in the system when this function is + invoked. In addition, every time a protocol of type ProtocolGuid instance is + installed or reinstalled, the notification function is also executed. + + @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @return The notification event that was created. + +**/ +EFI_EVENT +EFIAPI +EfiCreateProtocolNotifyEvent( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, OPTIONAL + OUT VOID **Registration + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + // + // Create the event + // + + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &Event + ); + ASSERT_EFI_ERROR (Status); + + // + // Register for protocol notifactions on this event + // + + Status = gBS->RegisterProtocolNotify ( + ProtocolGuid, + Event, + Registration + ); + + ASSERT_EFI_ERROR (Status); + + // + // Kick the event so we will perform an initial pass of + // current installed drivers + // + + gBS->SignalEvent (Event); + return Event; +} + +/** + This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. + This event is signaled with EfiNamedEventSignal(). This provide the ability for + one or more listeners on the same event named by the GUID specified by Name. + + @param Name Supplies GUID name of the event. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @retval EFI_SUCCESS A named event was created. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventListen ( + IN CONST EFI_GUID *Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN CONST VOID *NotifyContext, OPTIONAL + OUT VOID *Registration OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + VOID *RegistrationLocal; + + // + // Create event + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + (VOID *) NotifyContext, + &Event + ); + ASSERT_EFI_ERROR (Status); + + // + // The Registration is not optional to RegisterProtocolNotify(). + // To make it optional to EfiNamedEventListen(), may need to substitute with a local. + // + if (Registration != NULL) { + RegistrationLocal = Registration; + } else { + RegistrationLocal = &RegistrationLocal; + } + + // + // Register for an installation of protocol interface + // + + Status = gBS->RegisterProtocolNotify ( + (EFI_GUID *) Name, + Event, + RegistrationLocal + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + This function signals the named event specified by Name. The named event must + have been created with EfiNamedEventListen(). + + @param Name Supplies GUID name of the event. + + @retval EFI_SUCCESS A named event was signaled. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventSignal ( + IN CONST EFI_GUID *Name + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + (EFI_GUID *) Name, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->UninstallProtocolInterface ( + Handle, + (EFI_GUID *) Name, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + Returns the current TPL. + + This function returns the current TPL. There is no EFI service to directly + retrieve the current TPL. Instead, the RaiseTPL() function is used to raise + the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level + can then immediately be restored back to the current TPL level with a call + to RestoreTPL(). + + @param VOID + + @retvale EFI_TPL The current TPL. + +**/ +EFI_TPL +EFIAPI +EfiGetCurrentTpl ( + VOID + ) +{ + EFI_TPL Tpl; + + Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); + gBS->RestoreTPL (Tpl); + + return Tpl; +} + + +/** + This function initializes a basic mutual exclusion lock to the released state + and returns the lock. Each lock provides mutual exclusion access at its task + priority level. Since there is no preemption or multiprocessor support in EFI, + acquiring the lock only consists of raising to the locks TPL. + + @param Lock A pointer to the lock data structure to initialize. + @param Priority EFI TPL associated with the lock. + + @return The lock. + +**/ +EFI_LOCK * +EFIAPI +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +{ + ASSERT (Lock != NULL); + ASSERT (Priority <= TPL_HIGH_LEVEL); + + Lock->Tpl = Priority; + Lock->OwnerTpl = TPL_APPLICATION; + Lock->Lock = EfiLockReleased ; + return Lock; +} + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it places the lock in the + acquired state. + + @param Priority The task priority level of the lock. + +**/ +VOID +EFIAPI +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +{ + ASSERT (Lock != NULL); + ASSERT (Lock->Lock == EfiLockReleased); + + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + Lock->Lock = EfiLockAcquired; +} + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it attempts to place the + lock in the acquired state. + + @param Lock A pointer to the lock to acquire. + + @retval EFI_SUCCESS The lock was acquired. + @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned. + +**/ +EFI_STATUS +EFIAPI +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +{ + + ASSERT (Lock != NULL); + ASSERT (Lock->Lock != EfiLockUninitialized); + + if (Lock->Lock == EfiLockAcquired) { + // + // Lock is already owned, so bail out + // + return EFI_ACCESS_DENIED; + } + + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + + Lock->Lock = EfiLockAcquired; + + return EFI_SUCCESS; +} + +/** + This function transitions a mutual exclusion lock from the acquired state to + the released state, and restores the system's task priority level to its + previous level. + + @param Lock A pointer to the lock to release. + +**/ +VOID +EFIAPI +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +{ + EFI_TPL Tpl; + + ASSERT (Lock != NULL); + ASSERT (Lock->Lock == EfiLockAcquired); + + Tpl = Lock->OwnerTpl; + + Lock->Lock = EfiLockReleased; + + gBS->RestoreTPL (Tpl); +} + +/** + Tests whether a controller handle is being managed by a specific driver. + + This function tests whether the driver specified by DriverBindingHandle is + currently managing the controller specified by ControllerHandle. This test + is performed by evaluating if the the protocol specified by ProtocolGuid is + present on ControllerHandle and is was opened by DriverBindingHandle with an + attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a controller to test. + @param DriverBindingHandle Specifies the driver binding handle for the + driver. + @param ProtocolGuid Specifies the protocol that the driver specified + by DriverBindingHandle opens in its Start() + function. + + @retval EFI_SUCCESS ControllerHandle is managed by the driver + specifed by DriverBindingHandle. + @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver + specifed by DriverBindingHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestManagedDevice ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE DriverBindingHandle, + IN CONST EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + VOID *ManagedInterface; + + ASSERT (ProtocolGuid != NULL); + + Status = gBS->OpenProtocol ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + &ManagedInterface, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (!EFI_ERROR (Status)) { + gBS->CloseProtocol ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + DriverBindingHandle, + ControllerHandle + ); + return EFI_UNSUPPORTED; + } + + if (Status != EFI_ALREADY_STARTED) { + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + Tests whether a child handle is a child device of the controller. + + This function tests whether ChildHandle is one of the children of + ControllerHandle. This test is performed by checking to see if the protocol + specified by ProtocolGuid is present on ControllerHandle and opened by + ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a (parent) controller to test. + @param ChildHandle A child handle to test. + @param ConsumsedGuid Supplies the protocol that the child controller + opens on its parent controller. + + @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. + @retval EFI_UNSUPPORTED ChildHandle is not a child of the + ControllerHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestChildHandle ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE ChildHandle, + IN CONST EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; + UINTN EntryCount; + UINTN Index; + + ASSERT (ProtocolGuid != NULL); + + // + // Retrieve the list of agents that are consuming the specific protocol + // on ControllerHandle. + // + Status = gBS->OpenProtocolInformation ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + &OpenInfoBuffer, + &EntryCount + ); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + // + // Inspect if ChildHandle is one of the agents. + // + Status = EFI_UNSUPPORTED; + for (Index = 0; Index < EntryCount; Index++) { + if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) && + (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { + Status = EFI_SUCCESS; + break; + } + } + + FreePool (OpenInfoBuffer); + return Status; +} + +/** + This function looks up a Unicode string in UnicodeStringTable. If Language is + a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable + that matches the language code specified by Language, then it is returned in + UnicodeString. + + @param Language A pointer to the ISO 639-2 language code for the + Unicode string to look up and return. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. Language + must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string from UnicodeStringTable + that matches the language specified by Language. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found + in the table of Unicoide strings UnicodeStringTable, + and it was returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + @retval EFI_UNSUPPORTED The language specified by Language is not + supported by UnicodeStringTable. + +**/ +EFI_STATUS +EFIAPI +LookupUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + OUT CHAR16 **UnicodeString + ) +{ + // + // Make sure the parameters are valid + // + if (Language == NULL || UnicodeString == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, or the Unicode String Table is empty, then the + // Unicode String specified by Language is not supported by this Unicode String Table + // + if (SupportedLanguages == NULL || UnicodeStringTable == NULL) { + return EFI_UNSUPPORTED; + } + + // + // Make sure Language is in the set of Supported Languages + // + while (*SupportedLanguages != 0) { + if (CompareIso639LanguageCode (Language, SupportedLanguages)) { + + // + // Search the Unicode String Table for the matching Language specifier + // + while (UnicodeStringTable->Language != NULL) { + if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) { + + // + // A matching string was found, so return it + // + *UnicodeString = UnicodeStringTable->UnicodeString; + return EFI_SUCCESS; + } + + UnicodeStringTable++; + } + + return EFI_UNSUPPORTED; + } + + SupportedLanguages += 3; + } + + return EFI_UNSUPPORTED; +} + +/** + This function adds a Unicode string to UnicodeStringTable. + If Language is a member of SupportedLanguages then UnicodeString is added to + UnicodeStringTable. New buffers are allocated for both Language and + UnicodeString. The contents of Language and UnicodeString are copied into + these new buffers. These buffers are automatically freed when + FreeUnicodeStringTable() is called. + + @param Language A pointer to the ISO 639-2 language code for the Unicode + string to add. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. + Language must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string to add. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found in the table of + Unicode strings UnicodeStringTable, and it was + returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_ALREADY_STARTED A Unicode string with language Language is + already present in UnicodeStringTable. + @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another + Unicode string to UnicodeStringTable. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + +**/ +EFI_STATUS +EFIAPI +AddUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + IN CONST CHAR16 *UnicodeString + ) +{ + UINTN NumberOfEntries; + EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable; + EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable; + UINTN UnicodeStringLength; + + // + // Make sure the parameter are valid + // + if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, then a Unicode String can not be added + // + if (SupportedLanguages == NULL) { + return EFI_UNSUPPORTED; + } + + // + // If the Unicode String is empty, then a Unicode String can not be added + // + if (UnicodeString[0] == 0) { + return EFI_INVALID_PARAMETER; + } + + // + // Make sure Language is a member of SupportedLanguages + // + while (*SupportedLanguages != 0) { + if (CompareIso639LanguageCode (Language, SupportedLanguages)) { + + // + // Determine the size of the Unicode String Table by looking for a NULL Language entry + // + NumberOfEntries = 0; + if (*UnicodeStringTable != NULL) { + OldUnicodeStringTable = *UnicodeStringTable; + while (OldUnicodeStringTable->Language != NULL) { + if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) { + return EFI_ALREADY_STARTED; + } + + OldUnicodeStringTable++; + NumberOfEntries++; + } + } + + // + // Allocate space for a new Unicode String Table. It must hold the current number of + // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table + // marker + // + NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE)); + if (NewUnicodeStringTable == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // If the current Unicode String Table contains any entries, then copy them to the + // newly allocated Unicode String Table. + // + if (*UnicodeStringTable != NULL) { + CopyMem ( + NewUnicodeStringTable, + *UnicodeStringTable, + NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE) + ); + } + + // + // Allocate space for a copy of the Language specifier + // + NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language); + if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) { + gBS->FreePool (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Compute the length of the Unicode String + // + for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) + ; + + // + // Allocate space for a copy of the Unicode String + // + NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool ( + (UnicodeStringLength + 1) * sizeof (CHAR16), + UnicodeString + ); + if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) { + gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language); + gBS->FreePool (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Mark the end of the Unicode String Table + // + NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL; + NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL; + + // + // Free the old Unicode String Table + // + if (*UnicodeStringTable != NULL) { + gBS->FreePool (*UnicodeStringTable); + } + + // + // Point UnicodeStringTable at the newly allocated Unicode String Table + // + *UnicodeStringTable = NewUnicodeStringTable; + + return EFI_SUCCESS; + } + + SupportedLanguages += 3; + } + + return EFI_UNSUPPORTED; +} + +/** + This function frees the table of Unicode strings in UnicodeStringTable. + If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. + Otherwise, each language code, and each Unicode string in the Unicode string + table are freed, and EFI_SUCCESS is returned. + + @param UnicodeStringTable A pointer to the table of Unicode strings. + + @retval EFI_SUCCESS The Unicode string table was freed. + +**/ +EFI_STATUS +EFIAPI +FreeUnicodeStringTable ( + IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ) +{ + UINTN Index; + + // + // If the Unicode String Table is NULL, then it is already freed + // + if (UnicodeStringTable == NULL) { + return EFI_SUCCESS; + } + + // + // Loop through the Unicode String Table until we reach the end of table marker + // + for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) { + + // + // Free the Language string from the Unicode String Table + // + gBS->FreePool (UnicodeStringTable[Index].Language); + + // + // Free the Unicode String from the Unicode String Table + // + if (UnicodeStringTable[Index].UnicodeString != NULL) { + gBS->FreePool (UnicodeStringTable[Index].UnicodeString); + } + } + + // + // Free the Unicode String Table itself + // + gBS->FreePool (UnicodeStringTable); + + return EFI_SUCCESS; +} + diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c new file mode 100644 index 0000000000..7bc5f8a92a --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c @@ -0,0 +1,261 @@ +/** @file + Mde UEFI library API implemention. + Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE + + 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 "FrameworkUefiLib.h" + +/** + Internal function which prints a formatted Unicode string to the console output device + specified by Console + + This function prints a formatted Unicode string to the console output device + specified by Console and returns the number of Unicode characters that printed + to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize, + then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console. + + @param Format Null-terminated Unicode format string. + @param Console The output console. + @param Marker VA_LIST marker for the variable argument list. + + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ + +STATIC +UINTN +InternalPrint ( + IN CONST CHAR16 *Format, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console, + IN VA_LIST Marker + ) +{ + UINTN Return; + CHAR16 *Buffer; + UINTN BufferSize; + + ASSERT (Format != NULL); + ASSERT (((UINTN) Format & 0x01) == 0); + + BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); + + Buffer = (CHAR16 *) AllocatePool(BufferSize); + ASSERT (Buffer != NULL); + + Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); + + if (Console != NULL) { + // + // To be extra safe make sure Console has been initialized + // + Console->OutputString (Console, Buffer); + } + + FreePool (Buffer); + + return Return; +} + +/** + Prints a formatted Unicode string to the console output device specified by + ConOut defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted Unicode string to the console output device + specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode + characters that printed to ConOut. If the length of the formatted Unicode + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. + + @param Format Null-terminated Unicode format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ +UINTN +EFIAPI +Print ( + IN CONST CHAR16 *Format, + ... + ) +{ + VA_LIST Marker; + UINTN Return; + + VA_START (Marker, Format); + + Return = InternalPrint (Format, gST->ConOut, Marker); + + VA_END (Marker); + + return Return; +} + +/** + Prints a formatted Unicode string to the console output device specified by + StdErr defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted Unicode string to the console output device + specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode + characters that printed to StdErr. If the length of the formatted Unicode + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. + + @param Format Null-terminated Unicode format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ + +UINTN +EFIAPI +ErrorPrint ( + IN CONST CHAR16 *Format, + ... + ) +{ + VA_LIST Marker; + UINTN Return; + + VA_START (Marker, Format); + + Return = InternalPrint( Format, gST->StdErr, Marker); + + VA_END (Marker); + + return Return; +} + + +/** + Internal function which prints a formatted ASCII string to the console output device + specified by Console + + This function prints a formatted ASCII string to the console output device + specified by Console and returns the number of ASCII characters that printed + to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, + then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console. + + @param Format Null-terminated ASCII format string. + @param Console The output console. + @param Marker VA_LIST marker for the variable argument list. + + If Format is NULL, then ASSERT(). + +**/ + +STATIC +UINTN +AsciiInternalPrint ( + IN CONST CHAR8 *Format, + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console, + IN VA_LIST Marker + ) +{ + UINTN Return; + CHAR16 *Buffer; + UINTN BufferSize; + + ASSERT (Format != NULL); + + BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); + + Buffer = (CHAR16 *) AllocatePool(BufferSize); + ASSERT (Buffer != NULL); + + Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker); + + if (Console != NULL) { + // + // To be extra safe make sure Console has been initialized + // + Console->OutputString (Console, Buffer); + } + + FreePool (Buffer); + + return Return; +} + +/** + Prints a formatted ASCII string to the console output device specified by + ConOut defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted ASCII string to the console output device + specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII + characters that printed to ConOut. If the length of the formatted ASCII + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. + + @param Format Null-terminated ASCII format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ +UINTN +EFIAPI +AsciiPrint ( + IN CONST CHAR8 *Format, + ... + ) +{ + VA_LIST Marker; + UINTN Return; + + VA_START (Marker, Format); + + Return = AsciiInternalPrint( Format, gST->ConOut, Marker); + + VA_END (Marker); + + return Return; +} + +/** + Prints a formatted ASCII string to the console output device specified by + StdErr defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted ASCII string to the console output device + specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII + characters that printed to StdErr. If the length of the formatted ASCII + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. + + @param Format Null-terminated ASCII format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ +UINTN +EFIAPI +AsciiErrorPrint ( + IN CONST CHAR8 *Format, + ... + ) +{ + VA_LIST Marker; + UINTN Return; + + VA_START (Marker, Format); + + Return = AsciiInternalPrint( Format, gST->StdErr, Marker); + + VA_END (Marker); + + return Return; +} + diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c new file mode 100644 index 0000000000..f08b1ee754 --- /dev/null +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c @@ -0,0 +1,360 @@ +/** @file + Library functions that abstract areas of conflict between Tiano an UEFI 2.1. + + Help Port Framework/Tinao code that has conflicts with UEFI 2.1 by hiding the + oldconflicts with library functions and supporting implementations of the old + (EDK/EFI 1.10) and new (EDK II/UEFI 2.1) way. This module is a DXE driver as + it contains DXE enum extensions for EFI event services. + +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 "FrameworkUefiLib.h" + +/** + An empty function to pass error checking of CreateEventEx (). + + This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error + checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0. + +**/ +STATIC +VOID +EFIAPI +InternalEmptyFuntion ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + return; +} + +/** + Create a Legacy Boot Event. + + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBoot ( + OUT EFI_EVENT *LegacyBootEvent + ) +{ + return EfiCreateEventLegacyBootEx ( + TPL_CALLBACK, + InternalEmptyFuntion, + NULL, + LegacyBootEvent + ); +} + +/** + Create an EFI event in the Legacy Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Legacy Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If LegacyBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *LegacyBootEvent + ) +{ + EFI_STATUS Status; + + ASSERT (LegacyBootEvent != NULL); + + if (gST->Hdr.Revision < 0x00020000) { + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_LEGACY_BOOT | EVT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + LegacyBootEvent + ); + } else { + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &gEfiEventLegacyBootGuid, + LegacyBootEvent + ); + } + + return Status; +} + +/** + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBoot ( + OUT EFI_EVENT *ReadyToBootEvent + ) +{ + return EfiCreateEventReadyToBootEx ( + TPL_CALLBACK, + InternalEmptyFuntion, + NULL, + ReadyToBootEvent + ); +} + +/** + Create an EFI event in the Ready To Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Ready to Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If ReadyToBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToBootEvent + ) +{ + EFI_STATUS Status; + + ASSERT (ReadyToBootEvent != NULL); + + if (gST->Hdr.Revision < 0x00020000) { + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL, + NotifyTpl, + NotifyFunction, + NotifyContext, + ReadyToBootEvent + ); + } else { + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &gEfiEventReadyToBootGuid, + ReadyToBootEvent + ); + } + + return Status; +} + + +/** + Signal a Ready to Boot Event. + + Create a Ready to Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventReadyToBoot ( + VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT ReadyToBootEvent; + + Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent); + if (!EFI_ERROR (Status)) { + gBS->SignalEvent (ReadyToBootEvent); + gBS->CloseEvent (ReadyToBootEvent); + } +} + +/** + Signal a Legacy Boot Event. + + Create a legacy Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventLegacyBoot ( + VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT LegacyBootEvent; + + Status = EfiCreateEventLegacyBoot (&LegacyBootEvent); + if (!EFI_ERROR (Status)) { + gBS->SignalEvent (LegacyBootEvent); + gBS->CloseEvent (LegacyBootEvent); + } +} + + +/** + Check to see if the Firmware Volume (FV) Media Device Path is valid + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for Tiano extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. The return value to this + function points to a location in FvDevicePathNode and it does not allocate + new memory for the GUID pointer that is returned. + + @param FvDevicePathNode Pointer to FV device path to check. + + @retval NULL FvDevicePathNode is not valid. + @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned. + +**/ +EFI_GUID * +EFIAPI +EfiGetNameGuidFromFwVolDevicePathNode ( + IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ) +{ + FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FrameworkFvDevicePathNode; + + ASSERT (FvDevicePathNode != NULL); + + FrameworkFvDevicePathNode = (FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) FvDevicePathNode; + // + // Use the new Device path that does not conflict with the UEFI + // + if (DevicePathType (&FrameworkFvDevicePathNode->Tiano.Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FrameworkFvDevicePathNode->Tiano.Header) == MEDIA_VENDOR_DP) { + if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FrameworkFvDevicePathNode->Tiano.TianoSpecificDevicePath)) { + if (FrameworkFvDevicePathNode->Tiano.Type == TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) { + return (EFI_GUID *) &FrameworkFvDevicePathNode->NameGuid; + } + } + } + + return NULL; +} + + +/** + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for Tiano extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + + @param FvDevicePathNode Pointer to a FV device path node to initialize + @param NameGuid FV file name to use in FvDevicePathNode + +**/ +VOID +EFIAPI +EfiInitializeFwVolDevicepathNode ( + IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN CONST EFI_GUID *NameGuid + ) +{ + FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FrameworkFvDevicePathNode; + + ASSERT (FvDevicePathNode != NULL); + ASSERT (NameGuid != NULL); + + FrameworkFvDevicePathNode = (FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) FvDevicePathNode; + + // + // Use the new Device path that does not conflict with the UEFI + // + FrameworkFvDevicePathNode->Tiano.Header.Type = MEDIA_DEVICE_PATH; + FrameworkFvDevicePathNode->Tiano.Header.SubType = MEDIA_VENDOR_DP; + SetDevicePathNodeLength (&FrameworkFvDevicePathNode->Tiano.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + + // + // Add the GUID for generic Tiano device paths + // + CopyGuid (&FrameworkFvDevicePathNode->Tiano.TianoSpecificDevicePath, &gEfiFrameworkDevicePathGuid); + + // + // Add in the FW Vol File Path Tiano defined information + // + FrameworkFvDevicePathNode->Tiano.Type = TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE; + + CopyGuid (&FrameworkFvDevicePathNode->NameGuid, NameGuid); +} + diff --git a/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.c b/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.c deleted file mode 100644 index 354215af0f..0000000000 --- a/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.c +++ /dev/null @@ -1,70 +0,0 @@ -/** @file - HII Library implementation that uses DXE protocols and services. - - Copyright (c) 2006, 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: HiiLib.c - -**/ - - -#include - - -#include -#include -#include - -/** - This function allocates pool for an EFI_HII_PACKAGES structure - with enough space for the variable argument list of package pointers. - The allocated structure is initialized using NumberOfPackages, Guid, - and the variable length argument list of package pointers. - - @param NumberOfPackages The number of HII packages to prepare. - @param Guid Package GUID. - - @return The allocated and initialized packages. - -**/ -EFI_HII_PACKAGES * -EFIAPI -PreparePackages ( - IN UINTN NumberOfPackages, - IN CONST EFI_GUID *Guid OPTIONAL, - ... - ) -{ - VA_LIST Args; - EFI_HII_PACKAGES *HiiPackages; - VOID **Package; - UINTN Index; - - ASSERT (NumberOfPackages > 0); - - HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *)); - ASSERT (HiiPackages != NULL); - - HiiPackages->GuidId = (EFI_GUID *) Guid; - HiiPackages->NumberOfPackages = NumberOfPackages; - Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES)); - - VA_START (Args, Guid); - - for (Index = 0; Index < NumberOfPackages; Index++) { - *Package = VA_ARG (Args, VOID *); - Package++; - } - - VA_END (Args); - - return HiiPackages; - -} diff --git a/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf b/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf deleted file mode 100644 index 6a96b50859..0000000000 --- a/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf +++ /dev/null @@ -1,44 +0,0 @@ -#/** @file -# Library instance for HII common routines. -# -# This library instance implements the common HII routines. -# Copyright (c) 2006, 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. -# -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = HiiLibFramework - FILE_GUID = 1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = HiiLibFramework|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER - EDK_RELEASE_VERSION = 0x00020000 - EFI_SPECIFICATION_VERSION = 0x00020000 - - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources.common] - HiiLib.c - -[Packages] - MdePkg/MdePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - -[LibraryClasses] - MemoryAllocationLib - DebugLib - diff --git a/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.msa b/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.msa deleted file mode 100644 index 67e1f0d7f1..0000000000 --- a/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.msa +++ /dev/null @@ -1,45 +0,0 @@ - - - - HiiLibFramework - DXE_DRIVER - 1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c - 1.0 - Library instance for HII common routines. - This library instance implements the common HII routines. - Copyright (c) 2006, 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. - FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 - - - IA32 X64 IPF EBC - false - HiiLibFramework - - - - HiiLib - - - DebugLib - - - MemoryAllocationLib - - - - HiiLib.c - - - - - - EFI_SPECIFICATION_VERSION 0x00020000 - EDK_RELEASE_VERSION 0x00020000 - - \ No newline at end of file diff --git a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrCommon.c b/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrCommon.c deleted file mode 100644 index d9894c4e6c..0000000000 --- a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrCommon.c +++ /dev/null @@ -1,1005 +0,0 @@ -/*++ -Copyright (c) 2006, 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: - IfrCommon.c - -Abstract: - - Common Library Routines to assist in IFR creation on-the-fly - -Revision History: - ---*/ - -// -// Include common header file for this module. -// -#include "IfrSupportLibInternal.h" - -EFI_STATUS -EFIAPI -IfrLibConstruct ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EFI_SUCCESS; -} - -EFI_STATUS -GetCurrentLanguage ( - OUT CHAR16 *Lang - ) -/*++ - -Routine Description: - - Determine what is the current language setting - -Arguments: - - Lang - Pointer of system language - -Returns: - - Status code - ---*/ -{ - EFI_STATUS Status; - UINTN Size; - UINTN Index; - CHAR8 Language[4]; - - // - // Getting the system language and placing it into our Global Data - // - Size = sizeof (Language); - - Status = gRT->GetVariable ( - (CHAR16 *) L"Lang", - &gEfiGlobalVariableGuid, - NULL, - &Size, - Language - ); - - if (EFI_ERROR (Status)) { - AsciiStrCpy (Language, "eng"); - } - - for (Index = 0; Index < 3; Index++) { - // - // Bitwise AND ascii value with 0xDF yields an uppercase value. - // Sign extend into a unicode value - // - Lang[Index] = (CHAR16) (Language[Index] & 0xDF); - } - - // - // Null-terminate the value - // - Lang[3] = (CHAR16) 0; - - return Status; -} - - -EFI_STATUS -AddString ( - IN VOID *StringBuffer, - IN CHAR16 *Language, - IN CHAR16 *String, - IN OUT STRING_REF *StringToken - ) -/*++ - -Routine Description: - - Add a string to the incoming buffer and return the token and offset data - -Arguments: - - StringBuffer - The incoming buffer - - Language - Currrent language - - String - The string to be added - - StringToken - The index where the string placed - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - String successfully added to the incoming buffer - ---*/ -{ - EFI_HII_STRING_PACK *StringPack; - EFI_HII_STRING_PACK *StringPackBuffer; - VOID *NewBuffer; - RELOFST *PackSource; - RELOFST *PackDestination; - UINT8 *Source; - UINT8 *Destination; - UINTN Index; - BOOLEAN Finished; - UINTN SizeofLanguage; - UINTN SizeofString; - - StringPack = (EFI_HII_STRING_PACK *) StringBuffer; - Finished = FALSE; - - // - // Pre-allocate a buffer sufficient for us to work on. - // We will use it as a destination scratch pad to build data on - // and when complete shift the data back to the original buffer - // - NewBuffer = AllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE); - if (NewBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - StringPackBuffer = (EFI_HII_STRING_PACK *) NewBuffer; - - // - // StringPack is terminated with a length 0 entry - // - for (; StringPack->Header.Length != 0;) { - // - // If this stringpack's language is same as CurrentLanguage, use it - // - if (CompareMem ((VOID *) ((CHAR8 *) (StringPack) + StringPack->LanguageNameString), Language, 3) == 0) { - // - // We have some data in this string pack, copy the string package up to the string data - // - CopyMem (&StringPackBuffer->Header, &StringPack->Header, sizeof (StringPack)); - - // - // These are references in the structure to tokens, need to increase them by the space occupied by an additional StringPointer - // - StringPackBuffer->LanguageNameString = (UINT16) (StringPackBuffer->LanguageNameString + (UINT16) sizeof (RELOFST)); - StringPackBuffer->PrintableLanguageName = (UINT16) (StringPackBuffer->PrintableLanguageName + (UINT16) sizeof (RELOFST)); - - PackSource = (RELOFST *) (StringPack + 1); - PackDestination = (RELOFST *) (StringPackBuffer + 1); - for (Index = 0; PackSource[Index] != 0x0000; Index++) { - // - // Copy the stringpointers from old to new buffer - // remember that we are adding a string, so the string offsets will all go up by sizeof (RELOFST) - // - PackDestination[Index] = (UINT16) (PackDestination[Index] + sizeof (RELOFST)); - } - - // - // Add a new stringpointer in the new buffer since we are adding a string. Null terminate it - // - PackDestination[Index] = (UINT16)(PackDestination[Index-1] + - StrSize((CHAR16 *)((CHAR8 *)(StringPack) + PackSource[Index-1]))); - PackDestination[Index + 1] = (UINT16) 0; - - // - // Index is the token value for the new string - // - *StringToken = (UINT16) Index; - - // - // Source now points to the beginning of the old buffer strings - // Destination now points to the beginning of the new buffer strings - // - Source = (UINT8 *) &PackSource[Index + 1]; - Destination = (UINT8 *) &PackDestination[Index + 2]; - - // - // This should copy all the strings from the old buffer to the new buffer - // - for (; Index != 0; Index--) { - // - // Copy Source string to destination buffer - // - StrCpy ((CHAR16 *) Destination, (CHAR16 *) Source); - - // - // Adjust the source/destination to the next string location - // - Destination = Destination + StrSize ((CHAR16 *) Source); - Source = Source + StrSize ((CHAR16 *) Source); - } - - // - // This copies the new string to the destination buffer - // - StrCpy ((CHAR16 *) Destination, (CHAR16 *) String); - - // - // Adjust the size of the changed string pack by adding the size of the new string - // along with the size of the additional offset entry for the new string - // - StringPackBuffer->Header.Length = (UINT32) ((UINTN) StringPackBuffer->Header.Length + StrSize (String) + sizeof (RELOFST)); - - // - // Advance the buffers to point to the next spots. - // - StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPackBuffer->Header.Length); - StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length); - Finished = TRUE; - continue; - } - // - // This isn't the language of the stringpack we were asked to add a string to - // so we need to copy it to the new buffer. - // - CopyMem (&StringPackBuffer->Header, &StringPack->Header, StringPack->Header.Length); - - // - // Advance the buffers to point to the next spots. - // - StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPack->Header.Length); - StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length); - } - - // - // If we didn't copy the new data to a stringpack yet - // - if (!Finished) { - PackDestination = (RELOFST *) (StringPackBuffer + 1); - // - // Pointing to a new string pack location - // - SizeofLanguage = StrSize (Language); - SizeofString = StrSize (String); - StringPackBuffer->Header.Length = (UINT32) - ( - sizeof (EFI_HII_STRING_PACK) - - sizeof (EFI_STRING) + - sizeof (RELOFST) + - sizeof (RELOFST) + - SizeofLanguage + - SizeofString - ); - StringPackBuffer->Header.Type = EFI_HII_STRING; - StringPackBuffer->LanguageNameString = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); - StringPackBuffer->PrintableLanguageName = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); - StringPackBuffer->Attributes = 0; - PackDestination[0] = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); - PackDestination[1] = (UINT16) (PackDestination[0] + StrSize (Language)); - PackDestination[2] = (UINT16) 0; - - // - // The first string location will be set to destination. The minimum number of strings - // associated with a stringpack will always be token 0 stored as the languagename (e.g. ENG, SPA, etc) - // and token 1 as the new string being added and and null entry for the stringpointers - // - Destination = (UINT8 *) &PackDestination[3]; - - // - // Copy the language name string to the new buffer - // - StrCpy ((CHAR16 *) Destination, Language); - - // - // Advance the destination to the new empty spot - // - Destination = Destination + StrSize (Language); - - // - // Copy the string to the new buffer - // - StrCpy ((CHAR16 *) Destination, String); - - // - // Since we are starting with a new string pack - we know the new string is token 1 - // - *StringToken = (UINT16) 1; - } - - // - // Zero out the original buffer and copy the updated data in the new buffer to the old buffer - // - ZeroMem (StringBuffer, DEFAULT_STRING_BUFFER_SIZE); - CopyMem (StringBuffer, NewBuffer, DEFAULT_STRING_BUFFER_SIZE); - - // - // Free the newly created buffer since we don't need it anymore - // - gBS->FreePool (NewBuffer); - return EFI_SUCCESS; -} - - -EFI_STATUS -AddOpCode ( - IN VOID *FormBuffer, - IN OUT VOID *OpCodeData - ) -/*++ - -Routine Description: - - Add op-code data to the FormBuffer - -Arguments: - - FormBuffer - Form buffer to be inserted to - - OpCodeData - Op-code data to be inserted - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - Op-code data successfully inserted - ---*/ -{ - EFI_HII_PACK_HEADER *NewBuffer; - UINT8 *Source; - UINT8 *Destination; - - // - // Pre-allocate a buffer sufficient for us to work on. - // We will use it as a destination scratch pad to build data on - // and when complete shift the data back to the original buffer - // - NewBuffer = AllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE); - if (NewBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Source = (UINT8 *) FormBuffer; - Destination = (UINT8 *) NewBuffer; - - // - // Copy the IFR Package header to the new buffer - // - CopyMem (Destination, Source, sizeof (EFI_HII_PACK_HEADER)); - - // - // Advance Source and Destination to next op-code - // - Source = Source + sizeof (EFI_HII_PACK_HEADER); - Destination = Destination + sizeof (EFI_HII_PACK_HEADER); - - // - // Copy data to the new buffer until we run into the end_form - // - for (; ((EFI_IFR_OP_HEADER *) Source)->OpCode != EFI_IFR_END_FORM_OP;) { - // - // If the this opcode is an end_form_set we better be creating and endform - // Nonetheless, we will add data before the end_form_set. This also provides - // for interesting behavior in the code we will run, but has no bad side-effects - // since we will possibly do a 0 byte copy in this particular end-case. - // - if (((EFI_IFR_OP_HEADER *) Source)->OpCode == EFI_IFR_END_FORM_SET_OP) { - break; - } - - // - // Copy data to new buffer - // - CopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); - - // - // Adjust Source/Destination to next op-code location - // - Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; - Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; - } - - // - // Prior to the end_form is where we insert the new op-code data - // - CopyMem (Destination, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length); - Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) OpCodeData)->Length; - - NewBuffer->Length = (UINT32) (NewBuffer->Length + (UINT32) (((EFI_IFR_OP_HEADER *) OpCodeData)->Length)); - - // - // Copy end-form data to new buffer - // - CopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); - - // - // Adjust Source/Destination to next op-code location - // - Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; - Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; - - // - // Copy end-formset data to new buffer - // - CopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); - - // - // Zero out the original buffer and copy the updated data in the new buffer to the old buffer - // - ZeroMem (FormBuffer, DEFAULT_FORM_BUFFER_SIZE); - CopyMem (FormBuffer, NewBuffer, DEFAULT_FORM_BUFFER_SIZE); - - // - // Free the newly created buffer since we don't need it anymore - // - gBS->FreePool (NewBuffer); - return EFI_SUCCESS; -} - -STATIC -EFI_STATUS -GetHiiInterface ( - OUT EFI_HII_PROTOCOL **Hii - ) -/*++ - -Routine Description: - - Get the HII protocol interface - -Arguments: - - Hii - HII protocol interface - -Returns: - - Status code - ---*/ -{ - EFI_STATUS Status; - - // - // There should only be one HII protocol - // - Status = gBS->LocateProtocol ( - &gEfiHiiProtocolGuid, - NULL, - (VOID **) Hii - ); - - return Status;; -} - - -EFI_STATUS -ExtractDataFromHiiHandle ( - IN EFI_HII_HANDLE HiiHandle, - IN OUT UINT16 *ImageLength, - OUT UINT8 *DefaultImage, - OUT EFI_GUID *Guid - ) -/*++ - -Routine Description: - - Extract information pertaining to the HiiHandle - -Arguments: - - HiiHandle - Hii handle - - ImageLength - For input, length of DefaultImage; - For output, length of actually required - - DefaultImage - Image buffer prepared by caller - - Guid - Guid information about the form - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength - - EFI_SUCCESS - Successfully extract data from Hii database. - - ---*/ -{ - EFI_STATUS Status; - EFI_HII_PROTOCOL *Hii; - UINTN DataLength; - UINT8 *RawData; - UINT8 *OldData; - UINTN Index; - UINTN Temp; - UINTN SizeOfNvStore; - UINTN CachedStart; - - DataLength = DEFAULT_FORM_BUFFER_SIZE; - SizeOfNvStore = 0; - CachedStart = 0; - - Status = GetHiiInterface (&Hii); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Allocate space for retrieval of IFR data - // - RawData = AllocateZeroPool (DataLength); - if (RawData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Get all the forms associated with this HiiHandle - // - Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData); - - if (EFI_ERROR (Status)) { - gBS->FreePool (RawData); - - // - // Allocate space for retrieval of IFR data - // - RawData = AllocateZeroPool (DataLength); - if (RawData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Get all the forms associated with this HiiHandle - // - Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData); - } - - OldData = RawData; - - // - // Point RawData to the beginning of the form data - // - RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER)); - - for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { - switch (RawData[Index]) { - case EFI_IFR_FORM_SET_OP: - // - // Copy the GUID information from this handle - // - CopyMem (Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID)); - break; - - case EFI_IFR_ONE_OF_OP: - case EFI_IFR_CHECKBOX_OP: - case EFI_IFR_NUMERIC_OP: - case EFI_IFR_DATE_OP: - case EFI_IFR_TIME_OP: - case EFI_IFR_PASSWORD_OP: - case EFI_IFR_STRING_OP: - // - // Remember, multiple op-codes may reference the same item, so let's keep a running - // marker of what the highest QuestionId that wasn't zero length. This will accurately - // maintain the Size of the NvStore - // - if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) { - Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; - if (SizeOfNvStore < Temp) { - SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; - } - } - } - - Index = RawData[Index + 1] + Index; - } - - // - // Return an error if buffer is too small - // - if (SizeOfNvStore > *ImageLength) { - gBS->FreePool (OldData); - *ImageLength = (UINT16) SizeOfNvStore; - return EFI_BUFFER_TOO_SMALL; - } - - if (DefaultImage != NULL) { - ZeroMem (DefaultImage, SizeOfNvStore); - } - - // - // Copy the default image information to the user's buffer - // - for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { - switch (RawData[Index]) { - case EFI_IFR_ONE_OF_OP: - CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId; - break; - - case EFI_IFR_ONE_OF_OPTION_OP: - if (((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Flags & EFI_IFR_FLAG_DEFAULT) { - CopyMem (&DefaultImage[CachedStart], &((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value, 2); - } - break; - - case EFI_IFR_CHECKBOX_OP: - DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId] = ((EFI_IFR_CHECKBOX *) &RawData[Index])->Flags; - break; - - case EFI_IFR_NUMERIC_OP: - CopyMem ( - &DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId], - &((EFI_IFR_NUMERIC *) &RawData[Index])->Default, - 2 - ); - break; - - } - - Index = RawData[Index + 1] + Index; - } - - *ImageLength = (UINT16) SizeOfNvStore; - - // - // Free our temporary repository of form data - // - gBS->FreePool (OldData); - - return EFI_SUCCESS; -} - - -EFI_HII_HANDLE -FindHiiHandle ( - IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL - IN EFI_GUID *Guid - ) -/*++ - -Routine Description: - Finds HII handle for given pack GUID previously registered with the HII. - -Arguments: - HiiProtocol - pointer to pointer to HII protocol interface. - If NULL, the interface will be found but not returned. - If it points to NULL, the interface will be found and - written back to the pointer that is pointed to. - Guid - The GUID of the pack that registered with the HII. - -Returns: - Handle to the HII pack previously registered by the memory driver. - ---*/ -{ - EFI_STATUS Status; - - EFI_HII_HANDLE *HiiHandleBuffer; - EFI_HII_HANDLE HiiHandle; - UINT16 HiiHandleBufferLength; - UINT32 NumberOfHiiHandles; - EFI_GUID HiiGuid; - EFI_HII_PROTOCOL *HiiProt; - UINT32 Index; - UINT16 Length; - - HiiHandle = 0; - if ((HiiProtocol != NULL) && (*HiiProtocol != NULL)) { - // - // The protocol has been passed in - // - HiiProt = *HiiProtocol; - } else { - gBS->LocateProtocol ( - &gEfiHiiProtocolGuid, - NULL, - (VOID **) &HiiProt - ); - if (HiiProt == NULL) { - return HiiHandle; - } - - if (HiiProtocol != NULL) { - // - // Return back the HII protocol for the caller as promissed - // - *HiiProtocol = HiiProt; - } - } - // - // Allocate buffer - // - HiiHandleBufferLength = 10; - HiiHandleBuffer = AllocatePool (HiiHandleBufferLength); - ASSERT (HiiHandleBuffer != NULL); - - // - // Get the Handles of the packages that were registered with Hii - // - Status = HiiProt->FindHandles ( - HiiProt, - &HiiHandleBufferLength, - HiiHandleBuffer - ); - - // - // Get a bigger bugffer if this one is to small, and try again - // - if (Status == EFI_BUFFER_TOO_SMALL) { - - gBS->FreePool (HiiHandleBuffer); - - HiiHandleBuffer = AllocatePool (HiiHandleBufferLength); - ASSERT (HiiHandleBuffer != NULL); - - Status = HiiProt->FindHandles ( - HiiProt, - &HiiHandleBufferLength, - HiiHandleBuffer - ); - } - - if (EFI_ERROR (Status)) { - goto lbl_exit; - } - - NumberOfHiiHandles = HiiHandleBufferLength / sizeof (EFI_HII_HANDLE); - - // - // Iterate Hii handles and look for the one that matches our Guid - // - for (Index = 0; Index < NumberOfHiiHandles; Index++) { - - Length = 0; - ExtractDataFromHiiHandle (HiiHandleBuffer[Index], &Length, NULL, &HiiGuid); - - if (CompareGuid (&HiiGuid, Guid)) { - - HiiHandle = HiiHandleBuffer[Index]; - break; - } - } - -lbl_exit: - gBS->FreePool (HiiHandleBuffer); - return HiiHandle; -} - - -EFI_STATUS -ValidateDataFromHiiHandle ( - IN EFI_HII_HANDLE HiiHandle, - OUT BOOLEAN *Results - ) -/*++ - -Routine Description: - - Validate that the data associated with the HiiHandle in NVRAM is within - the reasonable parameters for that FormSet. Values for strings and passwords - are not verified due to their not having the equivalent of valid range settings. - -Arguments: - - HiiHandle - Handle of the HII database entry to query - - Results - If return Status is EFI_SUCCESS, Results provides valid data - TRUE = NVRAM Data is within parameters - FALSE = NVRAM Data is NOT within parameters - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - Data successfully validated ---*/ -{ - EFI_STATUS Status; - EFI_HII_PROTOCOL *Hii; - EFI_GUID Guid; - UINT8 *RawData; - UINT8 *OldData; - UINTN RawDataLength; - UINT8 *VariableData; - UINTN Index; - UINTN Temp; - UINTN SizeOfNvStore; - UINTN CachedStart; - BOOLEAN GotMatch; - - RawDataLength = DEFAULT_FORM_BUFFER_SIZE; - SizeOfNvStore = 0; - CachedStart = 0; - GotMatch = FALSE; - *Results = TRUE; - - Status = GetHiiInterface (&Hii); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Allocate space for retrieval of IFR data - // - RawData = AllocateZeroPool (RawDataLength); - if (RawData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Get all the forms associated with this HiiHandle - // - Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData); - - if (EFI_ERROR (Status)) { - gBS->FreePool (RawData); - - // - // Allocate space for retrieval of IFR data - // - RawData = AllocateZeroPool (RawDataLength); - if (RawData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Get all the forms associated with this HiiHandle - // - Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData); - } - - OldData = RawData; - - // - // Point RawData to the beginning of the form data - // - RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER)); - - for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { - if (RawData[Index] == EFI_IFR_FORM_SET_OP) { - CopyMem (&Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID)); - break; - } - - Index = RawData[Index + 1] + Index; - } - - for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { - switch (RawData[Index]) { - case EFI_IFR_FORM_SET_OP: - break; - - case EFI_IFR_ONE_OF_OP: - case EFI_IFR_CHECKBOX_OP: - case EFI_IFR_NUMERIC_OP: - case EFI_IFR_DATE_OP: - case EFI_IFR_TIME_OP: - case EFI_IFR_PASSWORD_OP: - case EFI_IFR_STRING_OP: - // - // Remember, multiple op-codes may reference the same item, so let's keep a running - // marker of what the highest QuestionId that wasn't zero length. This will accurately - // maintain the Size of the NvStore - // - if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) { - Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; - if (SizeOfNvStore < Temp) { - SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; - } - } - } - - Index = RawData[Index + 1] + Index; - } - - // - // Allocate memory for our File Form Tags - // - VariableData = AllocateZeroPool (SizeOfNvStore); - if (VariableData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = gRT->GetVariable ( - (CHAR16 *) L"Setup", - &Guid, - NULL, - &SizeOfNvStore, - (VOID *) VariableData - ); - - if (EFI_ERROR (Status)) { - - // - // If there is a variable that exists already and it is larger than what we calculated the - // storage needs to be, we must assume the variable size from GetVariable is correct and not - // allow the truncation of the variable. It is very possible that the user who created the IFR - // we are cracking is not referring to a variable that was in a previous map, however we cannot - // allow it's truncation. - // - if (Status == EFI_BUFFER_TOO_SMALL) { - // - // Free the buffer that was allocated that was too small - // - gBS->FreePool (VariableData); - - VariableData = AllocatePool (SizeOfNvStore); - if (VariableData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = gRT->GetVariable ( - (CHAR16 *) L"Setup", - &Guid, - NULL, - &SizeOfNvStore, - (VOID *) VariableData - ); - } - } - - // - // Walk through the form and see that the variable data it refers to is ok. - // This allows for the possibility of stale (obsoleted) data in the variable - // can be overlooked without causing an error - // - for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { - switch (RawData[Index]) { - case EFI_IFR_ONE_OF_OP: - // - // A one_of has no data, its the option that does - cache the storage Id - // - CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId; - break; - - case EFI_IFR_ONE_OF_OPTION_OP: - // - // A one_of_option can be any value - // - if (VariableData[CachedStart] == ((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value) { - GotMatch = TRUE; - } - break; - - case EFI_IFR_END_ONE_OF_OP: - // - // At this point lets make sure that the data value in the NVRAM matches one of the options - // - if (!GotMatch) { - *Results = FALSE; - return EFI_SUCCESS; - } - break; - - case EFI_IFR_CHECKBOX_OP: - // - // A checkbox is a boolean, so 0 and 1 are valid - // Remember, QuestionId corresponds to the offset location of the data in the variable - // - if (VariableData[((EFI_IFR_CHECKBOX *) &RawData[Index])->QuestionId] > 1) { - *Results = FALSE; - return EFI_SUCCESS; - } - break; - - case EFI_IFR_NUMERIC_OP: - if ((VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] < ((EFI_IFR_NUMERIC *)&RawData[Index])->Minimum) || - (VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] > ((EFI_IFR_NUMERIC *)&RawData[Index])->Maximum)) { - *Results = FALSE; - return EFI_SUCCESS; - } - break; - - } - - Index = RawData[Index + 1] + Index; - } - - // - // Free our temporary repository of form data - // - gBS->FreePool (OldData); - gBS->FreePool (VariableData); - - return EFI_SUCCESS; -} - diff --git a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrOnTheFly.c b/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrOnTheFly.c deleted file mode 100644 index e9ab48246c..0000000000 --- a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrOnTheFly.c +++ /dev/null @@ -1,977 +0,0 @@ -/*++ -Copyright (c) 2006, 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: - IfrOnTheFly.c - -Abstract: - - Library Routines to create IFR on-the-fly - -Revision History: - ---*/ - -// -// Include common header file for this module. -// -#include "IfrSupportLibInternal.h" - -EFI_STATUS -CreateFormSet ( - IN CHAR16 *FormSetTitle, - IN EFI_GUID *Guid, - IN UINT8 Class, - IN UINT8 SubClass, - IN OUT VOID **FormBuffer, - IN OUT VOID **StringBuffer - ) -/*++ - -Routine Description: - - Create a formset - -Arguments: - - FormSetTitle - Title of formset - - Guid - Guid of formset - - Class - Class of formset - - SubClass - Sub class of formset - - FormBuffer - Pointer of the formset created - - StringBuffer - Pointer of FormSetTitile string created - -Returns: - - EFI_OUT_OF_RESOURCES - No enough buffer to allocate - - EFI_SUCCESS - Formset successfully created - ---*/ -{ - EFI_STATUS Status; - EFI_HII_IFR_PACK IfrPack; - EFI_IFR_FORM_SET FormSet; - EFI_IFR_END_FORM_SET EndFormSet; - UINT8 *Destination; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // Pre-allocate a buffer sufficient for us to work from. - // - FormBuffer = AllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE); - if (FormBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Pre-allocate a buffer sufficient for us to work from. - // - StringBuffer = AllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE); - if (StringBuffer == NULL) { - gBS->FreePool (FormBuffer); - return EFI_OUT_OF_RESOURCES; - } - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - // - // Add the FormSetTitle to the string buffer and get the StringToken - // - Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Initialize the Ifr Package header data - // - IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (EFI_IFR_FORM_SET) + sizeof (EFI_IFR_END_FORM_SET); - IfrPack.Header.Type = EFI_HII_IFR; - - // - // Initialize FormSet with the appropriate information - // - FormSet.Header.OpCode = EFI_IFR_FORM_SET_OP; - FormSet.Header.Length = sizeof (EFI_IFR_FORM_SET); - FormSet.FormSetTitle = StringToken; - FormSet.Class = Class; - FormSet.SubClass = SubClass; - CopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID)); - - // - // Initialize the end formset data - // - EndFormSet.Header.Length = sizeof (EFI_IFR_END_FORM_SET); - EndFormSet.Header.OpCode = EFI_IFR_END_FORM_SET_OP; - - Destination = (UINT8 *) *FormBuffer; - - // - // Copy the formset/endformset data to the form buffer - // - CopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER)); - - Destination = Destination + sizeof (EFI_HII_PACK_HEADER); - - CopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET)); - - Destination = Destination + sizeof (EFI_IFR_FORM_SET); - - CopyMem (Destination, &EndFormSet, sizeof (EFI_IFR_END_FORM_SET)); - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateForm ( - IN CHAR16 *FormTitle, - IN UINT16 FormId, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a form - -Arguments: - - FormTitle - Title of the form - - FormId - Id of the form - - FormBuffer - Pointer of the form created - - StringBuffer - Pointer of FormTitil string created - -Returns: - - EFI_SUCCESS - Form successfully created - ---*/ -{ - EFI_STATUS Status; - EFI_IFR_FORM Form; - EFI_IFR_END_FORM EndForm; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Form.Header.OpCode = EFI_IFR_FORM_OP; - Form.Header.Length = sizeof (EFI_IFR_FORM); - Form.FormId = FormId; - Form.FormTitle = StringToken; - - Status = AddOpCode (FormBuffer, &Form); - - if (EFI_ERROR (Status)) { - return Status; - } - - EndForm.Header.OpCode = EFI_IFR_END_FORM_OP; - EndForm.Header.Length = sizeof (EFI_IFR_END_FORM); - - Status = AddOpCode (FormBuffer, &EndForm); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateSubTitle ( - IN CHAR16 *SubTitle, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a SubTitle - -Arguments: - - SubTitle - Sub title to be created - - FormBuffer - Where this subtitle to add to - - StringBuffer - String buffer created for subtitle - -Returns: - - EFI_SUCCESS - Subtitle successfully created - ---*/ -{ - EFI_STATUS Status; - EFI_IFR_SUBTITLE Subtitle; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP; - Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE); - Subtitle.SubTitle = StringToken; - - Status = AddOpCode (FormBuffer, &Subtitle); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateText ( - IN CHAR16 *String, - IN CHAR16 *String2, - IN CHAR16 *String3, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a line of text - -Arguments: - - String - First string of the text - - String2 - Second string of the text - - String3 - Help string of the text - - Flags - Flag of the text - - Key - Key of the text - - FormBuffer - The form where this text adds to - - StringBuffer - String buffer created for String, String2 and String3 - -Returns: - - EFI_SUCCESS - Text successfully created - ---*/ -{ - EFI_STATUS Status; - EFI_IFR_TEXT Text; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - // - // Add first string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Text.Header.OpCode = EFI_IFR_TEXT_OP; - Text.Header.Length = sizeof (EFI_IFR_TEXT); - Text.Text = StringToken; - - // - // Add second string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Text.TextTwo = StringToken; - - Text.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); - Text.Key = Key; - - // - // Add second string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Text.Help = StringToken; - - Status = AddOpCode (FormBuffer, &Text); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateGoto ( - IN UINT16 FormId, - IN CHAR16 *Prompt, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a hyperlink - -Arguments: - - FormId - Form ID of the hyperlink - - Prompt - Prompt of the hyperlink - - FormBuffer - The form where this hyperlink adds to - - StringBuffer - String buffer created for Prompt - -Returns: - - EFI_SUCCESS - Hyperlink successfully created - ---*/ -{ - EFI_STATUS Status; - EFI_IFR_REF Hyperlink; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Hyperlink.Header.OpCode = EFI_IFR_REF_OP; - Hyperlink.Header.Length = sizeof (EFI_IFR_REF); - Hyperlink.FormId = FormId; - Hyperlink.Prompt = StringToken; - - Status = AddOpCode (FormBuffer, &Hyperlink); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateOneOf ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a one-of question with a set of options to choose from. The - OptionsList is a pointer to a null-terminated list of option descriptions. - -Arguments: - - QuestionId - Question ID of the one-of box - - DataWidth - DataWidth of the one-of box - - Prompt - Prompt of the one-of box - - Help - Help of the one-of box - - OptionsList - Each string in it is an option of the one-of box - - OptionCount - Option string count - - FormBuffer - The form where this one-of box adds to - - StringBuffer - String buffer created for Prompt, Help and Option strings - -Returns: - - EFI_DEVICE_ERROR - DataWidth > 2 - - EFI_SUCCESS - One-Of box successfully created. - ---*/ -{ - EFI_STATUS Status; - UINTN Index; - EFI_IFR_ONE_OF OneOf; - EFI_IFR_ONE_OF_OPTION OneOfOption; - EFI_IFR_END_ONE_OF EndOneOf; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // We do not create op-code storage widths for one-of in excess of 16 bits for now - // - if (DataWidth > 2) { - return EFI_DEVICE_ERROR; - } - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - // - // Add first string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP; - OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF); - OneOf.QuestionId = QuestionId; - OneOf.Width = DataWidth; - OneOf.Prompt = StringToken; - - // - // Add second string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - OneOf.Help = StringToken; - - Status = AddOpCode (FormBuffer, &OneOf); - - if (EFI_ERROR (Status)) { - return Status; - } - - for (Index = 0; Index < OptionCount; Index++) { - OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; - OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); - - // - // Add string and get token back - // - Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken); - - OneOfOption.Option = StringToken; - OneOfOption.Value = OptionsList[Index].Value; - OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED); - OneOfOption.Key = OptionsList[Index].Key; - - Status = AddOpCode (FormBuffer, &OneOfOption); - - if (EFI_ERROR (Status)) { - return Status; - } - } - - EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF); - EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP; - - Status = AddOpCode (FormBuffer, &EndOneOf); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -CreateOrderedList ( - IN UINT16 QuestionId, - IN UINT8 MaxEntries, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a one-of question with a set of options to choose from. The - OptionsList is a pointer to a null-terminated list of option descriptions. - -Arguments: - - QuestionId - Question ID of the ordered list - - MaxEntries - MaxEntries of the ordered list - - Prompt - Prompt of the ordered list - - Help - Help of the ordered list - - OptionsList - Each string in it is an option of the ordered list - - OptionCount - Option string count - - FormBuffer - The form where this ordered list adds to - - StringBuffer - String buffer created for Prompt, Help and Option strings - -Returns: - - EFI_SUCCESS - Ordered list successfully created. - ---*/ -{ - EFI_STATUS Status; - UINTN Index; - EFI_IFR_ORDERED_LIST OrderedList; - EFI_IFR_ONE_OF_OPTION OrderedListOption; - EFI_IFR_END_ONE_OF EndOrderedList; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - // - // Add first string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP; - OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST); - OrderedList.QuestionId = QuestionId; - OrderedList.MaxEntries = MaxEntries; - OrderedList.Prompt = StringToken; - - // - // Add second string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - OrderedList.Help = StringToken; - - Status = AddOpCode (FormBuffer, &OrderedList); - - if (EFI_ERROR (Status)) { - return Status; - } - - for (Index = 0; Index < OptionCount; Index++) { - OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; - OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); - - // - // Add string and get token back - // - Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken); - - OrderedListOption.Option = StringToken; - OrderedListOption.Value = OptionsList[Index].Value; - OrderedListOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED); - OrderedListOption.Key = OptionsList[Index].Key; - - Status = AddOpCode (FormBuffer, &OrderedListOption); - - if (EFI_ERROR (Status)) { - return Status; - } - } - - EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF); - EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP; - - Status = AddOpCode (FormBuffer, &EndOrderedList); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateCheckBox ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN UINT8 Flags, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a checkbox - -Arguments: - - QuestionId - Question ID of the check box - - DataWidth - DataWidth of the check box - - Prompt - Prompt of the check box - - Help - Help of the check box - - Flags - Flags of the check box - - FormBuffer - The form where this check box adds to - - StringBuffer - String buffer created for Prompt and Help. - -Returns: - - EFI_DEVICE_ERROR - DataWidth > 1 - - EFI_SUCCESS - Check box successfully created - ---*/ -{ - EFI_STATUS Status; - EFI_IFR_CHECKBOX CheckBox; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // We do not create op-code storage widths for checkbox in excess of 8 bits for now - // - if (DataWidth > 1) { - return EFI_DEVICE_ERROR; - } - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - // - // Add first string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP; - CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX); - CheckBox.QuestionId = QuestionId; - CheckBox.Width = DataWidth; - CheckBox.Prompt = StringToken; - - // - // Add second string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - CheckBox.Help = StringToken; - CheckBox.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); - - Status = AddOpCode (FormBuffer, &CheckBox); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateNumeric ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN UINT16 Minimum, - IN UINT16 Maximum, - IN UINT16 Step, - IN UINT16 Default, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a numeric - -Arguments: - - QuestionId - Question ID of the numeric - - DataWidth - DataWidth of the numeric - - Prompt - Prompt of the numeric - - Help - Help of the numeric - - Minimum - Minumun boundary of the numeric - - Maximum - Maximum boundary of the numeric - - Step - Step of the numeric - - Default - Default value - - Flags - Flags of the numeric - - Key - Key of the numeric - - FormBuffer - The form where this numeric adds to - - StringBuffer - String buffer created for Prompt and Help. - -Returns: - - EFI_DEVICE_ERROR - DataWidth > 2 - - EFI_SUCCESS - Numeric is successfully created - ---*/ -{ - EFI_STATUS Status; - EFI_IFR_NUMERIC Numeric; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // We do not create op-code storage widths for numerics in excess of 16 bits for now - // - if (DataWidth > 2) { - return EFI_DEVICE_ERROR; - } - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - // - // Add first string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP; - Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC); - Numeric.QuestionId = QuestionId; - Numeric.Width = DataWidth; - Numeric.Prompt = StringToken; - - // - // Add second string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - Numeric.Help = StringToken; - Numeric.Minimum = Minimum; - Numeric.Maximum = Maximum; - Numeric.Step = Step; - Numeric.Default = Default; - Numeric.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); - Numeric.Key = Key; - - Status = AddOpCode (FormBuffer, &Numeric); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateString ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN CHAR16 *Prompt, - IN CHAR16 *Help, - IN UINT8 MinSize, - IN UINT8 MaxSize, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer, - IN OUT VOID *StringBuffer - ) -/*++ - -Routine Description: - - Create a string - -Arguments: - - QuestionId - Question ID of the string - - DataWidth - DataWidth of the string - - Prompt - Prompt of the string - - Help - Help of the string - - MinSize - Min size boundary of the string - - MaxSize - Max size boundary of the string - - Flags - Flags of the string - - Key - Key of the string - - FormBuffer - The form where this string adds to - - StringBuffer - String buffer created for Prompt and Help. - -Returns: - - EFI_SUCCESS - String successfully created. - ---*/ -{ - EFI_STATUS Status; - EFI_IFR_STRING String; - CHAR16 CurrentLanguage[4]; - STRING_REF StringToken; - - // - // Obtain current language value - // - GetCurrentLanguage (CurrentLanguage); - - // - // Add first string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - String.Header.OpCode = EFI_IFR_STRING_OP; - String.Header.Length = sizeof (EFI_IFR_STRING); - String.QuestionId = QuestionId; - String.Width = DataWidth; - String.Prompt = StringToken; - - // - // Add second string, get first string's token - // - Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); - - if (EFI_ERROR (Status)) { - return Status; - } - - String.Help = StringToken; - String.MinSize = MinSize; - String.MaxSize = MaxSize; - String.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); - String.Key = Key; - - Status = AddOpCode (FormBuffer, &String); - - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} diff --git a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrOpCodeCreation.c b/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrOpCodeCreation.c deleted file mode 100644 index 05b123887c..0000000000 --- a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrOpCodeCreation.c +++ /dev/null @@ -1,618 +0,0 @@ -/*++ -Copyright (c) 2006, 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: - IfrOpCodeCreation.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 common header file for this module. -// -#include "IfrSupportLibInternal.h" - -EFI_STATUS -CreateSubTitleOpCode ( - IN STRING_REF StringToken, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a SubTitle opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - StringToken - StringToken of the subtitle - - FormBuffer - Output of subtitle as a form - -Returns: - - EFI_SUCCESS - Subtitle created to be a form - ---*/ -{ - EFI_IFR_SUBTITLE Subtitle; - - Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP; - Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE); - Subtitle.SubTitle = StringToken; - - CopyMem (FormBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE)); - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateTextOpCode ( - IN STRING_REF StringToken, - IN STRING_REF StringTokenTwo, - IN STRING_REF StringTokenThree, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a Text opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - StringToken - First string token of the text - - StringTokenTwo - Second string token of the text - - StringTokenThree - Help string token of the text - - Flags - Flag of the text - - Key - Key of the text - - FormBuffer - Output of text as a form - -Returns: - - EFI_SUCCESS - Text created to be a form - ---*/ -{ - EFI_IFR_TEXT Text; - - Text.Header.OpCode = EFI_IFR_TEXT_OP; - Text.Header.Length = sizeof (EFI_IFR_TEXT); - Text.Text = StringToken; - - Text.TextTwo = StringTokenTwo; - Text.Help = StringTokenThree; - Text.Flags = Flags; - Text.Key = Key; - - CopyMem (FormBuffer, &Text, sizeof (EFI_IFR_TEXT)); - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateGotoOpCode ( - IN UINT16 FormId, - IN STRING_REF StringToken, - IN STRING_REF StringTokenTwo, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a hyperlink opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - FormId - Form ID of the hyperlink - - StringToken - Prompt string token of the hyperlink - - StringTokenTwo - Help string token of the hyperlink - - Flags - Flags of the hyperlink - - Key - Key of the hyperlink - - FormBuffer - Output of hyperlink as a form - -Returns: - - EFI_SUCCESS - Hyperlink created to be a form - ---*/ -{ - EFI_IFR_REF Hyperlink; - - Hyperlink.Header.OpCode = EFI_IFR_REF_OP; - Hyperlink.Header.Length = sizeof (EFI_IFR_REF); - Hyperlink.FormId = FormId; - Hyperlink.Prompt = StringToken; - Hyperlink.Help = StringTokenTwo; - Hyperlink.Key = Key; - Hyperlink.Flags = Flags; - - CopyMem (FormBuffer, &Hyperlink, sizeof (EFI_IFR_REF)); - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateOneOfOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a one-of opcode with a set of option op-codes to choose from independent of string creation. - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - - OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken - has been filled in since this routine will not generate StringToken values. - -Arguments: - - QuestionId - Question ID of the one-of box - - DataWidth - DataWidth of the one-of box - - PromptToken - Prompt string token of the one-of box - - HelpToken - Help string token of the one-of box - - OptionsList - Each string in it is an option of the one-of box - - OptionCount - Option string count - - FormBuffer - Output of One-Of box as a form - -Returns: - - EFI_SUCCESS - One-Of box created to be a form - - EFI_DEVICE_ERROR - DataWidth > 2 - ---*/ -{ - UINTN Index; - EFI_IFR_ONE_OF OneOf; - EFI_IFR_ONE_OF_OPTION OneOfOption; - EFI_IFR_END_ONE_OF EndOneOf; - UINT8 *LocalBuffer; - - // - // We do not create op-code storage widths for one-of in excess of 16 bits for now - // - if (DataWidth > 2) { - return EFI_DEVICE_ERROR; - } - - OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP; - OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF); - OneOf.QuestionId = QuestionId; - OneOf.Width = DataWidth; - OneOf.Prompt = PromptToken; - - OneOf.Help = HelpToken; - - LocalBuffer = (UINT8 *) FormBuffer; - - CopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF)); - - LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF)); - - 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.Option = OptionsList[Index].StringToken; - OneOfOption.Value = OptionsList[Index].Value; - OneOfOption.Flags = OptionsList[Index].Flags; - OneOfOption.Key = OptionsList[Index].Key; - - CopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION)); - - LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION)); - } - - EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF); - EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP; - - CopyMem (LocalBuffer, &EndOneOf, sizeof (EFI_IFR_END_ONE_OF)); - - LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF)); - - return EFI_SUCCESS; -} - -EFI_STATUS -CreateOrderedListOpCode ( - IN UINT16 QuestionId, - IN UINT8 MaxEntries, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN IFR_OPTION *OptionsList, - IN UINTN OptionCount, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a ordered list opcode with a set of option op-codes to choose from independent of string creation. - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - - OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken - has been filled in since this routine will not generate StringToken values. - -Arguments: - - QuestionId - Question ID of the ordered list - - MaxEntries - MaxEntries of the ordered list - - PromptToken - Prompt string token of the ordered list - - HelpToken - Help string token of the ordered list - - OptionsList - Each string in it is an option of the ordered list - - OptionCount - Option string count - - FormBuffer - Output of ordered list as a form - -Returns: - - EFI_SUCCESS - Ordered list created to be a form - ---*/ -{ - UINTN Index; - EFI_IFR_ORDERED_LIST OrderedList; - EFI_IFR_ONE_OF_OPTION OrderedListOption; - EFI_IFR_END_ONE_OF EndOrderedList; - UINT8 *LocalBuffer; - - OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP; - OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST); - OrderedList.QuestionId = QuestionId; - OrderedList.MaxEntries = MaxEntries; - OrderedList.Prompt = PromptToken; - - OrderedList.Help = HelpToken; - - LocalBuffer = (UINT8 *) FormBuffer; - - CopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST)); - - LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ORDERED_LIST)); - - for (Index = 0; Index < OptionCount; Index++) { - OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; - OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); - - OrderedListOption.Option = OptionsList[Index].StringToken; - OrderedListOption.Value = OptionsList[Index].Value; - OrderedListOption.Flags = OptionsList[Index].Flags; - OrderedListOption.Key = OptionsList[Index].Key; - - CopyMem (LocalBuffer, &OrderedListOption, sizeof (EFI_IFR_ONE_OF_OPTION)); - - LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION)); - } - - EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF); - EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP; - - CopyMem (LocalBuffer, &EndOrderedList, sizeof (EFI_IFR_END_ONE_OF)); - - LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF)); - - return EFI_SUCCESS; -} - -EFI_STATUS -CreateCheckBoxOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a checkbox opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - QuestionId - Question ID of the check box - - DataWidth - DataWidth of the check box - - PromptToken - Prompt string token of the check box - - HelpToken - Help string token of the check box - - Flags - Flags of the check box - - Key - Key of the check box - - FormBuffer - Output of the check box as a form - -Returns: - - EFI_SUCCESS - Checkbox created to be a form - - EFI_DEVICE_ERROR - DataWidth > 1 - ---*/ -{ - EFI_IFR_CHECKBOX CheckBox; - - // - // We do not create op-code storage widths for checkbox in excess of 8 bits for now - // - if (DataWidth > 1) { - return EFI_DEVICE_ERROR; - } - - CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP; - CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX); - CheckBox.QuestionId = QuestionId; - CheckBox.Width = DataWidth; - CheckBox.Prompt = PromptToken; - - CheckBox.Help = HelpToken; - CheckBox.Flags = Flags; - CheckBox.Key = Key; - - CopyMem (FormBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX)); - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateNumericOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN UINT16 Minimum, - IN UINT16 Maximum, - IN UINT16 Step, - IN UINT16 Default, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a numeric opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - QuestionId - Question ID of the numeric - - DataWidth - DataWidth of the numeric - - PromptToken - Prompt string token of the numeric - - HelpToken - Help string token of the numeric - - Minimum - Minumun boundary of the numeric - - Maximum - Maximum boundary of the numeric - - Step - Step of the numeric - - Default - Default value of the numeric - - Flags - Flags of the numeric - - Key - Key of the numeric - - FormBuffer - Output of the numeric as a form - -Returns: - - EFI_SUCCESS - The numeric created to be a form. - - EFI_DEVICE_ERROR - DataWidth > 2 - ---*/ -{ - EFI_IFR_NUMERIC Numeric; - - // - // We do not create op-code storage widths for numerics in excess of 16 bits for now - // - if (DataWidth > 2) { - return EFI_DEVICE_ERROR; - } - - Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP; - Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC); - Numeric.QuestionId = QuestionId; - Numeric.Width = DataWidth; - Numeric.Prompt = PromptToken; - - Numeric.Help = HelpToken; - Numeric.Minimum = Minimum; - Numeric.Maximum = Maximum; - Numeric.Step = Step; - Numeric.Default = Default; - Numeric.Flags = Flags; - Numeric.Key = Key; - - CopyMem (FormBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC)); - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateStringOpCode ( - IN UINT16 QuestionId, - IN UINT8 DataWidth, - IN STRING_REF PromptToken, - IN STRING_REF HelpToken, - IN UINT8 MinSize, - IN UINT8 MaxSize, - IN UINT8 Flags, - IN UINT16 Key, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a numeric opcode independent of string creation - This is used primarily by users who need to create just one particular valid op-code and the string - data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label - location to pre-defined forms in HII) - -Arguments: - - QuestionId - Question ID of the string - - DataWidth - DataWidth of the string - - PromptToken - Prompt token of the string - - HelpToken - Help token of the string - - MinSize - Min size boundary of the string - - MaxSize - Max size boundary of the string - - Flags - Flags of the string - - Key - Key of the string - - FormBuffer - Output of the string as a form - -Returns: - - EFI_SUCCESS - String created to be a form. - ---*/ -{ - EFI_IFR_STRING String; - - String.Header.OpCode = EFI_IFR_STRING_OP; - String.Header.Length = sizeof (EFI_IFR_STRING); - String.QuestionId = QuestionId; - String.Width = DataWidth; - String.Prompt = PromptToken; - - String.Help = HelpToken; - String.MinSize = MinSize; - String.MaxSize = MaxSize; - String.Flags = Flags; - String.Key = Key; - - CopyMem (FormBuffer, &String, sizeof (EFI_IFR_STRING)); - - return EFI_SUCCESS; -} - - -EFI_STATUS -CreateBannerOpCode ( - IN UINT16 Title, - IN UINT16 LineNumber, - IN UINT8 Alignment, - IN OUT VOID *FormBuffer - ) -/*++ - -Routine Description: - - Create a banner opcode. This is primarily used by the FrontPage implementation from BDS. - -Arguments: - - Title - Title of the banner - - LineNumber - LineNumber of the banner - - Alignment - Alignment of the banner - - FormBuffer - Output of banner as a form - -Returns: - - EFI_SUCCESS - Banner created to be a form. - ---*/ -{ - EFI_IFR_BANNER Banner; - - Banner.Header.OpCode = EFI_IFR_BANNER_OP; - Banner.Header.Length = sizeof (EFI_IFR_BANNER); - CopyMem (&Banner.Title, &Title, sizeof (UINT16)); - CopyMem (&Banner.LineNumber, &LineNumber, sizeof (UINT16)); - Banner.Alignment = Alignment; - - CopyMem (FormBuffer, &Banner, sizeof (EFI_IFR_BANNER)); - - return EFI_SUCCESS; -} diff --git a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf b/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf deleted file mode 100644 index 8b21d4327a..0000000000 --- a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf +++ /dev/null @@ -1,66 +0,0 @@ -#/** @file -# EDK Internal Form Refresentation Support Library Instance. -# -# The library instance provides common library routines help in -# IFR creation on-the-fly, HII variable access, HII database access, multi language supports. -# Copyright (c) 2006 - 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. -# -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = IfrSupportLibFramework - FILE_GUID = ea55bada-d488-427b-9d2d-227e0aaa3707 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = IfrSupportLibFramework|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER - EDK_RELEASE_VERSION = 0x00020000 - EFI_SPECIFICATION_VERSION = 0x00020000 - - CONSTRUCTOR = IfrLibConstruct - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# -# Variable Guid C Name: gLanGuid Variable Name: L"Lan" -# - -[Sources.common] - IfrVariable.c - IfrOpCodeCreation.c - IfrOnTheFly.c - IfrCommon.c - IfrSupportLibInternal.h - - -[Packages] - MdePkg/MdePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - - -[LibraryClasses] - UefiRuntimeServicesTableLib - UefiBootServicesTableLib - MemoryAllocationLib - BaseMemoryLib - BaseLib - DebugLib - - -[Guids] - gEfiGlobalVariableGuid # ALWAYS_CONSUMED - - -[Protocols] - gEfiHiiProtocolGuid # PROTOCOL ALWAYS_CONSUMED - diff --git a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.msa b/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.msa deleted file mode 100644 index 87f4f7411a..0000000000 --- a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.msa +++ /dev/null @@ -1,81 +0,0 @@ - - - - EdkIfrSupportLib - DXE_DRIVER - ea55bada-d488-427b-9d2d-227e0aaa3707 - 1.0 - EDK Internal Form Refresentation Support Library Instance. - The library instance provides common library routines help in - IFR creation on-the-fly, HII variable access, HII database access, multi language supports. - Copyright (c) 2006 - 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. - FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 - - - IA32 X64 IPF EBC - false - EdkIfrSupportLib - - - - EdkIfrSupportLib - - - DebugLib - - - BaseLib - - - BaseMemoryLib - - - MemoryAllocationLib - - - UefiBootServicesTableLib - - - UefiRuntimeServicesTableLib - - - - IfrCommon.c - IfrOnTheFly.c - IfrOpCodeCreation.c - IfrVariable.c - - - - - - - - gEfiHiiProtocolGuid - - - - - 0x004C 0x0061 0x006E - gLanGuid - - - - - gEfiGlobalVariableGuid - - - - EFI_SPECIFICATION_VERSION 0x00020000 - EDK_RELEASE_VERSION 0x00020000 - - IfrLibConstruct - - - \ No newline at end of file diff --git a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLibInternal.h b/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLibInternal.h deleted file mode 100644 index ed7cfd91b4..0000000000 --- a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLibInternal.h +++ /dev/null @@ -1,33 +0,0 @@ -/**@file - Common header file shared by all source files. - - This file includes package header files, library classes and protocol, PPI & GUID definitions. - - Copyright (c) 2006 - 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. -**/ - -#ifndef __IFRSUPPORT_LIB_INTERNAL_H_ -#define __IFRSUPPORT_LIB_INTERNAL_H_ - - - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrVariable.c b/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrVariable.c deleted file mode 100644 index 04aa4dcd9b..0000000000 --- a/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrVariable.c +++ /dev/null @@ -1,493 +0,0 @@ -/*++ - -Copyright (c) 2006, 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: - IfrVariable.c - -Abstract: - Variable/Map manipulations routines - ---*/ - -// -// Include common header file for this module. -// -#include "IfrSupportLibInternal.h" - -VOID -EfiLibHiiVariablePackGetMap ( - IN EFI_HII_VARIABLE_PACK *Pack, - OUT CHAR16 **Name, OPTIONAL - OUT EFI_GUID **Guid, OPTIONAL - OUT UINT16 *Id, OPTIONAL - OUT VOID **Var, OPTIONAL - OUT UINTN *Size OPTIONAL - ) -/*++ - -Routine Description: - - Extracts a variable form a Pack. - -Arguments: - - Pack - List of variables - Name - Name of the variable/map - Guid - GUID of the variable/map - Var - Pointer to the variable/map - Size - Size of the variable/map in bytes - -Returns: - - VOID - ---*/ -{ - if (NULL != Name) { - *Name = (VOID *) (Pack + 1); - } - - if (NULL != Guid) { - *Guid = (EFI_GUID *)(UINTN)&Pack->VariableGuid; - } - - - if (NULL != Id) { - *Id = Pack->VariableId; - } - - if (NULL != Var) { - *Var = (VOID *) ((CHAR8 *) (Pack + 1) + Pack->VariableNameLength); - } - - if (NULL != Size) { - *Size = Pack->Header.Length - sizeof (*Pack) - Pack->VariableNameLength; - } -} - - -UINTN -EfiLibHiiVariablePackListGetMapCnt ( - IN EFI_HII_VARIABLE_PACK_LIST *List - ) - -/*++ - -Routine Description: - - Finds a count of the variables/maps in the List. - -Arguments: - - List - List of variables - -Returns: - - UINTN - The number of map count. - ---*/ - -{ - UINTN Cnt = 0; - while (NULL != List) { - Cnt++; - List = List->NextVariablePack; - } - return Cnt; -} - - -VOID -EfiLibHiiVariablePackListForEachVar ( - IN EFI_HII_VARIABLE_PACK_LIST *List, - IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback - ) -/*++ - -Routine Description: - - Will iterate all variable/maps as appearing - in List and for each, it will call the Callback. - -Arguments: - - List - List of variables - Callback - Routine to be called for each iterated variable. - -Returns: - - VOID - ---*/ - -{ - CHAR16 *MapName; - EFI_GUID *MapGuid; - UINT16 MapId; - VOID *Map; - UINTN MapSize; - - while (NULL != List) { - EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); - // - // call the callback - // - Callback (MapName, MapGuid, MapId, Map, MapSize); - List = List->NextVariablePack; - } -} - - -EFI_STATUS -EfiLibHiiVariablePackListGetMapByIdx ( - IN UINTN Idx, - IN EFI_HII_VARIABLE_PACK_LIST *List, - OUT CHAR16 **Name, OPTIONAL - OUT EFI_GUID **Guid, OPTIONAL - OUT UINT16 *Id, OPTIONAL - OUT VOID **Var, - OUT UINTN *Size - ) - -/*++ - -Routine Description: - - Finds a variable form List given - the order number as appears in the List. - -Arguments: - - Idx - The index of the variable/map to retrieve - List - List of variables - Name - Name of the variable/map - Guid - GUID of the variable/map - Var - Pointer to the variable/map - Size - Size of the variable/map in bytes - -Returns: - - EFI_SUCCESS - Variable is found, OUT parameters are valid - EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid - ---*/ -{ - CHAR16 *MapName; - EFI_GUID *MapGuid; - UINT16 MapId; - VOID *Map; - UINTN MapSize; - - while (NULL != List) { - EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); - if (0 == Idx--) { - *Var = Map; - *Size = MapSize; - - if (NULL != Name) { - *Name = MapName; - } - - if (NULL != Guid) { - *Guid = MapGuid; - } - - if (NULL != Id) { - *Id = MapId; - } - - return EFI_SUCCESS; // Map found - } - List = List->NextVariablePack; - } - // - // If here, the map is not found - // - return EFI_NOT_FOUND; -} - - -EFI_STATUS -EfiLibHiiVariablePackListGetMapById ( - IN UINT16 Id, - IN EFI_HII_VARIABLE_PACK_LIST *List, - OUT CHAR16 **Name, OPTIONAL - OUT EFI_GUID **Guid, OPTIONAL - OUT VOID **Var, - OUT UINTN *Size - ) - -/*++ - -Routine Description: - - Finds a variable form List given the - order number as appears in the List. - -Arguments: - - Id - The ID of the variable/map to retrieve - List - List of variables - Name - Name of the variable/map - Guid - GUID of the variable/map - Var - Pointer to the variable/map - Size - Size of the variable/map in bytes - -Returns: - - EFI_SUCCESS - Variable is found, OUT parameters are valid - EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid - ---*/ - -{ - CHAR16 *MapName; - EFI_GUID *MapGuid; - UINT16 MapId; - VOID *Map; - UINTN MapSize; - - while (NULL != List) { - EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); - if (MapId == Id) { - *Var = Map; - *Size = MapSize; - if (NULL != Name) { - *Name = MapName; - } - if (NULL != Guid) { - *Guid = MapGuid; - } - // - // Map found - // - return EFI_SUCCESS; - } - List = List->NextVariablePack; - } - // - // If here, the map is not found - // - return EFI_NOT_FOUND; -} - - -EFI_STATUS -EfiLibHiiVariablePackListGetMap ( - IN EFI_HII_VARIABLE_PACK_LIST *List, - IN CHAR16 *Name, - IN EFI_GUID *Guid, - OUT UINT16 *Id, - OUT VOID **Var, - OUT UINTN *Size - ) - -/*++ - -Routine Description: - - Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID. - -Arguments: - - List - List of variables - Name - Name of the variable/map to be found - Guid - GUID of the variable/map to be found - Var - Pointer to the variable/map found - Size - Size of the variable/map in bytes found - -Returns: - - EFI_SUCCESS - variable is found, OUT parameters are valid - EFI_NOT_FOUND - variable is not found, OUT parameters are not valid - ---*/ - -{ - VOID *Map; - UINTN MapSize; - UINT16 MapId; - CHAR16 *MapName; - EFI_GUID *MapGuid; - - while (NULL != List) { - EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); - if ((0 == StrCmp (Name, MapName)) && CompareGuid (Guid, MapGuid)) { - *Id = MapId; - *Var = Map; - *Size = MapSize; - return EFI_SUCCESS; - } - List = List->NextVariablePack; - } - // - // If here, the map is not found - // - return EFI_NOT_FOUND; -} - -EFI_STATUS -EfiLibHiiVariableRetrieveFromNv ( - IN CHAR16 *Name, - IN EFI_GUID *Guid, - IN UINTN Size, - OUT VOID **Var - ) -/*++ - -Routine Description: - Finds out if a variable of specific Name/Guid/Size exists in NV. - If it does, it will retrieve it into the Var. - -Arguments: - Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. - Var - Variable will be retrieved into buffer pointed by this pointer. - If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer. -Returns: - EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var. - EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. - EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. - ---*/ -{ - EFI_STATUS Status; - UINTN SizeNv; - - // - // Test for existence of the variable. - // - SizeNv = 0; - Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, NULL); - if (EFI_BUFFER_TOO_SMALL != Status) { - ASSERT (EFI_SUCCESS != Status); - return EFI_NOT_FOUND; - } - if (SizeNv != Size) { - // - // The variable is considered corrupt, as it has different size from expected. - // - return EFI_LOAD_ERROR; - } - - if (NULL == *Var) { - *Var = AllocatePool (Size); - ASSERT (NULL != *Var); - } - SizeNv = Size; - // - // Final read into the Var - // - Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, *Var); - // - // No tolerance for random failures. Such behavior is undetermined and not validated. - // - ASSERT_EFI_ERROR (Status); - ASSERT (SizeNv == Size); - return EFI_SUCCESS; -} - - - -EFI_STATUS -EfiLibHiiVariableOverrideIfSuffix ( - IN CHAR16 *Suffix, - IN CHAR16 *Name, - IN EFI_GUID *Guid, - IN UINTN Size, - OUT VOID *Var - ) -/*++ - -Routine Description: - Overrrides the variable with NV data if found. - But it only does it if the Name ends with specified Suffix. - For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride", - the Suffix matches the end of Name, so the variable will be loaded from NV - provided the variable exists and the GUID and Size matches. - -Arguments: - Suffix - Suffix the Name should end with. - Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. - Var - Variable will be retrieved into this buffer. - Caller is responsible for providing storage of exactly Size size in bytes. -Returns: - EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. - EFI_INVALID_PARAMETER - The name of the variable does not end with . - EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. - EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. - ---*/ -{ - UINTN StrLength; - UINTN StrLenSuffix; - - StrLength = StrLen (Name); - StrLenSuffix = StrLen (Suffix); - if ((StrLength <= StrLenSuffix) || (0 != StrCmp (Suffix, &Name[StrLength - StrLenSuffix]))) { - // - // Not ending with . - // - return EFI_INVALID_PARAMETER; - } - return EfiLibHiiVariableRetrieveFromNv (Name, Guid, Size, &Var); -} - -EFI_STATUS -EfiLibHiiVariableOverrideBySuffix ( - IN CHAR16 *Suffix, - IN CHAR16 *Name, - IN EFI_GUID *Guid, - IN UINTN Size, - OUT VOID *Var - ) -/*++ - -Routine Description: - Overrrides the variable with NV data if found. - But it only does it if the NV contains the same variable with Name is appended with Suffix. - For example, if Suffix="MyOverride" and the Name="XyzSetup", - the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride" - will be loaded from NV provided the variable exists and the GUID and Size matches. - -Arguments: - Suffix - Suffix the variable will be appended with. - Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. - Var - Variable will be retrieved into this buffer. - Caller is responsible for providing storage of exactly Size size in bytes. - -Returns: - EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. - EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. - EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. - ---*/ -{ - EFI_STATUS Status; - CHAR16 *NameSuffixed; - UINTN NameLength; - UINTN SuffixLength; - - // - // enough to concatenate both strings. - // - NameLength = StrLen (Name); - SuffixLength = StrLen (Suffix); - NameSuffixed = AllocateZeroPool ((NameLength + SuffixLength + 1) * sizeof (CHAR16)); - - StrCpy (NameSuffixed, Name); - StrCat (NameSuffixed, Suffix); - - Status = EfiLibHiiVariableRetrieveFromNv (NameSuffixed, Guid, Size, &Var); - gBS->FreePool (NameSuffixed); - - return Status; -} - diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/Console.c b/IntelFrameworkPkg/Library/UefiLibFramework/Console.c deleted file mode 100644 index 6260555e9e..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/Console.c +++ /dev/null @@ -1,282 +0,0 @@ -/** @file - Mde UEFI library functions. - - 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: Console.c - -**/ - -#include "UefiLibFramework.h" - -typedef struct { - CHAR16 WChar; - UINT32 Width; -} UNICODE_WIDTH_ENTRY; - -UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = { - // - // General script area - // - {(CHAR16)0x1FFF, 1}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all narrow glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x007F, 1}, // C0 controls and basic Latin. 0x0000-0x007F - {(CHAR16)0x00FF, 1}, // C1 controls and Latin-1 support. 0x0080-0x00FF - {(CHAR16)0x017F, 1}, // Latin extended-A. 0x0100-0x017F - {(CHAR16)0x024F, 1}, // Latin extended-B. 0x0180-0x024F - {(CHAR16)0x02AF, 1}, // IPA extensions. 0x0250-0x02AF - {(CHAR16)0x02FF, 1}, // Spacing modifier letters. 0x02B0-0x02FF - {(CHAR16)0x036F, 1}, // Combining diacritical marks. 0x0300-0x036F - {(CHAR16)0x03FF, 1}, // Greek. 0x0370-0x03FF - {(CHAR16)0x04FF, 1}, // Cyrillic. 0x0400-0x04FF - {(CHAR16)0x052F, 0}, // Unassigned. As Armenian in ver3.0. 0x0500-0x052F - {(CHAR16)0x058F, 1}, // Armenian. 0x0530-0x058F - {(CHAR16)0x05FF, 1}, // Hebrew. 0x0590-0x05FF - {(CHAR16)0x06FF, 1}, // Arabic. 0x0600-0x06FF - {(CHAR16)0x08FF, 0}, // Unassigned. 0x0700-0x08FF - {(CHAR16)0x097F, 1}, // Devanagari. 0x0900-0x097F - {(CHAR16)0x09FF, 1}, // Bengali. 0x0980-0x09FF - {(CHAR16)0x0A7F, 1}, // Gurmukhi. 0x0A00-0x0A7F - {(CHAR16)0x0AFF, 1}, // Gujarati. 0x0A80-0x0AFF - {(CHAR16)0x0B7F, 1}, // Oriya. 0x0B00-0x0B7F - {(CHAR16)0x0BFF, 1}, // Tamil. (See page 7-92). 0x0B80-0x0BFF - {(CHAR16)0x0C7F, 1}, // Telugu. 0x0C00-0x0C7F - {(CHAR16)0x0CFF, 1}, // Kannada. (See page 7-100). 0x0C80-0x0CFF - {(CHAR16)0x0D7F, 1}, // Malayalam (See page 7-104). 0x0D00-0x0D7F - {(CHAR16)0x0DFF, 0}, // Unassigned. 0x0D80-0x0DFF - {(CHAR16)0x0E7F, 1}, // Thai. 0x0E00-0x0E7F - {(CHAR16)0x0EFF, 1}, // Lao. 0x0E80-0x0EFF - {(CHAR16)0x0FBF, 1}, // Tibetan. 0x0F00-0x0FBF - {(CHAR16)0x109F, 0}, // Unassigned. 0x0FC0-0x109F - {(CHAR16)0x10FF, 1}, // Georgian. 0x10A0-0x10FF - {(CHAR16)0x11FF, 1}, // Hangul Jamo. 0x1100-0x11FF - {(CHAR16)0x1DFF, 0}, // Unassigned. 0x1200-0x1DFF - {(CHAR16)0x1EFF, 1}, // Latin extended additional. 0x1E00-0x1EFF - {(CHAR16)0x1FFF, 1}, // Greek extended. 0x1F00-0x1FFF - * - */ - - // - // Symbol area - // - {(CHAR16)0x2FFF, 1}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all narrow glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x206F, 1}, // General punctuation. (See page7-154). 0x200-0x206F - {(CHAR16)0x209F, 1}, // Superscripts and subscripts. 0x2070-0x209F - {(CHAR16)0x20CF, 1}, // Currency symbols. 0x20A0-0x20CF - {(CHAR16)0x20FF, 1}, // Combining diacritical marks for symbols. 0x20D0-0x20FF - {(CHAR16)0x214F, 1}, // Letterlike sympbols. 0x2100-0x214F - {(CHAR16)0x218F, 1}, // Number forms. 0x2150-0x218F - {(CHAR16)0x21FF, 1}, // Arrows. 0x2190-0x21FF - {(CHAR16)0x22FF, 1}, // Mathematical operators. 0x2200-0x22FF - {(CHAR16)0x23FF, 1}, // Miscellaneous technical. 0x2300-0x23FF - {(CHAR16)0x243F, 1}, // Control pictures. 0x2400-0x243F - {(CHAR16)0x245F, 1}, // Optical character recognition. 0x2440-0x245F - {(CHAR16)0x24FF, 1}, // Enclosed alphanumerics. 0x2460-0x24FF - {(CHAR16)0x257F, 1}, // Box drawing. 0x2500-0x257F - {(CHAR16)0x259F, 1}, // Block elements. 0x2580-0x259F - {(CHAR16)0x25FF, 1}, // Geometric shapes. 0x25A0-0x25FF - {(CHAR16)0x26FF, 1}, // Miscellaneous symbols. 0x2600-0x26FF - {(CHAR16)0x27BF, 1}, // Dingbats. 0x2700-0x27BF - {(CHAR16)0x2FFF, 0}, // Reserved. 0x27C0-0x2FFF - * - */ - - // - // CJK phonetics and symbol area - // - {(CHAR16)0x33FF, 2}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all wide glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x303F, 2}, // CJK symbols and punctuation. 0x3000-0x303F - {(CHAR16)0x309F, 2}, // Hiragana. 0x3040-0x309F - {(CHAR16)0x30FF, 2}, // Katakana. 0x30A0-0x30FF - {(CHAR16)0x312F, 2}, // Bopomofo. 0x3100-0x312F - {(CHAR16)0x318F, 2}, // Hangul compatibility jamo. 0x3130-0x318F - {(CHAR16)0x319F, 2}, // Kanbun. 0x3190-0x319F - {(CHAR16)0x31FF, 0}, // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF - {(CHAR16)0x32FF, 2}, // Enclosed CJK letters and months. 0x3200-0x32FF - {(CHAR16)0x33FF, 2}, // CJK compatibility. 0x3300-0x33FF - * - */ - - // - // CJK ideograph area - // - {(CHAR16)0x9FFF, 2}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all wide glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0x4DFF, 0}, // Reserved. 0x3400-0x4DBF as CJK unified ideographs - // extension A in ver3.0. 0x3400-0x4DFF - {(CHAR16)0x9FFF, 2}, // CJK unified ideographs. 0x4E00-0x9FFF - * - */ - - // - // Reserved - // - {(CHAR16)0xABFF, 0}, // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0 - // as Yi radicals in ver3.0. 0xA000-0xABFF - // - // Hangul syllables - // - {(CHAR16)0xD7FF, 2}, - /* - * Merge the blocks and replace them with the above entry as they fall to - * the same category and they are all wide glyph. This will reduce search - * time and table size. The merge will omit the reserved code. - * - * Remove the above item if below is un-commented. - * - {(CHAR16)0xD7A3, 2}, // Hangul syllables. 0xAC00-0xD7A3 - {(CHAR16)0xD7FF, 0}, // Reserved. 0xD7A3-0xD7FF - * - */ - - // - // Surrogates area - // - {(CHAR16)0xDFFF, 0}, // Surrogates, not used now. 0xD800-0xDFFF - - // - // Private use area - // - {(CHAR16)0xF8FF, 0}, // Private use area. 0xE000-0xF8FF - - // - // Compatibility area and specials - // - {(CHAR16)0xFAFF, 2}, // CJK compatibility ideographs. 0xF900-0xFAFF - {(CHAR16)0xFB4F, 1}, // Alphabetic presentation forms. 0xFB00-0xFB4F - {(CHAR16)0xFDFF, 1}, // Arabic presentation forms-A. 0xFB50-0xFDFF - {(CHAR16)0xFE1F, 0}, // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F - {(CHAR16)0xFE2F, 1}, // Combining half marks. 0xFE20-0xFE2F - {(CHAR16)0xFE4F, 2}, // CJK compatibility forms. 0xFE30-0xFE4F - {(CHAR16)0xFE6F, 1}, // Small Form Variants. 0xFE50-0xFE6F - {(CHAR16)0xFEFF, 1}, // Arabic presentation forms-B. 0xFE70-0xFEFF - {(CHAR16)0xFFEF, 1}, // Half width and full width forms. 0xFF00-0xFFEF - {(CHAR16)0xFFFF, 0}, // Speicials. 0xFFF0-0xFFFF -}; - -/** - This function computes and returns the width of the Unicode character - specified by UnicodeChar. - - @param UnicodeChar A Unicode character. - - @retval 0 The width if UnicodeChar could not be determined. - @retval 1 UnicodeChar is a narrow glyph. - @retval 2 UnicodeChar is a wide glyph. - -**/ -UINTN -EFIAPI -GetGlyphWidth ( - IN CHAR16 UnicodeChar - ) -{ - UINTN Index; - UINTN Low; - UINTN High; - UNICODE_WIDTH_ENTRY *Item; - - Item = NULL; - Low = 0; - High = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1; - while (Low <= High) { - Index = (Low + High) >> 1; - Item = &(mUnicodeWidthTable[Index]); - if (Index == 0) { - if (UnicodeChar <= Item->WChar) { - break; - } - - return 0; - } - - if (UnicodeChar > Item->WChar) { - Low = Index + 1; - } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) { - High = Index - 1; - } else { - // - // Index - 1 < UnicodeChar <= Index. Found - // - break; - } - } - - if (Low <= High) { - return Item->Width; - } - - return 0; -} - -/** - This function computes and returns the display length of - the Null-terminated Unicode string specified by String. - If String is NULL, then 0 is returned. - If any of the widths of the Unicode characters in String - can not be determined, then 0 is returned. - - @param String A pointer to a Null-terminated Unicode string. - - @return The display length of the Null-terminated Unicode string specified by String. - -**/ -UINTN -EFIAPI -UnicodeStringDisplayLength ( - IN CONST CHAR16 *String - ) -{ - UINTN Length; - UINTN Width; - - if (String == NULL) { - return 0; - } - - Length = 0; - while (*String != 0) { - Width = GetGlyphWidth (*String); - if (Width == 0) { - return 0; - } - - Length += Width; - String++; - } - - return Length; -} diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/UefiDriverModel.c b/IntelFrameworkPkg/Library/UefiLibFramework/UefiDriverModel.c deleted file mode 100644 index f6919a6a78..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/UefiDriverModel.c +++ /dev/null @@ -1,667 +0,0 @@ -/** @file - Library functions that abstract driver model protocols - installation. - - Copyright (c) 2006 - 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 "UefiLibFramework.h" - -/** - Intialize a driver by installing the Driver Binding Protocol onto the driver's - DriverBindingHandle. This is typically the same as the driver's ImageHandle, but - it can be different if the driver produces multiple DriverBinding Protocols. - If the Drvier Binding Protocol interface is NULL, then ASSERT (). - If the installation fails, then ASSERT (). - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this - parameter is NULL, then a new handle is created. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallDriverBinding ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle - ) -{ - EFI_STATUS Status; - - ASSERT (NULL != DriverBinding); - - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - return Status; -} - - -/** - Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name, - Driver Configure and Driver Diagnostic Protocols onto the driver's DriverBindingHandle. This is - typically the same as the driver's ImageHandle, but it can be different if the driver produces multiple - DriverBinding Protocols. - If the Drvier Binding Protocol interface is NULL, then ASSERT (). - If the installation fails, then ASSERT (). - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this - parameter is NULL, then a new handle is created. - @param ComponentName A Component Name Protocol instance that this driver is producing. - @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing. - @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallAllDriverProtocols ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle, - IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL - IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL - IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL - ) -{ - EFI_STATUS Status; - - ASSERT (NULL != DriverBinding); - - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverConfiguration == NULL) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - NULL - ); - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } - } - } else { - if (DriverConfiguration == NULL) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } - - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - return Status; -} - - - -/** - Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name, - Component Name 2 onto the driver's DriverBindingHandle. This is typically the same as the driver's - ImageHandle, but it can be different if the driver produces multiple DriverBinding Protocols. - If the Drvier Binding Protocol interface is NULL, then ASSERT (). - If the installation fails, then ASSERT (). - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this - parameter is NULL, then a new handle is created. - @param ComponentName A Component Name Protocol instance that this driver is producing. - @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallDriverBindingComponentName2 ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle, - IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL - IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL - ) -{ - EFI_STATUS Status; - - ASSERT (NULL != DriverBinding); - - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - return Status; -} - - - -/** - Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name, - Component Name 2, Driver Configure, Driver Diagnostic and Driver Diagnostic 2 Protocols onto the driver's - DriverBindingHandle. This is typically the same as the driver's ImageHandle, but it can be different if - the driver produces multiple DriverBinding Protocols. - If the Drvier Binding Protocol interface is NULL, then ASSERT (). - If the installation fails, then ASSERT (). - - @param ImageHandle The image handle of the driver. - @param SystemTable The EFI System Table that was passed to the driver's entry point. - @param DriverBinding A Driver Binding Protocol instance that this driver is producing. - @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this - parameter is NULL, then a new handle is created. - @param ComponentName A Component Name Protocol instance that this driver is producing. - @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing. - @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing. - @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing. - @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing. - - @retval EFI_SUCCESS The protocol installation is completed successfully. - @retval Others Status from gBS->InstallMultipleProtocolInterfaces(). - -**/ -EFI_STATUS -EFIAPI -EfiLibInstallAllDriverProtocols2 ( - IN CONST EFI_HANDLE ImageHandle, - IN CONST EFI_SYSTEM_TABLE *SystemTable, - IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, - IN EFI_HANDLE DriverBindingHandle, - IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL - IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL - IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL - IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL - IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL - ) -{ - EFI_STATUS Status; - - ASSERT (NULL != DriverBinding); - - if (DriverConfiguration == NULL) { - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } else { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } - } else { - if (DriverDiagnostics == NULL || FeaturePcdGet(PcdDriverDiagnosticsDisable)) { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } else { - if (DriverDiagnostics2 == NULL || FeaturePcdGet(PcdDriverDiagnostics2Disable)) { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - NULL - ); - } - } - } else { - if (ComponentName == NULL || FeaturePcdGet(PcdComponentNameDisable)) { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } else { - if (ComponentName2 == NULL || FeaturePcdGet(PcdComponentName2Disable)) { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } else { - Status = gBS->InstallMultipleProtocolInterfaces ( - &DriverBindingHandle, - &gEfiDriverBindingProtocolGuid, DriverBinding, - &gEfiComponentNameProtocolGuid, ComponentName, - &gEfiComponentName2ProtocolGuid, ComponentName2, - &gEfiDriverConfigurationProtocolGuid, DriverConfiguration, - &gEfiDriverDiagnosticsProtocolGuid, DriverDiagnostics, - &gEfiDriverDiagnostics2ProtocolGuid, DriverDiagnostics2, - NULL - ); - } - } - } - } - } - - // - // ASSERT if the call to InstallMultipleProtocolInterfaces() failed - // - ASSERT_EFI_ERROR (Status); - - // - // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol - // - DriverBinding->ImageHandle = ImageHandle; - DriverBinding->DriverBindingHandle = DriverBindingHandle; - - return Status; -} - - diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLib.c b/IntelFrameworkPkg/Library/UefiLibFramework/UefiLib.c deleted file mode 100644 index 65c7641b74..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLib.c +++ /dev/null @@ -1,813 +0,0 @@ -/** @file - Mde UEFI library functions. - - Copyright (c) 2006 - 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: UefiLib.c - -**/ - -#include "UefiLibFramework.h" - -/** - Compare whether two names of languages are identical. - - @param Language1 Name of language 1. - @param Language2 Name of language 2. - - @retval TRUE Language 1 and language 2 are the same. - @retval FALSE Language 1 and language 2 are not the same. - -**/ -STATIC -BOOLEAN -CompareIso639LanguageCode ( - IN CONST CHAR8 *Language1, - IN CONST CHAR8 *Language2 - ) -{ - UINT32 Name1; - UINT32 Name2; - - Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1); - Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2); - - return (BOOLEAN) (Name1 == Name2); -} - -/** - This function searches the list of configuration tables stored in the EFI System - Table for a table with a GUID that matches TableGuid. If a match is found, - then a pointer to the configuration table is returned in Table, and EFI_SUCCESS - is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. - - @param TableGuid Pointer to table's GUID type.. - @param Table Pointer to the table associated with TableGuid in the EFI System Table. - - @retval EFI_SUCCESS A configuration table matching TableGuid was found. - @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. - -**/ -EFI_STATUS -EFIAPI -EfiGetSystemConfigurationTable ( - IN EFI_GUID *TableGuid, - OUT VOID **Table - ) -{ - EFI_SYSTEM_TABLE *SystemTable; - UINTN Index; - - ASSERT (TableGuid != NULL); - ASSERT (Table != NULL); - - SystemTable = gST; - *Table = NULL; - for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { - if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) { - *Table = SystemTable->ConfigurationTable[Index].VendorTable; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} - -/** - This function causes the notification function to be executed for every protocol - of type ProtocolGuid instance that exists in the system when this function is - invoked. In addition, every time a protocol of type ProtocolGuid instance is - installed or reinstalled, the notification function is also executed. - - @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired. - @param NotifyTpl Supplies the task priority level of the event notifications. - @param NotifyFunction Supplies the function to notify when the event is signaled. - @param NotifyContext The context parameter to pass to NotifyFunction. - @param Registration A pointer to a memory location to receive the registration value. - - @return The notification event that was created. - -**/ -EFI_EVENT -EFIAPI -EfiCreateProtocolNotifyEvent( - IN EFI_GUID *ProtocolGuid, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, - IN VOID *NotifyContext, OPTIONAL - OUT VOID **Registration - ) -{ - EFI_STATUS Status; - EFI_EVENT Event; - - // - // Create the event - // - - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - &Event - ); - ASSERT_EFI_ERROR (Status); - - // - // Register for protocol notifactions on this event - // - - Status = gBS->RegisterProtocolNotify ( - ProtocolGuid, - Event, - Registration - ); - - ASSERT_EFI_ERROR (Status); - - // - // Kick the event so we will perform an initial pass of - // current installed drivers - // - - gBS->SignalEvent (Event); - return Event; -} - -/** - This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. - This event is signaled with EfiNamedEventSignal(). This provide the ability for - one or more listeners on the same event named by the GUID specified by Name. - - @param Name Supplies GUID name of the event. - @param NotifyTpl Supplies the task priority level of the event notifications. - @param NotifyFunction Supplies the function to notify when the event is signaled. - @param NotifyContext The context parameter to pass to NotifyFunction. - @param Registration A pointer to a memory location to receive the registration value. - - @retval EFI_SUCCESS A named event was created. - @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event. - -**/ -EFI_STATUS -EFIAPI -EfiNamedEventListen ( - IN CONST EFI_GUID *Name, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, - IN CONST VOID *NotifyContext, OPTIONAL - OUT VOID *Registration OPTIONAL - ) -{ - EFI_STATUS Status; - EFI_EVENT Event; - VOID *RegistrationLocal; - - // - // Create event - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - (VOID *) NotifyContext, - &Event - ); - ASSERT_EFI_ERROR (Status); - - // - // The Registration is not optional to RegisterProtocolNotify(). - // To make it optional to EfiNamedEventListen(), may need to substitute with a local. - // - if (Registration != NULL) { - RegistrationLocal = Registration; - } else { - RegistrationLocal = &RegistrationLocal; - } - - // - // Register for an installation of protocol interface - // - - Status = gBS->RegisterProtocolNotify ( - (EFI_GUID *) Name, - Event, - RegistrationLocal - ); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} - -/** - This function signals the named event specified by Name. The named event must - have been created with EfiNamedEventListen(). - - @param Name Supplies GUID name of the event. - - @retval EFI_SUCCESS A named event was signaled. - @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event. - -**/ -EFI_STATUS -EFIAPI -EfiNamedEventSignal ( - IN CONST EFI_GUID *Name - ) -{ - EFI_STATUS Status; - EFI_HANDLE Handle; - - Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Handle, - (EFI_GUID *) Name, - EFI_NATIVE_INTERFACE, - NULL - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->UninstallProtocolInterface ( - Handle, - (EFI_GUID *) Name, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} - -/** - Returns the current TPL. - - This function returns the current TPL. There is no EFI service to directly - retrieve the current TPL. Instead, the RaiseTPL() function is used to raise - the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level - can then immediately be restored back to the current TPL level with a call - to RestoreTPL(). - - @param VOID - - @retvale EFI_TPL The current TPL. - -**/ -EFI_TPL -EFIAPI -EfiGetCurrentTpl ( - VOID - ) -{ - EFI_TPL Tpl; - - Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); - gBS->RestoreTPL (Tpl); - - return Tpl; -} - - -/** - This function initializes a basic mutual exclusion lock to the released state - and returns the lock. Each lock provides mutual exclusion access at its task - priority level. Since there is no preemption or multiprocessor support in EFI, - acquiring the lock only consists of raising to the locks TPL. - - @param Lock A pointer to the lock data structure to initialize. - @param Priority EFI TPL associated with the lock. - - @return The lock. - -**/ -EFI_LOCK * -EFIAPI -EfiInitializeLock ( - IN OUT EFI_LOCK *Lock, - IN EFI_TPL Priority - ) -{ - ASSERT (Lock != NULL); - ASSERT (Priority <= TPL_HIGH_LEVEL); - - Lock->Tpl = Priority; - Lock->OwnerTpl = TPL_APPLICATION; - Lock->Lock = EfiLockReleased ; - return Lock; -} - -/** - This function raises the system's current task priority level to the task - priority level of the mutual exclusion lock. Then, it places the lock in the - acquired state. - - @param Priority The task priority level of the lock. - -**/ -VOID -EFIAPI -EfiAcquireLock ( - IN EFI_LOCK *Lock - ) -{ - ASSERT (Lock != NULL); - ASSERT (Lock->Lock == EfiLockReleased); - - Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); - Lock->Lock = EfiLockAcquired; -} - -/** - This function raises the system's current task priority level to the task - priority level of the mutual exclusion lock. Then, it attempts to place the - lock in the acquired state. - - @param Lock A pointer to the lock to acquire. - - @retval EFI_SUCCESS The lock was acquired. - @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned. - -**/ -EFI_STATUS -EFIAPI -EfiAcquireLockOrFail ( - IN EFI_LOCK *Lock - ) -{ - - ASSERT (Lock != NULL); - ASSERT (Lock->Lock != EfiLockUninitialized); - - if (Lock->Lock == EfiLockAcquired) { - // - // Lock is already owned, so bail out - // - return EFI_ACCESS_DENIED; - } - - Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); - - Lock->Lock = EfiLockAcquired; - - return EFI_SUCCESS; -} - -/** - This function transitions a mutual exclusion lock from the acquired state to - the released state, and restores the system's task priority level to its - previous level. - - @param Lock A pointer to the lock to release. - -**/ -VOID -EFIAPI -EfiReleaseLock ( - IN EFI_LOCK *Lock - ) -{ - EFI_TPL Tpl; - - ASSERT (Lock != NULL); - ASSERT (Lock->Lock == EfiLockAcquired); - - Tpl = Lock->OwnerTpl; - - Lock->Lock = EfiLockReleased; - - gBS->RestoreTPL (Tpl); -} - -/** - Tests whether a controller handle is being managed by a specific driver. - - This function tests whether the driver specified by DriverBindingHandle is - currently managing the controller specified by ControllerHandle. This test - is performed by evaluating if the the protocol specified by ProtocolGuid is - present on ControllerHandle and is was opened by DriverBindingHandle with an - attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. - If ProtocolGuid is NULL, then ASSERT(). - - @param ControllerHandle A handle for a controller to test. - @param DriverBindingHandle Specifies the driver binding handle for the - driver. - @param ProtocolGuid Specifies the protocol that the driver specified - by DriverBindingHandle opens in its Start() - function. - - @retval EFI_SUCCESS ControllerHandle is managed by the driver - specifed by DriverBindingHandle. - @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver - specifed by DriverBindingHandle. - -**/ -EFI_STATUS -EFIAPI -EfiTestManagedDevice ( - IN CONST EFI_HANDLE ControllerHandle, - IN CONST EFI_HANDLE DriverBindingHandle, - IN CONST EFI_GUID *ProtocolGuid - ) -{ - EFI_STATUS Status; - VOID *ManagedInterface; - - ASSERT (ProtocolGuid != NULL); - - Status = gBS->OpenProtocol ( - ControllerHandle, - (EFI_GUID *) ProtocolGuid, - &ManagedInterface, - DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (!EFI_ERROR (Status)) { - gBS->CloseProtocol ( - ControllerHandle, - (EFI_GUID *) ProtocolGuid, - DriverBindingHandle, - ControllerHandle - ); - return EFI_UNSUPPORTED; - } - - if (Status != EFI_ALREADY_STARTED) { - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - -/** - Tests whether a child handle is a child device of the controller. - - This function tests whether ChildHandle is one of the children of - ControllerHandle. This test is performed by checking to see if the protocol - specified by ProtocolGuid is present on ControllerHandle and opened by - ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. - If ProtocolGuid is NULL, then ASSERT(). - - @param ControllerHandle A handle for a (parent) controller to test. - @param ChildHandle A child handle to test. - @param ConsumsedGuid Supplies the protocol that the child controller - opens on its parent controller. - - @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. - @retval EFI_UNSUPPORTED ChildHandle is not a child of the - ControllerHandle. - -**/ -EFI_STATUS -EFIAPI -EfiTestChildHandle ( - IN CONST EFI_HANDLE ControllerHandle, - IN CONST EFI_HANDLE ChildHandle, - IN CONST EFI_GUID *ProtocolGuid - ) -{ - EFI_STATUS Status; - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; - UINTN EntryCount; - UINTN Index; - - ASSERT (ProtocolGuid != NULL); - - // - // Retrieve the list of agents that are consuming the specific protocol - // on ControllerHandle. - // - Status = gBS->OpenProtocolInformation ( - ControllerHandle, - (EFI_GUID *) ProtocolGuid, - &OpenInfoBuffer, - &EntryCount - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - // - // Inspect if ChildHandle is one of the agents. - // - Status = EFI_UNSUPPORTED; - for (Index = 0; Index < EntryCount; Index++) { - if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) && - (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { - Status = EFI_SUCCESS; - break; - } - } - - FreePool (OpenInfoBuffer); - return Status; -} - -/** - This function looks up a Unicode string in UnicodeStringTable. If Language is - a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable - that matches the language code specified by Language, then it is returned in - UnicodeString. - - @param Language A pointer to the ISO 639-2 language code for the - Unicode string to look up and return. - @param SupportedLanguages A pointer to the set of ISO 639-2 language codes - that the Unicode string table supports. Language - must be a member of this set. - @param UnicodeStringTable A pointer to the table of Unicode strings. - @param UnicodeString A pointer to the Unicode string from UnicodeStringTable - that matches the language specified by Language. - - @retval EFI_SUCCESS The Unicode string that matches the language - specified by Language was found - in the table of Unicoide strings UnicodeStringTable, - and it was returned in UnicodeString. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is NULL. - @retval EFI_UNSUPPORTED SupportedLanguages is NULL. - @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. - @retval EFI_UNSUPPORTED The language specified by Language is not a - member of SupportedLanguages. - @retval EFI_UNSUPPORTED The language specified by Language is not - supported by UnicodeStringTable. - -**/ -EFI_STATUS -EFIAPI -LookupUnicodeString ( - IN CONST CHAR8 *Language, - IN CONST CHAR8 *SupportedLanguages, - IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, - OUT CHAR16 **UnicodeString - ) -{ - // - // Make sure the parameters are valid - // - if (Language == NULL || UnicodeString == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // If there are no supported languages, or the Unicode String Table is empty, then the - // Unicode String specified by Language is not supported by this Unicode String Table - // - if (SupportedLanguages == NULL || UnicodeStringTable == NULL) { - return EFI_UNSUPPORTED; - } - - // - // Make sure Language is in the set of Supported Languages - // - while (*SupportedLanguages != 0) { - if (CompareIso639LanguageCode (Language, SupportedLanguages)) { - - // - // Search the Unicode String Table for the matching Language specifier - // - while (UnicodeStringTable->Language != NULL) { - if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) { - - // - // A matching string was found, so return it - // - *UnicodeString = UnicodeStringTable->UnicodeString; - return EFI_SUCCESS; - } - - UnicodeStringTable++; - } - - return EFI_UNSUPPORTED; - } - - SupportedLanguages += 3; - } - - return EFI_UNSUPPORTED; -} - -/** - This function adds a Unicode string to UnicodeStringTable. - If Language is a member of SupportedLanguages then UnicodeString is added to - UnicodeStringTable. New buffers are allocated for both Language and - UnicodeString. The contents of Language and UnicodeString are copied into - these new buffers. These buffers are automatically freed when - FreeUnicodeStringTable() is called. - - @param Language A pointer to the ISO 639-2 language code for the Unicode - string to add. - @param SupportedLanguages A pointer to the set of ISO 639-2 language codes - that the Unicode string table supports. - Language must be a member of this set. - @param UnicodeStringTable A pointer to the table of Unicode strings. - @param UnicodeString A pointer to the Unicode string to add. - - @retval EFI_SUCCESS The Unicode string that matches the language - specified by Language was found in the table of - Unicode strings UnicodeStringTable, and it was - returned in UnicodeString. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is NULL. - @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. - @retval EFI_UNSUPPORTED SupportedLanguages is NULL. - @retval EFI_ALREADY_STARTED A Unicode string with language Language is - already present in UnicodeStringTable. - @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another - Unicode string to UnicodeStringTable. - @retval EFI_UNSUPPORTED The language specified by Language is not a - member of SupportedLanguages. - -**/ -EFI_STATUS -EFIAPI -AddUnicodeString ( - IN CONST CHAR8 *Language, - IN CONST CHAR8 *SupportedLanguages, - IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable, - IN CONST CHAR16 *UnicodeString - ) -{ - UINTN NumberOfEntries; - EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable; - EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable; - UINTN UnicodeStringLength; - - // - // Make sure the parameter are valid - // - if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // If there are no supported languages, then a Unicode String can not be added - // - if (SupportedLanguages == NULL) { - return EFI_UNSUPPORTED; - } - - // - // If the Unicode String is empty, then a Unicode String can not be added - // - if (UnicodeString[0] == 0) { - return EFI_INVALID_PARAMETER; - } - - // - // Make sure Language is a member of SupportedLanguages - // - while (*SupportedLanguages != 0) { - if (CompareIso639LanguageCode (Language, SupportedLanguages)) { - - // - // Determine the size of the Unicode String Table by looking for a NULL Language entry - // - NumberOfEntries = 0; - if (*UnicodeStringTable != NULL) { - OldUnicodeStringTable = *UnicodeStringTable; - while (OldUnicodeStringTable->Language != NULL) { - if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) { - return EFI_ALREADY_STARTED; - } - - OldUnicodeStringTable++; - NumberOfEntries++; - } - } - - // - // Allocate space for a new Unicode String Table. It must hold the current number of - // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table - // marker - // - NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE)); - if (NewUnicodeStringTable == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // If the current Unicode String Table contains any entries, then copy them to the - // newly allocated Unicode String Table. - // - if (*UnicodeStringTable != NULL) { - CopyMem ( - NewUnicodeStringTable, - *UnicodeStringTable, - NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE) - ); - } - - // - // Allocate space for a copy of the Language specifier - // - NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language); - if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) { - gBS->FreePool (NewUnicodeStringTable); - return EFI_OUT_OF_RESOURCES; - } - - // - // Compute the length of the Unicode String - // - for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) - ; - - // - // Allocate space for a copy of the Unicode String - // - NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool ( - (UnicodeStringLength + 1) * sizeof (CHAR16), - UnicodeString - ); - if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) { - gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language); - gBS->FreePool (NewUnicodeStringTable); - return EFI_OUT_OF_RESOURCES; - } - - // - // Mark the end of the Unicode String Table - // - NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL; - NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL; - - // - // Free the old Unicode String Table - // - if (*UnicodeStringTable != NULL) { - gBS->FreePool (*UnicodeStringTable); - } - - // - // Point UnicodeStringTable at the newly allocated Unicode String Table - // - *UnicodeStringTable = NewUnicodeStringTable; - - return EFI_SUCCESS; - } - - SupportedLanguages += 3; - } - - return EFI_UNSUPPORTED; -} - -/** - This function frees the table of Unicode strings in UnicodeStringTable. - If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. - Otherwise, each language code, and each Unicode string in the Unicode string - table are freed, and EFI_SUCCESS is returned. - - @param UnicodeStringTable A pointer to the table of Unicode strings. - - @retval EFI_SUCCESS The Unicode string table was freed. - -**/ -EFI_STATUS -EFIAPI -FreeUnicodeStringTable ( - IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable - ) -{ - UINTN Index; - - // - // If the Unicode String Table is NULL, then it is already freed - // - if (UnicodeStringTable == NULL) { - return EFI_SUCCESS; - } - - // - // Loop through the Unicode String Table until we reach the end of table marker - // - for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) { - - // - // Free the Language string from the Unicode String Table - // - gBS->FreePool (UnicodeStringTable[Index].Language); - - // - // Free the Unicode String from the Unicode String Table - // - if (UnicodeStringTable[Index].UnicodeString != NULL) { - gBS->FreePool (UnicodeStringTable[Index].UnicodeString); - } - } - - // - // Free the Unicode String Table itself - // - gBS->FreePool (UnicodeStringTable); - - return EFI_SUCCESS; -} - diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.h b/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.h deleted file mode 100644 index 913b653335..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.h +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - Header file to include header files common to all source files in - UefiLibFramework. - - 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: UefiLibFramework.h - -**/ - -#ifndef _UEFI_LIB_FRAMEWORK_H_ -#define _UEFI_LIB_FRAMEWORK_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.inf b/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.inf deleted file mode 100644 index c5f227eada..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.inf +++ /dev/null @@ -1,80 +0,0 @@ -#/** @file -# Component description file for the entry point to a EFIDXE Drivers -# -# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification -# -# Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the oldconflicts with library functions and supporting implementations of the old -# (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as it contains DXE enum extensions for EFI event services. -# Copyright (c) 2006, 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. -# -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = UefiLibFramework - FILE_GUID = B2F0D71A-A39F-4094-854B-0C6BA6910CCE - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = UefiLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER - EDK_RELEASE_VERSION = 0x00020000 - EFI_SPECIFICATION_VERSION = 0x00020000 - - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources.common] - UefiLibPrint.c - UefiNotTiano.c - Console.c - UefiLib.c - UefiDriverModel.c - -[Packages] - MdePkg/MdePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - - -[LibraryClasses] - PrintLib - PcdLib - MemoryAllocationLib - DebugLib - BaseMemoryLib - BaseLib - UefiBootServicesTableLib - -[Protocols] - gEfiDriverBindingProtocolGuid # ALWAYS_CONSUMED - gEfiComponentNameProtocolGuid # SOMETIMES_CONSUMED - gEfiComponentName2ProtocolGuid # SOMETIMES_CONSUMED - gEfiDriverConfigurationProtocolGuid # SOMETIMES_CONSUMED - gEfiDriverDiagnosticsProtocolGuid # SOMETIMES_CONSUMED - gEfiDriverDiagnostics2ProtocolGuid # SOMETIMES_CONSUMED - gEfiFirmwareVolume2ProtocolGuid # ALWAYS_CONSUMED - -[Guids] - gEfiFrameworkDevicePathGuid # ALWAYS_CONSUMED - gEfiEventReadyToBootGuid # ALWAYS_CONSUMED - gEfiEventLegacyBootGuid # ALWAYS_CONSUMED - - -[Pcd.common] - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize - -[FeaturePcd.common] - gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable - gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable - gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable - gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.msa b/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.msa deleted file mode 100644 index 49866165f7..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibFramework.msa +++ /dev/null @@ -1,84 +0,0 @@ - - - - UefiLib - DXE_DRIVER - B2F0D71A-A39F-4094-854B-0C6BA6910CCE - 1.0 - Component description file for the entry point to a EFIDXE Drivers - Library to abstract Framework extensions that conflict with UEFI 2.0 Specification - - Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the oldconflicts with library functions and supporting implementations of the old - (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as it contains DXE enum extensions for EFI event services. - Copyright (c) 2006, 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. - FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 - - - IA32 X64 IPF EBC - false - UefiLib - - - - UefiLib - - - UefiBootServicesTableLib - - - BaseLib - - - BaseMemoryLib - - - DebugLib - - - MemoryAllocationLib - - - PcdLib - - - PrintLib - - - - UefiLib.c - Console.c - UefiNotTiano.c - UefiLibPrint.c - - - - - - - gEfiEventLegacyBootGuid - - - gEfiEventReadyToBootGuid - - - gEfiFrameworkDevicePathGuid - - - - EFI_SPECIFICATION_VERSION 0x00020000 - EDK_RELEASE_VERSION 0x00020000 - - - - PcdUefiLibMaxPrintBufferSize - gEfiMdePkgTokenSpaceGuid - This PCD is used by UefiLib APIs, which are Print, ErrorPrint, AsciiPrint, AsciiErrorPrint. If the length of the formatted Unicode or ASCII string is greater than PcdUefiLibMaxPrintBufferSize, then only the first (PcdUefiLibMaxPrintBufferSize / Sizeof(CHAR16)) Unicode characters or PcdUefiLibMaxPrintBufferSize Ascii characters are sent to the respective console. - - - \ No newline at end of file diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibPrint.c b/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibPrint.c deleted file mode 100644 index 9a7592e9e6..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/UefiLibPrint.c +++ /dev/null @@ -1,261 +0,0 @@ -/** @file - Mde UEFI library API implemention. - Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE - - 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 "UefiLibFramework.h" - -/** - Internal function which prints a formatted Unicode string to the console output device - specified by Console - - This function prints a formatted Unicode string to the console output device - specified by Console and returns the number of Unicode characters that printed - to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize, - then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console. - - @param Format Null-terminated Unicode format string. - @param Console The output console. - @param Marker VA_LIST marker for the variable argument list. - - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - -**/ - -STATIC -UINTN -InternalPrint ( - IN CONST CHAR16 *Format, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console, - IN VA_LIST Marker - ) -{ - UINTN Return; - CHAR16 *Buffer; - UINTN BufferSize; - - ASSERT (Format != NULL); - ASSERT (((UINTN) Format & 0x01) == 0); - - BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); - - Buffer = (CHAR16 *) AllocatePool(BufferSize); - ASSERT (Buffer != NULL); - - Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); - - if (Console != NULL) { - // - // To be extra safe make sure Console has been initialized - // - Console->OutputString (Console, Buffer); - } - - FreePool (Buffer); - - return Return; -} - -/** - Prints a formatted Unicode string to the console output device specified by - ConOut defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted Unicode string to the console output device - specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode - characters that printed to ConOut. If the length of the formatted Unicode - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. - - @param Format Null-terminated Unicode format string. - @param ... VARARG list consumed to process Format. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - -**/ -UINTN -EFIAPI -Print ( - IN CONST CHAR16 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - - VA_START (Marker, Format); - - Return = InternalPrint (Format, gST->ConOut, Marker); - - VA_END (Marker); - - return Return; -} - -/** - Prints a formatted Unicode string to the console output device specified by - StdErr defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted Unicode string to the console output device - specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode - characters that printed to StdErr. If the length of the formatted Unicode - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. - - @param Format Null-terminated Unicode format string. - @param ... VARARG list consumed to process Format. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - -**/ - -UINTN -EFIAPI -ErrorPrint ( - IN CONST CHAR16 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - - VA_START (Marker, Format); - - Return = InternalPrint( Format, gST->StdErr, Marker); - - VA_END (Marker); - - return Return; -} - - -/** - Internal function which prints a formatted ASCII string to the console output device - specified by Console - - This function prints a formatted ASCII string to the console output device - specified by Console and returns the number of ASCII characters that printed - to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, - then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console. - - @param Format Null-terminated ASCII format string. - @param Console The output console. - @param Marker VA_LIST marker for the variable argument list. - - If Format is NULL, then ASSERT(). - -**/ - -STATIC -UINTN -AsciiInternalPrint ( - IN CONST CHAR8 *Format, - IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console, - IN VA_LIST Marker - ) -{ - UINTN Return; - CHAR16 *Buffer; - UINTN BufferSize; - - ASSERT (Format != NULL); - - BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16); - - Buffer = (CHAR16 *) AllocatePool(BufferSize); - ASSERT (Buffer != NULL); - - Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker); - - if (Console != NULL) { - // - // To be extra safe make sure Console has been initialized - // - Console->OutputString (Console, Buffer); - } - - FreePool (Buffer); - - return Return; -} - -/** - Prints a formatted ASCII string to the console output device specified by - ConOut defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted ASCII string to the console output device - specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII - characters that printed to ConOut. If the length of the formatted ASCII - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. - - @param Format Null-terminated ASCII format string. - @param ... VARARG list consumed to process Format. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - -**/ -UINTN -EFIAPI -AsciiPrint ( - IN CONST CHAR8 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - - VA_START (Marker, Format); - - Return = AsciiInternalPrint( Format, gST->ConOut, Marker); - - VA_END (Marker); - - return Return; -} - -/** - Prints a formatted ASCII string to the console output device specified by - StdErr defined in the EFI_SYSTEM_TABLE. - - This function prints a formatted ASCII string to the console output device - specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII - characters that printed to StdErr. If the length of the formatted ASCII - string is greater than PcdUefiLibMaxPrintBufferSize, then only the first - PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. - - @param Format Null-terminated ASCII format string. - @param ... VARARG list consumed to process Format. - If Format is NULL, then ASSERT(). - If Format is not aligned on a 16-bit boundary, then ASSERT(). - -**/ -UINTN -EFIAPI -AsciiErrorPrint ( - IN CONST CHAR8 *Format, - ... - ) -{ - VA_LIST Marker; - UINTN Return; - - VA_START (Marker, Format); - - Return = AsciiInternalPrint( Format, gST->StdErr, Marker); - - VA_END (Marker); - - return Return; -} - diff --git a/IntelFrameworkPkg/Library/UefiLibFramework/UefiNotTiano.c b/IntelFrameworkPkg/Library/UefiLibFramework/UefiNotTiano.c deleted file mode 100644 index b920db01e1..0000000000 --- a/IntelFrameworkPkg/Library/UefiLibFramework/UefiNotTiano.c +++ /dev/null @@ -1,360 +0,0 @@ -/** @file - Library functions that abstract areas of conflict between Tiano an UEFI 2.1. - - Help Port Framework/Tinao code that has conflicts with UEFI 2.1 by hiding the - oldconflicts with library functions and supporting implementations of the old - (EDK/EFI 1.10) and new (EDK II/UEFI 2.1) way. This module is a DXE driver as - it contains DXE enum extensions for EFI event services. - -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 "UefiLibFramework.h" - -/** - An empty function to pass error checking of CreateEventEx (). - - This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error - checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0. - -**/ -STATIC -VOID -EFIAPI -InternalEmptyFuntion ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - return; -} - -/** - Create a Legacy Boot Event. - - Tiano extended the CreateEvent Type enum to add a legacy boot event type. - This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was - added and now it's possible to not voilate the UEFI specification by - declaring a GUID for the legacy boot event class. This library supports - the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to - work both ways. - - @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventLegacyBoot ( - OUT EFI_EVENT *LegacyBootEvent - ) -{ - return EfiCreateEventLegacyBootEx ( - TPL_CALLBACK, - InternalEmptyFuntion, - NULL, - LegacyBootEvent - ); -} - -/** - Create an EFI event in the Legacy Boot Event Group and allows - the caller to specify a notification function. - - This function abstracts the creation of the Legacy Boot Event. - The Framework moved from a proprietary to UEFI 2.0 based mechanism. - This library abstracts the caller from how this event is created to prevent - to code form having to change with the version of the specification supported. - If LegacyBootEvent is NULL, then ASSERT(). - - @param NotifyTpl The task priority level of the event. - @param NotifyFunction The notification function to call when the event is signaled. - @param NotifyContext The content to pass to NotifyFunction when the event is signaled. - @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventLegacyBootEx ( - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN VOID *NotifyContext, OPTIONAL - OUT EFI_EVENT *LegacyBootEvent - ) -{ - EFI_STATUS Status; - - ASSERT (LegacyBootEvent != NULL); - - if (gST->Hdr.Revision < 0x00020000) { - // - // prior to UEFI 2.0 use Tiano extension to EFI - // - Status = gBS->CreateEvent ( - EFI_EVENT_SIGNAL_LEGACY_BOOT | EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - LegacyBootEvent - ); - } else { - // - // For UEFI 2.0 and the future use an Event Group - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - &gEfiEventLegacyBootGuid, - LegacyBootEvent - ); - } - - return Status; -} - -/** - Create a Read to Boot Event. - - Tiano extended the CreateEvent Type enum to add a ready to boot event type. - This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was - added and now it's possible to not voilate the UEFI specification and use - the ready to boot event class defined in UEFI 2.0. This library supports - the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to - work both ways. - - @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventReadyToBoot ( - OUT EFI_EVENT *ReadyToBootEvent - ) -{ - return EfiCreateEventReadyToBootEx ( - TPL_CALLBACK, - InternalEmptyFuntion, - NULL, - ReadyToBootEvent - ); -} - -/** - Create an EFI event in the Ready To Boot Event Group and allows - the caller to specify a notification function. - - This function abstracts the creation of the Ready to Boot Event. - The Framework moved from a proprietary to UEFI 2.0 based mechanism. - This library abstracts the caller from how this event is created to prevent - to code form having to change with the version of the specification supported. - If ReadyToBootEvent is NULL, then ASSERT(). - - @param NotifyTpl The task priority level of the event. - @param NotifyFunction The notification function to call when the event is signaled. - @param NotifyContext The content to pass to NotifyFunction when the event is signaled. - @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). - - @retval EFI_SUCCESS Event was created. - @retval Other Event was not created. - -**/ -EFI_STATUS -EFIAPI -EfiCreateEventReadyToBootEx ( - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN VOID *NotifyContext, OPTIONAL - OUT EFI_EVENT *ReadyToBootEvent - ) -{ - EFI_STATUS Status; - - ASSERT (ReadyToBootEvent != NULL); - - if (gST->Hdr.Revision < 0x00020000) { - // - // prior to UEFI 2.0 use Tiano extension to EFI - // - Status = gBS->CreateEvent ( - EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL, - NotifyTpl, - NotifyFunction, - NotifyContext, - ReadyToBootEvent - ); - } else { - // - // For UEFI 2.0 and the future use an Event Group - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - NotifyTpl, - NotifyFunction, - NotifyContext, - &gEfiEventReadyToBootGuid, - ReadyToBootEvent - ); - } - - return Status; -} - - -/** - Signal a Ready to Boot Event. - - Create a Ready to Boot Event. Signal it and close it. This causes other - events of the same event group to be signaled in other modules. - -**/ -VOID -EFIAPI -EfiSignalEventReadyToBoot ( - VOID - ) -{ - EFI_STATUS Status; - EFI_EVENT ReadyToBootEvent; - - Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent); - if (!EFI_ERROR (Status)) { - gBS->SignalEvent (ReadyToBootEvent); - gBS->CloseEvent (ReadyToBootEvent); - } -} - -/** - Signal a Legacy Boot Event. - - Create a legacy Boot Event. Signal it and close it. This causes other - events of the same event group to be signaled in other modules. - -**/ -VOID -EFIAPI -EfiSignalEventLegacyBoot ( - VOID - ) -{ - EFI_STATUS Status; - EFI_EVENT LegacyBootEvent; - - Status = EfiCreateEventLegacyBoot (&LegacyBootEvent); - if (!EFI_ERROR (Status)) { - gBS->SignalEvent (LegacyBootEvent); - gBS->CloseEvent (LegacyBootEvent); - } -} - - -/** - Check to see if the Firmware Volume (FV) Media Device Path is valid - - Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum - so as we move to UEFI 2.0 support we must use a mechanism that conforms with - the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed - device path is defined for Tiano extensions of device path. If the code - is compiled to conform with the UEFI 2.0 specification use the new device path - else use the old form for backwards compatability. The return value to this - function points to a location in FvDevicePathNode and it does not allocate - new memory for the GUID pointer that is returned. - - @param FvDevicePathNode Pointer to FV device path to check. - - @retval NULL FvDevicePathNode is not valid. - @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned. - -**/ -EFI_GUID * -EFIAPI -EfiGetNameGuidFromFwVolDevicePathNode ( - IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode - ) -{ - FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FrameworkFvDevicePathNode; - - ASSERT (FvDevicePathNode != NULL); - - FrameworkFvDevicePathNode = (FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) FvDevicePathNode; - // - // Use the new Device path that does not conflict with the UEFI - // - if (DevicePathType (&FrameworkFvDevicePathNode->Tiano.Header) == MEDIA_DEVICE_PATH && - DevicePathSubType (&FrameworkFvDevicePathNode->Tiano.Header) == MEDIA_VENDOR_DP) { - if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FrameworkFvDevicePathNode->Tiano.TianoSpecificDevicePath)) { - if (FrameworkFvDevicePathNode->Tiano.Type == TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) { - return (EFI_GUID *) &FrameworkFvDevicePathNode->NameGuid; - } - } - } - - return NULL; -} - - -/** - Initialize a Firmware Volume (FV) Media Device Path node. - - Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum - so as we move to UEFI 2.0 support we must use a mechanism that conforms with - the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed - device path is defined for Tiano extensions of device path. If the code - is compiled to conform with the UEFI 2.0 specification use the new device path - else use the old form for backwards compatability. - - @param FvDevicePathNode Pointer to a FV device path node to initialize - @param NameGuid FV file name to use in FvDevicePathNode - -**/ -VOID -EFIAPI -EfiInitializeFwVolDevicepathNode ( - IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, - IN CONST EFI_GUID *NameGuid - ) -{ - FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FrameworkFvDevicePathNode; - - ASSERT (FvDevicePathNode != NULL); - ASSERT (NameGuid != NULL); - - FrameworkFvDevicePathNode = (FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) FvDevicePathNode; - - // - // Use the new Device path that does not conflict with the UEFI - // - FrameworkFvDevicePathNode->Tiano.Header.Type = MEDIA_DEVICE_PATH; - FrameworkFvDevicePathNode->Tiano.Header.SubType = MEDIA_VENDOR_DP; - SetDevicePathNodeLength (&FrameworkFvDevicePathNode->Tiano.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); - - // - // Add the GUID for generic Tiano device paths - // - CopyGuid (&FrameworkFvDevicePathNode->Tiano.TianoSpecificDevicePath, &gEfiFrameworkDevicePathGuid); - - // - // Add in the FW Vol File Path Tiano defined information - // - FrameworkFvDevicePathNode->Tiano.Type = TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE; - - CopyGuid (&FrameworkFvDevicePathNode->NameGuid, NameGuid); -} - diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 5f3be975fc..6e62654fee 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -116,7 +116,7 @@ FvbServiceLib|MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf ScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf UsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h index 115d237415..98780f704a 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h @@ -24,7 +24,7 @@ Revision History #define _GRAPHICS_CONSOLE_H #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ Revision History #include #include #include -#include +#include #include #include #include diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf index 768e8cbcfa..013bc18389 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf @@ -52,7 +52,7 @@ UefiLib UefiDriverEntryPoint DebugLib - HiiLibFramework + FrameworkHiiLib [Protocols] gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED diff --git a/Nt32Pkg/CpuRuntimeDxe/CpuDriver.h b/Nt32Pkg/CpuRuntimeDxe/CpuDriver.h index b539928607..54ab820a56 100644 --- a/Nt32Pkg/CpuRuntimeDxe/CpuDriver.h +++ b/Nt32Pkg/CpuRuntimeDxe/CpuDriver.h @@ -26,14 +26,14 @@ Abstract: #include #include #include -#include +#include #include #include #include #include #include #include -#include +#include #include #include #include diff --git a/Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf b/Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf index e16c9af829..ee76efa60b 100644 --- a/Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf +++ b/Nt32Pkg/CpuRuntimeDxe/CpuRuntimeDxe.inf @@ -48,7 +48,7 @@ MemoryAllocationLib BaseMemoryLib UefiDriverEntryPoint - HiiLibFramework + FrameworkHiiLib DebugLib [Guids] diff --git a/Nt32Pkg/Include/Library/EdkGenericBdsLib.h b/Nt32Pkg/Include/Library/EdkGenericBdsLib.h index 360407b9f4..351e4cd74c 100644 --- a/Nt32Pkg/Include/Library/EdkGenericBdsLib.h +++ b/Nt32Pkg/Include/Library/EdkGenericBdsLib.h @@ -23,7 +23,7 @@ Abstract: #define _BDS_LIB_H_ #include -#include +#include extern EFI_HANDLE mBdsImageHandle; diff --git a/Nt32Pkg/Library/EdkGenericBdsLib/EdkGenericBdsLibInternal.h b/Nt32Pkg/Library/EdkGenericBdsLib/EdkGenericBdsLibInternal.h index f94809d2b2..830e715e70 100644 --- a/Nt32Pkg/Library/EdkGenericBdsLib/EdkGenericBdsLibInternal.h +++ b/Nt32Pkg/Library/EdkGenericBdsLib/EdkGenericBdsLibInternal.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf index b0ccb41642..92a2ea4381 100644 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf @@ -69,7 +69,7 @@ BaseMemoryLib UefiDriverEntryPoint UefiLib - HiiLibFramework + FrameworkHiiLib DebugLib BaseLib PcdLib diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.h b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.h index 779d33063e..dcc52c211a 100644 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.h +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.h @@ -30,7 +30,7 @@ Abstract: #include #include #include -#include +#include #include #include #include diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index c0aed8cf20..940e6f24a1 100644 --- a/Nt32Pkg/Nt32Pkg.dsc +++ b/Nt32Pkg/Nt32Pkg.dsc @@ -59,12 +59,12 @@ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf PciIncompatibleDeviceSupportLib|IntelFrameworkModulePkg/Library/PciIncompatibleDeviceSupportLib/PciIncompatibleDeviceSupportLib.inf CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf - IfrSupportLibFramework|IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf + FrameworkIfrSupportLib|IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrSupportLib.inf GraphicsLib|IntelFrameworkModulePkg/Library/GraphicsLib/GraphicsLib.inf FvbServiceLib|MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf S3Lib|MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf RecoveryLib|MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf @@ -99,7 +99,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER] DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf ScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf @@ -153,7 +153,7 @@ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf @@ -171,7 +171,7 @@ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf ScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf @@ -188,7 +188,7 @@ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf ScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf @@ -203,7 +203,7 @@ [LibraryClasses.common.UEFI_APPLICATION] DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf ScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf - HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf + FrameworkHiiLib|IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf diff --git a/Nt32Pkg/PlatformBdsDxe/Generic/Bds.h b/Nt32Pkg/PlatformBdsDxe/Generic/Bds.h index 15f9c5f095..36e05cdb14 100644 --- a/Nt32Pkg/PlatformBdsDxe/Generic/Bds.h +++ b/Nt32Pkg/PlatformBdsDxe/Generic/Bds.h @@ -26,19 +26,19 @@ Revision History #include #include -#include +#include #include #include #include #include #include -#include +#include #include #include #include #include #include -#include +#include #include #include #include @@ -59,7 +59,7 @@ Revision History #include #include #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ Revision History #include #include #include -#include +#include #include #include diff --git a/Nt32Pkg/PlatformBdsDxe/PlatformBdsDxe.inf b/Nt32Pkg/PlatformBdsDxe/PlatformBdsDxe.inf index 70e0559606..9d2b0b0cb5 100644 --- a/Nt32Pkg/PlatformBdsDxe/PlatformBdsDxe.inf +++ b/Nt32Pkg/PlatformBdsDxe/PlatformBdsDxe.inf @@ -82,7 +82,7 @@ [LibraryClasses] PeCoffLib - HiiLibFramework + FrameworkHiiLib DevicePathLib UefiRuntimeServicesTableLib UefiBootServicesTableLib @@ -91,7 +91,7 @@ EdkGenericBdsLib HobLib ReportStatusCodeLib - IfrSupportLibFramework + FrameworkIfrSupportLib PrintLib PerformanceLib DxeServicesTableLib