Skip to content

Commit

Permalink
Kernel: Separate framebuffers from bootmode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BenWiederhake authored and awesomekling committed Oct 25, 2021
1 parent 314b8a3 commit 542a88a
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions Base/usr/share/man/man7/boot_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,7 +70,3 @@ List of options:
## See also

* [`SystemServer`(7)](../man7/SystemServer.md).




2 changes: 1 addition & 1 deletion Documentation/BareMetalInstallation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
4 changes: 2 additions & 2 deletions Documentation/NetworkBoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Documentation/RunningTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
5 changes: 2 additions & 3 deletions Kernel/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Kernel/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CommandLine {
[[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;
Expand Down
13 changes: 8 additions & 5 deletions Kernel/Graphics/GraphicsManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Kernel/Graphics/GraphicsManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GraphicsManagement {
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; }
Expand All @@ -54,7 +54,6 @@ class GraphicsManagement {
// 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;
};
Expand Down
2 changes: 1 addition & 1 deletion Meta/Azure/Serenity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion Meta/extlinux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Meta/grub-ebr.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion Meta/grub-gpt.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion Meta/grub-mbr.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions Meta/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Meta/serenity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 542a88a

Please sign in to comment.