diff --git a/Base/usr/share/man/man7/boot_parameters.md b/Base/usr/share/man/man7/boot_parameters.md index 91fc7db01a..c829bb146f 100644 --- a/Base/usr/share/man/man7/boot_parameters.md +++ b/Base/usr/share/man/man7/boot_parameters.md @@ -60,6 +60,8 @@ List of options: * **`root`** - This parameter configures the device to use as the root file system. It defaults to **`/dev/hda`** if unspecified. +* **`pcspeaker`** - This parameter controls whether the kernel can use the PC speaker or not. It defaults to **`off`** and can be set to **`on`** to enable the PC speaker. + * **`smp`** - This parameter expects a binary value of **`on`** or **`off`**. If enabled kernel will enable available APs (application processors) and use them with the BSP (Bootstrap processor) to schedule and run threads. diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index e87565c32d..00d74292b8 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -155,6 +155,16 @@ UNMAP_AFTER_INIT bool CommandLine::is_legacy_time_enabled() const return lookup("time"sv).value_or("modern"sv) == "legacy"sv; } +bool CommandLine::is_pc_speaker_enabled() const +{ + auto value = lookup("pcspeaker"sv).value_or("off"sv); + if (value == "on"sv) + return true; + if (value == "off"sv) + return false; + PANIC("Unknown pcspeaker setting: {}", value); +} + UNMAP_AFTER_INIT bool CommandLine::is_force_pio() const { return contains("force_pio"sv); diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index f28b97a0de..492650e781 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -71,6 +71,7 @@ public: [[nodiscard]] bool is_vmmouse_enabled() const; [[nodiscard]] PCIAccessLevel pci_access_level() const; [[nodiscard]] bool is_legacy_time_enabled() const; + [[nodiscard]] bool is_pc_speaker_enabled() const; [[nodiscard]] FrameBufferDevices are_framebuffer_devices_enabled() const; [[nodiscard]] bool is_force_pio() const; [[nodiscard]] AcpiFeatureLevel acpi_feature_level() const; diff --git a/Kernel/Syscalls/beep.cpp b/Kernel/Syscalls/beep.cpp index 3e2453107f..c8a897a756 100644 --- a/Kernel/Syscalls/beep.cpp +++ b/Kernel/Syscalls/beep.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include @@ -12,6 +13,8 @@ namespace Kernel { ErrorOr Process::sys$beep() { VERIFY_NO_PROCESS_BIG_LOCK(this); + if (!kernel_command_line().is_pc_speaker_enabled()) + return ENODEV; PCSpeaker::tone_on(440); auto result = Thread::current()->sleep(Time::from_nanoseconds(200'000'000)); PCSpeaker::tone_off(); diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index 86654a2de6..e6470d48d9 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -321,6 +322,8 @@ void VirtualConsole::flush_dirty_lines() void VirtualConsole::beep() { + if (!kernel_command_line().is_pc_speaker_enabled()) + return; PCSpeaker::tone_on(440); IO::delay(10000); PCSpeaker::tone_off();