From 542a88a7be9fbdbc2ff3eadc38cdcaa33292fb97 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 23 Oct 2021 17:18:57 +0200 Subject: [PATCH] Kernel: Separate framebuffers from bootmode Bootmode used to control framebuffers, panic behavior, and SystemServer. This patch factors framebuffer control into a separate flag. Note that the combination 'bootmode=self-test fbdev=on' leads to unexpected behavior, which can only be fixed in a later commit. --- .github/workflows/cmake.yml | 2 +- Base/usr/share/man/man7/boot_parameters.md | 6 ++---- Documentation/BareMetalInstallation.md | 2 +- Documentation/NetworkBoot.md | 4 ++-- Documentation/RunningTests.md | 2 +- Kernel/CommandLine.cpp | 5 ++--- Kernel/CommandLine.h | 2 +- Kernel/Graphics/GraphicsManagement.cpp | 13 ++++++++----- Kernel/Graphics/GraphicsManagement.h | 3 +-- Meta/Azure/Serenity.yml | 2 +- Meta/extlinux.conf | 2 +- Meta/grub-ebr.cfg | 2 +- Meta/grub-gpt.cfg | 2 +- Meta/grub-mbr.cfg | 2 +- Meta/run.sh | 1 + Meta/serenity.sh | 2 +- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 68e1d84823c..c7f898170c6 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -183,7 +183,7 @@ jobs: working-directory: ${{ github.workspace }}/Build/${{ matrix.arch }} env: SERENITY_QEMU_CPU: "max,vmx=off" - SERENITY_KERNEL_CMDLINE: "boot_mode=self-test" + SERENITY_KERNEL_CMDLINE: "fbdev=off boot_mode=self-test" SERENITY_RUN: "ci" run: | echo "::group::ninja run # Qemu output" diff --git a/Base/usr/share/man/man7/boot_parameters.md b/Base/usr/share/man/man7/boot_parameters.md index cec7d2e44df..74fb8490849 100644 --- a/Base/usr/share/man/man7/boot_parameters.md +++ b/Base/usr/share/man/man7/boot_parameters.md @@ -38,6 +38,8 @@ List of options: * **`disable_virtio`** - If present on the command line, virtio devices will not be detected, and initialized on boot. +* **`fbdev`** - This parameter expects **`on`** or **`off`**. + * **`force_pio`** - If present on the command line, the IDE controllers will be force into PIO mode when initialized IDE Channels on boot. * **`hpet`** - This parameter expects one of the following values. **`periodic`** - The High Precision Event Timer should @@ -68,7 +70,3 @@ List of options: ## See also * [`SystemServer`(7)](../man7/SystemServer.md). - - - - diff --git a/Documentation/BareMetalInstallation.md b/Documentation/BareMetalInstallation.md index f662bcf8032..9ca9ff7a584 100644 --- a/Documentation/BareMetalInstallation.md +++ b/Documentation/BareMetalInstallation.md @@ -56,5 +56,5 @@ framebuffer with 8x8 font glyphs. You can force capable multiboot bootloaders to boot Serenity into high resolution mode by editing **Kernel/Arch/i386/Boot/boot.S** and adding **| MULTIBOOT_VIDEO_MODE** to the end of the **multiboot_flags** before building Serenity. -Setting a boot argument of `boot_mode=no-fbdev` will force the kernel to not initialize any framebuffer devices, hence allowing the system +Setting a boot argument of `fbdev=off` will force the kernel to not initialize any framebuffer devices, hence allowing the system to boot into console-only mode as `SystemServer` will detect this condition and will not initialize `WindowServer`. diff --git a/Documentation/NetworkBoot.md b/Documentation/NetworkBoot.md index a2776f36eae..f8506adcf44 100644 --- a/Documentation/NetworkBoot.md +++ b/Documentation/NetworkBoot.md @@ -87,7 +87,7 @@ menuentry 'SerenityOS - netboot diskless text mode' { set gfxkeep=text terminal_output console echo 'Loading prekernel...' - multiboot (tftp)/serenity/prekernel root=/dev/ramdisk0 boot_mode=text + multiboot (tftp)/serenity/prekernel root=/dev/ramdisk0 fbdev=off echo 'Loading kernel...' module (tftp)/serenity/kernel echo 'Loading ramdisk...' @@ -179,7 +179,7 @@ For troubleshooting purposes, you can add the following command line arguments i - `disable_uhci_controller` Because iPXE (unlike GRUB) doesn't support VESA VBE modesetting when booting a multiboot kernel, -you might not see any output, so add the `boot_mode=text` argument as well to boot into VGA text mode. +you might not see any output, so add the `fbdev=off` argument as well to boot into VGA text mode. Afterwards you will need to enable the `console` iPXE command by uncommenting the following line in `src/config/general.h`: ```c diff --git a/Documentation/RunningTests.md b/Documentation/RunningTests.md index 9aeea0529c9..01d7aa058e4 100644 --- a/Documentation/RunningTests.md +++ b/Documentation/RunningTests.md @@ -114,6 +114,6 @@ lines will boot SerenityOS in self-test mode, run tests, and exit. ```sh export SERENITY_RUN=ci -export SERENITY_KERNEL_CMDLINE="boot_mode=self-test" +export SERENITY_KERNEL_CMDLINE="fbdev=off boot_mode=self-test" ninja run ``` diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index c661a9dd770..369ffd9027b 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -214,10 +214,9 @@ BootMode CommandLine::boot_mode(Validate should_validate) const return BootMode::Unknown; } -UNMAP_AFTER_INIT bool CommandLine::is_no_framebuffer_devices_mode() const +UNMAP_AFTER_INIT bool CommandLine::are_framebuffer_devices_enabled() const { - const auto mode = boot_mode(); - return mode == BootMode::NoFramebufferDevices || mode == BootMode::SelfTest; + return lookup("fbdev"sv).value_or("on"sv) == "on"sv; } StringView CommandLine::userspace_init() const diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index 5e3b6b7a6e7..27afe795887 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -66,7 +66,7 @@ public: [[nodiscard]] bool is_vmmouse_enabled() const; [[nodiscard]] PCIAccessLevel pci_access_level() const; [[nodiscard]] bool is_legacy_time_enabled() const; - [[nodiscard]] bool is_no_framebuffer_devices_mode() const; + [[nodiscard]] bool are_framebuffer_devices_enabled() const; [[nodiscard]] bool is_force_pio() const; [[nodiscard]] AcpiFeatureLevel acpi_feature_level() const; [[nodiscard]] BootMode boot_mode(Validate should_validate = Validate::No) const; diff --git a/Kernel/Graphics/GraphicsManagement.cpp b/Kernel/Graphics/GraphicsManagement.cpp index a8602d74e0a..55f7cbca543 100644 --- a/Kernel/Graphics/GraphicsManagement.cpp +++ b/Kernel/Graphics/GraphicsManagement.cpp @@ -33,10 +33,14 @@ bool GraphicsManagement::is_initialized() } UNMAP_AFTER_INIT GraphicsManagement::GraphicsManagement() - : m_framebuffer_devices_allowed(!kernel_command_line().is_no_framebuffer_devices_mode()) { } +bool GraphicsManagement::framebuffer_devices_allowed() const +{ + return kernel_command_line().are_framebuffer_devices_enabled(); +} + void GraphicsManagement::deactivate_graphical_mode() { for (auto& graphics_device : m_graphics_devices) { @@ -69,7 +73,7 @@ UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_devi VERIFY(is_vga_compatible_pci_device(device_identifier) || is_display_controller_pci_device(device_identifier)); auto add_and_configure_adapter = [&](GraphicsDevice& graphics_device) { m_graphics_devices.append(graphics_device); - if (!m_framebuffer_devices_allowed) { + if (!framebuffer_devices_allowed()) { graphics_device.enable_consoles(); return; } @@ -175,9 +179,8 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize() * be created, so SystemServer will not try to initialize WindowServer. */ - if (kernel_command_line().is_no_framebuffer_devices_mode()) { - dbgln("Forcing no initialization of framebuffer devices"); - } + if (!framebuffer_devices_allowed()) + dbgln("Forcing non-initialization of framebuffer devices"); PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) { // Note: Each graphics controller will try to set its native screen resolution diff --git a/Kernel/Graphics/GraphicsManagement.h b/Kernel/Graphics/GraphicsManagement.h index 5c58926d036..d21cee52f84 100644 --- a/Kernel/Graphics/GraphicsManagement.h +++ b/Kernel/Graphics/GraphicsManagement.h @@ -37,7 +37,7 @@ public: unsigned allocate_minor_device_number() { return m_current_minor_number++; }; GraphicsManagement(); - bool framebuffer_devices_allowed() const { return m_framebuffer_devices_allowed; } + bool framebuffer_devices_allowed() const; bool framebuffer_devices_exist() const; Spinlock& main_vga_lock() { return m_main_vga_lock; } @@ -54,7 +54,6 @@ private: // Note: there could be multiple VGA adapters, but only one can operate in VGA mode RefPtr m_vga_adapter; unsigned m_current_minor_number { 0 }; - const bool m_framebuffer_devices_allowed; Spinlock m_main_vga_lock; }; diff --git a/Meta/Azure/Serenity.yml b/Meta/Azure/Serenity.yml index ddd715729e6..a115f3e3dc7 100644 --- a/Meta/Azure/Serenity.yml +++ b/Meta/Azure/Serenity.yml @@ -80,7 +80,7 @@ jobs: timeoutInMinutes: 60 env: SERENITY_QEMU_CPU: 'max,vmx=off' - SERENITY_KERNEL_CMDLINE: 'boot_mode=self-test' + SERENITY_KERNEL_CMDLINE: 'fbdev=off boot_mode=self-test' SERENITY_RUN: 'ci' - script: | diff --git a/Meta/extlinux.conf b/Meta/extlinux.conf index 4a994484882..3a2ed93ce74 100644 --- a/Meta/extlinux.conf +++ b/Meta/extlinux.conf @@ -13,7 +13,7 @@ LABEL SerenityOS LABEL SerenityOSText MENU LABEL SerenityOS (text mode) KERNEL mboot.c32 - APPEND ../Prekernel root=/dev/hda1 boot_mode=text --- ../Kernel + APPEND ../Prekernel root=/dev/hda1 fbdev=off --- ../Kernel LABEL SerenityOSNoACPI MENU LABEL SerenityOS (No ACPI) diff --git a/Meta/grub-ebr.cfg b/Meta/grub-ebr.cfg index 0ee30831fad..d70e838c157 100644 --- a/Meta/grub-ebr.cfg +++ b/Meta/grub-ebr.cfg @@ -8,7 +8,7 @@ menuentry 'SerenityOS (normal)' { menuentry 'SerenityOS (text mode)' { root=hd0,5 - multiboot /boot/Prekernel boot_mode=no-fbdev root=/dev/hda4 + multiboot /boot/Prekernel fbdev=off root=/dev/hda4 module /boot/Kernel } diff --git a/Meta/grub-gpt.cfg b/Meta/grub-gpt.cfg index 91e6f6b1105..c46256a85fc 100644 --- a/Meta/grub-gpt.cfg +++ b/Meta/grub-gpt.cfg @@ -8,7 +8,7 @@ menuentry 'SerenityOS (normal)' { menuentry 'SerenityOS (text mode)' { root=hd0,2 - multiboot /boot/Prekernel boot_mode=no-fbdev root=/dev/hda2 + multiboot /boot/Prekernel fbdev=off root=/dev/hda2 module /boot/Kernel } diff --git a/Meta/grub-mbr.cfg b/Meta/grub-mbr.cfg index 20e8ef83df4..05e83598796 100644 --- a/Meta/grub-mbr.cfg +++ b/Meta/grub-mbr.cfg @@ -8,7 +8,7 @@ menuentry 'SerenityOS (normal)' { menuentry 'SerenityOS (text mode)' { root=hd0,1 - multiboot /boot/Prekernel boot_mode=no-fbdev root=/dev/hda1 + multiboot /boot/Prekernel fbdev=off root=/dev/hda1 module /boot/Kernel } diff --git a/Meta/run.sh b/Meta/run.sh index bf33a14c308..8aa424a1106 100755 --- a/Meta/run.sh +++ b/Meta/run.sh @@ -69,6 +69,7 @@ fi [ "$KVM_SUPPORT" -eq "1" ] && SERENITY_VIRT_TECH_ARG="-enable-kvm" +# For default values, see Kernel/CommandLine.cpp [ -z "$SERENITY_KERNEL_CMDLINE" ] && SERENITY_KERNEL_CMDLINE="hello" [ -z "$SERENITY_RAM_SIZE" ] && SERENITY_RAM_SIZE=1G diff --git a/Meta/serenity.sh b/Meta/serenity.sh index 6e70ec78b03..46bd9f54d90 100755 --- a/Meta/serenity.sh +++ b/Meta/serenity.sh @@ -358,7 +358,7 @@ if [[ "$CMD" =~ ^(build|install|image|copy-src|run|gdb|test|rebuild|recreate|kad else build_target install build_target image - export SERENITY_KERNEL_CMDLINE="boot_mode=self-test" + export SERENITY_KERNEL_CMDLINE="fbdev=off boot_mode=self-test" export SERENITY_RUN="ci" build_target run fi