2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/hal/x86/beep.c
5 * PURPOSE: Speaker function (it's only one)
6 * PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
16 #include <internal/debug.h>
19 /* CONSTANTS *****************************************************************/
24 #define CLOCKFREQ 1193167
27 /* FUNCTIONS *****************************************************************/
29 * FUNCTION: Beeps the speaker.
31 * Frequency = If 0, the speaker will be switched off, otherwise
32 * the speaker beeps with the specified frequency.
43 /* save flags and disable interrupts */
48 b = READ_PORT_UCHAR((PUCHAR)PORT_B);
49 WRITE_PORT_UCHAR((PUCHAR)PORT_B, b & 0xFC);
53 DWORD Divider = CLOCKFREQ / Frequency;
55 if (Divider > 0x10000)
63 /* set timer divider */
64 WRITE_PORT_UCHAR((PUCHAR)TIMER3, 0xB6);
65 WRITE_PORT_UCHAR((PUCHAR)TIMER2, (UCHAR)(Divider & 0xFF));
66 WRITE_PORT_UCHAR((PUCHAR)TIMER2, (UCHAR)((Divider>>8) & 0xFF));
69 WRITE_PORT_UCHAR((PUCHAR)PORT_B, READ_PORT_UCHAR((PUCHAR)PORT_B) | 0x03);