Add Ramoops dump to common create

This commit adjusts the handling of ramoops (RAM OOPS) dumps to use
the common BMC dump creation interface. Previously, when a ramoops
dump was detected, the ramoops manager would inform the dump manager
via an internal D-Bus interface. With the changes in this commit,
upon detecting a ramoops event, the ramoops manager will now request
the dump manager to create a BMC dump, incorporating the relevant
ramoops data, via the common create DBus interface.

Tested:
Create a Ramoops dump
busctl --verbose call xyz.openbmc_project.Dump.Manager \
/xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create \
CreateDump a{sv} 2 "xyz.openbmc_project.Dump.Create.CreateParameters.\
DumpType" s "xyz.openbmc_project.Dump.Create.DumpType.Ramoops" \
"xyz.openbmc_project.Dump.Create.CreateParameters.FilePath" \
s "/tmp/ramoops"
MESSAGE "o" {
        OBJECT_PATH "/xyz/openbmc_project/dump/bmc/entry/4";
};

> Initiating new BMC dump with type: ramoops path: /tmp/ramoops

Change-Id: I0437cfa6c63fe261ca9b51f6a90c8183abacd5c7
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/dump_types.cpp b/dump_types.cpp
index 8dcdf15..ac3b31c 100644
--- a/dump_types.cpp
+++ b/dump_types.cpp
@@ -13,10 +13,15 @@
     {"xyz.openbmc_project.Dump.Create.DumpType.UserRequested",
      {DumpTypes::USER, "BMC_DUMP"}},
     {"xyz.openbmc_project.Dump.Create.DumpType.ApplicationCored",
-     {DumpTypes::CORE, "BMC_DUMP"}}};
+     {DumpTypes::CORE, "BMC_DUMP"}},
+    {"xyz.openbmc_project.Dump.Create.DumpType.Ramoops",
+     {DumpTypes::RAMOOPS, "BMC_DUMP"}}};
 
-DUMP_TYPE_TO_STRING_MAP dumpTypeToStringMap = {{DumpTypes::USER, "user"},
-                                               {DumpTypes::CORE, "core"}};
+DUMP_TYPE_TO_STRING_MAP dumpTypeToStringMap = {
+    {DumpTypes::USER, "user"},
+    {DumpTypes::CORE, "core"},
+    {DumpTypes::RAMOOPS, "ramoops"},
+};
 
 std::optional<std::string> dumpTypeToString(const DumpTypes& dumpType)
 {
diff --git a/dump_types.hpp b/dump_types.hpp
index 38cef98..11c500d 100644
--- a/dump_types.hpp
+++ b/dump_types.hpp
@@ -23,6 +23,7 @@
 {
     USER,
     CORE,
+    RAMOOPS,
 };
 
 // A table of dump types
diff --git a/ramoops_manager.cpp b/ramoops_manager.cpp
index 321f90f..a3df837 100644
--- a/ramoops_manager.cpp
+++ b/ramoops_manager.cpp
@@ -2,9 +2,13 @@
 
 #include "ramoops_manager.hpp"
 
+#include "dump_manager.hpp"
+
 #include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/exception.hpp>
+#include <xyz/openbmc_project/Dump/Create/common.hpp>
+#include <xyz/openbmc_project/Dump/Create/server.hpp>
 
 #include <filesystem>
 #include <set>
@@ -37,14 +41,12 @@
     constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
     constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
     constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-    constexpr auto IFACE_INTERNAL("xyz.openbmc_project.Dump.Internal.Create");
-    constexpr auto RAMOOPS =
-        "xyz.openbmc_project.Dump.Internal.Create.Type.Ramoops";
+    constexpr auto DUMP_CREATE_IFACE = "xyz.openbmc_project.Dump.Create";
 
     auto b = sdbusplus::bus::new_default();
     auto mapper = b.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
                                     MAPPER_INTERFACE, "GetObject");
-    mapper.append(OBJ_INTERNAL, std::set<std::string>({IFACE_INTERNAL}));
+    mapper.append(BMC_DUMP_OBJPATH, std::set<std::string>({DUMP_CREATE_IFACE}));
 
     std::map<std::string, std::set<std::string>> mapperResponse;
     try
@@ -65,9 +67,20 @@
     }
 
     const auto& host = mapperResponse.cbegin()->first;
-    auto m = b.new_method_call(host.c_str(), OBJ_INTERNAL, IFACE_INTERNAL,
-                               "Create");
-    m.append(RAMOOPS, files);
+    auto m = b.new_method_call(host.c_str(), BMC_DUMP_OBJPATH,
+                               DUMP_CREATE_IFACE, "CreateDump");
+    phosphor::dump::DumpCreateParams params;
+    using CreateParameters =
+        sdbusplus::common::xyz::openbmc_project::dump::Create::CreateParameters;
+    using DumpType =
+        sdbusplus::common::xyz::openbmc_project::dump::Create::DumpType;
+    using DumpIntr = sdbusplus::common::xyz::openbmc_project::dump::Create;
+    params[DumpIntr::convertCreateParametersToString(
+        CreateParameters::DumpType)] =
+        DumpIntr::convertDumpTypeToString(DumpType::Ramoops);
+    params[DumpIntr::convertCreateParametersToString(
+        CreateParameters::FilePath)] = files.front();
+    m.append(params);
     try
     {
         b.call_noreply(m);