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 contains the installation function for the driver.
25 #include "LegacyMetronome.h"
28 // Handle for the Metronome Architectural Protocol instance produced by this driver
30 EFI_HANDLE mMetronomeHandle
= NULL
;
33 // The Metronome Architectural Protocol instance produced by this driver
35 EFI_METRONOME_ARCH_PROTOCOL mMetronome
= {
41 // The CPU I/O Protocol used to access system hardware
43 EFI_CPU_IO_PROTOCOL
*mCpuIo
= NULL
;
50 Write an 8 bit value to an I/O port and save it to the S3 script
53 @param Data Data in IO Port
76 Read the refresh bit from the REFRESH_PORT
97 return (UINT8
) (Data
& REFRESH_ON
);
102 Waits for the TickNumber of ticks from a known platform time source.
104 @param This Pointer to the protocol instance.
105 @param TickNumber Tick Number to be waited
108 @retval EFI_SUCCESS If number of ticks occurred.
109 @retval EFI_NOT_FOUND Could not locate CPU IO protocol
115 IN EFI_METRONOME_ARCH_PROTOCOL
*This
,
120 // Wait for TickNumber toggles of the Refresh bit
122 for (; TickNumber
!= 0x00; TickNumber
--) {
123 while (ReadRefresh () == REFRESH_ON
)
125 while (ReadRefresh () == REFRESH_OFF
)
133 // Driver Entry Point
136 Install the LegacyMetronome driver. Loads a Metronome Arch Protocol based
137 on the Port 61 timer.
139 @param ImageHandle Handle for the image of this driver
140 @param SystemTable Pointer to the EFI System Table
142 @retval EFI_SUCCESS Metronome Architectural Protocol Installed
147 InstallLegacyMetronome (
148 IN EFI_HANDLE ImageHandle
,
149 IN EFI_SYSTEM_TABLE
*SystemTable
155 // Make sure the Metronome Architectural Protocol is not already installed in the system
157 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiMetronomeArchProtocolGuid
);
160 // Get the CPU I/O Protocol that this driver requires
161 // If the CPU I/O Protocol is not found, then ASSERT because the dependency expression
162 // should guarantee that it is present in the handle database.
164 Status
= gBS
->LocateProtocol (
165 &gEfiCpuIoProtocolGuid
,
169 ASSERT_EFI_ERROR (Status
);
172 // Program port 61 timer 1 as refresh timer. We could use ACPI timer in the
175 ScriptWriteIo8 (TIMER1_CONTROL_PORT
, LOAD_COUNTER1_LSB
);
176 ScriptWriteIo8 (TIMER1_COUNT_PORT
, COUNTER1_COUNT
);
179 // Install on a new handle
181 Status
= gBS
->InstallMultipleProtocolInterfaces (
183 &gEfiMetronomeArchProtocolGuid
,
187 ASSERT_EFI_ERROR (Status
);