Browse Source

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.
Ben Wiederhake 3 years ago
parent
commit
542a88a7be

+ 1 - 1
.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"

+ 2 - 4
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).
-
-
-
-

+ 1 - 1
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`.

+ 2 - 2
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

+ 1 - 1
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
 ```

+ 2 - 3
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

+ 1 - 1
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;

+ 8 - 5
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

+ 1 - 2
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<VGACompatibleAdapter> m_vga_adapter;
     unsigned m_current_minor_number { 0 };
-    const bool m_framebuffer_devices_allowed;
 
     Spinlock m_main_vga_lock;
 };

+ 1 - 1
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: |

+ 1 - 1
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)

+ 1 - 1
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
 }
 

+ 1 - 1
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
 }
 

+ 1 - 1
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
 }
 

+ 1 - 0
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

+ 1 - 1
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