Crate libfdt_rs

Source
Expand description

§libfdt-rs

libfdt-rs is a library for handling FDT binaries. It uses libfdt under the hood.

§Zero-copy

As much as possible, the library avoids copying data. Nodes and properties are cheap references into the FDT binary in memory. Lifetime is property handled, avoiding some pitfalls met while manipulating FDT binaries.

§Devicetree compliant

This crates aims at being compliant with the devicetree specification as much as possible.

This crate officially supports the devicetree specification v0.4.

§Linux special properties

The crate handles special properties used by the Linux kernel. It makes it easy to retrieve phandle links between subnodes, as detected by the Linux kernel.

§no_std compatible

The crate is fully compatible with no_std.

§Example code

use std::fs;
use libfdt_rs::Fdt;

let fdt_bin = fs::read("dtb/zuma-a0-foplp.dtb").unwrap();
let fdt = Fdt::new(fdt_bin.into_boxed_slice()).unwrap();
let root_node = fdt.get_node("/").unwrap();

for subnode in root_node.subnodes_iter() {
    println!("subnode:?");
}

for property in root_node.properties_iter() {
    println!("subnode:?");
}

Structs§

Fdt
Fdt
FdtNode
Node representation in an Fdt.
FdtNodeIter
An iterator over the subnodes of a parent node.
FdtProperty
A node property.
FdtPropertyIter
An iterator over the properties of a node.
Offset
Phandle
PhandleLink
A link between two nodes.
PropertyCellParser
A property reader, for cells.
PropertyReader
A property data reader.

Enums§

Error
The possible errors libfdt can output. It is a 1-to-1 translation of errorlibfdt can issue.
FdtNodeRef
A node reference in an Fdt. There are two possible references: - FdtNodeRef::Path: a full path to a node. - FdtNodeRef::Symbol: a symbol pointing to a node.

Constants§

PHANDLE_LINKS_SIMPLE
PHANDLE_LINKS_SUFFIX

Traits§

PropertyParser
A property parser.