blob: b454d37682b8d4c23ff9c409e589e1ca2d93f01e [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"
18#include "extensions.hpp"
Matt Spinler4e8078c2019-07-09 13:22:32 -050019#include "manager.hpp"
Matt Spinler99c2b402019-05-23 14:29:16 -050020
21namespace openpower
22{
23namespace pels
24{
25
26using namespace phosphor::logging;
27
Matt Spinler4e8078c2019-07-09 13:22:32 -050028std::unique_ptr<Manager> manager;
29
Matt Spinler99c2b402019-05-23 14:29:16 -050030void pelStartup(internal::Manager& logManager)
31{
Matt Spinlerc8705e22019-09-11 12:36:07 -050032 std::unique_ptr<DataInterfaceBase> dataIface =
33 std::make_unique<DataInterface>(logManager.getBus());
34
35 manager = std::make_unique<Manager>(logManager, std::move(dataIface));
Matt Spinler99c2b402019-05-23 14:29:16 -050036}
37
38REGISTER_EXTENSION_FUNCTION(pelStartup);
39
40void pelCreate(const std::string& message, uint32_t id, uint64_t timestamp,
41 Entry::Level severity, const AdditionalDataArg& additionalData,
42 const AssociationEndpointsArg& assocs)
43{
Matt Spinler4e8078c2019-07-09 13:22:32 -050044 manager->create(message, id, timestamp, severity, additionalData, assocs);
Matt Spinler99c2b402019-05-23 14:29:16 -050045}
46
47REGISTER_EXTENSION_FUNCTION(pelCreate);
48
49void pelDelete(uint32_t id)
50{
Matt Spinler4e8078c2019-07-09 13:22:32 -050051 return manager->erase(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050052}
53
54REGISTER_EXTENSION_FUNCTION(pelDelete);
55
56void pelDeleteProhibited(uint32_t id, bool& prohibited)
57{
Matt Spinler4e8078c2019-07-09 13:22:32 -050058 prohibited = manager->isDeleteProhibited(id);
Matt Spinler99c2b402019-05-23 14:29:16 -050059}
60
61REGISTER_EXTENSION_FUNCTION(pelDeleteProhibited);
62
63} // namespace pels
64} // namespace openpower