blob: bfd554691e46194f671dae36791c8e7e270565d4 [file] [log] [blame]
Willy Tua2056e92021-10-10 13:36:16 -07001// 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 Ventureab650002019-03-16 09:08:47 -070015#pragma once
16
Patrick Venture3fb74292019-03-16 11:32:16 -070017#include <cstdint>
Patrick Ventureab650002019-03-16 09:08:47 -070018#include <nlohmann/json.hpp>
19#include <string>
Patrick Venture3fb74292019-03-16 11:32:16 -070020#include <tuple>
21#include <vector>
Patrick Ventureab650002019-03-16 09:08:47 -070022
23namespace google
24{
25namespace 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 */
35nlohmann::json parseConfig(const std::string& file);
36
Patrick Venture8d5c9ce2019-03-16 11:20:12 -070037/**
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 */
43std::string readPropertyFile(const std::string& fileName);
44
Patrick Venture3fb74292019-03-16 11:32:16 -070045/**
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 */
50std::vector<std::tuple<std::uint32_t, std::string>> buildPcieMap();
51
Patrick Ventureab650002019-03-16 09:08:47 -070052} // namespace ipmi
53} // namespace google