BIOS: Implement HelpText and DisplayName properties

Introduce HelpText and DisplayName fields in the PLDM BIOS JSONs, these should
be parsed and passed to the D-Bus APIs that populates the BIOS table.
https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/BIOSConfig/Manager.interface.yaml#L68
Also, they have the same names in the Redfish schema.
https://redfish.dmtf.org/schemas/v1/AttributeRegistry.v1_3_3.json

Tested: test with JSON
https://gist.github.com/lxwinspur/2afffff2e445fddf90dfed6eceef4014

busctl get-property xyz.openbmc_project.BIOSConfigManager
/xyz/openbmc_project/bios_config/manager
xyz.openbmc_project.BIOSConfig.Manager BaseBIOSTable

a{s(sbsssvva(sv))} 5

"CodeUpdatePolicy"
"xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration"
true "CodeUpdatePolicy DisplayName" "CodeUpdatePolicy HelpText" "" s
"Concurrent" s "Concurrent" 2
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.OneOf" s "Concurrent"
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.OneOf" s "Disruptive"

"Led"
"xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration"
false "Led DisplayName" "Led HelpText" "" s "Off" s "Off" 2
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.OneOf" s "On"
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.OneOf" s "Off"

"Model"
"xyz.openbmc_project.BIOSConfig.Manager.AttributeType.String"
false "Model DisplayName" "Model HelpText" "" s "powersupply0" s "FP5280G2" 2
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.MinStringLength" x 1
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.MaxStringLength" x 100

"OUTLET"
"xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Integer"
false "OUTLET DisplayName" "OUTLET HelpText" "" x 9127925392260618112 x 0 3
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.LowerBound" x 0
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.UpperBound" x 68002
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.ScalarIncrement" x 1

"str_example3"
"xyz.openbmc_project.BIOSConfig.Manager.AttributeType.String"
true "str_example3 DisplayName" "str_example3 HelpText" "" s "ef" s "ef" 2
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.MinStringLength" x 1
"xyz.openbmc_project.BIOSConfig.Manager.BoundType.MaxStringLength" x 100

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I4e0e28a6fbaeb409b4d57dfcb54d79aee1c5b211
diff --git a/test/bios_jsons/enum_attrs.json b/test/bios_jsons/enum_attrs.json
index 5ad3ad2..bee666f 100644
--- a/test/bios_jsons/enum_attrs.json
+++ b/test/bios_jsons/enum_attrs.json
@@ -5,6 +5,8 @@
          "possible_values" : [ "On", "Off" ],
          "default_values" : [ "On" ],
          "readOnly" : false,
+         "helpText" : "HMCManagedState HelpText",
+         "displayName" : "HMCManagedState DisplayName",
          "dbus":
             {
                "object_path" : "/xyz/abc/def",
@@ -19,6 +21,8 @@
          "possible_values" : [ "Perm", "Temp" ],
          "default_values" : [ "Perm" ],
          "readOnly" : false,
+         "helpText" : "FWBootSide HelpText",
+         "displayName" : "FWBootSide DisplayName",
          "dbus":
             {
                "object_path" : "/xyz/abc/def",
@@ -33,6 +37,8 @@
          "possible_values" : [ "Allowed", "NotAllowed" ],
          "default_values" : [ "Allowed" ],
          "readOnly" : false,
+         "helpText" : "InbandCodeUpdate HelpText",
+         "displayName" : "InbandCodeUpdate DisplayName",
          "dbus":
             {
                "object_path" : "/xyz/abc/def",
@@ -46,7 +52,9 @@
          "attribute_name" : "CodeUpdatePolicy",
          "possible_values" : [ "Concurrent", "Disruptive" ],
          "default_values" : [ "Concurrent" ],
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "CodeUpdatePolicy HelpText",
+         "displayName" : "CodeUpdatePolicy DisplayName"
       }
     ]
 }
