fru: Add default configuration for fru record

Add mapping between the D-Bus properties to the PLDM FRU
properties can be in the code. Use this mapping when fru
jsons are not available

Tested:

Picked this change[30624], and tested on fp5280g2, saw the D-Bus
properties is mapped to the PLDM FRU properties as expected

[30624] https://gerrit.openbmc-project.xyz/c/openbmc/pldm/+/30624

1. Remove the fru configurations:
root@fp5280g2:rm -rf /usr/share/pldm/fru

2. Start pldmd
root@fp5280g2: pldmd&

Test
root@fp5280g2: pldmtool fru getfruRecordTable
FRUTableLength : 95
Total number of Record Set Identifiers in table : 2
Total number of records in table :  2
FRU Record Set Identifier: 1
FRU Record Type: General
Number of FRU fields: 4
Encoding Type for FRU fields: ASCII

FRU Table Data:
FRU Field Type: Part Number
FRU Field Length: 7
FRU Field Value: 02CY296
FRU Field Type: Serial Number
FRU Field Length: 12
FRU Field Value: YA1934415306
FRU Field Type: Manufacturer
FRU Field Length: 3
FRU Field Value: IBM
FRU Field Type: Version
FRU Field Length: 2
FRU Field Value: 22
FRU Record Set Identifier: 2
FRU Record Type: General
Number of FRU fields: 3
Encoding Type for FRU fields: ASCII

FRU Table Data:
FRU Field Type: Model
FRU Field Length: 20
FRU Field Value: 9ASF1G72PZ-2G6D1
FRU Field Type: Serial Number
FRU Field Length: 10
FRU Field Value: 0x1514b700
FRU Field Type: Manufacturer
FRU Field Length: 17
FRU Field Value: Micron Technology

Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I0e5ec3e4e1ede17c06ef716c6d6231156eddfd44
diff --git a/libpldmresponder/fru_parser.cpp b/libpldmresponder/fru_parser.cpp
index a2e2e92..84d3898 100644
--- a/libpldmresponder/fru_parser.cpp
+++ b/libpldmresponder/fru_parser.cpp
@@ -30,8 +30,8 @@
     fs::path dir(dirPath);
     if (!fs::exists(dir) || fs::is_empty(dir))
     {
-        std::cerr << "FRU config directory does not exist or empty, DIR="
-                  << dirPath << "\n";
+        setupDefaultDBusLookup();
+        setupDefaultFruRecordMap();
         return;
     }
 
@@ -47,6 +47,34 @@
     setupFruRecordMap(dirPath);
 }
 
+void FruParser::setupDefaultDBusLookup()
+{
+    constexpr auto service = "xyz.openbmc_project.Inventory.Manager";
+    constexpr auto rootPath = "/xyz/openbmc_project/inventory";
+
+    // DSP0249 1.0.0    Table 15 Entity ID Codes
+    const std::map<Interface, EntityType> defIntfToEntityType = {
+        {"xyz.openbmc_project.Inventory.Item.Chassis", 45},
+        {"xyz.openbmc_project.Inventory.Item.Board", 60},
+        {"xyz.openbmc_project.Inventory.Item.Board.Motherboard", 64},
+        {"xyz.openbmc_project.Inventory.Item.Panel", 69},
+        {"xyz.openbmc_project.Inventory.Item.PowerSupply", 120},
+        {"xyz.openbmc_project.Inventory.Item.Vrm", 123},
+        {"xyz.openbmc_project.Inventory.Item.Cpu", 135},
+        {"xyz.openbmc_project.Inventory.Item.Bmc", 137},
+        {"xyz.openbmc_project.Inventory.Item.Dimm", 142},
+    };
+
+    Interfaces interfaces{};
+    for (auto [intf, entityType] : defIntfToEntityType)
+    {
+        intfToEntityType[intf] = entityType;
+        interfaces.emplace(intf);
+    }
+
+    lookupInfo.emplace(service, rootPath, std::move(interfaces));
+}
+
 void FruParser::setupDBusLookup(const fs::path& filePath)
 {
     std::ifstream jsonFile(filePath);
@@ -74,6 +102,34 @@
                                        std::move(interfaces)));
 }
 
+void FruParser::setupDefaultFruRecordMap()
+{
+    const FruRecordInfo generalRecordInfo = {
+        1, // generalRecordType
+        1, // encodingTypeASCII
+        {
+            // DSP0257 Table 5 General FRU Record Field Type Definitions
+            {"xyz.openbmc_project.Inventory.Decorator.Asset", "Model", "string",
+             2},
+            {"xyz.openbmc_project.Inventory.Decorator.Asset", "PartNumber",
+             "string", 3},
+            {"xyz.openbmc_project.Inventory.Decorator.Asset", "SerialNumber",
+             "string", 4},
+            {"xyz.openbmc_project.Inventory.Decorator.Asset", "Manufacturer",
+             "string", 5},
+            {"xyz.openbmc_project.Inventory.Item", "PrettyName", "string", 8},
+            {"xyz.openbmc_project.Inventory.Decorator.AssetTag", "AssetTag",
+             "string", 11},
+            {"xyz.openbmc_project.Inventory.Decorator.Revision", "Version",
+             "string", 10},
+        }};
+
+    for (auto [intf, entityType] : intfToEntityType)
+    {
+        recordMap[intf] = {generalRecordInfo};
+    }
+}
+
 void FruParser::setupFruRecordMap(const std::string& dirPath)
 {
     for (auto& file : fs::directory_iterator(dirPath))
diff --git a/libpldmresponder/fru_parser.hpp b/libpldmresponder/fru_parser.hpp
index f93c1fc..aec27cb 100644
--- a/libpldmresponder/fru_parser.hpp
+++ b/libpldmresponder/fru_parser.hpp
@@ -119,6 +119,14 @@
      */
     void setupFruRecordMap(const std::string& dirPath);
 
+    /** @brief Set the default service root D-Bus path and the item interfaces.
+     */
+    void setupDefaultDBusLookup();
+
+    /** @brief Build the default FRU record informations
+     */
+    void setupDefaultFruRecordMap();
+
     std::optional<DBusLookupInfo> lookupInfo;
     FruRecordMap recordMap;
     std::map<Interface, EntityType> intfToEntityType;