public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-staging][PATCH 2/3] edk2-staging/RedfishPkg: Introduce new interfaces to Redfish protocol
@ 2022-12-07 14:10 Nickle Wang
  2022-12-12  2:44 ` Chang, Abner
  0 siblings, 1 reply; 2+ messages in thread
From: Nickle Wang @ 2022-12-07 14:10 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nick Ramirez

Add two new iterfaces to Redfish Platform Config Protocol.
GetAttribute() return attribute details and GetDefaultValue() get default
value of attribute. These two interfaces are used to generate BIOS
Attribute Registry

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
 .../Protocol/EdkIIRedfishPlatformConfig.h     | 105 +++
 .../RedfishPlatformConfigDxe.c                | 625 ++++++++++++++----
 .../RedfishPlatformConfigDxe.h                |   2 +
 .../RedfishPlatformConfigImpl.c               |  55 +-
 .../RedfishPlatformConfigImpl.h               |  44 +-
 5 files changed, 705 insertions(+), 126 deletions(-)

diff --git a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h b/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
index bbbab90b03..9be83b5e0b 100644
--- a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
+++ b/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
@@ -2,6 +2,7 @@
   This file defines the EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL interface.
 
   (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -38,6 +39,18 @@ typedef enum {
   REDFISH_VALUE_TYPE_MAX
 } EDKII_REDFISH_VALUE_TYPES;
 
+/**
+  Definition of EDKII_REDFISH_ATTRIBUTE_TYPES
+ **/
+typedef enum {
+  REDFISH_ATTRIBUTE_TYPE_UNKNOWN = 0,
+  REDFISH_ATTRIBUTE_TYPE_ENUMERATION,
+  REDFISH_ATTRIBUTE_TYPE_STRING,
+  REDFISH_ATTRIBUTE_TYPE_INTEGER,
+  REDFISH_ATTRIBUTE_TYPE_BOOLEAN,
+  REDFISH_ATTRIBUTE_TYPE_PASSWORD
+} EDKII_REDFISH_ATTRIBUTE_TYPES;
+
 /**
   Definition of EDKII_REDFISH_VALUE
  **/
@@ -47,6 +60,41 @@ typedef struct {
   UINTN                     ArrayCount;
 } EDKII_REDFISH_VALUE;
 
+/**
+  Definition of EDKII_REDFISH_ATTRIBUTE_VALUE
+ **/
+typedef struct {
+  CHAR8    *ValueName;
+  CHAR8    *ValueDisplayName;
+} EDKII_REDFISH_ATTRIBUTE_VALUE;
+
+/**
+  Definition of EDKII_REDFISH_POSSIBLE_VALUES
+ **/
+typedef struct {
+  UINTN                            ValueCount;
+  EDKII_REDFISH_ATTRIBUTE_VALUE    *ValueArray;
+} EDKII_REDFISH_POSSIBLE_VALUES;
+
+/**
+  Definition of EDKII_REDFISH_ATTRIBUTE
+ **/
+typedef struct {
+  CHAR8                            *AttributeName;
+  CHAR8                            *DisplayName;
+  CHAR8                            *HelpText;
+  CHAR8                            *MenuPath;
+  EDKII_REDFISH_ATTRIBUTE_TYPES    Type;
+  BOOLEAN                          ResetRequired;
+  BOOLEAN                          ReadOnly;
+  UINT64                           NumMaximum;
+  UINT64                           NumMinimum;
+  UINT64                           NumStep;
+  UINT8                            StrMaxSize;
+  UINT8                            StrMinSize;
+  EDKII_REDFISH_POSSIBLE_VALUES    Values;
+} EDKII_REDFISH_ATTRIBUTE;
+
 /**
   Get Redfish value with the given Schema and Configure Language.
 
@@ -70,6 +118,37 @@ EFI_STATUS
   OUT    EDKII_REDFISH_VALUE                    *Value
   );
 
+//
+// Default class standard
+//
+#define EDKII_REDFISH_DEFAULT_CLASS_STANDARD  EFI_HII_DEFAULT_CLASS_STANDARD
+
+/**
+  Get Redfish default value with the given Schema and Configure Language.
+
+  @param[in]   This                Pointer to EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
+  @param[in]   Schema              The Redfish schema to query.
+  @param[in]   Version             The Redfish version to query.
+  @param[in]   ConfigureLang       The target value which match this configure Language.
+  @param[in]   DefaultClass        The UEFI defined default class.
+                                   Please refer to UEFI spec. 33.2.5.8 "defaults" for details.
+  @param[out]  Value               The returned value.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_DEFAULT_VALUE)(
+  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,
+  IN     CHAR8                                  *Schema,
+  IN     CHAR8                                  *Version,
+  IN     EFI_STRING                             ConfigureLang,
+  IN     UINT16                                 DefaultClass,
+  OUT    EDKII_REDFISH_VALUE                    *Value
+  );
+
 /**
   Set Redfish value with the given Schema and Configure Language.
 
@@ -93,6 +172,29 @@ EFI_STATUS
   IN     EDKII_REDFISH_VALUE                    Value
   );
 
+/**
+  Get Redfish attribute value with the given Schema and Configure Language.
+
+  @param[in]   This                Pointer to EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
+  @param[in]   Schema              The Redfish schema to query.
+  @param[in]   Version             The Redfish version to query.
+  @param[in]   ConfigureLang       The target value which match this configure Language.
+  @param[out]  AttributeValue      The attribute value.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_ATTRIBUTE)(
+  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,
+  IN     CHAR8                                  *Schema,
+  IN     CHAR8                                  *Version,
+  IN     EFI_STRING                             ConfigureLang,
+  OUT    EDKII_REDFISH_ATTRIBUTE                *AttributeValue
+  );
+
 /**
   Get the list of Configure Language from platform configuration by the given Schema and RegexPattern.
 
@@ -143,8 +245,11 @@ EFI_STATUS
   );
 
 struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL {
+  UINT64                                              Revision;
   EDKII_REDFISH_PLATFORM_CONFIG_GET_VALUE             GetValue;
   EDKII_REDFISH_PLATFORM_CONFIG_SET_VALUE             SetValue;
+  EDKII_REDFISH_PLATFORM_CONFIG_GET_DEFAULT_VALUE     GetDefaultValue;
+  EDKII_REDFISH_PLATFORM_CONFIG_GET_ATTRIBUTE         GetAttribute;
   EDKII_REDFISH_PLATFORM_CONFIG_GET_CONFIG_LANG       GetConfigureLang;
   EDKII_REDFISH_PLATFORM_CONFIG_GET_SUPPORTED_SCHEMA  GetSupportedSchema;
 };
diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
index 971035f27d..96b50b201c 100644
--- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
+++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
@@ -3,6 +3,7 @@
   The implementation of EDKII Redfidh Platform Config Protocol.
 
   (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -13,6 +14,182 @@
 
 REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate = NULL;
 
+/**
+  Get the attribute name from config language.
+
+  For example:  /Bios/Attributes/BiosOption1 is config laugnage
+  and attribute name is BiosOption1.
+
+  @param[in]  ConfigLanguage     Config language string.
+
+  @retval CHAR8 *                Attribute name string.
+  @retval NULL                   Can not find attribute name.
+
+**/
+CHAR8 *
+GetAttributeNameFromConfigLanguage (
+  IN  CHAR8  *ConfigLanguage
+  )
+{
+  CHAR8  *attributeName;
+  CHAR8  *Pointer;
+  UINTN  StrLen;
+  UINTN  Index;
+  UINTN  AttrStrLen;
+
+  if (IS_EMPTY_STRING (ConfigLanguage)) {
+    return NULL;
+  }
+
+  attributeName = NULL;
+  Pointer       = NULL;
+  AttrStrLen    = 0;
+  StrLen        = AsciiStrLen (ConfigLanguage);
+
+  if (ConfigLanguage[StrLen - 1] == '/') {
+    //
+    // wrong format
+    //
+    DEBUG ((DEBUG_ERROR, "%a, invalid format: %a\n", __FUNCTION__, ConfigLanguage));
+    ASSERT (FALSE);
+    return NULL;
+  }
+
+  Index = StrLen;
+  while (TRUE) {
+    Index -= 1;
+
+    if (ConfigLanguage[Index] == '/') {
+      Pointer = &ConfigLanguage[Index + 1];
+      break;
+    }
+
+    if (Index == 0) {
+      break;
+    }
+  }
+
+  //
+  // Not found. There is no '/' in input string.
+  //
+  if (Pointer == NULL) {
+    return NULL;
+  }
+
+  AttrStrLen    = StrLen - Index;
+  attributeName = AllocateCopyPool (AttrStrLen, Pointer);
+
+  return attributeName;
+}
+
+/**
+  Convert one-of options to string array in Redfish attribute.
+
+  @param[in]  HiiHandle          HII handle.
+  @param[in]  SchemaName         Schema string.
+  @param[in]  HiiStatement       Target HII statement.
+  @param[out] Values             Attribute value array.
+
+  @retval EFI_SUCCESS            Options are converted successfully.
+  @retval Other                  Error occurs.
+
+**/
+EFI_STATUS
+OneOfStatementToAttributeValues (
+  IN  EFI_HII_HANDLE                 HiiHandle,
+  IN  CHAR8                          *SchemaName,
+  IN  HII_STATEMENT                  *HiiStatement,
+  OUT EDKII_REDFISH_POSSIBLE_VALUES  *Values
+  )
+{
+  LIST_ENTRY           *Link;
+  HII_QUESTION_OPTION  *Option;
+  UINTN                Index;
+
+  if ((HiiHandle == NULL) || (HiiStatement == NULL) || (Values == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (IsListEmpty (&HiiStatement->OptionListHead)) {
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Loop through the option to get count
+  //
+  Values->ValueCount = 0;
+  Link               = GetFirstNode (&HiiStatement->OptionListHead);
+  while (!IsNull (&HiiStatement->OptionListHead, Link)) {
+    Values->ValueCount += 1;
+    Link                = GetNextNode (&HiiStatement->OptionListHead, Link);
+  }
+
+  Values->ValueArray = AllocateZeroPool (sizeof (EDKII_REDFISH_ATTRIBUTE_VALUE) * Values->ValueCount);
+  if (Values->ValueArray == NULL) {
+    Values->ValueCount = 0;
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Index = 0;
+  Link  = GetFirstNode (&HiiStatement->OptionListHead);
+  while (!IsNull (&HiiStatement->OptionListHead, Link)) {
+    Option = HII_QUESTION_OPTION_FROM_LINK (Link);
+
+    if (Option->Text != 0) {
+      Values->ValueArray[Index].ValueName = HiiGetRedfishAsciiString (HiiHandle, SchemaName, Option->Text);
+      Values->ValueArray[Index].ValueName = HiiGetEnglishAsciiString (HiiHandle, Option->Text);
+    }
+
+    Index += 1;
+    Link   = GetNextNode (&HiiStatement->OptionListHead, Link);
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Return Redfish attribute type from given HII statment operand.
+
+  @param[in]  HiiStatement       Target HII statement.
+
+  @retval EDKII_REDFISH_ATTRIBUTE_TYPES    Attribute type.
+
+**/
+EDKII_REDFISH_ATTRIBUTE_TYPES
+HiiStatementToAttributeType (
+  IN  HII_STATEMENT  *HiiStatement
+  )
+{
+  EDKII_REDFISH_ATTRIBUTE_TYPES  type;
+
+  if (HiiStatement == NULL) {
+    return REDFISH_ATTRIBUTE_TYPE_UNKNOWN;
+  }
+
+  type = REDFISH_ATTRIBUTE_TYPE_UNKNOWN;
+  switch (HiiStatement->Operand) {
+    case EFI_IFR_ONE_OF_OP:
+    case EFI_IFR_ORDERED_LIST_OP:
+      type = REDFISH_ATTRIBUTE_TYPE_ENUMERATION;
+      break;
+    case EFI_IFR_STRING_OP:
+      type = REDFISH_ATTRIBUTE_TYPE_STRING;
+      break;
+    case EFI_IFR_NUMERIC_OP:
+      type = REDFISH_ATTRIBUTE_TYPE_INTEGER;
+      break;
+    case EFI_IFR_CHECKBOX_OP:
+      type = REDFISH_ATTRIBUTE_TYPE_BOOLEAN;
+      break;
+    case EFI_IFR_DATE_OP:
+    case EFI_IFR_TIME_OP:
+    default:
+      DEBUG ((DEBUG_ERROR, "%a, unsupported operand: 0x%x\n", __FUNCTION__, HiiStatement->Operand));
+      break;
+  }
+
+  return type;
+}
 
 /**
   Zero extend integer/boolean to UINT64 for comparing.
@@ -264,7 +441,8 @@ CompareHiiStatementValue (
 /**
   Convert HII value to the string in HII one-of opcode.
 
-  @param[in]  Statement     Statement private instance
+  @param[in]  HiiStatement  HII Statement private instance
+  @param[in]  Value         HII Statement value
 
   @retval EFI_STRING_ID     The string ID in HII database.
                             0 is returned when something goes wrong.
@@ -272,29 +450,34 @@ CompareHiiStatementValue (
 **/
 EFI_STRING_ID
 HiiValueToOneOfOptionStringId (
-  IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement
+  IN HII_STATEMENT        *HiiStatement,
+  IN HII_STATEMENT_VALUE  *Value
   )
 {
   LIST_ENTRY            *Link;
   HII_QUESTION_OPTION   *Option;
 
-  if (Statement->HiiStatement->Operand != EFI_IFR_ONE_OF_OP) {
+  if ((HiiStatement == NULL) || (Value == NULL)) {
     return 0;
   }
 
-  if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {
+  if (HiiStatement->Operand != EFI_IFR_ONE_OF_OP) {
     return 0;
   }
 
-  Link = GetFirstNode (&Statement->HiiStatement->OptionListHead);
-  while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {
+  if (IsListEmpty (&HiiStatement->OptionListHead)) {
+    return 0;
+  }
+
+  Link = GetFirstNode (&HiiStatement->OptionListHead);
+  while (!IsNull (&HiiStatement->OptionListHead, Link)) {
     Option = HII_QUESTION_OPTION_FROM_LINK (Link);
 
-    if (CompareHiiStatementValue (&Statement->HiiStatement->Value, &Option->Value) == 0) {
+    if (CompareHiiStatementValue (Value, &Option->Value) == 0) {
       return Option->Text;
     }
 
-    Link = GetNextNode (&Statement->HiiStatement->OptionListHead, Link);
+    Link = GetNextNode (&HiiStatement->OptionListHead, Link);
   }
 
   return 0;
@@ -531,7 +714,7 @@ DumpOrderedListValue (
   Convert HII value to the string in HII ordered list opcode. It's caller's
   responsibility to free returned buffer using FreePool().
 
-  @param[in]  Statement     Statement private instance
+  @param[in]  HiiStatement  HII Statement private instance
   @param[out] ReturnSize    The size of returned array
 
   @retval EFI_STRING_ID     The string ID array for options in ordered list.
@@ -539,8 +722,8 @@ DumpOrderedListValue (
 **/
 EFI_STRING_ID *
 HiiValueToOrderedListOptionStringId (
-  IN  REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement,
-  OUT UINTN                                     *ReturnSize
+  IN  HII_STATEMENT  *HiiStatement,
+  OUT UINTN          *ReturnSize
   )
 {
   LIST_ENTRY            *Link;
@@ -550,32 +733,32 @@ HiiValueToOrderedListOptionStringId (
   UINTN                 Index;
   UINT64                Value;
 
-  if (Statement == NULL || ReturnSize == NULL) {
+  if ((HiiStatement == NULL) || (ReturnSize == NULL)) {
     return NULL;
   }
 
   *ReturnSize = 0;
 
-  if (Statement->HiiStatement->Operand != EFI_IFR_ORDERED_LIST_OP) {
+  if (HiiStatement->Operand != EFI_IFR_ORDERED_LIST_OP) {
     return NULL;
   }
 
-  if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {
+  if (IsListEmpty (&HiiStatement->OptionListHead)) {
     return NULL;
   }
 
   DEBUG_CODE (
-    DumpOrderedListValue (Statement->HiiStatement);
-  );
+    DumpOrderedListValue (HiiStatement);
+    );
 
   OptionCount = 0;
-  Link = GetFirstNode (&Statement->HiiStatement->OptionListHead);
-  while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {
+  Link        = GetFirstNode (&HiiStatement->OptionListHead);
+  while (!IsNull (&HiiStatement->OptionListHead, Link)) {
     Option = HII_QUESTION_OPTION_FROM_LINK (Link);
 
     ++OptionCount;
 
-    Link = GetNextNode (&Statement->HiiStatement->OptionListHead, Link);
+    Link = GetNextNode (&HiiStatement->OptionListHead, Link);
   }
 
   *ReturnSize = OptionCount;
@@ -587,8 +770,8 @@ HiiValueToOrderedListOptionStringId (
   }
 
   for (Index = 0; Index < OptionCount; Index++) {
-    Value = OrderedListGetArrayData (Statement->HiiStatement->Value.Buffer, Statement->HiiStatement->Value.BufferValueType, Index);
-    ReturnedArray[Index] = OrderedListOptionValueToStringId (Statement->HiiStatement, Value);
+    Value                = OrderedListGetArrayData (HiiStatement->Value.Buffer, HiiStatement->Value.BufferValueType, Index);
+    ReturnedArray[Index] = OrderedListOptionValueToStringId (HiiStatement, Value);
   }
 
   return ReturnedArray;
@@ -657,6 +840,126 @@ HiiStringToOrderedListOptionValue (
   return EFI_NOT_FOUND;
 }
 
+/**
+  Convert HII value to Redfish value.
+
+  @param[in]  HiiHandle     HII handle.
+  @param[in]  FullSchema    Schema string.
+  @param[in]  HiiStatement  HII statement.
+  @param[in]  Value         Value to be converted.
+  @param[out] RedfishValue  Value in Redfish format.
+
+  @retval EFI_SUCCESS       Redfish value is returned successfully.
+  @retval Others            Errors occur
+
+**/
+EFI_STATUS
+HiiValueToRedfishValue (
+  IN  EFI_HII_HANDLE       HiiHandle,
+  IN  CHAR8                *FullSchema,
+  IN  HII_STATEMENT        *HiiStatement,
+  IN  HII_STATEMENT_VALUE  *Value,
+  OUT EDKII_REDFISH_VALUE  *RedfishValue
+  )
+{
+  EFI_STATUS     Status;
+  EFI_STRING_ID  StringId;
+  UINTN          Index;
+  UINTN          Count;
+  EFI_STRING_ID  *StringIdArray;
+
+  if ((HiiHandle == NULL) || (HiiStatement == NULL) || (Value == NULL) || (RedfishValue == NULL) || IS_EMPTY_STRING (FullSchema)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  StringIdArray = NULL;
+  Count         = 0;
+
+  switch (HiiStatement->Operand) {
+    case EFI_IFR_ONE_OF_OP:
+      StringId = HiiValueToOneOfOptionStringId (HiiStatement, Value);
+      if (StringId == 0) {
+        ASSERT (FALSE);
+        Status = EFI_DEVICE_ERROR;
+        break;
+      }
+
+      RedfishValue->Value.Buffer = HiiGetRedfishAsciiString (HiiHandle, FullSchema, StringId);
+      if (RedfishValue->Value.Buffer == NULL) {
+        Status = EFI_OUT_OF_RESOURCES;
+        break;
+      }
+
+      RedfishValue->Type = REDFISH_VALUE_TYPE_STRING;
+      break;
+    case EFI_IFR_STRING_OP:
+      if (Value->Type != EFI_IFR_TYPE_STRING) {
+        ASSERT (FALSE);
+        Status = EFI_DEVICE_ERROR;
+        break;
+      }
+
+      RedfishValue->Type         = REDFISH_VALUE_TYPE_STRING;
+      RedfishValue->Value.Buffer = AllocatePool (StrLen ((CHAR16 *)Value->Buffer) + 1);
+      UnicodeStrToAsciiStrS ((CHAR16 *)Value->Buffer, RedfishValue->Value.Buffer, StrLen ((CHAR16 *)Value->Buffer) + 1);
+      break;
+    case EFI_IFR_CHECKBOX_OP:
+    case EFI_IFR_NUMERIC_OP:
+      Status = HiiValueToRedfishNumeric (Value, RedfishValue);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a, failed to convert HII value to Redfish value: %r\n", __FUNCTION__, Status));
+        break;
+      }
+
+      break;
+    case EFI_IFR_ACTION_OP:
+      if (Value->Type != EFI_IFR_TYPE_ACTION) {
+        ASSERT (FALSE);
+        Status = EFI_DEVICE_ERROR;
+        break;
+      }
+
+      //
+      // Action has no value. Just return unknown type.
+      //
+      RedfishValue->Type = REDFISH_VALUE_TYPE_UNKNOWN;
+      break;
+    case EFI_IFR_ORDERED_LIST_OP:
+      StringIdArray = HiiValueToOrderedListOptionStringId (HiiStatement, &Count);
+      if (StringIdArray == NULL) {
+        ASSERT (FALSE);
+        Status = EFI_DEVICE_ERROR;
+        break;
+      }
+
+      RedfishValue->Value.StringArray = AllocatePool (sizeof (CHAR8 *) * Count);
+      if (RedfishValue->Value.StringArray == NULL) {
+        ASSERT (FALSE);
+        Status = EFI_OUT_OF_RESOURCES;
+        break;
+      }
+
+      for (Index = 0; Index < Count; Index++) {
+        ASSERT (StringIdArray[Index] != 0);
+        RedfishValue->Value.StringArray[Index] = HiiGetRedfishAsciiString (HiiHandle, FullSchema, StringIdArray[Index]);
+        ASSERT (RedfishValue->Value.StringArray[Index] != NULL);
+      }
+
+      RedfishValue->ArrayCount = Count;
+      RedfishValue->Type       = REDFISH_VALUE_TYPE_STRING_ARRAY;
+
+      FreePool (StringIdArray);
+      break;
+    default:
+      DEBUG ((DEBUG_ERROR, "%a, catch unsupported type: 0x%x! Please contact with author if we need to support this type.\n", __FUNCTION__, HiiStatement->Operand));
+      ASSERT (FALSE);
+      Status = EFI_UNSUPPORTED;
+      break;
+  }
+
+  return Status;
+}
+
 /**
   Convert input ascii string to unicode string. It's caller's
   responsibility to free returned buffer using FreePool().
@@ -825,12 +1128,7 @@ RedfishPlatformConfigProtocolGetValue (
   EFI_STATUS                                Status;
   REDFISH_PLATFORM_CONFIG_PRIVATE           *RedfishPlatformConfigPrivate;
   REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement;
-  EFI_STRING_ID                             StringId;
-  EFI_STRING_ID                             *StringIdArray;
   CHAR8                                     *FullSchema;
-  EFI_STRING                                HiiString;
-  UINTN                                     Count;
-  UINTN                                     Index;
 
   if (This == NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_STRING (ConfigureLang) || Value == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -839,10 +1137,7 @@ RedfishPlatformConfigProtocolGetValue (
   RedfishPlatformConfigPrivate = REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS (This);
   Value->Type = REDFISH_VALUE_TYPE_UNKNOWN;
   Value->ArrayCount = 0;
-  Count = 0;
   FullSchema = NULL;
-  HiiString = NULL;
-  StringIdArray = NULL;
 
   FullSchema = GetFullSchemaString (Schema, Version);
   if (FullSchema == NULL) {
@@ -854,82 +1149,15 @@ RedfishPlatformConfigProtocolGetValue (
     goto RELEASE_RESOURCE;
   }
 
-  switch (TargetStatement->HiiStatement->Operand) {
-    case EFI_IFR_ONE_OF_OP:
-      StringId = HiiValueToOneOfOptionStringId (TargetStatement);
-      if (StringId == 0) {
-        ASSERT (FALSE);
-        Status = EFI_DEVICE_ERROR;
-        goto RELEASE_RESOURCE;
-      }
-
-      Value->Value.Buffer = HiiGetRedfishAsciiString (TargetStatement->ParentForm->ParentFormset->HiiHandle, FullSchema, StringId);
-      if (Value->Value.Buffer == NULL) {
-        Status = EFI_OUT_OF_RESOURCES;
-        goto RELEASE_RESOURCE;
-      }
-
-      Value->Type = REDFISH_VALUE_TYPE_STRING;
-      break;
-    case EFI_IFR_STRING_OP:
-      if (TargetStatement->HiiStatement->Value.Type != EFI_IFR_TYPE_STRING) {
-        ASSERT (FALSE);
-        Status = EFI_DEVICE_ERROR;
-        goto RELEASE_RESOURCE;
-      }
-
-      Value->Type = REDFISH_VALUE_TYPE_STRING;
-      Value->Value.Buffer = AllocatePool (StrLen ((CHAR16 *)TargetStatement->HiiStatement->Value.Buffer) + 1);
-      UnicodeStrToAsciiStrS ((CHAR16 *)TargetStatement->HiiStatement->Value.Buffer, Value->Value.Buffer, StrLen ((CHAR16 *)TargetStatement->HiiStatement->Value.Buffer) + 1);
-      break;
-    case EFI_IFR_CHECKBOX_OP:
-    case EFI_IFR_NUMERIC_OP:
-      Status = HiiValueToRedfishNumeric (&TargetStatement->HiiStatement->Value, Value);
-      if (EFI_ERROR (Status)) {
-        DEBUG ((DEBUG_ERROR, "%a, failed to convert HII value to Redfish value: %r\n", __FUNCTION__, Status));
-        goto RELEASE_RESOURCE;
-      }
-      break;
-    case EFI_IFR_ACTION_OP:
-      if (TargetStatement->HiiStatement->Value.Type != EFI_IFR_TYPE_ACTION) {
-        ASSERT (FALSE);
-        Status = EFI_DEVICE_ERROR;
-        goto RELEASE_RESOURCE;
-      }
-
-      //
-      // Action has no value. Just return unknown type.
-      //
-      Value->Type = REDFISH_VALUE_TYPE_UNKNOWN;
-      break;
-    case EFI_IFR_ORDERED_LIST_OP:
-      StringIdArray = HiiValueToOrderedListOptionStringId (TargetStatement, &Count);
-      if (StringIdArray == NULL) {
-        ASSERT (FALSE);
-        Status = EFI_DEVICE_ERROR;
-        goto RELEASE_RESOURCE;
-      }
-
-      Value->Value.StringArray = AllocatePool (sizeof (CHAR8 *) * Count);
-      if (Value->Value.StringArray == NULL) {
-        ASSERT (FALSE);
-        Status = EFI_OUT_OF_RESOURCES;
-        goto RELEASE_RESOURCE;
-      }
-
-      for (Index = 0; Index < Count; Index++) {
-        ASSERT (StringIdArray[Index] != 0);
-        Value->Value.StringArray[Index] = HiiGetRedfishAsciiString (TargetStatement->ParentForm->ParentFormset->HiiHandle, FullSchema, StringIdArray[Index]);
-      }
-
-      Value->ArrayCount = Count;
-      Value->Type = REDFISH_VALUE_TYPE_STRING_ARRAY;
-      break;
-    default:
-      DEBUG ((DEBUG_ERROR, "%a, catch unsupported type: 0x%x! Please contact with author if we need to support this type.\n", __FUNCTION__, TargetStatement->HiiStatement->Operand));
-      ASSERT (FALSE);
-      Status = EFI_UNSUPPORTED;
-      goto RELEASE_RESOURCE;
+  Status = HiiValueToRedfishValue (
+             TargetStatement->ParentForm->ParentFormset->HiiHandle,
+             FullSchema,
+             TargetStatement->HiiStatement,
+             &TargetStatement->HiiStatement->Value,
+             Value
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a, HiiValueToRedfishValue failed: %r\n", __FUNCTION__, Status));
   }
 
 RELEASE_RESOURCE:
@@ -938,14 +1166,6 @@ RELEASE_RESOURCE:
     FreePool (FullSchema);
   }
 
-  if (HiiString != NULL) {
-    FreePool (HiiString);
-  }
-
-  if (StringIdArray != NULL) {
-    FreePool (StringIdArray);
-  }
-
   return Status;
 }
 
@@ -1433,6 +1653,176 @@ RedfishPlatformConfigProtocolGetSupportedSchema (
   return EFI_SUCCESS;
 }
 
+/**
+  Get Redfish default value with the given Schema and Configure Language.
+
+  @param[in]   This                Pointer to EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
+  @param[in]   Schema              The Redfish schema to query.
+  @param[in]   Version             The Redfish version to query.
+  @param[in]   ConfigureLang       The target value which match this configure Language.
+  @param[in]   DefaultClass        The UEFI defined default class.
+                                   Please refer to UEFI spec. 33.2.5.8 "defaults" for details.
+  @param[out]  Value               The returned value.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+RedfishPlatformConfigProtocolGetDefaultValue (
+  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL  *This,
+  IN     CHAR8                                   *Schema,
+  IN     CHAR8                                   *Version,
+  IN     EFI_STRING                              ConfigureLang,
+  IN     UINT16                                  DefaultClass,
+  OUT    EDKII_REDFISH_VALUE                     *Value
+  )
+{
+  EFI_STATUS                                 Status;
+  REDFISH_PLATFORM_CONFIG_PRIVATE            *RedfishPlatformConfigPrivate;
+  REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE  *TargetStatement;
+  CHAR8                                      *FullSchema;
+  HII_STATEMENT_VALUE                        DefaultValue;
+
+  if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_STRING (ConfigureLang) || (Value == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  RedfishPlatformConfigPrivate = REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS (This);
+  Value->Type                  = REDFISH_VALUE_TYPE_UNKNOWN;
+  Value->ArrayCount            = 0;
+
+  FullSchema = NULL;
+  FullSchema = GetFullSchemaString (Schema, Version);
+  if (FullSchema == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Status = RedfishPlatformConfigGetStatementCommon (RedfishPlatformConfigPrivate, FullSchema, ConfigureLang, &TargetStatement);
+  if (EFI_ERROR (Status)) {
+    goto RELEASE_RESOURCE;
+  }
+
+  Status = GetQuestionDefault (TargetStatement->ParentForm->ParentFormset->HiiFormSet, TargetStatement->ParentForm->HiiForm, TargetStatement->HiiStatement, DefaultClass, &DefaultValue);
+  if (EFI_ERROR (Status)) {
+    goto RELEASE_RESOURCE;
+  }
+
+  Status = HiiValueToRedfishValue (
+             TargetStatement->ParentForm->ParentFormset->HiiHandle,
+             FullSchema,
+             TargetStatement->HiiStatement,
+             &DefaultValue,
+             Value
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a, HiiValueToRedfishValue failed: %r\n", __FUNCTION__, Status));
+  }
+
+RELEASE_RESOURCE:
+
+  if (FullSchema != NULL) {
+    FreePool (FullSchema);
+  }
+
+  return Status;
+}
+
+/**
+  Get Redfish attribute value with the given Schema and Configure Language.
+
+  @param[in]   This                Pointer to EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
+  @param[in]   Schema              The Redfish schema to query.
+  @param[in]   Version             The Redfish version to query.
+  @param[in]   ConfigureLang       The target value which match this configure Language.
+  @param[out]  AttributeValue      The attribute value.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+RedfishPlatformConfigProtocolGetAttribute (
+  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL  *This,
+  IN     CHAR8                                   *Schema,
+  IN     CHAR8                                   *Version,
+  IN     EFI_STRING                              ConfigureLang,
+  OUT    EDKII_REDFISH_ATTRIBUTE                 *AttributeValue
+  )
+{
+  EFI_STATUS                                 Status;
+  REDFISH_PLATFORM_CONFIG_PRIVATE            *RedfishPlatformConfigPrivate;
+  REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE  *TargetStatement;
+  CHAR8                                      *FullSchema;
+  CHAR8                                      *Buffer;
+
+  if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_STRING (ConfigureLang) || (AttributeValue == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  RedfishPlatformConfigPrivate = REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS (This);
+  ZeroMem (AttributeValue, sizeof (EDKII_REDFISH_ATTRIBUTE));
+  FullSchema = NULL;
+  FullSchema = GetFullSchemaString (Schema, Version);
+  if (FullSchema == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Status = RedfishPlatformConfigGetStatementCommon (RedfishPlatformConfigPrivate, FullSchema, ConfigureLang, &TargetStatement);
+  if (EFI_ERROR (Status)) {
+    goto RELEASE_RESOURCE;
+  }
+
+  if (TargetStatement->Description != 0) {
+    AttributeValue->AttributeName = HiiGetRedfishAsciiString (TargetStatement->ParentForm->ParentFormset->HiiHandle, FullSchema, TargetStatement->Description);
+    Buffer                        = GetAttributeNameFromConfigLanguage (AttributeValue->AttributeName);
+    if (Buffer != NULL) {
+      FreePool (AttributeValue->AttributeName);
+      AttributeValue->AttributeName = Buffer;
+    }
+
+    AttributeValue->DisplayName = HiiGetEnglishAsciiString (TargetStatement->ParentForm->ParentFormset->HiiHandle, TargetStatement->Description);
+  }
+
+  if (TargetStatement->Help != 0) {
+    AttributeValue->HelpText = HiiGetEnglishAsciiString (TargetStatement->ParentForm->ParentFormset->HiiHandle, TargetStatement->Help);
+  }
+
+  AttributeValue->ReadOnly      = ((TargetStatement->Flags & EFI_IFR_FLAG_READ_ONLY) == 0 ? FALSE : TRUE);
+  AttributeValue->ResetRequired = ((TargetStatement->Flags & EFI_IFR_FLAG_RESET_REQUIRED) == 0 ? FALSE : TRUE);
+  AttributeValue->Type          = HiiStatementToAttributeType (TargetStatement->HiiStatement);
+
+  //
+  // Deal with maximum and minimum
+  //
+  if (AttributeValue->Type == REDFISH_ATTRIBUTE_TYPE_STRING) {
+    AttributeValue->StrMaxSize = TargetStatement->StatementData.StrMaxSize;
+    AttributeValue->StrMinSize = TargetStatement->StatementData.StrMinSize;
+  } else if (AttributeValue->Type == REDFISH_ATTRIBUTE_TYPE_INTEGER) {
+    AttributeValue->NumMaximum = TargetStatement->StatementData.NumMaximum;
+    AttributeValue->NumMinimum = TargetStatement->StatementData.NumMinimum;
+    AttributeValue->NumStep    = TargetStatement->StatementData.NumStep;
+  }
+
+  //
+  // Provide value array if this is enumeration type.
+  //
+  if (TargetStatement->HiiStatement->Operand == EFI_IFR_ONE_OF_OP) {
+    Status = OneOfStatementToAttributeValues (TargetStatement->ParentForm->ParentFormset->HiiHandle, FullSchema, TargetStatement->HiiStatement, &AttributeValue->Values);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "%a, failed to convert one-of options to attribute values: %r\n", __FUNCTION__, Status));
+    }
+  }
+
+RELEASE_RESOURCE:
+
+  if (FullSchema != NULL) {
+    FreePool (FullSchema);
+  }
+
+  return Status;
+}
+
 /**
   Functions which are registered to receive notification of
   database events have this prototype. The actual event is encoded
@@ -1715,10 +2105,13 @@ RedfishPlatformConfigDxeEntryPoint (
   // Protocol initialization
   //
   mRedfishPlatformConfigPrivate->ImageHandle = ImageHandle;
-  mRedfishPlatformConfigPrivate->Protocol.GetValue = RedfishPlatformConfigProtocolGetValue;
-  mRedfishPlatformConfigPrivate->Protocol.SetValue = RedfishPlatformConfigProtocolSetValue;
-  mRedfishPlatformConfigPrivate->Protocol.GetConfigureLang = RedfishPlatformConfigProtocolGetConfigureLang;
+  mRedfishPlatformConfigPrivate->Protocol.Revision           = REDFISH_PLATFORM_CONFIG_VERSION;
+  mRedfishPlatformConfigPrivate->Protocol.GetValue           = RedfishPlatformConfigProtocolGetValue;
+  mRedfishPlatformConfigPrivate->Protocol.SetValue           = RedfishPlatformConfigProtocolSetValue;
+  mRedfishPlatformConfigPrivate->Protocol.GetConfigureLang   = RedfishPlatformConfigProtocolGetConfigureLang;
   mRedfishPlatformConfigPrivate->Protocol.GetSupportedSchema = RedfishPlatformConfigProtocolGetSupportedSchema;
+  mRedfishPlatformConfigPrivate->Protocol.GetAttribute       = RedfishPlatformConfigProtocolGetAttribute;
+  mRedfishPlatformConfigPrivate->Protocol.GetDefaultValue    = RedfishPlatformConfigProtocolGetDefaultValue;
 
   InitializeListHead (&mRedfishPlatformConfigPrivate->FormsetList);
   InitializeListHead (&mRedfishPlatformConfigPrivate->PendingList);
diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
index d3f7af55ad..8155484702 100644
--- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
+++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
@@ -2,6 +2,7 @@
   This file defines the EDKII Redfish Platform Config Protocol interface.
 
   (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -60,5 +61,6 @@ typedef struct {
 #define REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS(a)  BASE_CR (a, REDFISH_PLATFORM_CONFIG_PRIVATE, Protocol)
 #define REGULAR_EXPRESSION_INCLUDE_ALL                L".*"
 #define CONFIGURE_LANGUAGE_PREFIX                     "x-uefi-redfish-"
+#define REDFISH_PLATFORM_CONFIG_VERSION               0x00010000
 
 #endif
diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
index b2bb5f64e4..65a0e5766a 100644
--- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
+++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
@@ -3,6 +3,7 @@
   The implementation of EDKII Redfish Platform Config Protocol.
 
   (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -300,6 +301,45 @@ HiiGetEnglishString (
   return HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId);
 }
 
+/**
+  Get ASCII string from HII database in English language.
+
+  @param[in]  HiiHandle         A handle that was previously registered in the HII Database.
+  @param[in]  StringId          The identifier of the string to retrieved from the string
+                                package associated with HiiHandle.
+
+  @retval NULL   The string specified by StringId is not present in the string package.
+  @retval Other  The string was returned.
+
+**/
+CHAR8 *
+HiiGetEnglishAsciiString (
+  IN EFI_HII_HANDLE  HiiHandle,
+  IN EFI_STRING_ID   StringId
+  )
+{
+  EFI_STRING  HiiString;
+  UINTN       StringSize;
+  CHAR8       *AsciiString;
+
+  HiiString = HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId);
+  if (HiiString == NULL) {
+    DEBUG ((DEBUG_ERROR, "%a, Can not find string ID: 0x%x with %a\n", __FUNCTION__, StringId, ENGLISH_LANGUAGE_CODE));
+    return NULL;
+  }
+
+  StringSize  = (StrLen (HiiString) + 1) * sizeof (CHAR8);
+  AsciiString = AllocatePool (StringSize);
+  if (AsciiString == NULL) {
+    return NULL;
+  }
+
+  UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize);
+
+  FreePool (HiiString);
+  return AsciiString;
+}
+
 /**
   Check and see if this is supported schema or not.
 
@@ -885,10 +925,17 @@ LoadFormset (
       //
       // Initialize statement private data.
       //
-      HiiStatementPrivate->HiiStatement = HiiStatement;
-      HiiStatementPrivate->QuestionId = HiiStatement->QuestionId;
-      HiiStatementPrivate->Description = HiiStatement->Prompt;
-      HiiStatementPrivate->ParentForm = HiiFormPrivate;
+      HiiStatementPrivate->HiiStatement             = HiiStatement;
+      HiiStatementPrivate->QuestionId               = HiiStatement->QuestionId;
+      HiiStatementPrivate->Description              = HiiStatement->Prompt;
+      HiiStatementPrivate->Help                     = HiiStatement->Help;
+      HiiStatementPrivate->ParentForm               = HiiFormPrivate;
+      HiiStatementPrivate->Flags                    = HiiStatement->QuestionFlags;
+      HiiStatementPrivate->StatementData.NumMaximum = HiiStatement->ExtraData.NumData.Maximum;
+      HiiStatementPrivate->StatementData.NumMinimum = HiiStatement->ExtraData.NumData.Minimum;
+      HiiStatementPrivate->StatementData.NumStep    = HiiStatement->ExtraData.NumData.Step;
+      HiiStatementPrivate->StatementData.StrMaxSize = HiiStatement->ExtraData.StrData.MaxSize;
+      HiiStatementPrivate->StatementData.StrMinSize = HiiStatement->ExtraData.StrData.MinSize;
 
       //
       // Attach to statement list.
diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
index cd7a52aef3..f66f5a8799 100644
--- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
+++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
@@ -2,6 +2,7 @@
   This file defines the EDKII Redfish Platform Config Protocol interface.
 
   (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -74,16 +75,30 @@ typedef struct {
 
 #define REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK(a)  BASE_CR (a, REDFISH_PLATFORM_CONFIG_FORM_PRIVATE, Link)
 
+//
+// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_DATA
+//
+typedef struct {
+  UINT64    NumMinimum;
+  UINT64    NumMaximum;
+  UINT64    NumStep;
+  UINT8     StrMinSize;
+  UINT8     StrMaxSize;
+} REDFISH_PLATFORM_CONFIG_STATEMENT_DATA;
+
 //
 // Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE
 //
 typedef struct {
-  LIST_ENTRY                            Link;
-  REDFISH_PLATFORM_CONFIG_FORM_PRIVATE  *ParentForm;
-  HII_STATEMENT                         *HiiStatement;  // Pointer to HII statement data.
-  EFI_QUESTION_ID                       QuestionId;     // Question ID of this statement.
-  EFI_STRING_ID                         Description;    // String token of this question.
-  EFI_STRING                            DesStringCache; // The string cache for search function.
+  LIST_ENTRY                                Link;
+  REDFISH_PLATFORM_CONFIG_FORM_PRIVATE      *ParentForm;
+  HII_STATEMENT                             *HiiStatement;  // Pointer to HII statement data.
+  EFI_QUESTION_ID                           QuestionId;     // Question ID of this statement.
+  EFI_STRING_ID                             Description;    // String token of this question.
+  EFI_STRING_ID                             Help;           // String token of help message.
+  EFI_STRING                                DesStringCache; // The string cache for search function.
+  UINT8                                     Flags;          // The statement flag.
+  REDFISH_PLATFORM_CONFIG_STATEMENT_DATA    StatementData;  // The max/min for statement value.
 } REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE;
 
 #define REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK(a)  BASE_CR (a, REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE, Link)
@@ -280,6 +295,23 @@ HiiGetRedfishAsciiString (
   IN EFI_STRING_ID            StringId
   );
 
+/**
+  Get ASCII string from HII database in English language.
+
+  @param[in]  HiiHandle         A handle that was previously registered in the HII Database.
+  @param[in]  StringId          The identifier of the string to retrieved from the string
+                                package associated with HiiHandle.
+
+  @retval NULL   The string specified by StringId is not present in the string package.
+  @retval Other  The string was returned.
+
+**/
+CHAR8 *
+HiiGetEnglishAsciiString (
+  IN EFI_HII_HANDLE  HiiHandle,
+  IN EFI_STRING_ID   StringId
+  );
+
 /**
   Release all resource in statement list.
 
-- 
2.38.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-staging][PATCH 2/3] edk2-staging/RedfishPkg: Introduce new interfaces to Redfish protocol
  2022-12-07 14:10 [edk2-staging][PATCH 2/3] edk2-staging/RedfishPkg: Introduce new interfaces to Redfish protocol Nickle Wang
@ 2022-12-12  2:44 ` Chang, Abner
  0 siblings, 0 replies; 2+ messages in thread
