📄 syswdog.c
字号:
/* sysWdog.c - hardware watchdog driver */
/* Copyright 2002-2005 Founder Communications, Inc. */
/*
modification history
--------------------
01a,3feb05,fhchen written
*/
/*
DESCRIPTION
This file provides routines to control hardware watchdog on V100R001SCB
board. The internal watchdog of MPC8260 is not used currently, MAX706 is
used instead. MAX706 is connected to IRQ0 and PD12 of 8260.
A dedicated high priority task is spawned to feed the watchdog. To use
this module, simple call sysWdgStart, and all is going.
NOTE:
- machine check exception depend on the value of HID0[EMCP], MSR[ME],
RMR[CSRE].
- Be careful when using sysWdgDisable.
TODO:
- add PD12 initialization?
*/
#ifdef INCLUDE_EXTERNAL_WATCHDOG
/* defines */
#define INCLUDE_WDG_CONTROL
/* includes */
#include <vxWorks.h>
#include <taskLib.h>
#include "sysWdog.h"
#include "config.h"
#if defined(INCLUDE_WDG_CONTROL)
# include "arch/ppc/vxPpcLib.h"
# include "arch/ppc/archPpc.h"
#endif /* INCLUDE_WDG_CONTROL*/
/***********************************************************************
*
* sysWdgEnable - enable watchdog
*
* This routine enable the hardware watchdog. If enable/disable is not
* supported, it returns ERROR, and this can be safely ignored.
*
* RETURNS: OK, or ERROR if enable function not supported by hardware.
*/
STATUS sysWdgEnable(void)
{
#if defined(INCLUDE_WDG_CONTROL)
/* set HID0[EMCP]. It is a temp solution */
vxHid0Set(vxHid0Get() | _PPC_HID0_EMCP);
/* set MSR[ME] */
vxMsrSet(vxMsrGet() | _PPC_MSR_ME);
return (OK);
#else
return (ERROR);
#endif /* INCLUDE_WDG_CONTROL */
}
/***********************************************************************
*
* sysWdgDisable - disable watchdog
*
* This routine disable the hardware watchdog, if enable/disable is not
* supported, it returns ERROR, and this can be safely ignored.
*
* RETURNS: OK, or ERROR if disable function not supported by hardware.
*/
STATUS sysWdgDisable (void)
{
#if defined(INCLUDE_WDG_CONTROL)
/*
* clear HID0[EMCP]. if watchdog was disabled using sysWdgEnable,
* this routine will work.
*/
vxHid0Set(vxHid0Get() & ~_PPC_HID0_EMCP);
return (OK);
#else
return (ERROR);
#endif /* INCLUDE_WDG_CONTROL */
}
/***********************************************************************
*
* sysWdgStart - start hardware watchdog related facility
*
* This routine enable the watchdog and then start the feeder.
*
* NOTE:
* - Currently the feeder is a task.
*
* RETURNS: OK, or ERROR if taskSpawn failed.
*/
STATUS sysWdgStart(void)
{
/* enable the hardware watchdog */
sysWdgEnable();
/* start the feeder */
return (taskSpawn(WDG_TASK_NAME, WDG_TASK_PRIO, VX_UNBREAKABLE,
WDG_TASK_STACK_SIZE, (FUNCPTR)wdgTaskEntry,
WDG_TIMEOUT, 0,0,0,0,0,0,0,0, 0));
}
/***********************************************************************
*
* wdgTaskEntry - entry point for watchdog feeding task
*
* There are various ways to feeding hardware watchdog, using a dedicated
* task may be the best one.
*
* RETURNS: N/A
*/
void wdgTaskEntry
(
UINT32 interval /* the interval between feed actions */
)
{
/* check parameter */
UINT32 delay = (interval < WDG_TIMEOUT) ? (interval) : (WDG_TIMEOUT - 10);
for(;;)
{
/* feeding the watchdog */
sysWdgFeed();
/* sleep for a while */
taskDelay(delay);
}
}
#endif /* INCLUDE_EXTERNAL_WATCHDOG */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -