User:Finxx/Device Tree Blob

From OSDev Wiki
Jump to navigation Jump to search

This article is a stub! This page or section is a stub. You can help the wiki by accurately contributing to it.

This page is under construction! This page or section is a work in progress and may thus be incomplete. Its content may be changed in the near future.

A Device Tree Blob (DTB) is a binary representation of a Flattened Device Tree that is passed to your kernel.

Location

The location in memory of the DTB is dependent on the motherboard, but it is generally loaded at the start of memory.

Method of locating the DTB
CPU Motherboard Boot Method Location
Arm Virt ELF Kernel Pointer in register R2
Arm Virt Bare-Metal 0x40000000
AArch64 Virt ELF Kernel Pointer in register X0
AArch64 Virt Bare-Metal 0x40000000
Risc-V Virt ELF Kernel Pointer in register A1

Please expand this table if you know the correct values!

Structure

All integers are stored in big endian.

typedef struct {
	uint32_t magic; /* 0xD00DFEED */
	uint32_t size; /* includes header and data */
	uint32_t struct_offset; /* offset of struct block */
	uint32_t strings_offset; /* offset of strings block */
	uint32_t memory_offset; /* offset of memory block */
	uint32_t version; /* version of dtb (17) */
	uint32_t min_version; /* minimum version (16) */
	uint32_t cpu_id; /* id of boot cpu */
	uint32_t strings_size; /* size of strings block */
	uint32_t struct_size; /* size of struct block */
} dtb_header;

Todo