From: Chang, Abner @ 2022-12-12  2:44 UTC (permalink / raw)
  To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy, Nick Ramirez

[AMD Official Use Only - General]



> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Wednesday, December 7, 2022 10:10 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>
> Subject: [edk2-staging][PATCH 2/3] edk2-staging/RedfishPkg: Introduce new
> interfaces to Redfish protocol
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Add two new iterfaces to Redfish Platform Config Protocol.
> GetAttribute() return attribute details and GetDefaultValue() get default
> value of attribute. These two interfaces are used to generate BIOS Attribute
> Registry
> 
> Signed-off-by: Nickle Wang <nicklew@nvidia.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Cc: Nick Ramirez <nramirez@nvidia.com>
> ---
>  .../Protocol/EdkIIRedfishPlatformConfig.h     | 105 +++
>  .../RedfishPlatformConfigDxe.c                | 625 ++++++++++++++----
>  .../RedfishPlatformConfigDxe.h                |   2 +
>  .../RedfishPlatformConfigImpl.c               |  55 +-
>  .../RedfishPlatformConfigImpl.h               |  44 +-
>  5 files changed, 705 insertions(+), 126 deletions(-)
Please assign the file order next time when format patch. You can refer to here:
https://github.com/tianocore/tianocore.github.io/wiki/Laszlo's-unkempt-git-guide-for-edk2-contributors-and-maintainers#contrib-10

