IfrMatch2 should handle the case when there are regular expression protocol instances, but none of them support the requested regex type guid. The uefi spec specifies what to do in that case.
-------- Original message -------- From: Eric Dong <eric.d...@intel.com> Date: 04/30/2015 12:51 AM (GMT-06:00) To: edk2-devel@lists.sourceforge.net, liming....@intel.com Subject: [edk2] [Patch 3/3] MdeModulePkg: Add match2 opcode support in SetupBrowserDxe and sample code in DriverSampleDxe.vfr Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.d...@intel.com> --- .../Universal/DriverSampleDxe/NVDataStruc.h | 1 + MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 13 ++ .../Universal/DriverSampleDxe/VfrStrings.uni | Bin 61414 -> 62662 bytes .../Universal/SetupBrowserDxe/Expression.c | 171 ++++++++++++++++++++- MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 9 +- MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 1 + .../Universal/SetupBrowserDxe/SetupBrowserDxe.inf | 3 +- 7 files changed, 194 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h index 3c317cd..c8262a4 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -66,10 +66,11 @@ typedef struct { UINT8 SerialPortIrq; UINT8 GetDefaultValueFromCallBack; UINT8 GetDefaultValueFromAccess; EFI_HII_TIME Time; UINT8 RefreshGuidCount; + UINT8 Match2; } DRIVER_SAMPLE_CONFIGURATION; // // 2nd NV data structure definition // diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index b808abc..bd90fcd 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -44,10 +44,13 @@ #define EFI_VARIABLE_READ_ONLY 0x00000008 #define EFI_USER_INFO_ACCESS_SETUP_ADMIN_GUID \ { 0x85b75607, 0xf7ce, 0x471e, { 0xb7, 0xe4, 0x2a, 0xea, 0x5f, 0x72, 0x32, 0xee } } +#define PERL_GUID \ + { 0x63E60A51, 0x497D, 0xD427, {0xC4, 0xA5, 0xB8, 0xAB, 0xDC, 0x3A, 0xAE, 0xB6 }} + // // Labels definition // #define LABEL_1_VALUE 0x01 #define LABEL_2_VALUE 0x1000 @@ -648,10 +651,20 @@ formset step = 0, default = 0, refresh interval = 3 // Refresh interval in seconds endnumeric; + grayoutif match2 (stringref(STRING_TOKEN(STR_STRING)), stringref(STRING_TOKEN(STR_PATTERN)), PERL_GUID); + numeric + varid = MyIfrNVData.Match2, + prompt = STRING_TOKEN(STR_MATCH2_PROMPT), + help = STRING_TOKEN(STR_MATCH2_HELP), + minimum = 0, + maximum = 243, + endnumeric; + endif; + label LABEL_UPDATE2; label LABEL_END; endform; diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni index 05dba38b9e7ddb8a31842d8f56d319cbde067d1a..7053b7cc364630d9950fc9cf3103ad55adf34e18 100644 GIT binary patch delta 314 zcmaEMpZVBJ<_*u@PoCu^G5Ny^7WNPZX9f=jqsb4ewI?^cRpIw#NMtBsNM^`jFk(<( z2$^iSuv%DwL5TrfTz`owivGj~@yQSR_$Diut4&_;7G!P)LncG<<Ul*&$#=L_By&;B z&1Wb8+L6zY!jL*y@O?E2swa9WPF}EqXR@D|(&Psv8X&t!a<hRS3ug#J2!ks_5QE=j WK}JoGuep(YH+iF2sSvu4l^6gT`c&Qk delta 9 RcmX^1lKI(v<_*u@0{|TI1^@s6 diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c index e8829c1..3a015d6 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c @@ -1,9 +1,9 @@ /** @file Utility functions for expression evaluation. -Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> 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 @@ -1473,10 +1473,175 @@ Done: } return Status; } +/** + Evaluate opcode EFI_IFR_MATCH2. + + @param FormSet Formset which contains this opcode. + @param SyntaxType Syntax type for match2. + @param Result Evaluation result for this opcode. + + @retval EFI_SUCCESS Opcode evaluation success. + @retval Other Opcode evaluation failed. + +**/ +EFI_STATUS +IfrMatch2 ( + IN FORM_BROWSER_FORMSET *FormSet, + IN EFI_GUID *SyntaxType, + OUT EFI_HII_VALUE *Result + ) +{ + EFI_STATUS Status; + EFI_HII_VALUE Value[2]; + CHAR16 *String[2]; + UINTN Index; + UINTN GuidIndex; + EFI_HANDLE *HandleBuffer; + UINTN BufferSize; + EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionProtocol; + UINTN RegExSyntaxTypeListSize; + EFI_REGEX_SYNTAX_TYPE *RegExSyntaxTypeList; + UINTN CapturesCount; + + // + // String[0] - The string to search + // String[1] - pattern + // + String[0] = NULL; + String[1] = NULL; + HandleBuffer = NULL; + RegExSyntaxTypeList = NULL; + Status = EFI_SUCCESS; + ZeroMem (Value, sizeof (Value)); + + Status = PopExpression (&Value[0]); + if (EFI_ERROR (Status)) { + goto Done; + } + + Status = PopExpression (&Value[1]); + if (EFI_ERROR (Status)) { + goto Done; + } + + for (Index = 0; Index < 2; Index++) { + if (Value[Index].Type != EFI_IFR_TYPE_STRING) { + Result->Type = EFI_IFR_TYPE_UNDEFINED; + Status = EFI_SUCCESS; + goto Done; + } + + String[Index] = GetToken (Value[Index].Value.string, FormSet->HiiHandle); + if (String [Index] == NULL) { + Status = EFI_NOT_FOUND; + goto Done; + } + } + + BufferSize = 0; + HandleBuffer = NULL; + Status = gBS->LocateHandle( + ByProtocol, + &gEfiRegularExpressionProtocolGuid, + NULL, + &BufferSize, + HandleBuffer); + if (Status == EFI_BUFFER_TOO_SMALL) { + HandleBuffer = AllocateZeroPool(BufferSize); + if (HandleBuffer == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + Status = gBS->LocateHandle( + ByProtocol, + &gEfiRegularExpressionProtocolGuid, + NULL, + &BufferSize, + HandleBuffer); + + } else if (EFI_ERROR (Status)) { + Value->Type = EFI_IFR_TYPE_UNDEFINED; + Status = EFI_SUCCESS; + goto Done; + } + + for ( Index = 0; Index < BufferSize / sizeof(EFI_HANDLE); Index ++) { + Status = gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiRegularExpressionProtocolGuid, + (VOID**)&RegularExpressionProtocol + ); + + if (EFI_ERROR (Status)) { + goto Done; + } + + RegExSyntaxTypeListSize = 0; + RegExSyntaxTypeList = NULL; + + Status = RegularExpressionProtocol->GetInfo ( + RegularExpressionProtocol, + &RegExSyntaxTypeListSize, + RegExSyntaxTypeList + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + RegExSyntaxTypeList = AllocateZeroPool(RegExSyntaxTypeListSize); + if (RegExSyntaxTypeList == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + Status = RegularExpressionProtocol->GetInfo ( + RegularExpressionProtocol, + &RegExSyntaxTypeListSize, + RegExSyntaxTypeList + ); + } else if (EFI_ERROR (Status)) { + goto Done; + } + + for (GuidIndex = 0; GuidIndex < RegExSyntaxTypeListSize / sizeof(EFI_GUID); GuidIndex++) { + if (CompareGuid (&RegExSyntaxTypeList[GuidIndex], SyntaxType)) { + // + // Find the match type, return the value. + // + Result->Type = EFI_IFR_TYPE_BOOLEAN; + Status = RegularExpressionProtocol->MatchString ( + RegularExpressionProtocol, + String[0], + String[1], + SyntaxType, + &Result->Value.b, + NULL, + &CapturesCount + ); + goto Done; + } + } + + if (RegExSyntaxTypeList != NULL) { + FreePool (RegExSyntaxTypeList); + } + } + +Done: + if (String[0] != NULL) { + FreePool (String[0]); + } + if (String[1] != NULL) { + FreePool (String[1]); + } + if (RegExSyntaxTypeList != NULL) { + FreePool (RegExSyntaxTypeList); + } + if (HandleBuffer != NULL) { + FreePool (HandleBuffer); + } + return Status; +} /** Evaluate opcode EFI_IFR_FIND. @param FormSet Formset which contains this opcode. @@ -3265,10 +3430,14 @@ EvaluateExpression ( } Status = IfrMatch (FormSet, Value); break; + case EFI_IFR_MATCH2_OP: + Status = IfrMatch2 (FormSet, &OpCode->Guid, Value); + break; + case EFI_IFR_CATENATE_OP: Status = IfrCatenate (FormSet, Value); break; // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index 0e9c823..26cc638 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -1147,11 +1147,12 @@ IsExpressionOpCode ( (Operand == EFI_IFR_CATENATE_OP) || (Operand == EFI_IFR_TO_LOWER_OP) || (Operand == EFI_IFR_TO_UPPER_OP) || (Operand == EFI_IFR_MAP_OP) || (Operand == EFI_IFR_VERSION_OP) || - (Operand == EFI_IFR_SECURITY_OP)) { + (Operand == EFI_IFR_SECURITY_OP) || + (Operand == EFI_IFR_MATCH2_OP)) { return TRUE; } else { return FALSE; } } @@ -1202,11 +1203,11 @@ IsStatementOpCode ( BOOLEAN IsUnKnownOpCode ( IN UINT8 Operand ) { - return Operand > EFI_IFR_WARNING_IF_OP ? TRUE : FALSE; + return Operand > EFI_IFR_MATCH2_OP ? TRUE : FALSE; } /** Calculate number of Statemens(Questions) and Expression OpCodes. @@ -1474,10 +1475,14 @@ ParseOpCodes ( case EFI_IFR_SECURITY_OP: CopyMem (&ExpressionOpCode->Guid, &((EFI_IFR_SECURITY *) OpCodeData)->Permissions, sizeof (EFI_GUID)); break; + case EFI_IFR_MATCH2_OP: + CopyMem (&ExpressionOpCode->Guid, &((EFI_IFR_MATCH2 *) OpCodeData)->SyntaxType, sizeof (EFI_GUID)); + break; + case EFI_IFR_GET_OP: case EFI_IFR_SET_OP: CopyMem (&TempVarstoreId, &((EFI_IFR_GET *) OpCodeData)->VarStoreId, sizeof (TempVarstoreId)); if (TempVarstoreId != 0) { if (FormSet->StorageListHead.ForwardLink != NULL) { diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index 9a300fa..d59a22d 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -30,10 +30,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/HiiConfigRouting.h> #include <Protocol/HiiDatabase.h> #include <Protocol/HiiString.h> #include <Protocol/UserManager.h> #include <Protocol/DevicePathFromText.h> +#include <Protocol/RegularExpressionProtocol.h> #include <Guid/MdeModuleHii.h> #include <Guid/HiiPlatformSetupFormset.h> #include <Guid/HiiFormMapMethodGuid.h> diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf index d7b537f..08f71f3 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf +++ b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf @@ -1,11 +1,11 @@ ## @file # The DXE driver produces FORM BROWSER2 protocol defined in UEFI specification. # # It also produces FormBrowserEx(2) protocol to let user register the different Hot key service. # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> # # 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 @@ -73,10 +73,11 @@ gEfiDevicePathFromTextProtocolGuid ## SOMETIMES_CONSUMES ## CONSUMES ## NOTIFY gEdkiiFormDisplayEngineProtocolGuid gEfiFormBrowserExProtocolGuid ## PRODUCES + gEfiRegularExpressionProtocolGuid ## CONSUMES [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES [Depex] -- 1.9.5.msysgit.1 ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel