-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+/** @file\r
+ Implementation of Watchdog Timer Architectural Protocol using UEFI APIs.\r
+ \r
+Copyright (c) 2006 - 2010, 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
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
-\r
- WatchdogTimer.c\r
-\r
-Abstract:\r
-\r
- Generic watchdog timer implemenetation using EFI APIs\r
-\r
-Revision History\r
-\r
---*/\r
+**/\r
\r
#include "WatchdogTimer.h"\r
\r
//\r
// Handle for the Watchdog Timer Architectural Protocol instance produced by this driver\r
//\r
-EFI_HANDLE mWatchdogTimerHandle = NULL;\r
+EFI_HANDLE mWatchdogTimerHandle = NULL;\r
\r
//\r
// The Watchdog Timer Architectural Protocol instance produced by this driver\r
};\r
\r
//\r
-// The watchdog timer period in 100 nS units\r
+// The watchdog timer period in 100 ns units\r
//\r
-UINT64 mWatchdogTimerPeriod = 0;\r
+UINT64 mWatchdogTimerPeriod = 0;\r
\r
//\r
// The notification function to call if the watchdig timer fires\r
//\r
-EFI_WATCHDOG_TIMER_NOTIFY mWatchdogTimerNotifyFunction = NULL;\r
+EFI_WATCHDOG_TIMER_NOTIFY mWatchdogTimerNotifyFunction = NULL;\r
\r
//\r
// The one-shot timer event that is armed when the watchdog timer is enabled\r
//\r
-EFI_EVENT mWatchdogTimerEvent;\r
+EFI_EVENT mWatchdogTimerEvent;\r
\r
-//\r
-// Worker Functions\r
-//\r
-STATIC\r
+\r
+/**\r
+ Notification function that is called if the watchdog timer is fired.\r
+\r
+ Notification function for the one-shot timer event that was signaled\r
+ when the watchdog timer expired. If a handler has been registered with\r
+ the Watchdog Timer Architectural Protocol, then that handler is called\r
+ passing in the time period that has passed that cause the watchdog timer\r
+ to fire. Then, a call to the Runtime Service ResetSystem() is made to\r
+ reset the platform.\r
+\r
+ @param Timer The one-shot timer event that was signaled when the\r
+ watchdog timer expired.\r
+ @param Context The context that was registered when the event Timer was created.\r
+\r
+**/\r
VOID\r
EFIAPI\r
WatchdogTimerDriverExpires (\r
IN EFI_EVENT Timer,\r
IN VOID *Context\r
)\r
-/*++\r
-\r
- Routine Description:\r
-\r
- Notification function that is called if the watchdog timer is fired. If a\r
- handler has been registered with the Watchdog Timer Architectural Protocol,\r
- then that handler is called passing in the time period that has passed that\r
- cause the watchdog timer to fire. Then, a call to the Runtime Service\r
- ResetSystem() is made to reset the platform.\r
-\r
- Arguments:\r
-\r
- Timer - The one-shot timer event that was signaled when the watchdog timer\r
- expired.\r
-\r
- Context - The context that was registered when the event Timer was created.\r
-\r
- Returns:\r
-\r
- None.\r
-\r
---*/\r
{\r
- REPORT_STATUS_CODE (EFI_ERROR_CODE | EFI_ERROR_MINOR, PcdGet32 (PcdStatusCodeValueEfiWatchDogTimerExpired));\r
+ REPORT_STATUS_CODE (EFI_ERROR_CODE | EFI_ERROR_MINOR, (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_TIMER_EXPIRED));\r
\r
//\r
// If a notification function has been registered, then call it\r
if (mWatchdogTimerNotifyFunction != NULL) {\r
mWatchdogTimerNotifyFunction (mWatchdogTimerPeriod);\r
}\r
+ \r
+ DEBUG ((EFI_D_ERROR, "Watchdog Timer reseting system\n"));\r
+\r
//\r
// Reset the platform\r
//\r
}\r
\r
\r
-EFI_STATUS\r
-EFIAPI\r
-WatchdogTimerDriverRegisterHandler (\r
- IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,\r
- IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
+ Registers a handler that is to be invoked when the watchdog timer fires.\r
\r
This function registers a handler that is to be invoked when the watchdog\r
timer fires. By default, the EFI_WATCHDOG_TIMER protocol will call the\r
If an attempt is made to uninstall a handler when a handler is not installed,\r
then return EFI_INVALID_PARAMETER.\r
\r
-Arguments:\r
-\r
- This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+ @param This The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+ @param NotifyFunction The function to call when the watchdog timer fires. If this\r
+ is NULL, then the handler will be unregistered.\r
\r
- NotifyFunction - The function to call when the watchdog timer fires. If this\r
- is NULL, then the handler will be unregistered.\r
+ @retval EFI_SUCCESS The watchdog timer handler was registered or unregistered.\r
+ @retval EFI_ALREADY_STARTED NotifyFunction is not NULL, and a handler is already registered.\r
+ @retval EFI_INVALID_PARAMETER NotifyFunction is NULL, and a handler was not previously registered.\r
\r
-Returns:\r
-\r
- EFI_SUCCESS - The watchdog timer handler was registered or\r
- unregistered.\r
-\r
- EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already\r
- registered.\r
-\r
- EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not\r
- previously registered.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+WatchdogTimerDriverRegisterHandler (\r
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,\r
+ IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction\r
+ )\r
{\r
+ //\r
+ // If NotifyFunction is NULL, and a handler was not previously registered,\r
+ // return EFI_INVALID_PARAMETER.\r
+ //\r
if (NotifyFunction == NULL && mWatchdogTimerNotifyFunction == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
-\r
+ //\r
+ // If NotifyFunction is not NULL, and a handler is already registered,\r
+ // return EFI_ALREADY_STARTED.\r
+ //\r
if (NotifyFunction != NULL && mWatchdogTimerNotifyFunction != NULL) {\r
return EFI_ALREADY_STARTED;\r
}\r
return EFI_SUCCESS;\r
}\r
\r
-EFI_STATUS\r
-EFIAPI\r
-WatchdogTimerDriverSetTimerPeriod (\r
- IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,\r
- IN UINT64 TimerPeriod\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
+ Sets the amount of time in the future to fire the watchdog timer.\r
\r
This function sets the amount of time to wait before firing the watchdog\r
- timer to TimerPeriod 100 nS units. If TimerPeriod is 0, then the watchdog\r
+ timer to TimerPeriod 100 ns units. If TimerPeriod is 0, then the watchdog\r
timer is disabled.\r
\r
-Arguments:\r
-\r
- This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+ @param This The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+ @param TimerPeriod The amount of time in 100 ns units to wait before the watchdog\r
+ timer is fired. If TimerPeriod is zero, then the watchdog\r
+ timer is disabled.\r
\r
- TimerPeriod - The amount of time in 100 nS units to wait before the watchdog\r
- timer is fired. If TimerPeriod is zero, then the watchdog\r
- timer is disabled.\r
+ @retval EFI_SUCCESS The watchdog timer has been programmed to fire in Time\r
+ 100 ns units.\r
+ @retval EFI_DEVICE_ERROR A watchdog timer could not be programmed due to a device\r
+ error.\r
\r
-Returns:\r
-\r
- EFI_SUCCESS - The watchdog timer has been programmed to fire in Time\r
- 100 nS units.\r
-\r
- EFI_DEVICE_ERROR - A watchdog timer could not be programmed due to a device\r
- error.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+WatchdogTimerDriverSetTimerPeriod (\r
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,\r
+ IN UINT64 TimerPeriod\r
+ )\r
{\r
mWatchdogTimerPeriod = TimerPeriod;\r
\r
);\r
}\r
\r
-EFI_STATUS\r
-EFIAPI\r
-WatchdogTimerDriverGetTimerPeriod (\r
- IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,\r
- IN UINT64 *TimerPeriod\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
+ Retrieves the amount of time in 100 ns units that the system will wait before firing the watchdog timer.\r
\r
This function retrieves the amount of time the system will wait before firing\r
the watchdog timer. This period is returned in TimerPeriod, and EFI_SUCCESS\r
is returned. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned.\r
\r
-Arguments:\r
-\r
- This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+ @param This The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+ @param TimerPeriod A pointer to the amount of time in 100 ns units that the system\r
+ will wait before the watchdog timer is fired. If TimerPeriod of\r
+ zero is returned, then the watchdog timer is disabled.\r
\r
- TimerPeriod - A pointer to the amount of time in 100 nS units that the system\r
- will wait before the watchdog timer is fired. If TimerPeriod of\r
- zero is returned, then the watchdog timer is disabled.\r
+ @retval EFI_SUCCESS The amount of time that the system will wait before\r
+ firing the watchdog timer was returned in TimerPeriod.\r
+ @retval EFI_INVALID_PARAMETER TimerPeriod is NULL.\r
\r
-Returns:\r
-\r
- EFI_SUCCESS - The amount of time that the system will wait before\r
- firing the watchdog timer was returned in TimerPeriod.\r
-\r
- EFI_INVALID_PARAMETER - TimerPeriod is NULL.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+WatchdogTimerDriverGetTimerPeriod (\r
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,\r
+ IN UINT64 *TimerPeriod\r
+ )\r
{\r
if (TimerPeriod == NULL) {\r
return EFI_INVALID_PARAMETER;\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Entry point of the Watchdog Timer Architectural Protocol driver.\r
+\r
+ @param ImageHandle The image handle of this driver.\r
+ @param SystemTable The pointer of EFI_SYSTEM_TABLE.\r
+\r
+ @retval EFI_SUCCESS Watchdog Timer Architectural Protocol successfully installed.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
WatchdogTimerDriverInitialize (\r
IN EFI_HANDLE ImageHandle,\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Initialize the Watchdog Timer Architectural Protocol driver\r
-\r
-Arguments:\r
-\r
- ImageHandle - ImageHandle of the loaded driver\r
-\r
- SystemTable - Pointer to the System Table\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Timer Architectural Protocol created\r
-\r
- EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver.\r
-\r
- EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver.\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
\r
//\r
- // Make sure the Watchdog Timer Architectural Protocol is not already installed in the system\r
+ // Make sure the Watchdog Timer Architectural Protocol has not been installed in the system yet.\r
//\r
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiWatchdogTimerArchProtocolGuid);\r
\r
//\r
- // Create the timer event used to implement a simple watchdog timer\r
+ // Create the timer event to implement a simple watchdog timer\r
//\r
Status = gBS->CreateEvent (\r
EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
- return Status;\r
+ return EFI_SUCCESS;\r
}\r