diff --git a/test/bios_jsons/integer_attrs.json b/test/bios_jsons/integer_attrs.json
index 576433e..e6833aa 100644
--- a/test/bios_jsons/integer_attrs.json
+++ b/test/bios_jsons/integer_attrs.json
@@ -7,6 +7,8 @@
          "scalar_increment" : 1,
          "default_value" : 0,
          "readOnly" : false,
+         "helpText" : "VDD_AVSBUS_RAIL HelpText",
+         "displayName" : "VDD_AVSBUS_RAIL DisplayName",
          "dbus":{
             "object_path" : "/xyz/openbmc_project/avsbus",
             "interface" : "xyz.openbmc.AvsBus.Manager",
@@ -20,7 +22,9 @@
          "upper_bound" : 15,
          "scalar_increment" : 1,
          "default_value" : 2,
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "SBE_IMAGE_MINIMUM_VALID_ECS HelpText",
+         "displayName" : "SBE_IMAGE_MINIMUM_VALID_ECS DisplayName"
       },
       {
          "attribute_name" : "INTEGER_INVALID_CASE",
@@ -28,7 +32,9 @@
          "upper_bound" : 15,
          "scalar_increment" : 2,
          "default_value" : 3,
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "INTEGER_INVALID_CASE HelpText",
+         "displayName" : "INTEGER_INVALID_CASE DisplayName"
       }
    ]
 }
diff --git a/test/bios_jsons/string_attrs.json b/test/bios_jsons/string_attrs.json
index e5b3920..09e0e4c 100644
--- a/test/bios_jsons/string_attrs.json
+++ b/test/bios_jsons/string_attrs.json
@@ -8,6 +8,8 @@
             "default_string_length" : 3,
             "default_string" : "abc",
             "readOnly" : false,
+            "helpText" : "str_example1 HelpText",
+            "displayName" : "str_example1 DisplayName",
             "dbus" : {
                 "object_path" : "/xyz/abc/def",
                 "interface" : "xyz.openbmc_project.str_example1.value",
@@ -23,6 +25,8 @@
             "default_string_length" : 0,
             "default_string" : "",
             "readOnly" : false,
+            "helpText" : "str_example2 HelpText",
+            "displayName" : "str_example2 DisplayName",
             "dbus" : {
                 "object_path" : "/xyz/abc/def",
                 "interface" : "xyz.openbmc_project.str_example2.value",
@@ -37,7 +41,9 @@
             "maximum_string_length" : 100,
             "default_string_length" : 2,
             "default_string" : "ef",
-            "readOnly" : true
+            "readOnly" : true,
+            "helpText" : "str_example3 HelpText",
+            "displayName" : "str_example3 DisplayName"
         }
     ]
 }
diff --git a/test/libpldmresponder_bios_attribute_test.cpp b/test/libpldmresponder_bios_attribute_test.cpp
index 1a7e74a..84fb661 100644
--- a/test/libpldmresponder_bios_attribute_test.cpp
+++ b/test/libpldmresponder_bios_attribute_test.cpp
@@ -43,7 +43,9 @@
 {
     auto jsonReadOnly = R"({
       "attribute_name" : "ReadOnly",
-      "readOnly" : true
+      "readOnly" : true,
+      "helpText" : "HelpText",
+      "displayName" : "DisplayName"
     })"_json;
 
     TestAttribute readOnly{jsonReadOnly, nullptr};
@@ -60,6 +62,8 @@
     auto jsonReadWrite = R"({
       "attribute_name":"ReadWrite",
       "readOnly" : false,
+      "helpText" : "HelpText",
+      "displayName" : "DisplayName",
       "dbus":
            {
                "object_path" : "/xyz/abc/def",
@@ -78,4 +82,16 @@
     EXPECT_EQ(dbusMap->interface, "xyz.openbmc.FWBoot.Side");
     EXPECT_EQ(dbusMap->propertyName, "Side");
     EXPECT_EQ(dbusMap->propertyType, "bool");
+
+    auto jsonReadWriteError = R"({
+      "attribute_name":"ReadWrite",
+      "dbus":
+           {
+               "object_path" : "/xyz/abc/def",
+               "interface" : "xyz.openbmc.FWBoot.Side",
+               "property_name" : "Side"
+           }
+    })"_json; // missing property_type.
+
+    EXPECT_THROW((TestAttribute{jsonReadWriteError, nullptr}), Json::exception);
 }
