各platform , chip 的 device tree 寫在 arch/arm/boot/dts
build kernel 時,kernel 與 dts file 會分開 build.
dts 會用 device tree compile compile 成 DTB 檔。
bootloader 啟動 kernel 時,會同時把 DTB 讀入記憶體,交給 kernel.
kernel 啟動後,在 arch/arm/kernel/setup.c : setup_arch( ) 中
unflatten_device_tree();負責把 DTB 解成 device tree 結構。
driver/of/fdt.c:
/** * unflatten_device_tree - create tree of device_nodes from flat blob * * unflattens the device-tree passed by the firmware, creating the * tree of struct device_node. It also fills the "name" and "type" * pointers of the nodes so the normal device-tree walking functions * can be used. */ void __init unflatten_device_tree(void) { __unflatten_device_tree(initial_boot_params, &of_allnodes, early_init_dt_alloc_memory_arch); /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */ of_alias_scan(early_init_dt_alloc_memory_arch); }
ref:
- http://events.linuxfoundation.org/sites/events/files/slides/petazzoni-device-tree-dummies.pdf
- http://blog.csdn.net/21cnbao/article/details/8457546
- https://sites.google.com/site/yucheng1102/linux-kernel/device-tree
- http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=dfcd04b19d16c0016c705ed96a8b3cfa5315a2e9
沒有留言:
張貼留言