Kernel+Userland: Add support for using the PCSpeaker with various tones

This commit is contained in:
Liav A 2023-03-01 22:05:04 +02:00 committed by Sam Atkins
commit 11a7e21c2a
Notes: sideshowbarker 2024-07-17 07:35:03 +09:00
9 changed files with 26 additions and 12 deletions

View file

@ -12,13 +12,15 @@
namespace Kernel {
ErrorOr<FlatPtr> Process::sys$beep()
ErrorOr<FlatPtr> Process::sys$beep(int tone)
{
VERIFY_NO_PROCESS_BIG_LOCK(this);
if (!kernel_command_line().is_pc_speaker_enabled())
return ENODEV;
if (tone < 20 || tone > 20000)
return EINVAL;
#if ARCH(X86_64)
PCSpeaker::tone_on(440);
PCSpeaker::tone_on(tone);
auto result = Thread::current()->sleep(Time::from_nanoseconds(200'000'000));
PCSpeaker::tone_off();
if (result.was_interrupted())