Skip to content

Commit ab4a969

Browse files
authored
refactor: improve iter (#6)
* Remove unused property parsing module and associated tests - Deleted the `property.rs` module which provided functionality for parsing and accessing device tree properties. - Removed tests related to device tree headers and memory reservations that relied on the deleted module. - Updated `Cargo.toml` to reflect the removal of the module and incremented the version to 0.2.0. * feat: Enhance FDT parsing and formatting utilities - Added new constants for size calculations in FDT parsing (`U32_SIZE`, `MEM_RSV_ENTRY_SIZE`). - Improved `Bytes` struct with additional documentation and examples for clarity. - Refactored `Fdt` struct methods to utilize new utility functions for path splitting and address translation. - Introduced `fmt_utils` module for shared formatting functions, improving code organization and readability. - Updated `Property` formatting to handle various types more gracefully, including a new method for typed formatting. - Enhanced error handling in iterators to allow for graceful degradation during parsing. - Added comprehensive documentation to several structs and methods to improve maintainability and usability. * feat: Add path tracking to FDT nodes and iterators * feat: Add batch address translation method to FDT parser * feat: Refactor address translation methods for improved batch processing * feat: Add method to find direct children of a node by path and corresponding tests * feat: Add fdt-edit module with Node and Property structures for device tree manipulation * feat: Implement editable FDT structure with node iteration and testing * feat: Refactor node iteration with new NodeRef and NodeRefMut structures * feat: Update property formatting in NodeRef display implementation * feat: Refactor Node handling with NodeGeneric and update NodeRef/NodeRefMut implementations * feat: Refactor Node iteration and enhance NodeKind with NodeOp trait * feat: Enhance compatible property formatting in NodeGeneric display implementation * feat: Add NodeMemory struct and enhance NodeKind with memory node support * feat: Enhance NodeIterMeta to support parent path tracking and update NodeIter for path construction * feat: Add path retrieval method to NodeKind and implement exact path lookup in Fdt * Refactor device tree node iteration and viewing - Removed obsolete node iteration and memory handling code from `node_iter` module. - Introduced `NodeView` and `NodeViewMut` for safe, typed access to device tree nodes. - Implemented visitor traits (`Visit` and `VisitMut`) for traversing device tree nodes. - Updated tests to validate new node iteration and classification logic. - Enhanced path lookup functionality to ensure correct resolution of node paths. * feat: Add methods to NodeType for accessing node properties and enhance test for node classification * feat: Add enum_dispatch dependency and implement NodeView for safe access to device tree nodes * Implement specialized node views for device tree nodes - Added `NodeGeneric` and `NodeGenericMut` for generic node views. - Introduced `IntcNodeView` and `IntcNodeViewMut` for interrupt controller nodes. - Created `MemoryNodeView` and `MemoryNodeViewMut` for memory nodes, including methods for parsing memory regions. - Refactored `NodeView` and `NodeType` to support new specialized views. - Removed the visitor traits and related implementations for traversing device tree nodes. - Updated tests to reflect changes in node view access and removed obsolete visitor tests. * fix: Adjust imports in memory and header modules for consistency * feat: Enhance Fdt with alias resolution and path normalization methods * feat: Implement address translation for memory regions and add tests * feat: Implement address translation for device tree node registers and add corresponding tests * fix: Remove unused set_regs method from IntcNodeViewMut and MemoryNodeViewMut * fix: Refactor path_of method to use while let for cleaner code and add dead code allowance for parent_mut method * feat: Add ViewMutOp trait and implement for NodeGenericMut; enhance child node addition methods * feat: Enhance ViewMutOp trait with new implementations for IntcNodeViewMut and MemoryNodeViewMut; adjust visibility of add_child method in NodeGenericMut * feat: Add root_mut method to Fdt for mutable access to the root node * feat: Implement parent mapping in Fdt and update node structure for parent access * feat: 添加 FDT 编码模块及相关测试用例,支持将 FDT 结构序列化为 DTB 格式 * feat: 修改 find_children_by_path 方法以返回 ChildrenIter,优化路径处理逻辑 * feat: 优化 find_children_by_path 方法,改进返回值处理和日志记录 * feat: 添加 FDT 重建测试,验证解析和编码的正确性 * feat: 添加时钟和PCI节点视图模块及相关测试,增强设备树解析能力 * feat: 优化代码格式,调整多个测试文件中的打印语句和属性设置的格式 * feat: 简化 Clippy 和构建命令,移除不必要的 manifest-path 和包参数 * feat: 优化 PciNodeView 中的地址和中断填充逻辑,使用更清晰的函数替代 * feat: 移除 CI 配置中的目标架构,简化构建和检查步骤
1 parent 943d275 commit ab4a969

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3512
-10700
lines changed

.claude/settings.local.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
"WebFetch(domain:elinux.org)",
1111
"mcp__web-search-prime__webSearchPrime",
1212
"WebFetch(domain:www.devicetree.org)",
13-
"Bash(RUST_BACKTRACE=1 cargo test -p fdt-parser -- test_pci2 --nocapture)"
13+
"Bash(RUST_BACKTRACE=1 cargo test -p fdt-parser -- test_pci2 --nocapture)",
14+
"Bash(cargo check:*)",
15+
"Bash(cargo clippy:*)",
16+
"mcp__zread__get_repo_structure",
17+
"Bash(find:*)",
18+
"mcp__zread__read_file"
1419
],
1520
"deny": [],
1621
"ask": []

