參考書籍:devicetree-specification-v0.2
鏈接:https://pan.baidu.com/s/1R3XFN8cqfnab3CI9Y8xXWg
提取碼:g82i
DTB Devicetree blob。devicetree的緊湊二進制表示。
DTC Devicetree compiler。一個開源工具,用於從DTS文件創建DTB文件。
DTS Devicetree syntax。DTC使用的設備樹的文本表示。
內核啓動時會加載dtb文件,加載流程:
void __init start_kernel(void)
void __init setup_arch(char **cmdline_p) //kernel/arch/arm/kernel/setup.c
void __init unflatten_device_tree(void) //kernel/drivers/of/fdt.c
__unflatten_device_tree(initial_boot_params, &of_allnodes,
early_init_dt_alloc_memory_arch);
unflatten_dt_node(blob, 0, &start, NULL, NULL, 0); //解析設備樹
of_alias_scan(early_init_dt_alloc_memory_arch);
/*創建一個設備樹,創建struct device_node的樹。它還填充節點的“name”和“type”指針,這樣就可以使用普
通的設備樹遍歷函數。
@blob:要展開的blob
@mynodes:調用創建的device_node樹
@dt_alloc:提供內存虛擬地址的分配器
*/
__unflatten_device_tree(struct boot_param_header *blob,struct device_node **mynodes,
void * (*dt_alloc)(u64 size, u64 align))
/* of_alias_scan -掃描“aliases”節點的所有屬性。該函數掃描“aliases”節點的所有屬性,並用這些屬性填充全局查找表。它返回找到的alias_prop的數量,或者在錯誤情況下返回錯誤代碼
* @dt_alloc:一個分配器,它爲生成的樹提供一個到內存的虛擬地址
*/
void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
設備樹文件
具體在使用中:
與設備樹文件匹配成功後會調用
卸載驅動