]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/LegacyMetronome/Metronome.c
EDK II Packages: Add Contributions.txt and License.txt files
[mirror_edk2.git] / DuetPkg / LegacyMetronome / Metronome.c
CommitLineData
c69dd9df 1/*++\r
2\r
b1f700a8
HT
3Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
c69dd9df 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13 LegacyMetronome.c\r
14\r
15Abstract:\r
16\r
17 This contains the installation function for the driver.\r
18\r
19--*/\r
20\r
21#include "Metronome.h"\r
22\r
23//\r
24// Handle for the Metronome Architectural Protocol instance produced by this driver\r
25//\r
26EFI_HANDLE mMetronomeHandle = NULL;\r
27\r
28//\r
29// The Metronome Architectural Protocol instance produced by this driver\r
30//\r
31EFI_METRONOME_ARCH_PROTOCOL mMetronome = {\r
32 WaitForTick,\r
33 TICK_PERIOD\r
34};\r
35\r
c69dd9df 36//\r
37// Worker Functions\r
38//\r
c69dd9df 39EFI_STATUS\r
40EFIAPI\r
41WaitForTick (\r
42 IN EFI_METRONOME_ARCH_PROTOCOL *This,\r
43 IN UINT32 TickNumber\r
44 )\r
45/*++\r
46\r
47Routine Description:\r
48\r
49 Waits for the TickNumber of ticks from a known platform time source.\r
50\r
51Arguments:\r
52\r
53 This Pointer to the protocol instance.\r
54\r
55Returns: \r
56\r
57 EFI_SUCCESS If number of ticks occurred.\r
58 EFI_NOT_FOUND Could not locate CPU IO protocol\r
59\r
60--*/\r
61// TODO: TickNumber - add argument and description to function comment\r
62{\r
63 //\r
64 // Wait for TickNumber toggles of the Refresh bit\r
65 //\r
66 for (; TickNumber != 0x00; TickNumber--) {\r
0f25cc14 67 while ((IoRead8(REFRESH_PORT) & REFRESH_ON) == REFRESH_ON);\r
68 while ((IoRead8(REFRESH_PORT) & REFRESH_ON) == REFRESH_OFF);\r
c69dd9df 69 }\r
70\r
71 return EFI_SUCCESS;\r
72}\r
73\r
74EFI_STATUS\r
75EFIAPI\r
76InstallMetronome (\r
77 IN EFI_HANDLE ImageHandle,\r
78 IN EFI_SYSTEM_TABLE *SystemTable\r
79 )\r
80/*++\r
81\r
82Routine Description:\r
83 \r
84 Install the LegacyMetronome driver. Loads a Metronome Arch Protocol based\r
85 on the Port 61 timer.\r
86\r
87Arguments:\r
88\r
89 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
90\r
91Returns:\r
92\r
93 EFI_SUCCESS - Metronome Architectural Protocol Installed\r
94\r
95--*/\r
96// TODO: ImageHandle - add argument and description to function comment\r
97// TODO: SystemTable - add argument and description to function comment\r
98{\r
99 EFI_STATUS Status;\r
100\r
101 //\r
102 // Make sure the Metronome Architectural Protocol is not already installed in the system\r
103 //\r
104 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiMetronomeArchProtocolGuid);\r
105\r
c69dd9df 106 //\r
107 // Program port 61 timer 1 as refresh timer. We could use ACPI timer in the\r
108 // future.\r
109 //\r
110 IoWrite8 (TIMER1_CONTROL_PORT, LOAD_COUNTER1_LSB);\r
111 IoWrite8 (TIMER1_COUNT_PORT, COUNTER1_COUNT);\r
112\r
113 //\r
114 // Install on a new handle\r
115 //\r
116 Status = gBS->InstallMultipleProtocolInterfaces (\r
117 &mMetronomeHandle,\r
118 &gEfiMetronomeArchProtocolGuid,\r
119 &mMetronome,\r
120 NULL\r
121 );\r
122 ASSERT_EFI_ERROR (Status);\r
123\r
124 return Status;\r
125}\r