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