diff --git a/test/libpldmresponder_bios_enum_attribute_test.cpp b/test/libpldmresponder_bios_enum_attribute_test.cpp
index 4a91dcb..b9a5277 100644
--- a/test/libpldmresponder_bios_enum_attribute_test.cpp
+++ b/test/libpldmresponder_bios_enum_attribute_test.cpp
@@ -35,7 +35,9 @@
          "attribute_name" : "CodeUpdatePolicy",
          "possible_values" : [ "Concurrent", "Disruptive" ],
          "default_values" : [ "Concurrent" ],
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName"
       })"_json;
 
     BIOSEnumAttribute enumReadOnly{jsonEnumReadOnly, nullptr};
@@ -49,7 +51,9 @@
          "attribute_name" : "CodeUpdatePolicy",
          "possible_value" : [ "Concurrent", "Disruptive" ],
          "default_values" : [ "Concurrent" ],
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName"
       })"_json; // possible_value -> possible_values
     EXPECT_THROW((BIOSEnumAttribute{jsonEnumReadOnlyError, nullptr}),
                  Json::exception);
@@ -59,6 +63,8 @@
          "possible_values" : [ "Perm", "Temp" ],
          "default_values" : [ "Perm" ],
          "readOnly" : false,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName",
          "dbus":
             {
                "object_path" : "/xyz/abc/def",
@@ -83,7 +89,9 @@
          "attribute_name" : "CodeUpdatePolicy",
          "possible_values" : [ "Concurrent", "Disruptive" ],
          "default_values" : [ "Disruptive" ],
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName"
       })"_json;
 
     std::vector<uint8_t> expectedAttrEntry{
@@ -121,6 +129,8 @@
          "possible_values" : [ "Concurrent", "Disruptive" ],
          "default_values" : [ "Disruptive" ],
          "readOnly" : false,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName",
          "dbus":
             {
                "object_path" : "/xyz/abc/def",
@@ -171,6 +181,8 @@
          "possible_values" : [ "Concurrent", "Disruptive" ],
          "default_values" : [ "Disruptive" ],
          "readOnly" : false,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName",
          "dbus":
             {
                "object_path" : "/xyz/abc/def",
@@ -216,4 +228,4 @@
             attrValueEntry.data()),
         reinterpret_cast<pldm_bios_attr_table_entry*>(attrEntry.data()),
         biosStringTable);
-}
\ No newline at end of file
+}
diff --git a/test/libpldmresponder_bios_integer_attribute_test.cpp b/test/libpldmresponder_bios_integer_attribute_test.cpp
index 4004ae9..f0f5780 100644
--- a/test/libpldmresponder_bios_integer_attribute_test.cpp
+++ b/test/libpldmresponder_bios_integer_attribute_test.cpp
@@ -32,7 +32,9 @@
          "upper_bound" : 15,
          "scalar_increment" : 1,
          "default_value" : 2,
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName"
       })"_json;
 
     BIOSIntegerAttribute integerReadOnly{jsonIntegerReadOnly, nullptr};
@@ -50,7 +52,9 @@
          "upper_bound" : 15,
          "scalar_increment" : 1,
          "default_valu" : 2,
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName"
       })"_json; // default_valu -> default_value
     EXPECT_THROW((BIOSIntegerAttribute{jsonIntegerReadOnlyError, nullptr}),
                  Json::exception);
