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