Willy Tu | a2056e9 | 2021-10-10 13:36:16 -0700 | [diff] [blame] | 1 | // Copyright 2021 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Patrick Venture | ab65000 | 2019-03-16 09:08:47 -0700 | [diff] [blame] | 15 | #pragma once |
| 16 | |
| 17 | #include <nlohmann/json.hpp> |
Patrick Williams | 444b5ea | 2023-05-19 13:56:42 -0500 | [diff] [blame] | 18 | |
| 19 | #include <cstdint> |
Patrick Venture | ab65000 | 2019-03-16 09:08:47 -0700 | [diff] [blame] | 20 | #include <string> |
Patrick Venture | 3fb7429 | 2019-03-16 11:32:16 -0700 | [diff] [blame] | 21 | #include <tuple> |
| 22 | #include <vector> |
Patrick Venture | ab65000 | 2019-03-16 09:08:47 -0700 | [diff] [blame] | 23 | |
| 24 | namespace google |
| 25 | { |
| 26 | namespace ipmi |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * Parse a file and return the json object. |
| 31 | * |
| 32 | * @param[in] file - the path to the file to parse. |
| 33 | * @return the json object if valid. |
| 34 | * @throw elog<InternalFailure> on failures. |
| 35 | */ |
| 36 | nlohmann::json parseConfig(const std::string& file); |
| 37 | |
Patrick Venture | 8d5c9ce | 2019-03-16 11:20:12 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Read a dts property file and return the contents. |
| 40 | * |
| 41 | * @param[in] file - the path to the file to parse. |
| 42 | * @return the property value or an empty string on failure. |
| 43 | */ |
| 44 | std::string readPropertyFile(const std::string& fileName); |
| 45 | |
Patrick Venture | 3fb7429 | 2019-03-16 11:32:16 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Build a map of the i2c bus numbers to their PCIe slot names. |
| 48 | * |
| 49 | * @return list of pairs of i2c bus with their corresponding slot names. |
| 50 | */ |
| 51 | std::vector<std::tuple<std::uint32_t, std::string>> buildPcieMap(); |
| 52 | |
Patrick Venture | ab65000 | 2019-03-16 09:08:47 -0700 | [diff] [blame] | 53 | } // namespace ipmi |
| 54 | } // namespace google |