More PDR refactor
- PDRs can be created not just by the platform monitoring and control
handlers, but by other handlers (eg FRU) as well.
- For this purpose, create the PDR repo in the pldm daemon, and pass it
to the handlers. This change warranted some refactor.
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: I4e789da9bae99dee1b535d92ce98ae5bb8eed62b
Signed-off-by: George Liu <liuxiwei@inspur.com>
diff --git a/pldmd.cpp b/pldmd.cpp
index a13383d..6ddbcde 100644
--- a/pldmd.cpp
+++ b/pldmd.cpp
@@ -20,6 +20,7 @@
#include <iomanip>
#include <iostream>
#include <iterator>
+#include <memory>
#include <sdeventplus/event.hpp>
#include <sdeventplus/source/io.hpp>
#include <sstream>
@@ -29,6 +30,7 @@
#include "libpldm/base.h"
#include "libpldm/bios.h"
+#include "libpldm/pdr.h"
#include "libpldm/platform.h"
#ifdef OEM_IBM
@@ -144,11 +146,14 @@
break;
}
+ std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)> pdrRepo(
+ pldm_pdr_init(), pldm_pdr_destroy);
+
Invoker invoker{};
invoker.registerHandler(PLDM_BASE, std::make_unique<base::Handler>());
invoker.registerHandler(PLDM_BIOS, std::make_unique<bios::Handler>());
- invoker.registerHandler(PLDM_PLATFORM,
- std::make_unique<platform::Handler>());
+ invoker.registerHandler(PLDM_PLATFORM, std::make_unique<platform::Handler>(
+ PDR_JSONS_DIR, pdrRepo.get()));
invoker.registerHandler(PLDM_FRU,
std::make_unique<fru::Handler>(FRU_JSONS_DIR));