2020-07-30 23:38:15 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 23:38:15 +02:00
|
|
|
*/
|
|
|
|
|
2022-01-22 12:29:55 +02:00
|
|
|
#include <Kernel/CommandLine.h>
|
2022-10-04 03:05:54 +03:00
|
|
|
#if ARCH(X86_64)
|
2022-10-04 13:46:11 +03:00
|
|
|
# include <Kernel/Arch/x86_64/PCSpeaker.h>
|
2022-09-02 15:50:56 +03:00
|
|
|
#endif
|
2020-07-30 23:38:15 +02:00
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-11-08 00:51:39 +01:00
|
|
|
ErrorOr<FlatPtr> Process::sys$beep()
|
2020-07-30 23:38:15 +02:00
|
|
|
{
|
2021-08-06 14:22:21 +03:00
|
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
2022-01-22 12:29:55 +02:00
|
|
|
if (!kernel_command_line().is_pc_speaker_enabled())
|
|
|
|
return ENODEV;
|
2022-10-04 03:05:54 +03:00
|
|
|
#if ARCH(X86_64)
|
2020-07-30 23:38:15 +02:00
|
|
|
PCSpeaker::tone_on(440);
|
2021-02-27 23:56:16 +01:00
|
|
|
auto result = Thread::current()->sleep(Time::from_nanoseconds(200'000'000));
|
2020-07-30 23:38:15 +02:00
|
|
|
PCSpeaker::tone_off();
|
2020-11-15 11:58:19 -07:00
|
|
|
if (result.was_interrupted())
|
2021-03-01 13:49:16 +01:00
|
|
|
return EINTR;
|
2020-07-30 23:38:15 +02:00
|
|
|
return 0;
|
2022-09-02 15:50:56 +03:00
|
|
|
#else
|
|
|
|
return ENOTIMPL;
|
|
|
|
#endif
|
2020-07-30 23:38:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|