blob: 28823b99c54fc259b0039f80f50e9acde4a88b28 [file] [log] [blame]
Alexander Hansen40fb5492025-10-28 17:56:12 +01001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright 2019 IBM Corporation
3
Matt Spinlerc8705e22019-09-11 12:36:07 -05004#include "data_interface.hpp"
Matt Spinler99c2b402019-05-23 14:29:16 -05005#include "elog_entry.hpp"
Matt Spinlerf682b402019-12-18 13:48:08 -06006#include "event_logger.hpp"
Matt Spinler99c2b402019-05-23 14:29:16 -05007#include "extensions.hpp"
Matt Spinlerd96fa602022-12-15 11:11:26 -06008#include "journal.hpp"
Matt Spinler4e8078c2019-07-09 13:22:32 -05009#include "manager.hpp"
Matt Spinler17ed2ed2019-12-12 14:12:23 -060010#include "pldm_interface.hpp"
Matt Spinler99c2b402019-05-23 14:29:16 -050011
Arya K Padman5bc26532024-04-10 06:19:25 -050012#include <phosphor-logging/lg2.hpp>
Jayanth Othayoth4d779b22021-06-03 05:45:13 -050013
Matt Spinler99c2b402019-05-23 14:29:16 -050014namespace openpower
15{
16namespace pels
17{
18
19using namespace phosphor::logging;
20
Matt Spinler4e8078c2019-07-09 13:22:32 -050021std::unique_ptr<Manager> manager;
22
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050023DISABLE_LOG_ENTRY_CAPS()
Matt Spinlerb9883ea2020-07-07 15:08:35 -050024
Matt Spinler99c2b402019-05-23 14:29:16 -050025void pelStartup(internal::Manager& logManager)
26{
Paul Fertser221b79b2024-03-04 15:40:23 +000027 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{});
Matt Spinlerf682b402019-12-18 13:48:08 -060031
Matt Spinlerc8705e22019-09-11 12:36:07 -050032 std::unique_ptr<DataInterfaceBase> dataIface =
33 std::make_unique<DataInterface>(logManager.getBus());
34
Matt Spinlerd96fa602022-12-15 11:11:26 -060035 std::unique_ptr<JournalBase> journal = std::make_unique<Journal>();
36
Matt Spinler17ed2ed2019-12-12 14:12:23 -060037#ifndef DONT_SEND_PELS_TO_HOST
38 std::unique_ptr<HostInterface> hostIface = std::make_unique<PLDMInterface>(
39 logManager.getBus().get_event(), *(dataIface.get()));
40
Patrick Williams2544b412022-10-04 08:41:06 -050041 manager = std::make_unique<Manager>(logManager, std::move(dataIface),
Matt Spinlerd96fa602022-12-15 11:11:26 -060042 std::move(logger), std::move(journal),
Patrick Williams2544b412022-10-04 08:41:06 -050043 std::move(hostIface));
Matt Spinler17ed2ed2019-12-12 14:12:23 -060044#else
Matt Spinlerf682b402019-12-18 13:48:08 -060045 manager = std::make_unique<Manager>(logManager, std::move(dataIface),
Matt Spinlerd96fa602022-12-15 11:11:26 -060046 std::move(logger), std::move(journal));
Matt Spinler17ed2ed2019-12-12 14:12:23 -060047#endif
Matt Spinler99c2b402019-05-23 14:29:16 -050048}
49
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050050REGISTER_EXTENSION_FUNCTION(pelStartup)
Matt Spinler99c2b402019-05-23 14:29:16 -050051
52void pelCreate(const std::string& message, uint32_t id, uint64_t timestamp,
53 Entry::Level severity, const AdditionalDataArg& additionalData,
Matt Spinlerc64b7122020-03-26 10:55:01 -050054 const AssociationEndpointsArg& assocs, const FFDCArg& ffdc)
Matt Spinler99c2b402019-05-23 14:29:16 -050055{
Matt Spinler56ad2a02020-03-26 14:00:52 -050056 manager->create(message, id, timestamp, severity, additionalData, assocs,
57 ffdc);
Matt Spinler99c2b402019-05-23 14:29:16 -050058}
59
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050060REGISTER_EXTENSION_FUNCTION(pelCreate)
Matt Spinler99c2b402019-05-23 14:29:16 -050061
62void pelDelete(uint32_t id)
63{
Matt Spinler4e8078c2019-07-09 13:22:32 -050064 return manager->erase(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050065}
66
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050067REGISTER_EXTENSION_FUNCTION(pelDelete)
Matt Spinler99c2b402019-05-23 14:29:16 -050068
69void pelDeleteProhibited(uint32_t id, bool& prohibited)
70{
Matt Spinler4e8078c2019-07-09 13:22:32 -050071 prohibited = manager->isDeleteProhibited(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050072}
73
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050074REGISTER_EXTENSION_FUNCTION(pelDeleteProhibited)
Matt Spinler99c2b402019-05-23 14:29:16 -050075
harsh-agarwal1d763db32024-09-03 09:18:50 -050076void getLogIDWithHwIsolation(std::vector<uint32_t>& logIDs)
77{
78 manager->getLogIDWithHwIsolation(logIDs);
79}
80
81REGISTER_EXTENSION_FUNCTION(getLogIDWithHwIsolation)
82
Matt Spinler99c2b402019-05-23 14:29:16 -050083} // namespace pels
84} // namespace openpower