.github/workflows/check.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
rust-toolchain: [nightly]
13-
targets: [x86_64-unknown-linux-gnu, x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none-softfloat]
1413
steps:
1514
- uses: actions/checkout@v4
1615
- uses: dtolnay/rust-toolchain@nightly
1716
with:
1817
toolchain: ${{ matrix.rust-toolchain }}
1918
components: rust-src, clippy, rustfmt
20-
targets: ${{ matrix.targets }}
2119
- name: Check rust version
2220
run: rustc --version --verbose
2321
- name: Check code format
2422
run: cargo fmt --all -- --check
2523
- name: Clippy
26-
run: cargo clippy --manifest-path ./fdt-parser/Cargo.toml --target ${{ matrix.targets }} --all-features -- -A clippy::new_without_default
24+
run: cargo clippy --all-features
2725
- name: Build
28-
run: cargo build -p fdt-parser --target ${{ matrix.targets }} --all-features
26+
run: cargo build --all-features

CLAUDE.md

Lines changed: 0 additions & 83 deletions
This file was deleted.

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[workspace]
2-
resolver = "2"
3-
members = ["fdt-parser", "dtb-tool", "dtb-file", "fdt-raw", "fdt-edit"]
2+
members = ["dtb-file", "fdt-edit", "fdt-raw"]
3+
resolver = "3"
4+
5+
[workspace.dependencies]
6+
dtb-file = {path = "dtb-file"}

demo_find_all.pdb

-1.29 MB
Binary file not shown.

dtb-tool/Cargo.toml

Lines changed: 0 additions & 18 deletions
This file was deleted.

dtb-tool/src/main.rs

Lines changed: 0 additions & 61 deletions
This file was deleted.

example_all_nodes.rs

Lines changed: 0 additions & 61 deletions
This file was deleted.

fdt-edit/Cargo.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@
22
authors = ["周睿 <zrufo747@outlook.com>"]
33
categories = ["embedded", "no-std", "hardware-support"]
44
description = "A high-level library for creating, editing, and encoding Flattened Device Tree (FDT) structures"
5-
documentation = "https://docs.rs/fdt-edit"
65
edition = "2024"
7-
exclude = [".git*", "*.md", "tests/"]
86
homepage = "https://github.com/drivercraft/fdt-parser"
97
keywords = ["device-tree", "dtb", "embedded", "no-std", "editor"]
108
license = "MIT OR Apache-2.0"
119
name = "fdt-edit"
12-
readme = "README.md"
1310
repository = "https://github.com/drivercraft/fdt-parser"
14-
version = "0.1.7"
11+
version = "0.2.0"
1512

1613
[dependencies]
17-
enum_dispatch = "0.3.13"
18-
fdt-raw = {version = "0.1.0", path = "../fdt-raw"}
14+
fdt-raw = {version = "0.2", path = "../fdt-raw"}
1915
log = "0.4"
16+
enum_dispatch = "0.3"
2017

2118
[dev-dependencies]
22-
dtb-file = {path = "../dtb-file"}
19+
dtb-file.workspace = true
2320
env_logger = "0.11"
2421

2522
[features]

0 commit comments

Comments
 (0)