1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright 2019 IBM Corporation
3
4 #include "data_interface.hpp"
5 #include "elog_entry.hpp"
6 #include "event_logger.hpp"
7 #include "extensions.hpp"
8 #include "journal.hpp"
9 #include "manager.hpp"
10 #include "pldm_interface.hpp"
11
12 #include <phosphor-logging/lg2.hpp>
13
14 namespace openpower
15 {
16 namespace pels
17 {
18
19 using namespace phosphor::logging;
20
21 std::unique_ptr<Manager> manager;
22
DISABLE_LOG_ENTRY_CAPS()23 DISABLE_LOG_ENTRY_CAPS()
24
25 void pelStartup(internal::Manager& logManager)
26 {
27 EventLogger::LogFunction logger =
28 std::bind(std::mem_fn(&internal::Manager::create), &logManager,
29 std::placeholders::_1, std::placeholders::_2,
30 std::placeholders::_3, phosphor::logging::FFDCEntries{});
31
32 std::unique_ptr<DataInterfaceBase> dataIface =
33 std::make_unique<DataInterface>(logManager.getBus());
34
35 std::unique_ptr<JournalBase> journal = std::make_unique<Journal>();
36
37 #ifndef DONT_SEND_PELS_TO_HOST
38 std::unique_ptr<HostInterface> hostIface = std::make_unique<PLDMInterface>(
39 logManager.getBus().get_event(), *(dataIface.get()));
40
41 manager = std::make_unique<Manager>(logManager, std::move(dataIface),
42 std::move(logger), std::move(journal),
43 std::move(hostIface));
44 #else
45 manager = std::make_unique<Manager>(logManager, std::move(dataIface),
46 std::move(logger), std::move(journal));
47 #endif
48 }
49
REGISTER_EXTENSION_FUNCTION(pelStartup)50 REGISTER_EXTENSION_FUNCTION(pelStartup)
51
52 void pelCreate(const std::string& message, uint32_t id, uint64_t timestamp,
53 Entry::Level severity, const AdditionalDataArg& additionalData,
54 const AssociationEndpointsArg& assocs, const FFDCArg& ffdc)
55 {
56 manager->create(message, id, timestamp, severity, additionalData, assocs,
57 ffdc);
58 }
59
REGISTER_EXTENSION_FUNCTION(pelCreate)60 REGISTER_EXTENSION_FUNCTION(pelCreate)
61
62 void pelDelete(uint32_t id)
63 {
64 return manager->erase(id);
65 }
66
REGISTER_EXTENSION_FUNCTION(pelDelete)67 REGISTER_EXTENSION_FUNCTION(pelDelete)
68
69 void pelDeleteProhibited(uint32_t id, bool& prohibited)
70 {
71 prohibited = manager->isDeleteProhibited(id);
72 }
73
REGISTER_EXTENSION_FUNCTION(pelDeleteProhibited)74 REGISTER_EXTENSION_FUNCTION(pelDeleteProhibited)
75
76 void getLogIDWithHwIsolation(std::vector<uint32_t>& logIDs)
77 {
78 manager->getLogIDWithHwIsolation(logIDs);
79 }
80
81 REGISTER_EXTENSION_FUNCTION(getLogIDWithHwIsolation)
82
83 } // namespace pels
84 } // namespace openpower
85