1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:27:43 +00:00

Kernel: Add a beep() syscall that beeps the PC speaker.

Hook this up in Terminal so that the '\a' character generates a beep.
Finally emit an '\a' character in the shell line editing code when
backspacing at the start of the line.
This commit is contained in:
Andreas Kling 2019-05-15 21:40:41 +02:00
parent dcf490ecab
commit 3cba2a8a78
14 changed files with 82 additions and 25 deletions

View file

@ -5,6 +5,7 @@
#include <AK/TemporaryChange.h>
#include <Kernel/Alarm.h>
#include <Kernel/FileSystem/FileDescriptor.h>
#include <Kernel/Devices/PCSpeaker.h>
//#define LOG_EVERY_CONTEXT_SWITCH
//#define SCHEDULER_DEBUG
@ -30,6 +31,7 @@ Thread* g_last_fpu_thread;
Thread* g_finalizer;
static Process* s_colonel_process;
qword g_uptime;
static qword s_beep_timeout;
struct TaskRedirectionData {
word selector;
@ -43,6 +45,12 @@ bool Scheduler::is_active()
return s_active;
}
void Scheduler::beep()
{
PCSpeaker::tone_on(440);
s_beep_timeout = g_uptime + 100;
}
bool Scheduler::pick_next()
{
ASSERT_INTERRUPTS_DISABLED();
@ -395,6 +403,11 @@ void Scheduler::timer_tick(RegisterDump& regs)
++g_uptime;
if (s_beep_timeout && g_uptime > s_beep_timeout) {
PCSpeaker::tone_off();
s_beep_timeout = 0;
}
if (current->tick())
return;