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 15 #pragma once 16 17 #include <cstdint> 18 #include <nlohmann/json.hpp> 19 #include <string> 20 #include <tuple> 21 #include <vector> 22 23 namespace google 24 { 25 namespace ipmi 26 { 27 28 /** 29 * Parse a file and return the json object. 30 * 31 * @param[in] file - the path to the file to parse. 32 * @return the json object if valid. 33 * @throw elog<InternalFailure> on failures. 34 */ 35 nlohmann::json parseConfig(const std::string& file); 36 37 /** 38 * Read a dts property file and return the contents. 39 * 40 * @param[in] file - the path to the file to parse. 41 * @return the property value or an empty string on failure. 42 */ 43 std::string readPropertyFile(const std::string& fileName); 44 45 /** 46 * Build a map of the i2c bus numbers to their PCIe slot names. 47 * 48 * @return list of pairs of i2c bus with their corresponding slot names. 49 */ 50 std::vector<std::tuple<std::uint32_t, std::string>> buildPcieMap(); 51 52 } // namespace ipmi 53 } // namespace google 54