3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
16 This contains the installation function for the driver.
20 #include "LegacyMetronome.h"
23 // Handle for the Metronome Architectural Protocol instance produced by this driver
25 EFI_HANDLE mMetronomeHandle
= NULL
;
28 // The Metronome Architectural Protocol instance produced by this driver
30 EFI_METRONOME_ARCH_PROTOCOL mMetronome
= {
36 // The CPU I/O Protocol used to access system hardware
38 EFI_CPU_IO_PROTOCOL
*mCpuIo
= NULL
;
45 Write an 8 bit value to an I/O port and save it to the S3 script
48 @param Data Data in IO Port
71 Read the refresh bit from the REFRESH_PORT
92 return (UINT8
) (Data
& REFRESH_ON
);
97 Waits for the TickNumber of ticks from a known platform time source.
99 @param This Pointer to the protocol instance.
100 @param TickNumber Tick Number to be waited
103 @retval EFI_SUCCESS If number of ticks occurred.
104 @retval EFI_NOT_FOUND Could not locate CPU IO protocol
110 IN EFI_METRONOME_ARCH_PROTOCOL
*This
,
115 // Wait for TickNumber toggles of the Refresh bit
117 for (; TickNumber
!= 0x00; TickNumber
--) {
118 while (ReadRefresh () == REFRESH_ON
)
120 while (ReadRefresh () == REFRESH_OFF
)
128 // Driver Entry Point
131 Install the LegacyMetronome driver. Loads a Metronome Arch Protocol based
132 on the Port 61 timer.
134 @param ImageHandle Handle for the image of this driver
135 @param SystemTable Pointer to the EFI System Table
137 @retval EFI_SUCCESS Metronome Architectural Protocol Installed
142 InstallLegacyMetronome (
143 IN EFI_HANDLE ImageHandle
,
144 IN EFI_SYSTEM_TABLE
*SystemTable
150 // Make sure the Metronome Architectural Protocol is not already installed in the system
152 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiMetronomeArchProtocolGuid
);
155 // Get the CPU I/O Protocol that this driver requires
156 // If the CPU I/O Protocol is not found, then ASSERT because the dependency expression
157 // should guarantee that it is present in the handle database.
159 Status
= gBS
->LocateProtocol (
160 &gEfiCpuIoProtocolGuid
,
164 ASSERT_EFI_ERROR (Status
);
167 // Program port 61 timer 1 as refresh timer. We could use ACPI timer in the
170 ScriptWriteIo8 (TIMER1_CONTROL_PORT
, LOAD_COUNTER1_LSB
);
171 ScriptWriteIo8 (TIMER1_COUNT_PORT
, COUNTER1_COUNT
);
174 // Install on a new handle
176 Status
= gBS
->InstallMultipleProtocolInterfaces (
178 &gEfiMetronomeArchProtocolGuid
,
182 ASSERT_EFI_ERROR (Status
);