1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

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
parent 2d27c98659
commit 11a7e21c2a
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())