wdt.c revision 3c431bb5ee3cefe718333980f115132d63be0c60
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/hypervisor_api.h>
#include <sys/mach_descrip.h>
#define WDT_ON 1
#define WDT_OFF 0
/*
* MILLISEC defines the number of milliseconds in a second.
*/
#define WDT_MIN_COREAPI_MAJOR 1
#define WDT_MIN_COREAPI_MINOR 1
/*
* The ratio to calculate the watchdog timer pat interval.
*/
#define WDT_PAT_INTERVAL(x) ((x) / 2)
int watchdog_enabled = 1;
static void set_watchdog_pat_intervals(void);
static void config_watchdog(uint64_t, int);
/*
*/
static int watchdog_activated = WDT_OFF;
static uint64_t watchdog_long_timeout = 0;
static int64_t watchdog_long_pat_interval = 0;
static int64_t watchdog_regular_pat_interval = 0;
void
watchdog_init(void)
{
int num_nodes;
int nplat;
int listsz;
if (!watchdog_enabled) {
return;
}
major != WDT_MIN_COREAPI_MAJOR ||
"not available\n");
watchdog_enabled = 0;
return;
}
/*
* Get the watchdog-max-timeout and watchdog-resolution MD properties.
*/
"watchdog is disabled.");
watchdog_enabled = 0;
return;
}
&watchdog_max_timeout)) {
"is disabled.");
watchdog_enabled = 0;
(void) md_fini_handle(mdp);
return;
}
if (watchdog_max_timeout < WDT_REGULAR_TIMEOUT) {
"is disabled.");
watchdog_enabled = 0;
(void) md_fini_handle(mdp);
return;
}
&watchdog_resolution)) {
"is disabled.");
watchdog_enabled = 0;
(void) md_fini_handle(mdp);
return;
}
if (watchdog_resolution == 0 ||
}
(void) md_fini_handle(mdp);
/*
* round the timeout to the nearest smaller value.
*/
}
/*
* Pat the watchdog timer periodically, for regular pat in tod_get when
* the kernel runs normally and long pat in deadman when panicking.
*/
void
{
if (watchdog_enabled && watchdog_activated) {
if (panicstr) {
/*
* long timeout is only used while panicking.
*/
} else {
}
if ((current_lbolt64 - watchdog_last_pat)
>= last_pat_interval) {
/*
* Pat the watchdog via hv api:
*/
}
}
}
/*
*/
void
{
if (watchdog_enabled && watchdog_activated) {
config_watchdog(0, WDT_OFF);
}
}
/*
*/
void
{
if (watchdog_enabled && !watchdog_activated) {
if (panicstr) {
} else {
}
}
}
void
{
if (watchdog_enabled && watchdog_activated) {
config_watchdog(0, WDT_OFF);
}
}
/*
* Set the pat intervals for both regular (when Solaris is running),
* and long timeout (i.e., when panicking) cases.
*/
static void
{
}
static void
{
"Error = 0x%lx", ret);
watchdog_enabled = 0;
}
}