From 275be13b587638b8a31884ca4d93ae0d0e9132bb Mon Sep 17 00:00:00 2001 From: Rex Jolliff Date: Wed, 10 Mar 1999 06:39:59 +0000 Subject: [PATCH] Eric's beep driver and changes for same svn path=/trunk/; revision=286 --- reactos/include/ddk/ntddbeep.h | 15 +++++++ reactos/ntoskrnl/hal/x86/beep.c | 70 +++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 reactos/include/ddk/ntddbeep.h create mode 100644 reactos/ntoskrnl/hal/x86/beep.c diff --git a/reactos/include/ddk/ntddbeep.h b/reactos/include/ddk/ntddbeep.h new file mode 100644 index 00000000000..c73e8f601e9 --- /dev/null +++ b/reactos/include/ddk/ntddbeep.h @@ -0,0 +1,15 @@ +#ifndef _BEEP_H_INCLUDED_ +#define _BEEP_H_INCLUDED_ + +#define IOCTL_BEEP_SET CTL_CODE(FILE_DEVICE_BEEP,0,METHOD_BUFFERED,FILE_ANY_ACCESS) + +typedef struct tagBEEP_SET_PARAMETERS +{ + ULONG Frequency; + ULONG Duration; +} BEEP_SET_PARAMETERS, *PBEEP_SET_PARAMETERS; + +#define BEEP_FREQUENCY_MINIMUM 0x25 +#define BEEP_FREQUENCY_MAXIMUM 0x7FFF + +#endif /* _BEEP_H_INCLUDED_ */ diff --git a/reactos/ntoskrnl/hal/x86/beep.c b/reactos/ntoskrnl/hal/x86/beep.c new file mode 100644 index 00000000000..6aa9af703e0 --- /dev/null +++ b/reactos/ntoskrnl/hal/x86/beep.c @@ -0,0 +1,70 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/hal/x86/beep.c + * PURPOSE: Speaker function (it's only one) + * PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de) + * UPDATE HISTORY: + * Created 31/01/99 + */ + +/* INCLUDES *****************************************************************/ + +#include + +//#include +#include + +/* CONSTANTS *****************************************************************/ + +#define TIMER2 0x42 +#define TIMER3 0x43 +#define PORT_B 0x61 +#define CLOCKFREQ 1193167 + + +/* FUNCTIONS *****************************************************************/ +/* + * FUNCTION: Beeps the speaker. + * ARGUMENTS: + * Frequency = If 0, the speaker will be switched off, otherwise + * the speaker beeps with the specified frequency. + */ + +BOOLEAN +HalMakeBeep(ULONG Frequency) +{ + /* save flags and disable interrupts */ + __asm__("pushf\n\t" \ + "cli\n\t"); + + /* speaker off */ + outb_p(PORT_B, inb_p(PORT_B) & 0xFC); + + if (Frequency) + { + DWORD Divider = CLOCKFREQ / Frequency; + + if (Divider > 0x10000) + { + /* restore flags */ + __asm__("popf\n\t"); + + return FALSE; + } + + /* set timer divider */ + outb_p(TIMER3, 0xB6); + outb_p(TIMER2, (UCHAR)(Divider & 0xFF)); + outb_p(TIMER2, (UCHAR)((Divider>>8) & 0xFF)); + + /* speaker on */ + outb_p(PORT_B, inb_p(PORT_B) | 0x03); + } + + /* restore flags */ + __asm__("popf\n\t"); + + return TRUE; +} +