BIOS: support readonly attributes

Since the P10 system has BMC to manager the BIOS attributes,
and the BMC side does not know the attribute values of the BIOS,
it should allow the OOB interface(Host) to be able to set BIOS
readOnly attributes, while still preventing the redfish-doPATCH
operation on it.

Tested: if the readOnly attribute of the pvm_system_name is true,
so we can use `pldmtool` to update the BIOS attributes.

pldmtool bios SetBIOSAttributeCurrentValue -a pvm_system_name -d XXX
{
    "Response": "SUCCESS"
}

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Iabcb5c2400eb0a5c208cc76180d4b07e02457f44
diff --git a/libpldm/bios_table.c b/libpldm/bios_table.c
index 58c331b..ea9f669 100644
--- a/libpldm/bios_table.c
+++ b/libpldm/bios_table.c
@@ -20,11 +20,6 @@
 			return PLDM_ERROR_INVALID_DATA;                        \
 	} while (0)
 
-static bool attribute_is_readonly(uint8_t attr_type)
-{
-	return (attr_type & 0x80);
-}
-
 #define BUFFER_SIZE_EXPECT(current_size, expected_size)                        \
 	do {                                                                   \
 		if (current_size < expected_size)                              \
@@ -1089,10 +1084,6 @@
 				rc = PLDM_ERROR_INVALID_DATA;
 				goto out;
 			}
-			if (attribute_is_readonly(tmp->attr_type)) {
-				rc = PLDM_ERROR_INVALID_DATA;
-				goto out;
-			}
 			length = entry_length;
 			tmp = entry;
 		}
diff --git a/libpldmresponder/bios_attribute.cpp b/libpldmresponder/bios_attribute.cpp
index bc646ca..aa6ff9f 100644
--- a/libpldmresponder/bios_attribute.cpp
+++ b/libpldmresponder/bios_attribute.cpp
@@ -32,21 +32,18 @@
         // No action required, readOnly is initialised to false
     }
 
