3 Copyright (c) 2005, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 This contains the installation function for the driver.
21 #include "Metronome.h"
24 // Handle for the Metronome Architectural Protocol instance produced by this driver
26 EFI_HANDLE mMetronomeHandle
= NULL
;
29 // The Metronome Architectural Protocol instance produced by this driver
31 EFI_METRONOME_ARCH_PROTOCOL mMetronome
= {
37 // The CPU I/O Protocol used to access system hardware
39 EFI_CPU_IO_PROTOCOL
*mCpuIo
= NULL
;
53 Write an 8 bit value to an I/O port and save it to the S3 script
62 // TODO: Port - add argument and description to function comment
63 // TODO: Data - add argument and description to function comment
83 Read the refresh bit from the REFRESH_PORT
102 return (UINT8
) (Data
& REFRESH_ON
);
108 IN EFI_METRONOME_ARCH_PROTOCOL
*This
,
115 Waits for the TickNumber of ticks from a known platform time source.
119 This Pointer to the protocol instance.
123 EFI_SUCCESS If number of ticks occurred.
124 EFI_NOT_FOUND Could not locate CPU IO protocol
127 // TODO: TickNumber - add argument and description to function comment
130 // Wait for TickNumber toggles of the Refresh bit
132 for (; TickNumber
!= 0x00; TickNumber
--) {
133 while (ReadRefresh () == REFRESH_ON
)
135 while (ReadRefresh () == REFRESH_OFF
)
145 IN EFI_HANDLE ImageHandle
,
146 IN EFI_SYSTEM_TABLE
*SystemTable
152 Install the LegacyMetronome driver. Loads a Metronome Arch Protocol based
153 on the Port 61 timer.
157 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
161 EFI_SUCCESS - Metronome Architectural Protocol Installed
164 // TODO: ImageHandle - add argument and description to function comment
165 // TODO: SystemTable - add argument and description to function comment
170 // Make sure the Metronome Architectural Protocol is not already installed in the system
172 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiMetronomeArchProtocolGuid
);
175 // Get the CPU I/O Protocol that this driver requires
176 // If the CPU I/O Protocol is not found, then ASSERT because the dependency expression
177 // should guarantee that it is present in the handle database.
179 Status
= gBS
->LocateProtocol (&gEfiCpuIoProtocolGuid
, NULL
, &mCpuIo
);
180 ASSERT_EFI_ERROR (Status
);
183 // Program port 61 timer 1 as refresh timer. We could use ACPI timer in the
186 IoWrite8 (TIMER1_CONTROL_PORT
, LOAD_COUNTER1_LSB
);
187 IoWrite8 (TIMER1_COUNT_PORT
, COUNTER1_COUNT
);
190 // Install on a new handle
192 Status
= gBS
->InstallMultipleProtocolInterfaces (
194 &gEfiMetronomeArchProtocolGuid
,
198 ASSERT_EFI_ERROR (Status
);