麦当劳喜欢您来,喜欢您再来
设备树的终极目的
The “Open Firmware Device Tree”, or simply Device Tree (DT), is a data
structure and language for describing hardware. More specifically, it is a
description of hardware that is readable by an operating system
so that the operating system doesn’t need to hard code details of the
machine.
https://www.kernel.org/doc/Documentation/de
vicetree/usage-model.txt
历史和现在
最早:
2005 PowerPC Linux
现在:
arm, microblaze, mips, powerpc, sparc, x86
Openrisc, c6x
X86: arch/x86/platform/ce4100 (intel凌动处理器)
设备端:使用设备树之前
static struct resource dm9000_resource1[] = {
{
.start = 0x20100000,
.end = 0x20100000 + 1,
.flags = IORESOURCE_MEM
…
.start = IRQ_PF15,
.end = IRQ_PF15,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
}
};
static struct platform_device dm9000_device1 = {
.name = "dm9000",
.id = 0,
.num_resources = ARRAY_SIZE(dm9000_resource1),
.resource = dm9000_resource1,
};
static struct platform_device *ip0x_devices[] __initdata = {
&dm9000_device1,
&dm9000_device2,
};
static int __init ip0x_init(void)
{
platform_add_devices(ip0x_devices, ARRAY_SIZE(ip0x_devices));
}