]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
4 | \r\r | |
5 | This program and the accompanying materials are licensed and made available under\r\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution. \r\r | |
7 | The full text of the license may be found at \r\r | |
8 | http://opensource.org/licenses/bsd-license.php. \r\r | |
9 | \r\r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r | |
12 | \r\r | |
13 | \r | |
14 | Module Name:\r | |
15 | \r | |
16 | \r | |
17 | LegacySpeaker.c\r | |
18 | \r | |
19 | Abstract:\r | |
20 | \r | |
21 | This file implements PEIM for Legacy Speaker. This file is valid for platforms both\r | |
22 | on IA32 and Itanium Product Family\r | |
23 | \r | |
24 | --*/\r | |
25 | \r | |
26 | #include "PlatformEarlyInit.h"\r | |
27 | \r | |
28 | EFI_STATUS\r | |
29 | OutputBeep (\r | |
30 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
31 | IN UINTN NumberOfBeep,\r | |
32 | IN UINTN BeepDuration,\r | |
33 | IN UINTN TimerInterval\r | |
34 | );\r | |
35 | \r | |
36 | /**\r | |
37 | This function will enable the speaker to generate beep\r | |
38 | \r | |
39 | @param PeiServices PeiServices to locate PPI\r | |
40 | \r | |
41 | @retval EFI_STATUS\r | |
42 | \r | |
43 | **/\r | |
44 | EFI_STATUS\r | |
45 | TurnOnSpeaker (\r | |
46 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
47 | )\r | |
48 | {\r | |
49 | UINT8 Data;\r | |
50 | Data = IoRead8 (EFI_SPEAKER_CONTROL_PORT);\r | |
51 | Data |= 0x03;\r | |
52 | IoWrite8(EFI_SPEAKER_CONTROL_PORT, Data);\r | |
53 | return EFI_SUCCESS;\r | |
54 | }\r | |
55 | \r | |
56 | /**\r | |
57 | This function will stop beep from speaker.\r | |
58 | \r | |
59 | @param PeiServices PeiServices to locate PPI\r | |
60 | \r | |
61 | @retval Status\r | |
62 | \r | |
63 | **/\r | |
64 | EFI_STATUS\r | |
65 | TurnOffSpeaker (\r | |
66 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
67 | )\r | |
68 | {\r | |
69 | UINT8 Data;\r | |
70 | \r | |
71 | Data = IoRead8 (EFI_SPEAKER_CONTROL_PORT);\r | |
72 | Data &= 0xFC;\r | |
73 | IoWrite8(EFI_SPEAKER_CONTROL_PORT, Data);\r | |
74 | return EFI_SUCCESS;\r | |
75 | }\r | |
76 | \r | |
77 | \r | |
78 | EFI_STATUS\r | |
79 | OutputBeep (\r | |
80 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
81 | IN UINTN NumberOfBeep,\r | |
82 | IN UINTN BeepDuration,\r | |
83 | IN UINTN TimeInterval\r | |
84 | )\r | |
85 | {\r | |
86 | UINTN Num;\r | |
87 | EFI_PEI_STALL_PPI* StallPpi;\r | |
88 | \r | |
89 | (**PeiServices).LocatePpi (PeiServices, &gEfiPeiStallPpiGuid, 0, NULL, (void **)&StallPpi);\r | |
90 | \r | |
91 | for (Num=0; Num < NumberOfBeep; Num++) {\r | |
92 | TurnOnSpeaker (PeiServices);\r | |
93 | StallPpi->Stall(PeiServices, StallPpi, BeepDuration);\r | |
94 | TurnOffSpeaker(PeiServices);\r | |
95 | StallPpi->Stall(PeiServices, StallPpi, TimeInterval);\r | |
96 | }\r | |
97 | \r | |
98 | return EFI_SUCCESS;\r | |
99 | }\r | |
100 | \r | |
101 | /**\r | |
102 | This function will program the speaker tone frequency. The value should be with 64k\r | |
103 | boundary since it takes only 16 bit value which gets programmed in two step IO opearattion\r | |
104 | \r | |
105 | Frequency - A value which should be 16 bit only.\r | |
106 | \r | |
107 | EFI_SUCESS\r | |
108 | \r | |
109 | **/\r | |
110 | EFI_STATUS\r | |
111 | EFIAPI\r | |
112 | ProgramToneFrequency (\r | |
113 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
114 | IN UINT16 Frequency\r | |
115 | )\r | |
116 | {\r | |
117 | UINT8 Data;\r | |
118 | \r | |
119 | Data = 0xB6;\r | |
120 | IoWrite8(EFI_TIMER_CONTROL_PORT, Data);\r | |
121 | \r | |
122 | Data = (UINT8)(Frequency & 0x00FF);\r | |
123 | IoWrite8(EFI_TIMER_2_PORT, Data);\r | |
124 | Data = (UINT8)((Frequency & 0xFF00) >> 8);\r | |
125 | IoWrite8(EFI_TIMER_2_PORT, Data);\r | |
126 | return EFI_SUCCESS;\r | |
127 | }\r | |
128 | \r | |
129 | /**\r | |
130 | This function will generate the beep for specified duration.\r | |
131 | \r | |
132 | @param PeiServices PeiServices to locate various PPIs\r | |
133 | @param NumberOfBeeps Number of beeps which user want to produce\r | |
134 | @param BeepDuration Duration for speaker gate need to be enabled\r | |
135 | @param TimeInterval Interval between each beep\r | |
136 | \r | |
137 | @retval EFI_STATUS\r | |
138 | \r | |
139 | **/\r | |
140 | EFI_STATUS\r | |
141 | EFIAPI\r | |
142 | GenerateBeepTone (\r | |
143 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
144 | IN UINTN NumberOfBeeps,\r | |
145 | IN UINTN BeepDuration,\r | |
146 | IN UINTN TimeInterval\r | |
147 | )\r | |
148 | {\r | |
149 | \r | |
150 | if ((NumberOfBeeps == 1) && (BeepDuration == 0) && (TimeInterval == 0)) {\r | |
151 | TurnOnSpeaker (PeiServices);\r | |
152 | return EFI_SUCCESS;\r | |
153 | }\r | |
154 | \r | |
155 | if ((NumberOfBeeps == 0) && (BeepDuration == 0) && (TimeInterval == 0)) {\r | |
156 | TurnOffSpeaker (PeiServices);\r | |
157 | return EFI_SUCCESS;\r | |
158 | }\r | |
159 | \r | |
160 | if (BeepDuration == 0) {\r | |
161 | BeepDuration = EFI_DEFAULT_SHORT_BEEP_DURATION;\r | |
162 | }\r | |
163 | \r | |
164 | if (TimeInterval == 0) {\r | |
165 | TimeInterval = EFI_DEFAULT_BEEP_TIME_INTERVAL;\r | |
166 | }\r | |
167 | \r | |
168 | OutputBeep (PeiServices, NumberOfBeeps, BeepDuration, TimeInterval);\r | |
169 | return EFI_SUCCESS;\r | |
170 | \r | |
171 | \r | |
172 | }\r | |
173 | \r |