简体   繁体   English

U-Boot如何与Linux内核通信?

[英]How does U-Boot communicate with Linux kernel?

I'm reading the book and it tells that: 我正在读这本书,它告诉我:

After U-Boot loads Linux kernel, the kernel will claim all the resources of U-Boot U-Boot加载Linux内核后,内核将占用U-Boot的所有资源

What does this mean? 这是什么意思? Does it mean that all data structures that allocated in U-Boot will be discarded? 这是否意味着将丢弃U-Boot中分配的所有数据结构?

For example: during U-Boot, PCIE and Network Device will be initialized. 例如:在U-Boot期间,PCIE和网络设备将被初始化。 After booting Linux kernel, will the PCIE and Network Device data structure be discarded? 引导Linux内核后,PCIE和网络设备数据结构会被丢弃吗? Will the Linux kernel do PCIE and NEtwork initialize again? Linux内核会再次初始化PCIE和NEtwork吗? Or U-Boot will transfer some data to kernel? 还是U-Boot将一些数据传输到内核?

It depends on your CPU architecture how the communication happens, but it is usually via a special place in RAM, flash or the filesystem. 通讯如何进行取决于您的CPU体系结构,但通常是通过RAM,闪存或文件系统中的特殊位置进行的。 No data structures are transferred, they would be meaningless to the kernel and the memory space will be different between the two. 不会传输任何数据结构,它们对内核将毫无意义,并且两者之间的存储空间将有所不同。 Uboot generally passes boot parameters like what type of hardware is present, what memory to use for something, or which type of mode to use for a specific driver. Uboot通常会传递引导参数,例如存在的硬件类型,用于某些事物的内存或用于特定驱动程序的模式类型。 So yes, the kernel will re-initialize the hardware. 因此,是的,内核将重新初始化硬件。 The exception may be some of the low level CPU specifics which the kernel may expect uboot or a BIOS to have setup already. 内核可能希望uboot或BIOS已经设置了某些低级CPU细节,这是一个例外。

Depending on your architecture, there may be different mechanism for the u-boot to communicate with the Linux kernel. 根据您的体系结构,u-boot与Linux内核进行通信的机制可能有所不同。 Actually there may be some structures defined by u-boot which are transferred to and used by the kernel using ATAGS . 实际上,u-boot可能定义了一些结构,这些结构已使用ATAGS传递给内核并由内核使用。 The address in which these structure are passed is stored in r2 register on ARM. 传递这些结构的地址存储在ARM的r2寄存器中。 They convey information such as available RAM size and location, kernel command line, ... 它们传达信息,例如可用的RAM大小和位置,内核命令行,...

Note that on some architectures (like ARM again) we have support for device-tree which intends for defining the hardware in which the kernel is going to be run as well as kernel command line, memory and other thins. 请注意,在某些体系结构(再次类似于ARM)上,我们支持设备树,该树旨在定义要在其中运行内核的硬件以及内核命令行,内存和其他Thins。 Such description is usually created during kernel compile time, loaded into the memory by the u-boot and in case of ARM architecture, its address is transferred through r2 register. 这种描述通常是在内核编译时创建的,通过u-boot加载到内存中,对于ARM体系结构,其地址通过r2寄存器进行传输。

The interesting thing about this (regarding your question) is that u-boot can change this device-tree structure before passing it to the kernel through device tree overlay mechanism. 有趣的是(关于您的问题),u-boot可以在通过设备树覆盖机制将其传递到内核之前更改此设备树结构。 So this is a (relatively) new way of u-boot/kernel communication. 因此,这是(相对)u-boot /内核通信的新方式。 Note that device-tree is not supported on some architectures. 请注意,某些体系结构不支持设备树。

And at the end, yes, the hardware is reinitialized by the kernel even in they have already initialized by the u-boot except for memory controller and some other very low level initialization, AFAIK. 最后,是的,除了内存控制器和其他一些非常低级的初始化AFAIK外,硬件已经由u-boot进行了初始化,即使它们已经由u-boot进行了初始化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM