-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florian Zimmermann
committed
Feb 4, 2024
1 parent
6e68513
commit 395264b
Showing
5 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
BASEDIR=.. | ||
|
||
include $(BASEDIR)/Make.defs | ||
|
||
############################################################################### | ||
# | ||
# Include standard packaging commands. | ||
|
||
include $(BASEDIR)/Make.rules | ||
|
||
CFLAGS += -Wno-maybe-uninitialized | ||
|
||
############################################################################### | ||
|
||
PRGS = beep | ||
OBJS = beep.o | ||
#MAPFILE = -Wl,-Map=romprWg.map | ||
|
||
#HOSTPRGS = hostromprg | ||
|
||
all: $(PRGS) $(HOSTPRGS) | ||
|
||
beep: $(OBJS) | ||
$(LD) $(LDFLAGS) $(MAPFILE) -o beep $(OBJS) $(LDLIBS) | ||
|
||
HOSTSRC = beep.c | ||
hostromprg: $(HOSTSRC) | ||
$(HOSTCC) $(HOSTCFLAGS) $(HOSTSRC) -o $@ | ||
|
||
install: $(PRGS) | ||
$(INSTALL) $(PRGS) $(DESTDIR)/bin | ||
|
||
clean: | ||
rm -f $(PRGS) $(HOSTPRGS) *.o *.map | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* 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" | ||
|
||
#if 1 | ||
void outb(unsigned short port, unsigned char val) | ||
{ | ||
asm volatile("outb %0, %1" : : "a"(val), "Nd"(port) ); | ||
} | ||
|
||
unsigned char inb(unsigned short port) | ||
{ | ||
unsigned char ret; | ||
asm volatile ( "inb %1, %0" : "=a"(ret) : "Nd"(port) ); | ||
return ret; | ||
} | ||
#else | ||
#include "arch/io.h" | ||
#endif | ||
|
||
static void beep(int freq) | ||
{ | ||
//Set the PIT to the desired frequency | ||
unsigned int d = 1193180 / freq; | ||
outb(0x43, 0xb6); | ||
outb(0x42, (unsigned int)(d)); | ||
outb(0x42, (unsigned int)(d >> 8)); | ||
|
||
//And play the sound using the PC speaker | ||
unsigned int tmp = inb(0x61); | ||
if (tmp != (tmp | 3)) { | ||
outb(0x61, tmp | 3); | ||
} | ||
} | ||
|
||
static void silent() | ||
{ | ||
unsigned int tmp = inb(0x61) & 0xFC; | ||
outb(0x61, tmp); | ||
} | ||
|
||
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(SIGINT, beep_signal); | ||
signal(SIGTERM, beep_signal); | ||
|
||
beep(1000); | ||
usleep(duration * 1000L); | ||
silent(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters