Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <[email protected]>
---
 .../Include/Protocol/RegularExpressionProtocol.h   | 178 +++++++++++++++++++++
 .../Include/Uefi/UefiInternalFormRepresentation.h  |   6 +
 MdePkg/MdePkg.dec                                  |  14 +-
 3 files changed, 197 insertions(+), 1 deletion(-)
 create mode 100644 MdePkg/Include/Protocol/RegularExpressionProtocol.h

diff --git a/MdePkg/Include/Protocol/RegularExpressionProtocol.h 
b/MdePkg/Include/Protocol/RegularExpressionProtocol.h
new file mode 100644
index 0000000..e02dbbd
--- /dev/null
+++ b/MdePkg/Include/Protocol/RegularExpressionProtocol.h
@@ -0,0 +1,178 @@
+/** @file
+  This section defines the Regular Expression Protocol. This protocol isused 
to match
+  Unicode strings against Regular Expression patterns.
+
+Copyright (c) 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 that 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 __REGULAR_EXPRESSION_PROTOCOL_H__
+#define __REGULAR_EXPRESSION_PROTOCOL_H__
+
+#define EFI_REGULAR_EXPRESSION_PROTOCOL_GUID \
+  { \
+    0xB3F79D9A, 0x436C, 0xDC11, {0xB0, 0x52, 0xCD, 0x85, 0xDF, 0x52, 0x4C, 
0xE6 } \
+  }
+
+#define EFI_REGEX_SYNTAX_TYPE_POSIX_EXTENDED_GUID \
+  { \
+    0x5F05B20F, 0x4A56, 0xC231, {0xFA, 0x0B, 0xA7, 0xB1, 0xF1, 0x10, 0x04, 
0x1D } \
+  }
+
+#define EFI_REGEX_SYNTAX_TYPE_PERL_GUID \
+  { \
+    0x63E60A51, 0x497D, 0xD427, {0xC4, 0xA5, 0xB8, 0xAB, 0xDC, 0x3A, 0xAE, 
0xB6 } \
+  }
+
+#define EFI_REGEX_SYNTAX_TYPE_ECMA_262_GUID \
+  { \
+    0x9A473A4A, 0x4CEB, 0xB95A, {0x41, 0x5E, 0x5B, 0xA0, 0xBC, 0x63, 0x9B, 
0x2E } \
+  }
+
+typedef struct _EFI_REGULAR_EXPRESSION_PROTOCOL  
EFI_REGULAR_EXPRESSION_PROTOCOL;
+
+
+typedef struct {
+  CONST CHAR16 *CapturePtr; // Pointer to the start of the captured 
sub-expression 
+                            // within matched String.
+
+  UINTN        Length;      // Length of captured sub-expression.
+} EFI_REGEX_CAPTURE;
+
+typedef EFI_GUID EFI_REGEX_SYNTAX_TYPE;
+
+//
+// Protocol member functions
+//
+/**
+  Returns information about the regular expression syntax types supported
+  by the implementation.
+
+  This                     A pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL
+                           instance. 
+
+  RegExSyntaxTypeListSize  On input, the size in bytes of RegExSyntaxTypeList.
+                           On output with a return code of EFI_SUCCESS, the
+                           size in bytes of the data returned in 
+                           RegExSyntaxTypeList. On output with a return code
+                           of EFI_BUFFER_TOO_SMALL, the size of 
+                           RegExSyntaxTypeListrequired to obtain the list.
+
+  RegExSyntaxTypeList      A caller-allocated memory buffer filled by the 
+                           driver with one EFI_REGEX_SYNTAX_TYPEelement
+                           for each supported Regular expression syntax 
+                           type. The list must not change across multiple
+                           calls to the same driver. The first syntax 
+                           type in the list is the default type for the
+                           driver.
+
+  @retval EFI_SUCCESS            The regular expression syntax types list 
+                                 was returned successfully.
+  @retval EFI_UNSUPPORTED        The service is not supported by this driver.
+  @retval EFI_DEVICE_ERROR       The list of syntax types could not be 
+                                 retrieved due to a hardware or firmware error.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer RegExSyntaxTypeList is too small 
+                                 to hold the result.
+  @retval EFI_INVALID_PARAMETER  RegExSyntaxTypeListSize is NULL
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_REGULAR_EXPRESSION_GET_INFO) (
+  IN     EFI_REGULAR_EXPRESSION_PROTOCOL *This,
+  IN OUT UINTN                           *RegExSyntaxTypeListSize,
+  OUT    EFI_REGEX_SYNTAX_TYPE           *RegExSyntaxTypeList
+  );
+
+/**
+  Checks if the input string matches to the regular expression pattern.
+
+  This          A pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL instance. 
+                Type EFI_REGULAR_EXPRESSION_PROTOCOL is defined in Section
+                XYZ. 
+
+  String        A pointer to a NULL terminated string to match against the
+                regular expression string specified by Pattern.
+
+  Pattern       A pointer to a NULL terminated string that represents the
+                regular expression.
+
+  SyntaxType    A pointer to the EFI_REGEX_SYNTAX_TYPE that identifies the
+                regular expression syntax type to use. May be NULL in which
+                case the function will use its default regular expression 
+                syntax type.
+
+  Result        On return, points to TRUE if String fully matches against 
+                the regular expression Pattern using the regular expression
+                SyntaxType. Otherwise, points to FALSE.
+
+  Captures      A Pointer to an array of EFI_REGEX_CAPTURE objects to receive
+                the captured groups in the event of a match. The full 
+                sub-string match is put in Captures[0], and the results of N
+                capturing groups are put in Captures[1:N]. If Captures is 
+                NULL, then this function doesn't allocate the memory for the
+                array and does not build up the elements. It only returns the
+                number of matching patterns in CapturesCount. If Captures is
+                not NULL, this function returns a pointer to an array and 
+                builds up the elements in the array. CapturesCount is also 
+                updated to the number of matching patterns found. It is the
+                caller's responsibility to free the memory pool in Captures
+                and in each CapturePtr in the array elements.
+
+  CapturesCount On output, CapturesCount is the number of matching patterns 
+                found in String. Zero means no matching patterns were found 
+                in the string.
+
+  @retval EFI_SUCCESS            The regular expression string matching 
+                                 completed successfully.
+  @retval EFI_UNSUPPORTED        The regular expression syntax specified by 
+                                 SyntaxTypeis not supported by this driver.
+  @retval EFI_DEVICE_ERROR       The regular expression string matching 
+                                 failed due to a hardware or firmware error.
+  @retval EFI_INVALID_PARAMETER  String, Pattern, Result, or CapturesCountis 
+                                 NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_REGULAR_EXPRESSION_MATCH) (
+  IN  EFI_REGULAR_EXPRESSION_PROTOCOL *This,
+  IN  CHAR16                          *String,
+  IN  CHAR16                          *Pattern,
+  IN  EFI_REGEX_SYNTAX_TYPE           *SyntaxType, OPTIONAL
+  OUT BOOLEAN                         *Result,
+  OUT EFI_REGEX_CAPTURE               **Captures, OPTIONAL
+  OUT UINTN                           *CapturesCount
+  );
+
+struct _EFI_REGULAR_EXPRESSION_PROTOCOL { 
+  EFI_REGULAR_EXPRESSION_MATCH     MatchString; 
+  EFI_REGULAR_EXPRESSION_GET_INFO  GetInfo;
+} ;
+
+extern EFI_GUID gEfiRegularExpressionProtocolGuid;
+
+//
+// For regular expression rules specified in the POSIX Extended Regular 
+// Expression (ERE) Syntax:
+//
+extern EFI_GUID gEfiRegexSyntaxTypePosixExtendedGuid;
+
+//
+// For regular expression rules specifiedin the ECMA 262 Specification
+//
+extern EFI_GUID gEfiRegexSyntaxTypeEcma262Guid;
+
+//
+// For regular expression rules specified in the Perl standard:
+//
+extern EFI_GUID gEfiRegexSyntaxTypePerlGuid;
+
+#endif
diff --git a/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h 
b/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
index 70b0374..4f9549d 100644
--- a/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
+++ b/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
@@ -778,10 +778,11 @@ typedef union {
 #define EFI_IFR_GUID_OP                0x5F
 #define EFI_IFR_SECURITY_OP            0x60
 #define EFI_IFR_MODAL_TAG_OP           0x61
 #define EFI_IFR_REFRESH_ID_OP          0x62
 #define EFI_IFR_WARNING_IF_OP          0x63
+#define EFI_IFR_MATCH2_OP              0x64
 
 //
 // Definitions of IFR Standard Headers
 // Section 27.3.8.2
 //
@@ -1397,10 +1398,15 @@ typedef struct _EFI_IFR_LESS_THAN {
 
 typedef struct _EFI_IFR_MATCH {
   EFI_IFR_OP_HEADER        Header;
 } EFI_IFR_MATCH;
 
+typedef struct _EFI_IFR_MATCH2 {
+  EFI_IFR_OP_HEADER        Header;
+  EFI_GUID                 SyntaxType;
+} EFI_IFR_MATCH2;
+
 typedef struct _EFI_IFR_MULTIPLY {
   EFI_IFR_OP_HEADER        Header;
 } EFI_IFR_MULTIPLY;
 
 typedef struct _EFI_IFR_MODULO {
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index bfc21d4..11d3996 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -653,11 +653,20 @@
   # GUID defined in PI1.3
   #
   ## Guid for EFI_DISK_INFO_PROTOCOL.Interface to specify Nvme interface.
   ## Include/Protocol/DiskInfo.h
   gEfiDiskInfoNvmeInterfaceGuid  = { 0x3ab14680, 0x5d3f, 0x4a4d, { 0xbc, 0xdc, 
0xcc, 0x38, 0x0, 0x18, 0xc7, 0xf7 }}
-  
+
+  ## Include/Protocol/RegularExpressionProtocol.h
+  gEfiRegexSyntaxTypePosixExtendedGuid = {0x5F05B20F, 0x4A56, 0xC231, {0xFA, 
0x0B, 0xA7, 0xB1, 0xF1, 0x10, 0x04, 0x1D }}
+
+  ## Include/Protocol/RegularExpressionProtocol.h
+  gEfiRegexSyntaxTypeEcma262Guid = { 0x9A473A4A, 0x4CEB, 0xB95A, {0x41, 0x5E, 
0x5B, 0xA0, 0xBC, 0x63, 0x9B, 0x2E }}
+
+  ## Include/Protocol/RegularExpressionProtocol.h
+  gEfiRegexSyntaxTypePerlGuid = {0x63E60A51, 0x497D, 0xD427, {0xC4, 0xA5, 
0xB8, 0xAB, 0xDC, 0x3A, 0xAE, 0xB6 }}
+
   #
   # GUID defined in PI1.4
   #
   ## Include/Guid/GraphicsInfoHob.h
   gEfiGraphicsInfoHobGuid           = { 0x39f62cce, 0x6825, 0x4669, { 0xbb, 
0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 }}
@@ -1418,10 +1427,13 @@
   gEfiTimestampProtocolGuid            = { 0xafbfde41, 0x2e6e, 0x4262, {0xba, 
0x65, 0x62, 0xb9, 0x23, 0x6e, 0x54, 0x95 }}
 
   ## Include/Protocol/Rng.h
   gEfiRngProtocolGuid                  = { 0x3152bca5, 0xeade, 0x433d, {0x86, 
0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 }}
 
+  ## Include/Protocol/RegularExpressionProtocol.h
+  gEfiRegularExpressionProtocolGuid = { 0xB3F79D9A, 0x436C, 0xDC11, {0xB0, 
0x52, 0xCD, 0x85, 0xDF, 0x52, 0x4C, 0xE6 }}
+
   ## Include/Protocol/AdapterInformation.h
   gEfiAdapterInformationProtocolGuid    = { 0xE5DD1403, 0xD622, 0xC24E, {0x84, 
0x88, 0xC7, 0x1B, 0x17, 0xF5, 0xE8, 0x02 }}
 
   ## Include/Protocol/HiiConfigKeyword.h 
   gEfiConfigKeywordHandlerProtocolGuid = {0x0a8badd5, 0x03b8, 0x4d19, {0xb1, 
0x28, 0x7b, 0x8f, 0x0e, 0xda, 0xa5, 0x96}} 
-- 
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to