Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inital commit of elkscmd/beep #1796

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The ELKS kernel is licensed under the GNU General Public License version 2.

Software incldued beside the ELKS kernel (i.e. elkscmd) may be under different licensing terms, but all licenses are free software licenses that are legally permissible to distribute with the GPLv2 kernel code. If you are interested in the license information for a particular component, check its subdirectory or the top of its source code file(s) for its individual licensing details.
Software included beside the ELKS kernel (i.e. elkscmd) may be under different licensing terms, but all licenses are free software licenses that are legally permissible to distribute with the GPLv2 kernel code. If you are interested in the license information for a particular component, check its subdirectory or the top of its source code file(s) for its individual licensing details.

In the unlikely event that you discover a component with unclear, contradictory, or missing license information, please email Jody Bruchon <[email protected]> to resolve the issue.
1 change: 1 addition & 0 deletions elkscmd/Applications
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ sys_utils/sercat :sysutil :1200k
sys_utils/console :sysutil :1200k
#sys_utils/who :sysutil :1200k
sys_utils/unreal16 :sysutil
sys_utils/beep :sysutil
screen/screen :screen :1200k
cron/cron :cron :1200k
cron/crontab :cron :1200k
Expand Down
4 changes: 4 additions & 0 deletions elkscmd/sys_utils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ PRGS = \
chmem \
clock \
unreal16 \
beep \
mouse \
sercat \
console \
Expand Down Expand Up @@ -114,6 +115,9 @@ makeboot: makeboot.o $(TINYPRINTF)
unreal.o: $(ELKS_LIB)/unreal.S
$(LD) -melks-libc -mcmodel=small -c $(ELKS_LIB)/unreal.S -o unreal.o

beep: beep.o
$(LD) $(LDFLAGS) -o beep beep.o $(LDLIBS)

unreal16: unreal16.o unreal.o
$(LD) -melks-libc -mcmodel=small -c unreal16.S -o unreal16.o
$(LD) -melks-libc -mcmodel=small -nostdlib -o unreal16 unreal16.o unreal.o
Expand Down
60 changes: 60 additions & 0 deletions elkscmd/sys_utils/beep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* beep - This file is part of the ELKS project
* authors: Florian Zimmermann et al.
* Free software "as-is"
* Takes one optional parameter: the beep duration
*/
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "signal.h"
#include "arch/io.h"

static void beep(int freq)
{
//Set the PIT to the desired frequency
unsigned int d = 1193180 / freq;
outb(0xb6, 0x43);
outb((unsigned int)(d), 0x42);
outb((unsigned int)(d >> 8), 0x42);

//And play the sound using the PC speaker
unsigned int tmp = inb(0x61);
if (tmp != (tmp | 3)) {
outb(tmp | 3, 0x61);
}
}

static void silent()
{
unsigned int tmp = inb(0x61) & 0xFC;
outb(tmp, 0x61);
}

void beep_signal(int sig)
{
switch(sig) {
case SIGKILL: /* I'm falling */
case SIGTERM: /* I'm falling */
case SIGINT:
silent();
exit(sig);
}
}

int main(int ac, char **av)
{
long duration = 333L;
if(ac >= 2) {
duration = atoi(av[1]);
}

signal(SIGKILL, beep_signal);
signal(SIGINT, beep_signal);
signal(SIGTERM, beep_signal);

beep(1000);
usleep(duration * 1000L);
silent();

return 0;
}
5 changes: 4 additions & 1 deletion qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ NET="-netdev user,id=mynet,$FWD -device ne2k_isa,irq=12,netdev=mynet"
# Enable network dump here:
# NETDUMP="-net dump"

# Enable PC-Speaker here:
AUDIO="-audiodev pa,id=speaker -machine pcspk-audiodev=speaker"

# Determine display type ("Darwin" = OSX)
[ `uname` != 'Darwin' ] && QDISPLAY="-display sdl"

# Configure QEMU as pure ISA system

exec $QEMU $CONSOLE -nodefaults -name ELKS -machine isapc -cpu 486,tsc -m 4M \
exec $QEMU $AUDIO $CONSOLE -nodefaults -name ELKS -machine isapc -cpu 486,tsc -m 4M \
$KEYBOARD $QDISPLAY -vga std -rtc base=utc $SERIAL \
$NET $NETDUMP $IMAGE $DISK2 $@
Loading