mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
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.
This commit is contained in:
parent
8dbbef9b5c
commit
69f054616d
5 changed files with 19 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue