ReactOS 0.4.16-dev-306-g647d351
beep.c
Go to the documentation of this file.
1/*
2 * PROJECT: NEC PC-98 series HAL
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Speaker support (beeping)
5 * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6 */
7
8/* INCLUDES ******************************************************************/
9
10#include <hal.h>
11
12#define NDEBUG
13#include <debug.h>
14
15/* FUNCTIONS *****************************************************************/
16
21{
22 TIMER_CONTROL_PORT_REGISTER TimerControl;
23 ULONG Divider;
25
27
29
30 if (Frequency)
31 {
32 Divider = PIT_FREQUENCY / Frequency;
33
34 if (Divider <= 0x10000)
35 {
36 TimerControl.BcdMode = FALSE;
37 TimerControl.OperatingMode = PitOperatingMode3;
38 TimerControl.Channel = PitChannel1;
39 TimerControl.AccessMode = PitAccessModeLowHigh;
40 __outbyte(TIMER_CONTROL_PORT, TimerControl.Bits);
43
45
46 Success = TRUE;
47 }
48 }
49
51
52 return Success;
53}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ Success
Definition: eventcreate.c:712
BOOLEAN NTAPI HalMakeBeep(IN ULONG Frequency)
Definition: beep.c:22
VOID NTAPI HalpReleaseCmosSpinLock(VOID)
Definition: spinlock.c:243
VOID NTAPI HalpAcquireCmosSpinLock(VOID)
Definition: spinlock.c:226
#define PIT_FREQUENCY
Definition: halhw.h:61
@ PitChannel1
Definition: halhw.h:103
#define TIMER_CONTROL_PORT
Definition: halhw.h:70
@ PitAccessModeLowHigh
Definition: halhw.h:97
#define TIMER_CHANNEL1_DATA_PORT
Definition: halhw.h:68
@ PitOperatingMode3
Definition: halhw.h:85
PPC_QUAL void __outbyte(unsigned long const Port, const unsigned char Data)
Definition: intrin_ppc.h:605
#define _In_
Definition: no_sal2.h:158
static LARGE_INTEGER Frequency
Definition: clock.c:41
#define PPI_IO_o_CONTROL
Definition: sysport.h:12
#define PPI_TIMER_1_UNGATE_TO_SPEAKER
Definition: sysport.h:14
#define PPI_TIMER_1_GATE_TO_SPEAKER
Definition: sysport.h:13
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
#define SECONDBYTE(VALUE)
Definition: rtlfuncs.h:807
#define FIRSTBYTE(VALUE)
Definition: rtlfuncs.h:806