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