blob: 34b349982ac5a522e90f50d0c98afdcaa09c5454 [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
Matt Spinler99c2b402019-05-23 14:29:16 -050032void pelStartup(internal::Manager& logManager)
33{
Matt Spinlerf682b402019-12-18 13:48:08 -060034 EventLogger::LogFunction logger = std::bind(
35 std::mem_fn(&internal::Manager::create), &logManager,
36 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
37
Matt Spinlerc8705e22019-09-11 12:36:07 -050038 std::unique_ptr<DataInterfaceBase> dataIface =
39 std::make_unique<DataInterface>(logManager.getBus());
40
Matt Spinler17ed2ed2019-12-12 14:12:23 -060041#ifndef DONT_SEND_PELS_TO_HOST
42 std::unique_ptr<HostInterface> hostIface = std::make_unique<PLDMInterface>(
43 logManager.getBus().get_event(), *(dataIface.get()));
44
Matt Spinlerf682b402019-12-18 13:48:08 -060045 manager =
46 std::make_unique<Manager>(logManager, std::move(dataIface),
47 std::move(logger), std::move(hostIface));
Matt Spinler17ed2ed2019-12-12 14:12:23 -060048#else
Matt Spinlerf682b402019-12-18 13:48:08 -060049 manager = std::make_unique<Manager>(logManager, std::move(dataIface),
50 std::move(logger));
Matt Spinler17ed2ed2019-12-12 14:12:23 -060051#endif
Matt Spinler99c2b402019-05-23 14:29:16 -050052}
53
54REGISTER_EXTENSION_FUNCTION(pelStartup);
55
56void pelCreate(const std::string& message, uint32_t id, uint64_t timestamp,
57 Entry::Level severity, const AdditionalDataArg& additionalData,
Matt Spinlerc64b7122020-03-26 10:55:01 -050058 const AssociationEndpointsArg& assocs, const FFDCArg& ffdc)
Matt Spinler99c2b402019-05-23 14:29:16 -050059{
Matt Spinler56ad2a02020-03-26 14:00:52 -050060 manager->create(message, id, timestamp, severity, additionalData, assocs,
61 ffdc);
Matt Spinler99c2b402019-05-23 14:29:16 -050062}
63
64REGISTER_EXTENSION_FUNCTION(pelCreate);
65
66void pelDelete(uint32_t id)
67{
Matt Spinler4e8078c2019-07-09 13:22:32 -050068 return manager->erase(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050069}
70
71REGISTER_EXTENSION_FUNCTION(pelDelete);
72
73void pelDeleteProhibited(uint32_t id, bool& prohibited)
74{
Matt Spinler4e8078c2019-07-09 13:22:32 -050075 prohibited = manager->isDeleteProhibited(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050076}
77
78REGISTER_EXTENSION_FUNCTION(pelDeleteProhibited);
79
80} // namespace pels
81} // namespace openpower