blob: 4be961b58304366b819c72cf28445f83e05f6288 [file] [log] [blame]
Matt Spinler711d51d2019-11-06 09:36:51 -06001/**
2 * Copyright © 2019 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Matt Spinlerc8705e22019-09-11 12:36:07 -050016#include "data_interface.hpp"
Matt Spinler99c2b402019-05-23 14:29:16 -050017#include "elog_entry.hpp"
Matt Spinlerf682b402019-12-18 13:48:08 -060018#include "event_logger.hpp"
Matt Spinler99c2b402019-05-23 14:29:16 -050019#include "extensions.hpp"
Matt Spinler4e8078c2019-07-09 13:22:32 -050020#include "manager.hpp"
Matt Spinler17ed2ed2019-12-12 14:12:23 -060021#include "pldm_interface.hpp"
Matt Spinler99c2b402019-05-23 14:29:16 -050022
23namespace openpower
24{
25namespace pels
26{
27
28using namespace phosphor::logging;
29
Matt Spinler4e8078c2019-07-09 13:22:32 -050030std::unique_ptr<Manager> manager;
31
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050032DISABLE_LOG_ENTRY_CAPS()
Matt Spinlerb9883ea2020-07-07 15:08:35 -050033
Matt Spinler99c2b402019-05-23 14:29:16 -050034void pelStartup(internal::Manager& logManager)
35{
Matt Spinlerf682b402019-12-18 13:48:08 -060036 EventLogger::LogFunction logger = std::bind(
37 std::mem_fn(&internal::Manager::create), &logManager,
38 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
39
Matt Spinlerc8705e22019-09-11 12:36:07 -050040 std::unique_ptr<DataInterfaceBase> dataIface =
41 std::make_unique<DataInterface>(logManager.getBus());
42
Matt Spinler17ed2ed2019-12-12 14:12:23 -060043#ifndef DONT_SEND_PELS_TO_HOST
44 std::unique_ptr<HostInterface> hostIface = std::make_unique<PLDMInterface>(
45 logManager.getBus().get_event(), *(dataIface.get()));
46
Matt Spinlerf682b402019-12-18 13:48:08 -060047 manager =
48 std::make_unique<Manager>(logManager, std::move(dataIface),
49 std::move(logger), std::move(hostIface));
Matt Spinler17ed2ed2019-12-12 14:12:23 -060050#else
Matt Spinlerf682b402019-12-18 13:48:08 -060051 manager = std::make_unique<Manager>(logManager, std::move(dataIface),
52 std::move(logger));
Matt Spinler17ed2ed2019-12-12 14:12:23 -060053#endif
Matt Spinler99c2b402019-05-23 14:29:16 -050054}
55
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050056REGISTER_EXTENSION_FUNCTION(pelStartup)
Matt Spinler99c2b402019-05-23 14:29:16 -050057
58void pelCreate(const std::string& message, uint32_t id, uint64_t timestamp,
59 Entry::Level severity, const AdditionalDataArg& additionalData,
Matt Spinlerc64b7122020-03-26 10:55:01 -050060 const AssociationEndpointsArg& assocs, const FFDCArg& ffdc)
Matt Spinler99c2b402019-05-23 14:29:16 -050061{
Matt Spinler56ad2a02020-03-26 14:00:52 -050062 manager->create(message, id, timestamp, severity, additionalData, assocs,
63 ffdc);
Matt Spinler99c2b402019-05-23 14:29:16 -050064}
65
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050066REGISTER_EXTENSION_FUNCTION(pelCreate)
Matt Spinler99c2b402019-05-23 14:29:16 -050067
68void pelDelete(uint32_t id)
69{
Matt Spinler4e8078c2019-07-09 13:22:32 -050070 return manager->erase(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050071}
72
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050073REGISTER_EXTENSION_FUNCTION(pelDelete)
Matt Spinler99c2b402019-05-23 14:29:16 -050074
75void pelDeleteProhibited(uint32_t id, bool& prohibited)
76{
Matt Spinler4e8078c2019-07-09 13:22:32 -050077 prohibited = manager->isDeleteProhibited(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050078}
79
Patrick Williamsd26fa3e2021-04-21 15:22:23 -050080REGISTER_EXTENSION_FUNCTION(pelDeleteProhibited)
Matt Spinler99c2b402019-05-23 14:29:16 -050081
82} // namespace pels
83} // namespace openpower