blob: d8f7f186ea8ed2e02d8a236026c9c427c6660195 [file] [log] [blame]
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/*
* Boot the module.
*/
#include <iostream>
#include <memory>
#include <string>
#include <base/files/file_path.h>
#include <base/numerics/safe_conversions.h>
#include <base/strings/string_number_conversions.h>
#include "hps/hps.h"
#include "hps/hps_reg.h"
#include "hps/util/command.h"
#include "hps/utils.h"
namespace {
int Boot(std::unique_ptr<hps::HPS> hps,
const base::CommandLine::StringVector& args) {
std::string mcu = "/usr/lib/firmware/hps/mcu_stage1.bin";
std::string fpga_bitstream = "/usr/lib/firmware/hps/fpga_bitstream.bin";
std::string fpga_app_image = "/usr/lib/firmware/hps/fpga_application.bin";
std::string version_file = "/usr/lib/firmware/hps/mcu_stage1.version.txt";
if (args.size() > 1) {
mcu = args[1];
}
if (args.size() > 2) {
fpga_bitstream = args[2];
}
if (args.size() > 3) {
fpga_app_image = args[3];
}
if (args.size() > 4) {
version_file = args[4];
}
uint32_t version;
if (!hps::ReadVersionFromFile(base::FilePath(version_file), &version)) {
return 1;
}
hps->Init(version, base::FilePath(mcu), base::FilePath(fpga_bitstream),
base::FilePath(fpga_app_image));
hps->Boot();
return 0;
}
Command bootcmd("boot",
"boot [mcu-file [fpga-bitstream [fpga-application [version]]]] "
"- Boot module.",
Boot);
} // namespace