-/*++\r
-\r
-Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
- LegacyMetronome.c\r
-\r
-Abstract:\r
-\r
- This contains the installation function for the driver.\r
-\r
---*/\r
-\r
-#include "Metronome.h"\r
-\r
-//\r
-// Handle for the Metronome Architectural Protocol instance produced by this driver\r
-//\r
-EFI_HANDLE mMetronomeHandle = NULL;\r
-\r
-//\r
-// The Metronome Architectural Protocol instance produced by this driver\r
-//\r
-EFI_METRONOME_ARCH_PROTOCOL mMetronome = {\r
- WaitForTick,\r
- TICK_PERIOD\r
-};\r
-\r
-//\r
-// Worker Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-WaitForTick (\r
- IN EFI_METRONOME_ARCH_PROTOCOL *This,\r
- IN UINT32 TickNumber\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Waits for the TickNumber of ticks from a known platform time source.\r
-\r
-Arguments:\r
-\r
- This Pointer to the protocol instance.\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS If number of ticks occurred.\r
- EFI_NOT_FOUND Could not locate CPU IO protocol\r
-\r
---*/\r
-// TODO: TickNumber - add argument and description to function comment\r
-{\r
- //\r
- // Wait for TickNumber toggles of the Refresh bit\r
- //\r
- for (; TickNumber != 0x00; TickNumber--) {\r
- while ((IoRead8(REFRESH_PORT) & REFRESH_ON) == REFRESH_ON);\r
- while ((IoRead8(REFRESH_PORT) & REFRESH_ON) == REFRESH_OFF);\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InstallMetronome (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Install the LegacyMetronome driver. Loads a Metronome Arch Protocol based\r
- on the Port 61 timer.\r
-\r
-Arguments:\r
-\r
- (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Metronome Architectural Protocol Installed\r
-\r
---*/\r
-// TODO: ImageHandle - add argument and description to function comment\r
-// TODO: SystemTable - add argument and description to function comment\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Make sure the Metronome Architectural Protocol is not already installed in the system\r
- //\r
- ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiMetronomeArchProtocolGuid);\r
-\r
- //\r
- // Program port 61 timer 1 as refresh timer. We could use ACPI timer in the\r
- // future.\r
- //\r
- IoWrite8 (TIMER1_CONTROL_PORT, LOAD_COUNTER1_LSB);\r
- IoWrite8 (TIMER1_COUNT_PORT, COUNTER1_COUNT);\r
-\r
- //\r
- // Install on a new handle\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &mMetronomeHandle,\r
- &gEfiMetronomeArchProtocolGuid,\r
- &mMetronome,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return Status;\r
-}\r