Matt Spinler | 711d51d | 2019-11-06 09:36:51 -0600 | [diff] [blame] | 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 | */ |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 16 | #include "data_interface.hpp" |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 17 | #include "elog_entry.hpp" |
| 18 | #include "extensions.hpp" |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 19 | #include "manager.hpp" |
Matt Spinler | 17ed2ed | 2019-12-12 14:12:23 -0600 | [diff] [blame] | 20 | #include "pldm_interface.hpp" |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 21 | |
| 22 | namespace openpower |
| 23 | { |
| 24 | namespace pels |
| 25 | { |
| 26 | |
| 27 | using namespace phosphor::logging; |
| 28 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 29 | std::unique_ptr<Manager> manager; |
| 30 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 31 | void pelStartup(internal::Manager& logManager) |
| 32 | { |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 33 | std::unique_ptr<DataInterfaceBase> dataIface = |
| 34 | std::make_unique<DataInterface>(logManager.getBus()); |
| 35 | |
Matt Spinler | 17ed2ed | 2019-12-12 14:12:23 -0600 | [diff] [blame] | 36 | #ifndef DONT_SEND_PELS_TO_HOST |
| 37 | std::unique_ptr<HostInterface> hostIface = std::make_unique<PLDMInterface>( |
| 38 | logManager.getBus().get_event(), *(dataIface.get())); |
| 39 | |
| 40 | manager = std::make_unique<Manager>(logManager, std::move(dataIface), |
| 41 | std::move(hostIface)); |
| 42 | #else |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 43 | manager = std::make_unique<Manager>(logManager, std::move(dataIface)); |
Matt Spinler | 17ed2ed | 2019-12-12 14:12:23 -0600 | [diff] [blame] | 44 | #endif |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | REGISTER_EXTENSION_FUNCTION(pelStartup); |
| 48 | |
| 49 | void pelCreate(const std::string& message, uint32_t id, uint64_t timestamp, |
| 50 | Entry::Level severity, const AdditionalDataArg& additionalData, |
| 51 | const AssociationEndpointsArg& assocs) |
| 52 | { |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 53 | manager->create(message, id, timestamp, severity, additionalData, assocs); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | REGISTER_EXTENSION_FUNCTION(pelCreate); |
| 57 | |
| 58 | void pelDelete(uint32_t id) |
| 59 | { |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 60 | return manager->erase(id); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | REGISTER_EXTENSION_FUNCTION(pelDelete); |
| 64 | |
| 65 | void pelDeleteProhibited(uint32_t id, bool& prohibited) |
| 66 | { |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 67 | prohibited = manager->isDeleteProhibited(id); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | REGISTER_EXTENSION_FUNCTION(pelDeleteProhibited); |
| 71 | |
| 72 | } // namespace pels |
| 73 | } // namespace openpower |