LinuxBoot 在固件阶段与 Coreboot 有何不同?

How does LinuxBoot differs from Coreboot in the firmware phase?

我确实对使用 LinuxBoot 作为 Coreboot 的有效负载的用例感到困惑。

了解到LinuxBoot可以完全替代UEFI的DXE和BDS阶段,然后可以直接加载bootloader(比如GRUB)甚至Linux内核。

现在,我还了解到 LinuxBoot 可以用作 Coreboot 的负载。

如果LinuxBoot 可以完成从平台初始化到加载内核的所有工作,那么为什么有人还要将Coreboot 放在顺序中?简单地说,为什么存在使用 LinuxBoot 作为 Coreboot 负载的用例? Coreboot将扮演什么角色?

UEFI 由多个阶段组成:SEC、PEI 和 DXE。 LinuxBoot 取代了 DXE 阶段,Coreboot 取代了 SEC 和 PEI 阶段。

Coreboot负责Linux无法完成的平台初始化,如DRAM初始化(也叫"training")和ACPItable生成。 Linux 然后用作 Coreboot 负载,它执行 PCI 设备枚举等操作,并加载引导加载程序或可以 kexec() 进入另一个 Linux 内核。

我认为Coreboot不能完全处理SEC/PEI阶段,据我所知,这取决于你所说的Firmware Support Package,而Coreboot使用FSP来完成SEC/PEI。

LinuxBoot 无法进行平台初始化,而 coreboot 可以。正如 LinuxBoot: Linux as firmware 文章(强调我的)中所述:

Much like the LinuxBoot initramfs depends on the LinuxBoot kernel to start, so too does the LinuxBoot kernel depend on a previous step in the boot process. This is where coreboot may be involved. LinuxBoot and coreboot are not competitors, rather they address different stages of booting. Remember that the UEFI boot process consists of four stages, of which the third (the driver execution environment or DXE) is the point at which LinuxBoot starts. Coreboot is an implementation of the first two stages, where it can replace the UEFI firmware provided by the motherboard vendor. Coreboot only supports a narrow range of hardware but, when it can be used in concert with LinuxBoot, it enables an almost completely open boot process.

而LinuxBoot上的这张图homepage,LinuxBoot是在硬件初始化之后,也可以是UEFI的payload: LinuxBoot 的 FAQ 还指出:

LinuxBoot is compatible with UEFI as well as coreboot. You can use LinuxBoot as a UEFI DXE or as a coreboot payload.

至于您对 Eloy 回答的评论,我想 coreboot 的文档没有提及 SEC 和 PEI,因为它们是 UEFI 概念,而 coreboot 从未设计为遵循 UEFI 规范。如 Embedded Firmware Solutions

中所述

EFI (Extensible Firmware Interface) and coreboot began around the same time in the late 1990s. They started with two different purposes. One of the objectives of EFI was moving legacy BIOS to a modern interface with a modular driver model that allowed components to be added and removed with ease.coreboot, on the other hand, was mostly created from scratch to keep a minimum set of hardware initialization to boot Linux, and it was designed to be an open source project from the beginning. EFI was later adopted by many industry leaders, and turned into UEFI (Unified Extensible Firmware Interface).

并且由于 coreboot 与 UEFI 无关,它的功能并不完全映射到 UEFI 阶段,因此 "Linux as firmware" 文章在说 coreboot 实现 SEC 和 PEI 时有点笼统。 Embedded Firmware Solutions 在 table 中很好地解释了它们的相似之处,转载如下:

╔════════════════════════════════════╤════════════╤═════════════════╗
║ Capability                         │ coreboot   │ UEFI PI         ║
╠════════════════════════════════════╪════════════╪═════════════════╣
║ The reset vector and               │ boot block │ SEC             ║
║ pre cache-as-RAM setup.            │            │                 ║
╟────────────────────────────────────┼────────────┼─────────────────╢
║ Cache-as-RAM setup, early silicon  │ rom stage  │ PEI             ║
║ initialization, memory setup.      │            │ Create HOBs     ║
║ Covered largely by Intel FSP.      │            │                 ║
╟────────────────────────────────────┼────────────┼─────────────────╢
║ Normal device setup and main       │ ram stage  │ Early DXE       ║
║ board configuration. Publishes     │            │                 ║
║ SMBIOS/ACPI tables.                │            │                 ║
╟────────────────────────────────────┼────────────┼─────────────────╢
║ Memory map hand-off.               │ CBMEM      │ UEFI Memory Map ║
╟────────────────────────────────────┼────────────┼─────────────────╢
║ The OS or application boot loader. │ payload    │ DXE BDS &       ║
║                                    │            │ UEFI Drivers    ║
╚════════════════════════════════════╧════════════╧═════════════════╝

另外你说得对

certain architectures won't expose their initialization sequence, say Intel, which provides FSP probably for SEC and PEI phases

这就是为什么 coreboot 没有取代 FSP,而是依靠 Intel FSP 来实现它的目标。如 Embedded Firmware Solutions 中所述:

The coreboot philosophy aligns with the Intel FSP philosophy. The coreboot hardware initialization framework handles the FSP silicon initialization API, configures system peripherals, and loads the payload.

如果您有兴趣了解有关 Intel FSP、coreboot、UEFI 的更多信息,我鼓励您通读 Embedded Firmware Solutions。它解释了他们的历史并真正深入到技术细节,整本书可以免费下载。