Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6f7971c
wip commit
repnop Jun 12, 2024
b9049d8
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…
repnop Jun 21, 2024
f80208a
dafgdfgadfgdfgadfgdfgagag AAAAAAAAAAAAAAAA
repnop Jun 24, 2024
de784fa
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…
repnop Jun 25, 2024
f1b512d
suffering
repnop Jun 26, 2024
be7bd60
pain and suffering
repnop Jul 1, 2024
c17164c
suffering knows no bounds
repnop Jul 3, 2024
6d06108
aaaaaa
repnop Jul 8, 2024
2b2952f
please save me from this torment
repnop Jul 9, 2024
ea5b130
despair
repnop Jul 9, 2024
144a150
hmm yes
repnop Jul 12, 2024
1c0d921
stuff and or things
repnop Jul 12, 2024
cbdc150
:waa:
repnop Jul 13, 2024
48b51a7
whoopsie
repnop Jul 13, 2024
6c87794
yes
repnop Jul 13, 2024
55ddb80
yes
repnop Jul 15, 2024
a1d05a0
wauw
repnop Jul 16, 2024
bc9fd2e
buncha stuff
repnop Jul 18, 2024
2927b3c
fix
repnop Jul 26, 2024
d332c95
some `cpu` stuff
repnop Jul 28, 2024
56d48a7
hmm yes
repnop Jul 30, 2024
4258ebb
organize some things into modules
repnop Jul 30, 2024
89572a2
hellmo
repnop Jul 31, 2024
fc00b24
guh
repnop Aug 5, 2024
d1d6f7b
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
repnop Aug 7, 2024
5cbd06b
Add .direnv to .gitignore (#38)
lzcunt Sep 14, 2024
1f8367e
fix: apply a similar patch to #39
repnop Oct 15, 2024
3abf3b0
add some more documentation and impl some helper functions
repnop Oct 16, 2024
d0b2d9b
woop, all tests pass
repnop Nov 27, 2024
2a8ef75
fix: missing token consumption in node parsing
repnop Jan 5, 2025
3ed4acb
fix: filter out non-`cpu` child nodes
repnop Jan 5, 2025
b6b5650
wip: little refactors + add CPU topology nodes
repnop Jan 6, 2025
4174cb6
wip: more docs + remove some methods in favor of direct field access
repnop Jan 13, 2025
5f14f93
fix: missing lifetimes
repnop Dec 7, 2025
11792fb
fix: enable docs warnings for cleanup
repnop Dec 7, 2025
ef008d6
fix: buncha documentation and some fixes/adjustments for some types.
repnop Dec 8, 2025
11dea5e
chore: docs done
repnop Jan 11, 2026
df362b7
fix: clippy lints
repnop Jan 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Cargo.lock
target/
/.direnv/
/Cargo.lock
/target/
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "fdt"
version = "0.2.0-alpha1"
authors = ["Wesley Norris <repnop@outlook.com>"]
edition = "2018"
edition = "2021"

repository = "https://github.com/repnop/fdt"

Expand All @@ -15,5 +15,6 @@ readme = "README.md"

[features]
pretty-printing = []
linux-dt-bindings = []

[dependencies]
62 changes: 32 additions & 30 deletions examples/basic_info.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb");
// static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb");

fn main() {
let fdt = fdt::Fdt::new(MY_FDT).unwrap();
// fn main() {
// let fdt = fdt::Fdt::new(MY_FDT).unwrap();

println!("This is a devicetree representation of a {}", fdt.root().model());
println!("...which is compatible with at least: {}", fdt.root().compatible().first());
println!("...and has {} CPU(s)", fdt.cpus().count());
println!(
"...and has at least one memory location at: {:#X}\n",
fdt.memory().regions().next().unwrap().starting_address as usize
);
// println!("This is a devicetree representation of a {}", fdt.root().model());
// println!("...which is compatible with at least: {}", fdt.root().compatible().first());
// println!("...and has {} CPU(s)", fdt.cpus().count());
// println!(
// "...and has at least one memory location at: {:#X}\n",
// fdt.memory().regions().next().unwrap().starting_address as usize
// );

let chosen = fdt.chosen();
if let Some(bootargs) = chosen.bootargs() {
println!("The bootargs are: {:?}", bootargs);
}
// let chosen = fdt.chosen();
// if let Some(bootargs) = chosen.bootargs() {
// println!("The bootargs are: {:?}", bootargs);
// }

if let Some(stdout) = chosen.stdout() {
println!(
"It would write stdout to: {} with params: {:?}",
stdout.node().name,
stdout.params()
);
}
// if let Some(stdout) = chosen.stdout() {
// println!(
// "It would write stdout to: {} with params: {:?}",
// stdout.node().name,
// stdout.params()
// );
// }

let soc = fdt.find_node("/soc");
println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" });
if let Some(soc) = soc {
println!("...and it has the following children:");
for child in soc.children() {
println!(" {}", child.name);
}
}
}
// let soc = fdt.find_node("/soc");
// println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" });
// if let Some(soc) = soc {
// println!("...and it has the following children:");
// for child in soc.children() {
// println!(" {}", child.name);
// }
// }
// }

fn main() {}
8 changes: 4 additions & 4 deletions examples/tree_print.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use fdt::node::FdtNode;
use fdt::helpers::UnalignedInfallibleNode;

static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb");

fn main() {
let fdt = fdt::Fdt::new(MY_FDT).unwrap();
let fdt = fdt::Fdt::new_unaligned(MY_FDT).unwrap();

print_node(fdt.find_node("/").unwrap(), 0);
}

fn print_node(node: FdtNode<'_, '_>, n_spaces: usize) {
fn print_node(node: UnalignedInfallibleNode<'_>, n_spaces: usize) {
(0..n_spaces).for_each(|_| print!(" "));
println!("{}/", node.name);
println!("{}/", node.name());

for child in node.children() {
print_node(child, n_spaces + 4);
Expand Down
82 changes: 82 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
description = "fdt development flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};

outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem(system:
let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
rust-bin = pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-src"];
};
in {
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.nil
rust-bin
];
};
}
);
}
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
use_small_heuristics = "Max"
max_width = 120
Loading
Loading