1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:37:42 +00:00

Kernel/aarch64: Support reading the command line via the RPi Mailbox

This reuses the existing `RPi::Mailbox` interface to read the command
line via a VideoCore-specific mailbox message. This will have to be
replaced if that interface starts being smarter, as this is needed very
early, and nothing guarantees that a smarter Mailbox interface wouldn't
need to allocate or log, which is a no-no during early boot.

As the response string can be arbitrarily long, it's the caller's job to
provide a long enough buffer for `Mailbox::query_kernel_command_line`.
This commit chose 512 bytes, as it provides a large enough headroom over
the 150-200 characters implicitly added by the VC firmware.

The portable way would be to parse the `/chosen/bootargs` property of
the device tree, but we currently lack the scaffolding for doing that.

Support for this in QEMU relies on a patch that has not yet been
accepted upstream, but is available via our `Toolchain/BuildQEMU.sh`
script. It should, however, work on bare metal.

Tested-By: Timon Kruiper <timonkruiper@gmail.com>
This commit is contained in:
Daniel Bertalan 2023-04-24 20:35:29 +02:00 committed by Andreas Kling
parent 20fcbcb860
commit 81dd29f713
3 changed files with 46 additions and 1 deletions

View file

@ -149,6 +149,10 @@ READONLY_AFTER_INIT u8 multiboot_framebuffer_type;
Atomic<Graphics::Console*> g_boot_console;
#if ARCH(AARCH64)
READONLY_AFTER_INIT static u8 s_command_line_buffer[512];
#endif
extern "C" [[noreturn]] UNMAP_AFTER_INIT void init([[maybe_unused]] BootInfo const& boot_info)
{
g_in_early_boot = true;
@ -193,7 +197,8 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init([[maybe_unused]] BootInfo con
multiboot_module_entry_t modules[] = {};
multiboot_modules = modules;
multiboot_modules_count = 0;
kernel_cmdline = ""sv;
// FIXME: Read the /chosen/bootargs property.
kernel_cmdline = RPi::Mailbox::the().query_kernel_command_line(s_command_line_buffer);
#endif
setup_serial_debug();