Reviewed-by: Abner Chang <abner.chang@amd.com>
> 
> diff --git a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
> b/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
> index bbbab90b03..9be83b5e0b 100644
> --- a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
> +++ b/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
> @@ -2,6 +2,7 @@
>    This file defines the EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL
> interface.
> 
>    (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -38,6 +39,18 @@ typedef enum {
>    REDFISH_VALUE_TYPE_MAX
>  } EDKII_REDFISH_VALUE_TYPES;
> 
> +/**
> +  Definition of EDKII_REDFISH_ATTRIBUTE_TYPES  **/ typedef enum {
> +  REDFISH_ATTRIBUTE_TYPE_UNKNOWN = 0,
> +  REDFISH_ATTRIBUTE_TYPE_ENUMERATION,
> +  REDFISH_ATTRIBUTE_TYPE_STRING,
> +  REDFISH_ATTRIBUTE_TYPE_INTEGER,
> +  REDFISH_ATTRIBUTE_TYPE_BOOLEAN,
> +  REDFISH_ATTRIBUTE_TYPE_PASSWORD
> +} EDKII_REDFISH_ATTRIBUTE_TYPES;
> +
>  /**
>    Definition of EDKII_REDFISH_VALUE
>   **/
> @@ -47,6 +60,41 @@ typedef struct {
>    UINTN                     ArrayCount;
>  } EDKII_REDFISH_VALUE;
> 
> +/**
> +  Definition of EDKII_REDFISH_ATTRIBUTE_VALUE  **/ typedef struct {
> +  CHAR8    *ValueName;
> +  CHAR8    *ValueDisplayName;
> +} EDKII_REDFISH_ATTRIBUTE_VALUE;
> +
> +/**
> +  Definition of EDKII_REDFISH_POSSIBLE_VALUES  **/ typedef struct {
> +  UINTN                            ValueCount;
> +  EDKII_REDFISH_ATTRIBUTE_VALUE    *ValueArray;
> +} EDKII_REDFISH_POSSIBLE_VALUES;
> +
> +/**
> +  Definition of EDKII_REDFISH_ATTRIBUTE  **/ typedef struct {
> +  CHAR8                            *AttributeName;
> +  CHAR8                            *DisplayName;
> +  CHAR8                            *HelpText;
> +  CHAR8                            *MenuPath;
> +  EDKII_REDFISH_ATTRIBUTE_TYPES    Type;
> +  BOOLEAN                          ResetRequired;
> +  BOOLEAN                          ReadOnly;
> +  UINT64                           NumMaximum;
> +  UINT64                           NumMinimum;
> +  UINT64                           NumStep;
> +  UINT8                            StrMaxSize;
> +  UINT8                            StrMinSize;
> +  EDKII_REDFISH_POSSIBLE_VALUES    Values;
> +} EDKII_REDFISH_ATTRIBUTE;
> +
>  /**
>    Get Redfish value with the given Schema and Configure Language.
> 
> @@ -70,6 +118,37 @@ EFI_STATUS
>    OUT    EDKII_REDFISH_VALUE                    *Value
>    );
> 
> +//
> +// Default class standard
> +//
> +#define EDKII_REDFISH_DEFAULT_CLASS_STANDARD
> +EFI_HII_DEFAULT_CLASS_STANDARD
> +
> +/**
> +  Get Redfish default value with the given Schema and Configure Language.
> +
> +  @param[in]   This                Pointer to
> EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
> +  @param[in]   Schema              The Redfish schema to query.
> +  @param[in]   Version             The Redfish version to query.
> +  @param[in]   ConfigureLang       The target value which match this configure
> Language.
> +  @param[in]   DefaultClass        The UEFI defined default class.
> +                                   Please refer to UEFI spec. 33.2.5.8 "defaults" for details.
> +  @param[out]  Value               The returned value.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_DEFAULT_VALUE)(
> +  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,
> +  IN     CHAR8                                  *Schema,
> +  IN     CHAR8                                  *Version,
> +  IN     EFI_STRING                             ConfigureLang,
> +  IN     UINT16                                 DefaultClass,
> +  OUT    EDKII_REDFISH_VALUE                    *Value
> +  );
> +
>  /**
>    Set Redfish value with the given Schema and Configure Language.
> 
> @@ -93,6 +172,29 @@ EFI_STATUS
>    IN     EDKII_REDFISH_VALUE                    Value
>    );
> 
> +/**
> +  Get Redfish attribute value with the given Schema and Configure Language.
> +
> +  @param[in]   This                Pointer to
> EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
> +  @param[in]   Schema              The Redfish schema to query.
> +  @param[in]   Version             The Redfish version to query.
> +  @param[in]   ConfigureLang       The target value which match this configure
> Language.
> +  @param[out]  AttributeValue      The attribute value.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_ATTRIBUTE)(
> +  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,
> +  IN     CHAR8                                  *Schema,
> +  IN     CHAR8                                  *Version,
> +  IN     EFI_STRING                             ConfigureLang,
> +  OUT    EDKII_REDFISH_ATTRIBUTE                *AttributeValue
> +  );
> +
>  /**
>    Get the list of Configure Language from platform configuration by the given
> Schema and RegexPattern.
> 
> @@ -143,8 +245,11 @@ EFI_STATUS
>    );
> 
>  struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL {
> +  UINT64                                              Revision;
>    EDKII_REDFISH_PLATFORM_CONFIG_GET_VALUE             GetValue;
>    EDKII_REDFISH_PLATFORM_CONFIG_SET_VALUE             SetValue;
> +  EDKII_REDFISH_PLATFORM_CONFIG_GET_DEFAULT_VALUE
> GetDefaultValue;
> +  EDKII_REDFISH_PLATFORM_CONFIG_GET_ATTRIBUTE         GetAttribute;
>    EDKII_REDFISH_PLATFORM_CONFIG_GET_CONFIG_LANG
> GetConfigureLang;
>    EDKII_REDFISH_PLATFORM_CONFIG_GET_SUPPORTED_SCHEMA
> GetSupportedSchema;  }; diff --git
> a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> index 971035f27d..96b50b201c 100644
> --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> @@ -3,6 +3,7 @@
>    The implementation of EDKII Redfidh Platform Config Protocol.
> 
>    (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -13,6 +14,182 @@
> 
>  REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate =
> NULL;
> 
> +/**
> +  Get the attribute name from config language.
> +
> +  For example:  /Bios/Attributes/BiosOption1 is config laugnage  and
> + attribute name is BiosOption1.
> +
> +  @param[in]  ConfigLanguage     Config language string.
> +
> +  @retval CHAR8 *                Attribute name string.
> +  @retval NULL                   Can not find attribute name.
> +
> +**/
> +CHAR8 *
> +GetAttributeNameFromConfigLanguage (
> +  IN  CHAR8  *ConfigLanguage
> +  )
> +{
> +  CHAR8  *attributeName;
> +  CHAR8  *Pointer;
> +  UINTN  StrLen;
> +  UINTN  Index;
> +  UINTN  AttrStrLen;
> +
> +  if (IS_EMPTY_STRING (ConfigLanguage)) {
> +    return NULL;
> +  }
> +
> +  attributeName = NULL;
> +  Pointer       = NULL;
> +  AttrStrLen    = 0;
> +  StrLen        = AsciiStrLen (ConfigLanguage);
> +
> +  if (ConfigLanguage[StrLen - 1] == '/') {
> +    //
> +    // wrong format
> +    //
> +    DEBUG ((DEBUG_ERROR, "%a, invalid format: %a\n", __FUNCTION__,
> ConfigLanguage));
> +    ASSERT (FALSE);
> +    return NULL;
> +  }
> +
> +  Index = StrLen;
> +  while (TRUE) {
> +    Index -= 1;
> +
> +    if (ConfigLanguage[Index] == '/') {
> +      Pointer = &ConfigLanguage[Index + 1];
> +      break;
> +    }
> +
> +    if (Index == 0) {
> +      break;
> +    }
> +  }
> +
> +  //
> +  // Not found. There is no '/' in input string.
> +  //
> +  if (Pointer == NULL) {
> +    return NULL;
> +  }
> +
> +  AttrStrLen    = StrLen - Index;
> +  attributeName = AllocateCopyPool (AttrStrLen, Pointer);
> +
> +  return attributeName;
> +}
> +
> +/**
> +  Convert one-of options to string array in Redfish attribute.
> +
> +  @param[in]  HiiHandle          HII handle.
> +  @param[in]  SchemaName         Schema string.
> +  @param[in]  HiiStatement       Target HII statement.
> +  @param[out] Values             Attribute value array.
> +
> +  @retval EFI_SUCCESS            Options are converted successfully.
> +  @retval Other                  Error occurs.
> +
> +**/
> +EFI_STATUS
> +OneOfStatementToAttributeValues (
> +  IN  EFI_HII_HANDLE                 HiiHandle,
> +  IN  CHAR8                          *SchemaName,
> +  IN  HII_STATEMENT                  *HiiStatement,
> +  OUT EDKII_REDFISH_POSSIBLE_VALUES  *Values
> +  )
> +{
> +  LIST_ENTRY           *Link;
> +  HII_QUESTION_OPTION  *Option;
> +  UINTN                Index;
> +
> +  if ((HiiHandle == NULL) || (HiiStatement == NULL) || (Values == NULL)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if (IsListEmpty (&HiiStatement->OptionListHead)) {
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  //
> +  // Loop through the option to get count  //  Values->ValueCount = 0;
> +  Link               = GetFirstNode (&HiiStatement->OptionListHead);
> +  while (!IsNull (&HiiStatement->OptionListHead, Link)) {
> +    Values->ValueCount += 1;
> +    Link                = GetNextNode (&HiiStatement->OptionListHead, Link);
> +  }
> +
> +  Values->ValueArray = AllocateZeroPool (sizeof
> + (EDKII_REDFISH_ATTRIBUTE_VALUE) * Values->ValueCount);  if (Values-
> >ValueArray == NULL) {
> +    Values->ValueCount = 0;
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  Index = 0;
> +  Link  = GetFirstNode (&HiiStatement->OptionListHead);  while (!IsNull
> + (&HiiStatement->OptionListHead, Link)) {
> +    Option = HII_QUESTION_OPTION_FROM_LINK (Link);
> +
> +    if (Option->Text != 0) {
> +      Values->ValueArray[Index].ValueName = HiiGetRedfishAsciiString
> (HiiHandle, SchemaName, Option->Text);
> +      Values->ValueArray[Index].ValueName = HiiGetEnglishAsciiString
> (HiiHandle, Option->Text);
> +    }
> +
> +    Index += 1;
> +    Link   = GetNextNode (&HiiStatement->OptionListHead, Link);
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Return Redfish attribute type from given HII statment operand.
> +
> +  @param[in]  HiiStatement       Target HII statement.
> +
> +  @retval EDKII_REDFISH_ATTRIBUTE_TYPES    Attribute type.
> +
> +**/
> +EDKII_REDFISH_ATTRIBUTE_TYPES
> +HiiStatementToAttributeType (
> +  IN  HII_STATEMENT  *HiiStatement
> +  )
> +{
> +  EDKII_REDFISH_ATTRIBUTE_TYPES  type;
> +
> +  if (HiiStatement == NULL) {
> +    return REDFISH_ATTRIBUTE_TYPE_UNKNOWN;  }
> +
> +  type = REDFISH_ATTRIBUTE_TYPE_UNKNOWN;  switch
> + (HiiStatement->Operand) {
> +    case EFI_IFR_ONE_OF_OP:
> +    case EFI_IFR_ORDERED_LIST_OP:
> +      type = REDFISH_ATTRIBUTE_TYPE_ENUMERATION;
> +      break;
> +    case EFI_IFR_STRING_OP:
> +      type = REDFISH_ATTRIBUTE_TYPE_STRING;
> +      break;
> +    case EFI_IFR_NUMERIC_OP:
> +      type = REDFISH_ATTRIBUTE_TYPE_INTEGER;
> +      break;
> +    case EFI_IFR_CHECKBOX_OP:
> +      type = REDFISH_ATTRIBUTE_TYPE_BOOLEAN;
> +      break;
> +    case EFI_IFR_DATE_OP:
> +    case EFI_IFR_TIME_OP:
> +    default:
> +      DEBUG ((DEBUG_ERROR, "%a, unsupported operand: 0x%x\n",
> __FUNCTION__, HiiStatement->Operand));
> +      break;
> +  }
> +
> +  return type;
> +}
> 
>  /**
>    Zero extend integer/boolean to UINT64 for comparing.
> @@ -264,7 +441,8 @@ CompareHiiStatementValue (
>  /**
>    Convert HII value to the string in HII one-of opcode.
> 
> -  @param[in]  Statement     Statement private instance
> +  @param[in]  HiiStatement  HII Statement private instance
> +  @param[in]  Value         HII Statement value
> 
>    @retval EFI_STRING_ID     The string ID in HII database.
>                              0 is returned when something goes wrong.
> @@ -272,29 +450,34 @@ CompareHiiStatementValue (  **/  EFI_STRING_ID
> HiiValueToOneOfOptionStringId (
> -  IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement
> +  IN HII_STATEMENT        *HiiStatement,
> +  IN HII_STATEMENT_VALUE  *Value
>    )
>  {
>    LIST_ENTRY            *Link;
>    HII_QUESTION_OPTION   *Option;
> 
> -  if (Statement->HiiStatement->Operand != EFI_IFR_ONE_OF_OP) {
> +  if ((HiiStatement == NULL) || (Value == NULL)) {
>      return 0;
>    }
> 
> -  if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {
> +  if (HiiStatement->Operand != EFI_IFR_ONE_OF_OP) {
>      return 0;
>    }
> 
> -  Link = GetFirstNode (&Statement->HiiStatement->OptionListHead);
> -  while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {
> +  if (IsListEmpty (&HiiStatement->OptionListHead)) {
> +    return 0;
> +  }
> +
> +  Link = GetFirstNode (&HiiStatement->OptionListHead);  while (!IsNull
> + (&HiiStatement->OptionListHead, Link)) {
>      Option = HII_QUESTION_OPTION_FROM_LINK (Link);
> 
> -    if (CompareHiiStatementValue (&Statement->HiiStatement->Value,
> &Option->Value) == 0) {
> +    if (CompareHiiStatementValue (Value, &Option->Value) == 0) {
>        return Option->Text;
>      }
> 
> -    Link = GetNextNode (&Statement->HiiStatement->OptionListHead, Link);
> +    Link = GetNextNode (&HiiStatement->OptionListHead, Link);
>    }
> 
>    return 0;
> @@ -531,7 +714,7 @@ DumpOrderedListValue (
>    Convert HII value to the string in HII ordered list opcode. It's caller's
>    responsibility to free returned buffer using FreePool().
> 
> -  @param[in]  Statement     Statement private instance
> +  @param[in]  HiiStatement  HII Statement private instance
>    @param[out] ReturnSize    The size of returned array
> 
>    @retval EFI_STRING_ID     The string ID array for options in ordered list.
> @@ -539,8 +722,8 @@ DumpOrderedListValue (  **/  EFI_STRING_ID *
> HiiValueToOrderedListOptionStringId (
> -  IN  REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement,
> -  OUT UINTN                                     *ReturnSize
> +  IN  HII_STATEMENT  *HiiStatement,
> +  OUT UINTN          *ReturnSize
>    )
>  {
>    LIST_ENTRY            *Link;
> @@ -550,32 +733,32 @@ HiiValueToOrderedListOptionStringId (
>    UINTN                 Index;
>    UINT64                Value;
> 
> -  if (Statement == NULL || ReturnSize == NULL) {
> +  if ((HiiStatement == NULL) || (ReturnSize == NULL)) {
>      return NULL;
>    }
> 
>    *ReturnSize = 0;
> 
> -  if (Statement->HiiStatement->Operand != EFI_IFR_ORDERED_LIST_OP) {
> +  if (HiiStatement->Operand != EFI_IFR_ORDERED_LIST_OP) {
>      return NULL;
>    }
> 
> -  if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {
> +  if (IsListEmpty (&HiiStatement->OptionListHead)) {
>      return NULL;
>    }
> 
>    DEBUG_CODE (
> -    DumpOrderedListValue (Statement->HiiStatement);
> -  );
> +    DumpOrderedListValue (HiiStatement);
> +    );
> 
>    OptionCount = 0;
> -  Link = GetFirstNode (&Statement->HiiStatement->OptionListHead);
> -  while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {
> +  Link        = GetFirstNode (&HiiStatement->OptionListHead);
> +  while (!IsNull (&HiiStatement->OptionListHead, Link)) {
>      Option = HII_QUESTION_OPTION_FROM_LINK (Link);
> 
>      ++OptionCount;
> 
> -    Link = GetNextNode (&Statement->HiiStatement->OptionListHead, Link);
> +    Link = GetNextNode (&HiiStatement->OptionListHead, Link);
>    }
> 
>    *ReturnSize = OptionCount;
> @@ -587,8 +770,8 @@ HiiValueToOrderedListOptionStringId (
>    }
> 
>    for (Index = 0; Index < OptionCount; Index++) {
> -    Value = OrderedListGetArrayData (Statement->HiiStatement-
> >Value.Buffer, Statement->HiiStatement->Value.BufferValueType, Index);
> -    ReturnedArray[Index] = OrderedListOptionValueToStringId (Statement-
> >HiiStatement, Value);
> +    Value                = OrderedListGetArrayData (HiiStatement->Value.Buffer,
> HiiStatement->Value.BufferValueType, Index);
> +    ReturnedArray[Index] = OrderedListOptionValueToStringId
> + (HiiStatement, Value);
>    }
> 
>    return ReturnedArray;
> @@ -657,6 +840,126 @@ HiiStringToOrderedListOptionValue (
>    return EFI_NOT_FOUND;
>  }
> 
> +/**
> +  Convert HII value to Redfish value.
> +
> +  @param[in]  HiiHandle     HII handle.
> +  @param[in]  FullSchema    Schema string.
> +  @param[in]  HiiStatement  HII statement.
> +  @param[in]  Value         Value to be converted.
> +  @param[out] RedfishValue  Value in Redfish format.
> +
> +  @retval EFI_SUCCESS       Redfish value is returned successfully.
> +  @retval Others            Errors occur
> +
> +**/
> +EFI_STATUS
> +HiiValueToRedfishValue (
> +  IN  EFI_HII_HANDLE       HiiHandle,
> +  IN  CHAR8                *FullSchema,
> +  IN  HII_STATEMENT        *HiiStatement,
> +  IN  HII_STATEMENT_VALUE  *Value,
> +  OUT EDKII_REDFISH_VALUE  *RedfishValue
> +  )
> +{
> +  EFI_STATUS     Status;
> +  EFI_STRING_ID  StringId;
> +  UINTN          Index;
> +  UINTN          Count;
> +  EFI_STRING_ID  *StringIdArray;
> +
> +  if ((HiiHandle == NULL) || (HiiStatement == NULL) || (Value == NULL) ||
> (RedfishValue == NULL) || IS_EMPTY_STRING (FullSchema)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  StringIdArray = NULL;
> +  Count         = 0;
> +
> +  switch (HiiStatement->Operand) {
> +    case EFI_IFR_ONE_OF_OP:
> +      StringId = HiiValueToOneOfOptionStringId (HiiStatement, Value);
> +      if (StringId == 0) {
> +        ASSERT (FALSE);
> +        Status = EFI_DEVICE_ERROR;
> +        break;
> +      }
> +
> +      RedfishValue->Value.Buffer = HiiGetRedfishAsciiString (HiiHandle,
> FullSchema, StringId);
> +      if (RedfishValue->Value.Buffer == NULL) {
> +        Status = EFI_OUT_OF_RESOURCES;
> +        break;
> +      }
> +
> +      RedfishValue->Type = REDFISH_VALUE_TYPE_STRING;
> +      break;
> +    case EFI_IFR_STRING_OP:
> +      if (Value->Type != EFI_IFR_TYPE_STRING) {
> +        ASSERT (FALSE);
> +        Status = EFI_DEVICE_ERROR;
> +        break;
> +      }
> +
> +      RedfishValue->Type         = REDFISH_VALUE_TYPE_STRING;
> +      RedfishValue->Value.Buffer = AllocatePool (StrLen ((CHAR16 *)Value-
> >Buffer) + 1);
> +      UnicodeStrToAsciiStrS ((CHAR16 *)Value->Buffer, RedfishValue-
> >Value.Buffer, StrLen ((CHAR16 *)Value->Buffer) + 1);
> +      break;
> +    case EFI_IFR_CHECKBOX_OP:
> +    case EFI_IFR_NUMERIC_OP:
> +      Status = HiiValueToRedfishNumeric (Value, RedfishValue);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a, failed to convert HII value to Redfish
> value: %r\n", __FUNCTION__, Status));
> +        break;
> +      }
> +
> +      break;
> +    case EFI_IFR_ACTION_OP:
> +      if (Value->Type != EFI_IFR_TYPE_ACTION) {
> +        ASSERT (FALSE);
> +        Status = EFI_DEVICE_ERROR;
> +        break;
> +      }
> +
> +      //
> +      // Action has no value. Just return unknown type.
> +      //
> +      RedfishValue->Type = REDFISH_VALUE_TYPE_UNKNOWN;
> +      break;
> +    case EFI_IFR_ORDERED_LIST_OP:
> +      StringIdArray = HiiValueToOrderedListOptionStringId (HiiStatement,
> &Count);
> +      if (StringIdArray == NULL) {
> +        ASSERT (FALSE);
> +        Status = EFI_DEVICE_ERROR;
> +        break;
> +      }
> +
> +      RedfishValue->Value.StringArray = AllocatePool (sizeof (CHAR8 *) *
> Count);
> +      if (RedfishValue->Value.StringArray == NULL) {
> +        ASSERT (FALSE);
> +        Status = EFI_OUT_OF_RESOURCES;
> +        break;
> +      }
> +
> +      for (Index = 0; Index < Count; Index++) {
> +        ASSERT (StringIdArray[Index] != 0);
> +        RedfishValue->Value.StringArray[Index] = HiiGetRedfishAsciiString
> (HiiHandle, FullSchema, StringIdArray[Index]);
> +        ASSERT (RedfishValue->Value.StringArray[Index] != NULL);
> +      }
> +
> +      RedfishValue->ArrayCount = Count;
> +      RedfishValue->Type       = REDFISH_VALUE_TYPE_STRING_ARRAY;
> +
> +      FreePool (StringIdArray);
> +      break;
> +    default:
> +      DEBUG ((DEBUG_ERROR, "%a, catch unsupported type: 0x%x! Please
> contact with author if we need to support this type.\n", __FUNCTION__,
> HiiStatement->Operand));
> +      ASSERT (FALSE);
> +      Status = EFI_UNSUPPORTED;
> +      break;
> +  }
> +
> +  return Status;
> +}
> +
>  /**
>    Convert input ascii string to unicode string. It's caller's
>    responsibility to free returned buffer using FreePool().
> @@ -825,12 +1128,7 @@ RedfishPlatformConfigProtocolGetValue (
>    EFI_STATUS                                Status;
>    REDFISH_PLATFORM_CONFIG_PRIVATE
> *RedfishPlatformConfigPrivate;
>    REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement;
> -  EFI_STRING_ID                             StringId;
> -  EFI_STRING_ID                             *StringIdArray;
>    CHAR8                                     *FullSchema;
> -  EFI_STRING                                HiiString;
> -  UINTN                                     Count;
> -  UINTN                                     Index;
> 
>    if (This == NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING
> (Version) || IS_EMPTY_STRING (ConfigureLang) || Value == NULL) {
>      return EFI_INVALID_PARAMETER;
> @@ -839,10 +1137,7 @@ RedfishPlatformConfigProtocolGetValue (
>    RedfishPlatformConfigPrivate =
> REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS (This);
>    Value->Type = REDFISH_VALUE_TYPE_UNKNOWN;
>    Value->ArrayCount = 0;
> -  Count = 0;
>    FullSchema = NULL;
> -  HiiString = NULL;
> -  StringIdArray = NULL;
> 
>    FullSchema = GetFullSchemaString (Schema, Version);
>    if (FullSchema == NULL) {
> @@ -854,82 +1149,15 @@ RedfishPlatformConfigProtocolGetValue (
>      goto RELEASE_RESOURCE;
>    }
> 
> -  switch (TargetStatement->HiiStatement->Operand) {
> -    case EFI_IFR_ONE_OF_OP:
> -      StringId = HiiValueToOneOfOptionStringId (TargetStatement);
> -      if (StringId == 0) {
> -        ASSERT (FALSE);
> -        Status = EFI_DEVICE_ERROR;
> -        goto RELEASE_RESOURCE;
> -      }
> -
> -      Value->Value.Buffer = HiiGetRedfishAsciiString (TargetStatement-
> >ParentForm->ParentFormset->HiiHandle, FullSchema, StringId);
> -      if (Value->Value.Buffer == NULL) {
> -        Status = EFI_OUT_OF_RESOURCES;
> -        goto RELEASE_RESOURCE;
> -      }
> -
> -      Value->Type = REDFISH_VALUE_TYPE_STRING;
> -      break;
> -    case EFI_IFR_STRING_OP:
> -      if (TargetStatement->HiiStatement->Value.Type !=
> EFI_IFR_TYPE_STRING) {
> -        ASSERT (FALSE);
> -        Status = EFI_DEVICE_ERROR;
> -        goto RELEASE_RESOURCE;
> -      }
> -
> -      Value->Type = REDFISH_VALUE_TYPE_STRING;
> -      Value->Value.Buffer = AllocatePool (StrLen ((CHAR16
> *)TargetStatement->HiiStatement->Value.Buffer) + 1);
> -      UnicodeStrToAsciiStrS ((CHAR16 *)TargetStatement->HiiStatement-
> >Value.Buffer, Value->Value.Buffer, StrLen ((CHAR16 *)TargetStatement-
> >HiiStatement->Value.Buffer) + 1);
> -      break;
> -    case EFI_IFR_CHECKBOX_OP:
> -    case EFI_IFR_NUMERIC_OP:
> -      Status = HiiValueToRedfishNumeric (&TargetStatement->HiiStatement-
> >Value, Value);
> -      if (EFI_ERROR (Status)) {
> -        DEBUG ((DEBUG_ERROR, "%a, failed to convert HII value to Redfish
> value: %r\n", __FUNCTION__, Status));
> -        goto RELEASE_RESOURCE;
> -      }
> -      break;
> -    case EFI_IFR_ACTION_OP:
> -      if (TargetStatement->HiiStatement->Value.Type !=
> EFI_IFR_TYPE_ACTION) {
> -        ASSERT (FALSE);
> -        Status = EFI_DEVICE_ERROR;
> -        goto RELEASE_RESOURCE;
> -      }
> -
> -      //
> -      // Action has no value. Just return unknown type.
> -      //
> -      Value->Type = REDFISH_VALUE_TYPE_UNKNOWN;
> -      break;
> -    case EFI_IFR_ORDERED_LIST_OP:
> -      StringIdArray = HiiValueToOrderedListOptionStringId (TargetStatement,
> &Count);
> -      if (StringIdArray == NULL) {
> -        ASSERT (FALSE);
> -        Status = EFI_DEVICE_ERROR;
> -        goto RELEASE_RESOURCE;
> -      }
> -
> -      Value->Value.StringArray = AllocatePool (sizeof (CHAR8 *) * Count);
> -      if (Value->Value.StringArray == NULL) {
> -        ASSERT (FALSE);
> -        Status = EFI_OUT_OF_RESOURCES;
> -        goto RELEASE_RESOURCE;
> -      }
> -
> -      for (Index = 0; Index < Count; Index++) {
> -        ASSERT (StringIdArray[Index] != 0);
> -        Value->Value.StringArray[Index] = HiiGetRedfishAsciiString
> (TargetStatement->ParentForm->ParentFormset->HiiHandle, FullSchema,
> StringIdArray[Index]);
> -      }
> -
> -      Value->ArrayCount = Count;
> -      Value->Type = REDFISH_VALUE_TYPE_STRING_ARRAY;
> -      break;
> -    default:
> -      DEBUG ((DEBUG_ERROR, "%a, catch unsupported type: 0x%x! Please
> contact with author if we need to support this type.\n", __FUNCTION__,
> TargetStatement->HiiStatement->Operand));
> -      ASSERT (FALSE);
> -      Status = EFI_UNSUPPORTED;
> -      goto RELEASE_RESOURCE;
> +  Status = HiiValueToRedfishValue (
> +             TargetStatement->ParentForm->ParentFormset->HiiHandle,
> +             FullSchema,
> +             TargetStatement->HiiStatement,
> +             &TargetStatement->HiiStatement->Value,
> +             Value
> +             );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a, HiiValueToRedfishValue failed: %r\n",
> + __FUNCTION__, Status));
>    }
> 
>  RELEASE_RESOURCE:
> @@ -938,14 +1166,6 @@ RELEASE_RESOURCE:
>      FreePool (FullSchema);
>    }
> 
> -  if (HiiString != NULL) {
> -    FreePool (HiiString);
> -  }
> -
> -  if (StringIdArray != NULL) {
> -    FreePool (StringIdArray);
> -  }
> -
>    return Status;
>  }
> 
> @@ -1433,6 +1653,176 @@
> RedfishPlatformConfigProtocolGetSupportedSchema (
>    return EFI_SUCCESS;
>  }
> 
> +/**
> +  Get Redfish default value with the given Schema and Configure Language.
> +
> +  @param[in]   This                Pointer to
> EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
> +  @param[in]   Schema              The Redfish schema to query.
> +  @param[in]   Version             The Redfish version to query.
> +  @param[in]   ConfigureLang       The target value which match this configure
> Language.
> +  @param[in]   DefaultClass        The UEFI defined default class.
> +                                   Please refer to UEFI spec. 33.2.5.8 "defaults" for details.
> +  @param[out]  Value               The returned value.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +RedfishPlatformConfigProtocolGetDefaultValue (
> +  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL  *This,
> +  IN     CHAR8                                   *Schema,
> +  IN     CHAR8                                   *Version,
> +  IN     EFI_STRING                              ConfigureLang,
> +  IN     UINT16                                  DefaultClass,
> +  OUT    EDKII_REDFISH_VALUE                     *Value
> +  )
> +{
> +  EFI_STATUS                                 Status;
> +  REDFISH_PLATFORM_CONFIG_PRIVATE
> *RedfishPlatformConfigPrivate;
> +  REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE  *TargetStatement;
> +  CHAR8                                      *FullSchema;
> +  HII_STATEMENT_VALUE                        DefaultValue;
> +
> +  if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING
> (Version) || IS_EMPTY_STRING (ConfigureLang) || (Value == NULL)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  RedfishPlatformConfigPrivate =
> REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS (This);
> +  Value->Type                  = REDFISH_VALUE_TYPE_UNKNOWN;
> +  Value->ArrayCount            = 0;
> +
> +  FullSchema = NULL;
> +  FullSchema = GetFullSchemaString (Schema, Version);  if (FullSchema
> + == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  Status = RedfishPlatformConfigGetStatementCommon
> + (RedfishPlatformConfigPrivate, FullSchema, ConfigureLang,
> &TargetStatement);  if (EFI_ERROR (Status)) {
> +    goto RELEASE_RESOURCE;
> +  }
> +
> +  Status = GetQuestionDefault
> + (TargetStatement->ParentForm->ParentFormset->HiiFormSet,
> TargetStatement->ParentForm->HiiForm, TargetStatement->HiiStatement,
> DefaultClass, &DefaultValue);  if (EFI_ERROR (Status)) {
> +    goto RELEASE_RESOURCE;
> +  }
> +
> +  Status = HiiValueToRedfishValue (
> +             TargetStatement->ParentForm->ParentFormset->HiiHandle,
> +             FullSchema,
> +             TargetStatement->HiiStatement,
> +             &DefaultValue,
> +             Value
> +             );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a, HiiValueToRedfishValue failed: %r\n",
> + __FUNCTION__, Status));  }
> +
> +RELEASE_RESOURCE:
> +
> +  if (FullSchema != NULL) {
> +    FreePool (FullSchema);
> +  }
> +
> +  return Status;
> +}
> +
> +/**
> +  Get Redfish attribute value with the given Schema and Configure Language.
> +
> +  @param[in]   This                Pointer to
> EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance.
> +  @param[in]   Schema              The Redfish schema to query.
> +  @param[in]   Version             The Redfish version to query.
> +  @param[in]   ConfigureLang       The target value which match this configure
> Language.
> +  @param[out]  AttributeValue      The attribute value.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +RedfishPlatformConfigProtocolGetAttribute (
> +  IN     EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL  *This,
> +  IN     CHAR8                                   *Schema,
> +  IN     CHAR8                                   *Version,
> +  IN     EFI_STRING                              ConfigureLang,
> +  OUT    EDKII_REDFISH_ATTRIBUTE                 *AttributeValue
> +  )
> +{
> +  EFI_STATUS                                 Status;
> +  REDFISH_PLATFORM_CONFIG_PRIVATE
> *RedfishPlatformConfigPrivate;
> +  REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE  *TargetStatement;
> +  CHAR8                                      *FullSchema;
> +  CHAR8                                      *Buffer;
> +
> +  if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING
> (Version) || IS_EMPTY_STRING (ConfigureLang) || (AttributeValue == NULL))
> {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  RedfishPlatformConfigPrivate =
> + REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS (This);  ZeroMem
> + (AttributeValue, sizeof (EDKII_REDFISH_ATTRIBUTE));  FullSchema =
> + NULL;  FullSchema = GetFullSchemaString (Schema, Version);  if
> + (FullSchema == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  Status = RedfishPlatformConfigGetStatementCommon
> + (RedfishPlatformConfigPrivate, FullSchema, ConfigureLang,
> &TargetStatement);  if (EFI_ERROR (Status)) {
> +    goto RELEASE_RESOURCE;
> +  }
> +
> +  if (TargetStatement->Description != 0) {
> +    AttributeValue->AttributeName = HiiGetRedfishAsciiString
> (TargetStatement->ParentForm->ParentFormset->HiiHandle, FullSchema,
> TargetStatement->Description);
> +    Buffer                        = GetAttributeNameFromConfigLanguage
> (AttributeValue->AttributeName);
> +    if (Buffer != NULL) {
> +      FreePool (AttributeValue->AttributeName);
> +      AttributeValue->AttributeName = Buffer;
> +    }
> +
> +    AttributeValue->DisplayName = HiiGetEnglishAsciiString
> + (TargetStatement->ParentForm->ParentFormset->HiiHandle,
> + TargetStatement->Description);  }
> +
> +  if (TargetStatement->Help != 0) {
> +    AttributeValue->HelpText = HiiGetEnglishAsciiString
> + (TargetStatement->ParentForm->ParentFormset->HiiHandle,
> + TargetStatement->Help);  }
> +
> +  AttributeValue->ReadOnly      = ((TargetStatement->Flags &
> EFI_IFR_FLAG_READ_ONLY) == 0 ? FALSE : TRUE);
> +  AttributeValue->ResetRequired = ((TargetStatement->Flags &
> EFI_IFR_FLAG_RESET_REQUIRED) == 0 ? FALSE : TRUE);
> +  AttributeValue->Type          = HiiStatementToAttributeType
> (TargetStatement->HiiStatement);
> +
> +  //
> +  // Deal with maximum and minimum
> +  //
> +  if (AttributeValue->Type == REDFISH_ATTRIBUTE_TYPE_STRING) {
> +    AttributeValue->StrMaxSize = TargetStatement-
> >StatementData.StrMaxSize;
> +    AttributeValue->StrMinSize =
> + TargetStatement->StatementData.StrMinSize;
> +  } else if (AttributeValue->Type == REDFISH_ATTRIBUTE_TYPE_INTEGER) {
> +    AttributeValue->NumMaximum = TargetStatement-
> >StatementData.NumMaximum;
> +    AttributeValue->NumMinimum = TargetStatement-
> >StatementData.NumMinimum;
> +    AttributeValue->NumStep    = TargetStatement-
> >StatementData.NumStep;
> +  }
> +
> +  //
> +  // Provide value array if this is enumeration type.
> +  //
> +  if (TargetStatement->HiiStatement->Operand == EFI_IFR_ONE_OF_OP) {
> +    Status = OneOfStatementToAttributeValues (TargetStatement-
> >ParentForm->ParentFormset->HiiHandle, FullSchema, TargetStatement-
> >HiiStatement, &AttributeValue->Values);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "%a, failed to convert one-of options to
> attribute values: %r\n", __FUNCTION__, Status));
> +    }
> +  }
> +
> +RELEASE_RESOURCE:
> +
> +  if (FullSchema != NULL) {
> +    FreePool (FullSchema);
> +  }
> +
> +  return Status;
> +}
> +
>  /**
>    Functions which are registered to receive notification of
>    database events have this prototype. The actual event is encoded @@ -
> 1715,10 +2105,13 @@ RedfishPlatformConfigDxeEntryPoint (
>    // Protocol initialization
>    //
>    mRedfishPlatformConfigPrivate->ImageHandle = ImageHandle;
> -  mRedfishPlatformConfigPrivate->Protocol.GetValue =
> RedfishPlatformConfigProtocolGetValue;
> -  mRedfishPlatformConfigPrivate->Protocol.SetValue =
> RedfishPlatformConfigProtocolSetValue;
> -  mRedfishPlatformConfigPrivate->Protocol.GetConfigureLang =
> RedfishPlatformConfigProtocolGetConfigureLang;
> +  mRedfishPlatformConfigPrivate->Protocol.Revision           =
> REDFISH_PLATFORM_CONFIG_VERSION;
> +  mRedfishPlatformConfigPrivate->Protocol.GetValue           =
> RedfishPlatformConfigProtocolGetValue;
> +  mRedfishPlatformConfigPrivate->Protocol.SetValue           =
> RedfishPlatformConfigProtocolSetValue;
> +  mRedfishPlatformConfigPrivate->Protocol.GetConfigureLang   =
> RedfishPlatformConfigProtocolGetConfigureLang;
>    mRedfishPlatformConfigPrivate->Protocol.GetSupportedSchema =
> RedfishPlatformConfigProtocolGetSupportedSchema;
> +  mRedfishPlatformConfigPrivate->Protocol.GetAttribute       =
> RedfishPlatformConfigProtocolGetAttribute;
> +  mRedfishPlatformConfigPrivate->Protocol.GetDefaultValue    =
> RedfishPlatformConfigProtocolGetDefaultValue;
> 
>    InitializeListHead (&mRedfishPlatformConfigPrivate->FormsetList);
>    InitializeListHead (&mRedfishPlatformConfigPrivate->PendingList);
> diff --git
> a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
> b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
> index d3f7af55ad..8155484702 100644
> --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
> +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
> @@ -2,6 +2,7 @@
>    This file defines the EDKII Redfish Platform Config Protocol interface.
> 
>    (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -60,5 +61,6 @@ typedef struct {
>  #define REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS(a)  BASE_CR
> (a, REDFISH_PLATFORM_CONFIG_PRIVATE, Protocol)
>  #define REGULAR_EXPRESSION_INCLUDE_ALL                L".*"
>  #define CONFIGURE_LANGUAGE_PREFIX                     "x-uefi-redfish-"
> +#define REDFISH_PLATFORM_CONFIG_VERSION               0x00010000
> 
>  #endif
> diff --git
> a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
> b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
> index b2bb5f64e4..65a0e5766a 100644
> --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
> +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
> @@ -3,6 +3,7 @@
>    The implementation of EDKII Redfish Platform Config Protocol.
> 
>    (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -300,6 +301,45 @@ HiiGetEnglishString (
>    return HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE,
> StringId);  }
> 
> +/**
> +  Get ASCII string from HII database in English language.
> +
> +  @param[in]  HiiHandle         A handle that was previously registered in the
> HII Database.
> +  @param[in]  StringId          The identifier of the string to retrieved from the
> string
> +                                package associated with HiiHandle.
> +
> +  @retval NULL   The string specified by StringId is not present in the string
> package.
> +  @retval Other  The string was returned.
> +
> +**/
> +CHAR8 *
> +HiiGetEnglishAsciiString (
> +  IN EFI_HII_HANDLE  HiiHandle,
> +  IN EFI_STRING_ID   StringId
> +  )
> +{
> +  EFI_STRING  HiiString;
> +  UINTN       StringSize;
> +  CHAR8       *AsciiString;
> +
> +  HiiString = HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE,
> + StringId);  if (HiiString == NULL) {
> +    DEBUG ((DEBUG_ERROR, "%a, Can not find string ID: 0x%x with %a\n",
> __FUNCTION__, StringId, ENGLISH_LANGUAGE_CODE));
> +    return NULL;
> +  }
> +
> +  StringSize  = (StrLen (HiiString) + 1) * sizeof (CHAR8);  AsciiString
> + = AllocatePool (StringSize);  if (AsciiString == NULL) {
> +    return NULL;
> +  }
> +
> +  UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize);
> +
> +  FreePool (HiiString);
> +  return AsciiString;
> +}
> +
>  /**
>    Check and see if this is supported schema or not.
> 
> @@ -885,10 +925,17 @@ LoadFormset (
>        //
>        // Initialize statement private data.
>        //
> -      HiiStatementPrivate->HiiStatement = HiiStatement;
> -      HiiStatementPrivate->QuestionId = HiiStatement->QuestionId;
> -      HiiStatementPrivate->Description = HiiStatement->Prompt;
> -      HiiStatementPrivate->ParentForm = HiiFormPrivate;
> +      HiiStatementPrivate->HiiStatement             = HiiStatement;
> +      HiiStatementPrivate->QuestionId               = HiiStatement->QuestionId;
> +      HiiStatementPrivate->Description              = HiiStatement->Prompt;
> +      HiiStatementPrivate->Help                     = HiiStatement->Help;
> +      HiiStatementPrivate->ParentForm               = HiiFormPrivate;
> +      HiiStatementPrivate->Flags                    = HiiStatement->QuestionFlags;
> +      HiiStatementPrivate->StatementData.NumMaximum = HiiStatement-
> >ExtraData.NumData.Maximum;
> +      HiiStatementPrivate->StatementData.NumMinimum = HiiStatement-
> >ExtraData.NumData.Minimum;
> +      HiiStatementPrivate->StatementData.NumStep    = HiiStatement-
> >ExtraData.NumData.Step;
> +      HiiStatementPrivate->StatementData.StrMaxSize = HiiStatement-
> >ExtraData.StrData.MaxSize;
> +      HiiStatementPrivate->StatementData.StrMinSize =
> + HiiStatement->ExtraData.StrData.MinSize;
> 
>        //
>        // Attach to statement list.
> diff --git
> a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
> b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
> index cd7a52aef3..f66f5a8799 100644
> --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
> +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
> @@ -2,6 +2,7 @@
>    This file defines the EDKII Redfish Platform Config Protocol interface.
> 
>    (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -74,16 +75,30 @@ typedef struct {
> 
>  #define REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK(a)  BASE_CR (a,
> REDFISH_PLATFORM_CONFIG_FORM_PRIVATE, Link)
> 
> +//
> +// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_DATA
> +//
> +typedef struct {
> +  UINT64    NumMinimum;
> +  UINT64    NumMaximum;
> +  UINT64    NumStep;
> +  UINT8     StrMinSize;
> +  UINT8     StrMaxSize;
> +} REDFISH_PLATFORM_CONFIG_STATEMENT_DATA;
> +
>  //
>  // Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE
>  //
>  typedef struct {
> -  LIST_ENTRY                            Link;
> -  REDFISH_PLATFORM_CONFIG_FORM_PRIVATE  *ParentForm;
> -  HII_STATEMENT                         *HiiStatement;  // Pointer to HII statement
> data.
> -  EFI_QUESTION_ID                       QuestionId;     // Question ID of this
> statement.
> -  EFI_STRING_ID                         Description;    // String token of this question.
> -  EFI_STRING                            DesStringCache; // The string cache for search
> function.
> +  LIST_ENTRY                                Link;
> +  REDFISH_PLATFORM_CONFIG_FORM_PRIVATE      *ParentForm;
> +  HII_STATEMENT                             *HiiStatement;  // Pointer to HII statement
> data.
> +  EFI_QUESTION_ID                           QuestionId;     // Question ID of this
> statement.
> +  EFI_STRING_ID                             Description;    // String token of this question.
> +  EFI_STRING_ID                             Help;           // String token of help message.
> +  EFI_STRING                                DesStringCache; // The string cache for search
> function.
> +  UINT8                                     Flags;          // The statement flag.
> +  REDFISH_PLATFORM_CONFIG_STATEMENT_DATA    StatementData;  //
> The max/min for statement value.
>  } REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE;
> 
>  #define REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK(a)
> BASE_CR (a, REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE, Link) @@
> -280,6 +295,23 @@ HiiGetRedfishAsciiString (
>    IN EFI_STRING_ID            StringId
>    );
> 
> +/**
> +  Get ASCII string from HII database in English language.
> +
> +  @param[in]  HiiHandle         A handle that was previously registered in the
> HII Database.
> +  @param[in]  StringId          The identifier of the string to retrieved from the
> string
> +                                package associated with HiiHandle.
> +
> +  @retval NULL   The string specified by StringId is not present in the string
> package.
> +  @retval Other  The string was returned.
> +
> +**/
> +CHAR8 *
> +HiiGetEnglishAsciiString (
> +  IN EFI_HII_HANDLE  HiiHandle,
> +  IN EFI_STRING_ID   StringId
> +  );
> +
>  /**
>    Release all resource in statement list.
> 
> --
> 2.38.1.windows.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-12  2:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-07 14:10 [edk2-staging][PATCH 2/3] edk2-staging/RedfishPkg: Introduce new interfaces to Redfish protocol Nickle Wang
2022-12-12  2:44 ` Chang, Abner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox