3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 This file implements PEIM for Legacy Speaker. This file is valid for platforms both
22 on IA32 and Itanium Product Family
26 #include "PlatformEarlyInit.h"
30 IN CONST EFI_PEI_SERVICES
**PeiServices
,
31 IN UINTN NumberOfBeep
,
32 IN UINTN BeepDuration
,
33 IN UINTN TimerInterval
37 This function will enable the speaker to generate beep
39 @param PeiServices PeiServices to locate PPI
46 IN CONST EFI_PEI_SERVICES
**PeiServices
50 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
52 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
57 This function will stop beep from speaker.
59 @param PeiServices PeiServices to locate PPI
66 IN CONST EFI_PEI_SERVICES
**PeiServices
71 Data
= IoRead8 (EFI_SPEAKER_CONTROL_PORT
);
73 IoWrite8(EFI_SPEAKER_CONTROL_PORT
, Data
);
80 IN CONST EFI_PEI_SERVICES
**PeiServices
,
81 IN UINTN NumberOfBeep
,
82 IN UINTN BeepDuration
,
87 EFI_PEI_STALL_PPI
* StallPpi
;
89 (**PeiServices
).LocatePpi (PeiServices
, &gEfiPeiStallPpiGuid
, 0, NULL
, (void **)&StallPpi
);
91 for (Num
=0; Num
< NumberOfBeep
; Num
++) {
92 TurnOnSpeaker (PeiServices
);
93 StallPpi
->Stall(PeiServices
, StallPpi
, BeepDuration
);
94 TurnOffSpeaker(PeiServices
);
95 StallPpi
->Stall(PeiServices
, StallPpi
, TimeInterval
);
102 This function will program the speaker tone frequency. The value should be with 64k
103 boundary since it takes only 16 bit value which gets programmed in two step IO opearattion
105 Frequency - A value which should be 16 bit only.
112 ProgramToneFrequency (
113 IN CONST EFI_PEI_SERVICES
**PeiServices
,
120 IoWrite8(EFI_TIMER_CONTROL_PORT
, Data
);
122 Data
= (UINT8
)(Frequency
& 0x00FF);
123 IoWrite8(EFI_TIMER_2_PORT
, Data
);
124 Data
= (UINT8
)((Frequency
& 0xFF00) >> 8);
125 IoWrite8(EFI_TIMER_2_PORT
, Data
);
130 This function will generate the beep for specified duration.
132 @param PeiServices PeiServices to locate various PPIs
133 @param NumberOfBeeps Number of beeps which user want to produce
134 @param BeepDuration Duration for speaker gate need to be enabled
135 @param TimeInterval Interval between each beep
143 IN CONST EFI_PEI_SERVICES
**PeiServices
,
144 IN UINTN NumberOfBeeps
,
145 IN UINTN BeepDuration
,
146 IN UINTN TimeInterval
150 if ((NumberOfBeeps
== 1) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
151 TurnOnSpeaker (PeiServices
);
155 if ((NumberOfBeeps
== 0) && (BeepDuration
== 0) && (TimeInterval
== 0)) {
156 TurnOffSpeaker (PeiServices
);
160 if (BeepDuration
== 0) {
161 BeepDuration
= EFI_DEFAULT_SHORT_BEEP_DURATION
;
164 if (TimeInterval
== 0) {
165 TimeInterval
= EFI_DEFAULT_BEEP_TIME_INTERVAL
;
168 OutputBeep (PeiServices
, NumberOfBeeps
, BeepDuration
, TimeInterval
);