diff options
author | Liav A <liavalb@gmail.com> | 2022-01-22 12:29:55 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-23 00:40:54 +0000 |
commit | 69f054616d3c5bbcf8c4d3ba4546ee5ec0b82c36 (patch) | |
tree | 0be08f1257afd0c3407933a24da2edc05a267bae /Kernel | |
parent | 8dbbef9b5cf7a0ae96a8d31391eb29021756a36c (diff) | |
download | serenity-69f054616d3c5bbcf8c4d3ba4546ee5ec0b82c36.zip |
Kernel: Add CommandLine option to disable or enable the PC speaker
By default, we disable the PC speaker as it's quite annoying when using
the text mode console.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/CommandLine.cpp | 10 | ||||
-rw-r--r-- | Kernel/CommandLine.h | 1 | ||||
-rw-r--r-- | Kernel/Syscalls/beep.cpp | 3 | ||||
-rw-r--r-- | Kernel/TTY/VirtualConsole.cpp | 3 |
4 files changed, 17 insertions, 0 deletions
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 <Kernel/CommandLine.h> #include <Kernel/Devices/PCSpeaker.h> #include <Kernel/Process.h> @@ -12,6 +13,8 @@ namespace Kernel { ErrorOr<FlatPtr> 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 <AK/StdLibExtras.h> +#include <Kernel/CommandLine.h> #include <Kernel/Debug.h> #include <Kernel/Devices/DeviceManagement.h> #include <Kernel/Devices/HID/HIDManagement.h> @@ -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(); |