Add binaries for models, generate README.md from README.md.in

This commit is contained in:
Jeremy Soller
2019-03-18 12:19:30 -06:00
parent 73e4fedd68
commit d5ab76f9db
50 changed files with 418 additions and 56 deletions

1
scripts/modeltool/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target

44
scripts/modeltool/Cargo.lock generated Normal file
View File

@@ -0,0 +1,44 @@
[[package]]
name = "bitflags"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "modeltool"
version = "0.1.0"
dependencies = [
"redox_intelflash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"system76_ecflash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "plain"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "redox_intelflash"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_uefi 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_uefi"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "system76_ecflash"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
"checksum redox_intelflash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49e6f45d8c070090589005869e0b776f52c735f9b5411fca369229135fa1dbd8"
"checksum redox_uefi 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dafc50645c27c55ca19d27645a6d91e2a8cbc7aabb2ed024ce914512c75e1217"
"checksum system76_ecflash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2a81b23cd826ce944029420978cce3be94363188ed87ff8cc0778f80adac547"

View File

@@ -0,0 +1,9 @@
[package]
name = "modeltool"
version = "0.1.0"
authors = ["Jeremy Soller <jeremy@system76.com>"]
edition = "2018"
[dependencies]
redox_intelflash = "0.1.0"
system76_ecflash = "0.1.0"

View File

@@ -0,0 +1,86 @@
use ecflash::{Ec, EcFile};
use intelflash::{Me, Rom};
use std::{env, fs, process};
use std::path::Path;
fn ec(path: &Path) {
println!("- [EC]({})", path.display());
match fs::read(path) {
Ok(data) => {
println!(" - Size: {} KB", data.len() / 1024);
{
let mut ec = EcFile::new(data);
println!(" - Model: {}", ec.project());
println!(" - Version: {}", ec.version());
}
},
Err(err) => {
println!(" - *Read Error: {}*", err);
}
}
}
fn fd(path: &Path) {
println!("- [FD]({})", path.display());
match fs::read(path) {
Ok(data) => {
println!(" - Size: {} KB", data.len() / 1024);
match Rom::new(&data) {
Ok(rom) => {
match rom.high_assurance_platform() {
Ok(hap) => {
println!(" - HAP: {}", hap);
},
Err(err) => {
println!(" - *HAP Error: {}*", err);
}
}
},
Err(err) => {
println!(" - *Parse Error: {}*", err);
}
}
},
Err(err) => {
println!(" - *Read Error: {}*", err);
}
}
}
fn me(path: &Path) {
println!("- [ME]({})", path.display());
match fs::read(path) {
Ok(data) => {
println!(" - Size: {} KB", data.len() / 1024);
match Me::new(&data) {
Ok(me) => {
if let Some(version) = me.version() {
println!(" - Version: {}", version);
}
},
Err(err) => {
println!(" - *Parse Error: {}*", err);
}
}
},
Err(err) => {
println!(" - *Read Error: {}*", err);
}
}
}
fn main() {
let args: Vec<String> = env::args().skip(1).collect();
if args.is_empty() {
println!("modeltool [model directory]...");
process::exit(1);
}
for arg in args {
let path = Path::new(&arg);
ec(&path.join("ec.rom"));
fd(&path.join("fd.rom"));
me(&path.join("me.rom"));
}
}