-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.cpp
More file actions
58 lines (47 loc) · 1.48 KB
/
platform.cpp
File metadata and controls
58 lines (47 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#include "gpio.hpp"
#include "i2c.hpp"
#include "intel.hpp"
#include "nvidia.hpp"
#include "utilities.hpp"
#include <fcntl.h>
#include <systemd/sd-daemon.h>
#include <CLI/CLI.hpp>
#include <gpiod.hpp>
#include <algorithm>
#include <array>
#include <iostream>
#include <string_view>
#include <utility>
constexpr std::array<std::pair<std::string_view, int (*)()>, 5> init_functions{
{{"intel-acrp", intel::init_acrp},
{"intel-jcrp", intel::init_jcrp},
{"nvidia-gb200", nvidia::init_gb200_base},
{"nvidia-gb200-with-p2020", nvidia::init_gb200_with_p2020},
{"nvidia-nvl32", nvidia::init_nvl32}}};
int main(int argc, char** argv)
{
CLI::App app("Platform init CLI");
app.require_subcommand();
CLI::App* init_sub =
app.add_subcommand("init", "Initialize the platform and daemonize");
std::string platform_name;
init_sub
->add_option("platform_name", platform_name,
"Name of the platform to init")
->required();
app.require_subcommand();
CLI11_PARSE(app, argc, argv)
const auto* it = std::ranges::find_if(
init_functions,
[&platform_name](const std::pair<std::string_view, int (*)()> val) {
return val.first == platform_name;
});
if (it == init_functions.end())
{
std::cerr << init_sub->help() << "\n";
return EXIT_FAILURE;
}
return it->second();
}