在x86上,通常不需要设备树,因此在Linux内核编译期间默认禁用它.我更改了配置以启用它,但我找不到将设备树BLOB放入启动映像的方法.内核源代码中的x86架构只有one DTS file,但似乎根本没有使用它,所以它没有帮助.
从kernel documentation开始,我知道我需要将它放在x86 real-mode kernel header的setup_data字段中,但我不明白该怎么做以及何时(在内核构建时?构建引导程序时?).我应该直接破解arch/x86/boot/header.S
文件吗?
现在,我已经用硬编码值替换了模块配置,但使用设备树会更好.
@R_403_6120@ 在x86上,引导加载程序在调用内核入口点之前将设备树二进制数据(DTB)添加到setup_data结构的链接列表中. DTB可以从存储设备加载或嵌入到引导加载程序映像中.以下代码显示了如何在U-Boot中实现它.
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/x86/lib/zimage.c:
static int setup_device_tree(struct setup_header *hdr,const voID *fdt_blob){ int bootproto = get_boot_protocol(hdr); struct setup_data *sd; int size; if (bootproto < 0x0209) return -ENOTSUPP; if (!fdt_blob) return 0; size = fdt_totalsize(fdt_blob); if (size < 0) return -EINVAL; size += sizeof(struct setup_data); sd = (struct setup_data *)malloc(size); if (!sd) { printf("Not enough memory for DTB setup data\n"); return -ENOMEM; } sd->next = hdr->setup_data; sd->type = SETUP_DTB; sd->len = fdt_totalsize(fdt_blob); memcpy(sd->data,fdt_blob,sd->len); hdr->setup_data = (unsigned long)sd; return 0;}总结
以上是内存溢出为你收集整理的linux-kernel – 如何将设备树blob添加到Linux x86内核启动?全部内容,希望文章能够帮你解决linux-kernel – 如何将设备树blob添加到Linux x86内核启动?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)