在 ARM 架構中,start_kernel 會先呼叫 setup_arch。該函數負責解析 bootloader 傳入的 DTB 位址,並建立 device tree。
DTB 載入記憶體後,只是一段包含標頭與資料區的 blob。setup_machine_fdt 會把物理位址轉為虛擬位址,並記錄 initial_boot_params,供後續解析使用。
標頭中包含 magic、totalsize、off_dt_struct、off_dt_strings、版本等資訊。kernel 依這些欄位找到結構區與字串區,才能正確還原節點與屬性。
unflatten_device_tree 會呼叫 __unflatten_device_tree,把 DTB 轉成 device_node 結構,並將根節點記錄到 of_allnodes。之後 of_platform_populate 就能依 this tree 建立平台設備。
Device Tree 初始化是 ARM 開機的關鍵階段。只有先建立完整的節點樹,後續总线、設備與驅動匹配才有基礎。