diff --git a/libmaxsi/Makefile b/libmaxsi/Makefile
index 523da024..17f4a621 100644
--- a/libmaxsi/Makefile
+++ b/libmaxsi/Makefile
@@ -44,7 +44,7 @@ c/h/stdio.h
COMMONOBJS=c++.o thread.o io.o memory.o string.o error.o format.o
SORTIXOBJS:=$(addprefix sortix/,$(COMMONOBJS))
-LIBMAXSIOBJS:=$(COMMONOBJS) sortix-vga.o sortix-keyboard.o
+LIBMAXSIOBJS:=$(COMMONOBJS) sortix-vga.o sortix-keyboard.o sortix-sound.o
HEADERS=\
error.h \
io.h \
@@ -57,7 +57,8 @@ types.h \
format.h \
keyboard.h \
sortix-vga.h \
-sortix-keyboard.h
+sortix-keyboard.h \
+sortix-sound.h \
OBJS:=$(LIBMAXSIOBJS)
BINS:=libmaxsi.so
diff --git a/libmaxsi/hsrc/sortix-sound.h b/libmaxsi/hsrc/sortix-sound.h
new file mode 100644
index 00000000..b94b4e1f
--- /dev/null
+++ b/libmaxsi/hsrc/sortix-sound.h
@@ -0,0 +1,39 @@
+/******************************************************************************
+
+ COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ sortix-sound.cpp
+ Provides access to the sound devices. This is highly unportable and is very
+ likely to be removed or changed radically.
+
+******************************************************************************/
+
+#ifndef LIBMAXSI_SORTIX_SOUND_H
+#define LIBMAXSI_SORTIX_SOUND_H
+
+namespace System
+{
+ namespace Sound
+ {
+ // Sets the desired sound frequency on the current sound device. This is
+ // rather crude. A frequency of 0 disables the sound output.
+ void SetFrequency(unsigned frequency);
+ }
+}
+
+#endif
diff --git a/libmaxsi/sortix-sound.cpp b/libmaxsi/sortix-sound.cpp
new file mode 100644
index 00000000..b0b286d5
--- /dev/null
+++ b/libmaxsi/sortix-sound.cpp
@@ -0,0 +1,42 @@
+/******************************************************************************
+
+ COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ sortix-sound.cpp
+ Provides access to the sound devices. This is highly unportable and is very
+ likely to be removed or changed radically.
+
+******************************************************************************/
+
+#include "platform.h"
+#include "syscall.h"
+#include "sortix-sound.h"
+
+namespace System
+{
+ namespace Sound
+ {
+ DEFN_SYSCALL1_VOID(SysSetFrequency, 9, unsigned);
+
+ void SetFrequency(unsigned frequency)
+ {
+ SysSetFrequency(frequency);
+ }
+ }
+}
+
diff --git a/sortix/sound.cpp b/sortix/sound.cpp
index c35417f5..70bcdd5c 100644
--- a/sortix/sound.cpp
+++ b/sortix/sound.cpp
@@ -38,6 +38,8 @@ namespace Sortix
void Play(nat Frequency)
{
+ Log::PrintF("Playing frequency %u\n", Frequency);
+
//Set the PIT to the desired frequency
uint32_t Div = 1193180 / Frequency;
CPU::OutPortB(0x43, 0xB6);
@@ -52,6 +54,12 @@ namespace Sortix
CPU::OutPortB(0x61, TMP | 3);
}
}
+
+ void SysSetFrequency(CPU::InterruptRegisters* R)
+ {
+ unsigned frequency = R->ebx;
+ if ( frequency == 0 ) { Mute(); } else { Play(frequency); }
+ }
}
}
diff --git a/sortix/sound.h b/sortix/sound.h
index 9ffa8dd0..ec3815f2 100644
--- a/sortix/sound.h
+++ b/sortix/sound.h
@@ -31,6 +31,7 @@ namespace Sortix
{
void Mute();
void Play(nat Frequency);
+ void SysSetFrequency(CPU::InterruptRegisters* R);
}
}
diff --git a/sortix/syscall.cpp b/sortix/syscall.cpp
index 16d52be1..091edbf1 100644
--- a/sortix/syscall.cpp
+++ b/sortix/syscall.cpp
@@ -33,6 +33,7 @@
#include "panic.h"
#include "vga.h"
#include "keyboard.h"
+#include "sound.h"
namespace Sortix
{
@@ -49,7 +50,7 @@ namespace Sortix
#endif
}
- const size_t NumSyscalls = 9;
+ const size_t NumSyscalls = 10;
const Syscall Syscalls[NumSyscalls] =
{
&Scheduler::SysCreateThread,
@@ -61,6 +62,7 @@ namespace Sortix
&VGA::SysChangeFrame,
&VGA::SysDeleteFrame,
&Keyboard::SysReceieveKeystroke,
+ &Sound::SysSetFrequency,
};
void Init()