@@ -62,6 +66,8 @@
          "scalar_increment" : 1,
          "default_value" : 0,
          "readOnly" : false,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName",
          "dbus":{
             "object_path" : "/xyz/openbmc_project/avsbus",
             "interface" : "xyz.openbmc.AvsBus.Manager",
@@ -86,7 +92,9 @@
          "upper_bound" : 15,
          "scalar_increment" : 1,
          "default_value" : 2,
-         "readOnly" : true
+         "readOnly" : true,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName"
       })"_json;
 
     std::vector<uint8_t> expectedAttrEntry{
@@ -119,6 +127,8 @@
          "scalar_increment" : 1,
          "default_value" : 2,
          "readOnly" : false,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName",
          "dbus":{
             "object_path" : "/xyz/openbmc_project/avsbus",
             "interface" : "xyz.openbmc.AvsBus.Manager",
@@ -169,6 +179,8 @@
          "scalar_increment" : 1,
          "default_value" : 2,
          "readOnly" : false,
+         "helpText" : "HelpText",
+         "displayName" : "DisplayName",
          "dbus":{
             "object_path" : "/xyz/openbmc_project/avsbus",
             "interface" : "xyz.openbmc.AvsBus.Manager",
@@ -191,4 +203,4 @@
                 setDbusProperty(dbusMapping, PropertyValue{uint8_t(7)}))
         .Times(1);
     integerReadWrite.setAttrValueOnDbus(entry, nullptr, biosStringTable);
-}
\ No newline at end of file
+}
diff --git a/test/libpldmresponder_bios_string_attribute_test.cpp b/test/libpldmresponder_bios_string_attribute_test.cpp
index 01079c3..c086bbc 100644
--- a/test/libpldmresponder_bios_string_attribute_test.cpp
+++ b/test/libpldmresponder_bios_string_attribute_test.cpp
@@ -34,7 +34,9 @@
             "maximum_string_length" : 100,
             "default_string_length" : 2,
             "default_string" : "ef",
-            "readOnly" : true
+            "readOnly" : true,
+            "helpText" : "HelpText",
+            "displayName" : "DisplayName"
         })"_json;
     BIOSStringAttribute stringReadOnly{jsonStringReadOnly, nullptr};
     EXPECT_EQ(stringReadOnly.name, "str_example3");
@@ -53,7 +55,9 @@
             "string_type" : "ASCII",
             "minimum_string_length" : 1,
             "maximum_string_length" : 100,
-            "default_string" : "ef"
+            "default_string" : "ef",
+            "helpText" : "HelpText",
+            "displayName" : "DisplayName"
         })"_json; // missing default_string_length
 
     EXPECT_THROW((BIOSStringAttribute{jsonStringReadOnlyError, nullptr}),
@@ -67,6 +71,8 @@
             "default_string_length" : 3,
             "default_string" : "abc",
             "readOnly" : false,
+            "helpText" : "HelpText",
+            "displayName" : "DisplayName",
             "dbus" : {
                 "object_path" : "/xyz/abc/def",
                 "interface" : "xyz.openbmc_project.str_example1.value",
@@ -92,7 +98,9 @@
             "maximum_string_length" : 100,
             "default_string_length" : 3,
             "default_string" : "abc",
-            "readOnly" : true
+            "readOnly" : true,
+            "helpText" : "HelpText",
+            "displayName" : "DisplayName"
         })"_json;
 
     std::vector<uint8_t> expectedAttrEntry{
@@ -128,6 +136,8 @@
             "default_string_length" : 3,
             "default_string" : "abc",
             "readOnly" : false,
+            "helpText" : "HelpText",
+            "displayName" : "DisplayName",
             "dbus" : {
                 "object_path" : "/xyz/abc/def",
                 "interface" : "xyz.openbmc_project.str_example1.value",
@@ -177,6 +187,8 @@
             "default_string_length" : 3,
             "default_string" : "abc",
             "readOnly" : false,
+            "helpText" : "HelpText",
+            "displayName" : "DisplayName",
             "dbus" : {
                 "object_path" : "/xyz/abc/def",
                 "interface" : "xyz.openbmc_project.str_example1.value",