3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
16 This file implements PEIM for Legacy Speaker. This file is valid for platforms both
17 on IA32 and Itanium Product Family
21 #include "PlatformEarlyInit.h"
25 IN CONST EFI_PEI_SERVICES
**PeiServices
,
26 IN UINTN NumberOfBeep
,
27 IN UINTN BeepDuration
,
28 IN UINTN TimerInterval
32 This function will enable the speaker to generate beep
34 @param PeiServices PeiServices to locate PPI
41 IN CONST EFI_PEI_SERVICES
**PeiServices
45 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
47 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
52 This function will stop beep from speaker.
54 @param PeiServices PeiServices to locate PPI
61 IN CONST EFI_PEI_SERVICES
**PeiServices
66 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
68 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
75 IN CONST EFI_PEI_SERVICES
**PeiServices
,
76 IN UINTN NumberOfBeep
,
77 IN UINTN BeepDuration
,
82 EFI_PEI_STALL_PPI
* StallPpi
;
84 (**PeiServices
).LocatePpi (PeiServices
, &gEfiPeiStallPpiGuid
, 0, NULL
, (void **)&StallPpi
);
86 for (Num
=0; Num
< NumberOfBeep
; Num
++) {
87 TurnOnSpeaker (PeiServices
);
88 StallPpi
->Stall(PeiServices
, StallPpi
, BeepDuration
);
89 TurnOffSpeaker(PeiServices
);
90 StallPpi
->Stall(PeiServices
, StallPpi
, TimeInterval
);
97 This function will program the speaker tone frequency. The value should be with 64k
98 boundary since it takes only 16 bit value which gets programmed in two step IO opearattion
100 Frequency - A value which should be 16 bit only.
107 ProgramToneFrequency (
108 IN CONST EFI_PEI_SERVICES
**PeiServices
,
115 IoWrite8(EFI_TIMER_CONTROL_PORT
, Data
);
117 Data
= (UINT8
)(Frequency
& 0x00FF);
118 IoWrite8(EFI_TIMER_2_PORT
, Data
);
119 Data
= (UINT8
)((Frequency
& 0xFF00) >> 8);
120 IoWrite8(EFI_TIMER_2_PORT
, Data
);
125 This function will generate the beep for specified duration.
127 @param PeiServices PeiServices to locate various PPIs
128 @param NumberOfBeeps Number of beeps which user want to produce
129 @param BeepDuration Duration for speaker gate need to be enabled
130 @param TimeInterval Interval between each beep
138 IN CONST EFI_PEI_SERVICES
**PeiServices
,
139 IN UINTN NumberOfBeeps
,
140 IN UINTN BeepDuration
,
141 IN UINTN TimeInterval
145 if ((NumberOfBeeps
== 1) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
146 TurnOnSpeaker (PeiServices
);
150 if ((NumberOfBeeps
== 0) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
151 TurnOffSpeaker (PeiServices
);
155 if (BeepDuration
== 0) {
156 BeepDuration
= EFI_DEFAULT_SHORT_BEEP_DURATION
;
159 if (TimeInterval
== 0) {
160 TimeInterval
= EFI_DEFAULT_BEEP_TIME_INTERVAL
;
163 OutputBeep (PeiServices
, NumberOfBeeps
, BeepDuration
, TimeInterval
);