-    if (!readOnly)
+    try
     {
-        try
-        {
-            std::string objectPath = entry.at("dbus").at("object_path");
-            std::string interface = entry.at("dbus").at("interface");
-            std::string propertyName = entry.at("dbus").at("property_name");
-            std::string propertyType = entry.at("dbus").at("property_type");
+        std::string objectPath = entry.at("dbus").at("object_path");
+        std::string interface = entry.at("dbus").at("interface");
+        std::string propertyName = entry.at("dbus").at("property_name");
+        std::string propertyType = entry.at("dbus").at("property_type");
 
-            dBusMap = {objectPath, interface, propertyName, propertyType};
-        }
-        catch (const std::exception& e)
-        {
-            // No action required, dBusMap whill have no value
-        }
+        dBusMap = {objectPath, interface, propertyName, propertyType};
+    }
+    catch (const std::exception& e)
+    {
+        // No action required, dBusMap whill have no value
     }
 }
 
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index 10ec89c..57e2dc9 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -636,6 +636,7 @@
     switch (attrType)
     {
         case PLDM_BIOS_ENUMERATION:
+        case PLDM_BIOS_ENUMERATION_READ_ONLY:
         {
             auto value =
                 table::attribute_value::decodeEnumEntry(attrValueEntry);
@@ -652,6 +653,7 @@
             return PLDM_SUCCESS;
         }
         case PLDM_BIOS_INTEGER:
+        case PLDM_BIOS_INTEGER_READ_ONLY:
         {
             auto value =
                 table::attribute_value::decodeIntegerEntry(attrValueEntry);
@@ -667,6 +669,7 @@
             return PLDM_SUCCESS;
         }
         case PLDM_BIOS_STRING:
+        case PLDM_BIOS_STRING_READ_ONLY:
         {
             auto stringConf = table::attribute::decodeStringEntry(attrEntry);
             auto value =
diff --git a/libpldmresponder/bios_enum_attribute.cpp b/libpldmresponder/bios_enum_attribute.cpp
index 2ce2909..6dd87fc 100644
--- a/libpldmresponder/bios_enum_attribute.cpp
+++ b/libpldmresponder/bios_enum_attribute.cpp
@@ -125,7 +125,7 @@
 uint8_t BIOSEnumAttribute::getAttrValueIndex()
 {
     auto defaultValueIndex = getValueIndex(defaultValue, possibleValues);
-    if (readOnly || !dBusMap.has_value())
+    if (!dBusMap.has_value())
     {
         return defaultValueIndex;
     }
@@ -166,7 +166,7 @@
     const pldm_bios_attr_table_entry* attrEntry,
     const BIOSStringTable& stringTable)
 {
-    if (readOnly || !dBusMap.has_value())
+    if (!dBusMap.has_value())
     {
         return;
     }
@@ -263,15 +263,7 @@
     std::string value = std::get<std::string>(attributevalue);
     entry->attr_type = 0;
     entry->value[0] = 1; // number of current values, default 1
-
-    if (readOnly)
-    {
-        entry->value[1] = getValueIndex(defaultValue, possibleValues);
-    }
-    else
-    {
-        entry->value[1] = getAttrValueIndex(value);
-    }
+    entry->value[1] = getAttrValueIndex(value);
 }
 
 } // namespace bios
diff --git a/libpldmresponder/bios_integer_attribute.cpp b/libpldmresponder/bios_integer_attribute.cpp
index 6bfdde0..c025d9a 100644
--- a/libpldmresponder/bios_integer_attribute.cpp
+++ b/libpldmresponder/bios_integer_attribute.cpp
@@ -48,7 +48,7 @@
     const pldm_bios_attr_val_table_entry* attrValueEntry,
     const pldm_bios_attr_table_entry*, const BIOSStringTable&)
 {
-    if (readOnly || !dBusMap.has_value())
+    if (!dBusMap.has_value())
     {
         return;
     }
@@ -185,7 +185,7 @@
 
 uint64_t BIOSIntegerAttribute::getAttrValue()
 {
-    if (readOnly || !dBusMap.has_value())
+    if (!dBusMap.has_value())
     {
         return integerInfo.defaultValue;
     }
diff --git a/libpldmresponder/bios_string_attribute.cpp b/libpldmresponder/bios_string_attribute.cpp
index 6aa3dc5..d89ab49 100644
--- a/libpldmresponder/bios_string_attribute.cpp
+++ b/libpldmresponder/bios_string_attribute.cpp
@@ -62,7 +62,7 @@
     const pldm_bios_attr_val_table_entry* attrValueEntry,
     const pldm_bios_attr_table_entry*, const BIOSStringTable&)
 {
-    if (readOnly || !dBusMap.has_value())
+    if (!dBusMap.has_value())
     {
         return;
     }
@@ -74,7 +74,7 @@
 
 std::string BIOSStringAttribute::getAttrValue()
 {
-    if (readOnly || !dBusMap.has_value())
+    if (!dBusMap.has_value())
     {
         return stringInfo.defString;
     }
diff --git a/pldmtool/pldm_bios_cmd.cpp b/pldmtool/pldm_bios_cmd.cpp
index b47a1b5..03e5d9c 100644
--- a/pldmtool/pldm_bios_cmd.cpp
+++ b/pldmtool/pldm_bios_cmd.cpp
@@ -804,15 +804,8 @@
 
         switch (attrType)
         {
-            case PLDM_BIOS_ENUMERATION_READ_ONLY:
-            case PLDM_BIOS_STRING_READ_ONLY:
-            case PLDM_BIOS_INTEGER_READ_ONLY:
-            {
-                std::cerr << "Set attribute error: " << attrName
-                          << "is read only." << std::endl;
-                return;
-            }
             case PLDM_BIOS_ENUMERATION:
+            case PLDM_BIOS_ENUMERATION_READ_ONLY:
             {
                 entryLength =
                     pldm_bios_table_attr_value_entry_encode_enum_length(1);
@@ -856,6 +849,7 @@
                 break;
             }
             case PLDM_BIOS_STRING:
+            case PLDM_BIOS_STRING_READ_ONLY:
             {
                 entryLength =
                     pldm_bios_table_attr_value_entry_encode_string_length(
@@ -869,6 +863,7 @@
                 break;
             }
             case PLDM_BIOS_INTEGER:
+            case PLDM_BIOS_INTEGER_READ_ONLY:
             {
                 uint64_t value = std::stoll(attrValue);
                 entryLength =