Skip to content

Commit 6dace65

Browse files
committed
feat: update example/qemu-virt
Signed-off-by: Woshiluo Luo <woshiluo.luo@outlook.com>
1 parent d2eb042 commit 6dace65

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

examples/qemu-virt.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use serde_derive::Deserialize;
1111
// - `NodeSeq`: name@... 区分的一组同级同类的连续节点,这个类型要求可变的内存。
1212
// - `StrSeq`: '\0' 分隔的一组字符串,设备树中一种常见的属性类型,这个类型要求可变的内存。
1313
use serde_device_tree::{
14-
buildin::{NodeSeq, Reg, StrSeq},
14+
buildin::{Node, NodeSeq, Reg, StrSeq},
1515
error::Error,
1616
from_raw_mut, Dtb, DtbPtr,
1717
};
@@ -56,7 +56,7 @@ fn main() -> Result<(), Error> {
5656
chosen: Option<Chosen<'a>>,
5757
cpus: Cpus<'a>,
5858
memory: NodeSeq<'a>,
59-
soc: Soc<'a>,
59+
soc: Node<'a>,
6060
}
6161

6262
#[derive(Deserialize)]
@@ -90,6 +90,7 @@ fn main() -> Result<(), Error> {
9090
reg: Reg<'a>,
9191
}
9292

93+
#[allow(dead_code)]
9394
#[derive(Deserialize)]
9495
struct Soc<'a> {
9596
virtio_mmio: NodeSeq<'a>,
@@ -131,9 +132,14 @@ fn main() -> Result<(), Error> {
131132
);
132133
}
133134

134-
for peripheral in t.soc.virtio_mmio.iter() {
135-
let virtio_mmio: VirtIoMmio = peripheral.deserialize();
136-
println!("virtio_mmio@{}: {:?}", peripheral.at(), virtio_mmio.reg);
135+
for current_node in t.soc.node_iter().unwrap() {
136+
if current_node.get_split_name().0 == "virtio_mmio" {
137+
let mmio = current_node.deserialize::<VirtIoMmio>();
138+
println!("{:?} {:?}", current_node.get_split_name(), mmio.reg);
139+
}
140+
}
141+
for current_node in t.soc.prop_iter().unwrap() {
142+
println!("{}", current_node.get_name());
137143
}
138144

139145
// 解析过程中,设备树的内容被修改了。

0 commit comments

Comments
 (0)