linux/drivers/watchdog/indydog.c
<<
>>
Prefs
   1/*
   2 *      IndyDog 0.3     A Hardware Watchdog Device for SGI IP22
   3 *
   4 *      (c) Copyright 2002 Guido Guenther <agx@sigxcpu.org>,
   5 *                                              All Rights Reserved.
   6 *
   7 *      This program is free software; you can redistribute it and/or
   8 *      modify it under the terms of the GNU General Public License
   9 *      as published by the Free Software Foundation; either version
  10 *      2 of the License, or (at your option) any later version.
  11 *
  12 *      based on softdog.c by Alan Cox <alan@lxorguk.ukuu.org.uk>
  13 */
  14
  15#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  16
  17#include <linux/module.h>
  18#include <linux/moduleparam.h>
  19#include <linux/types.h>
  20#include <linux/kernel.h>
  21#include <linux/fs.h>
  22#include <linux/mm.h>
  23#include <linux/miscdevice.h>
  24#include <linux/watchdog.h>
  25#include <linux/notifier.h>
  26#include <linux/reboot.h>
  27#include <linux/init.h>
  28#include <linux/uaccess.h>
  29#include <asm/sgi/mc.h>
  30
  31static unsigned long indydog_alive;
  32static DEFINE_SPINLOCK(indydog_lock);
  33
  34#define WATCHDOG_TIMEOUT 30             /* 30 sec default timeout */
  35
  36static bool nowayout = WATCHDOG_NOWAYOUT;
  37module_param(nowayout, bool, 0);
  38MODULE_PARM_DESC(nowayout,
  39                "Watchdog cannot be stopped once started (default="
  40                                __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
  41
  42static void indydog_start(void)
  43{
  44        u32 mc_ctrl0;
  45
  46        spin_lock(&indydog_lock);
  47        mc_ctrl0 = sgimc->cpuctrl0;
  48        mc_ctrl0 = sgimc->cpuctrl0 | SGIMC_CCTRL0_WDOG;
  49        sgimc->cpuctrl0 = mc_ctrl0;
  50        spin_unlock(&indydog_lock);
  51}
  52
  53static void indydog_stop(void)
  54{
  55        u32 mc_ctrl0;
  56
  57        spin_lock(&indydog_lock);
  58
  59        mc_ctrl0 = sgimc->cpuctrl0;
  60        mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG;
  61        sgimc->cpuctrl0 = mc_ctrl0;
  62        spin_unlock(&indydog_lock);
  63
  64        pr_info("Stopped watchdog timer\n");
  65}
  66
  67static void indydog_ping(void)
  68{
  69        sgimc->watchdogt = 0;
  70}
  71
  72/*
  73 *      Allow only one person to hold it open
  74 */
  75static int indydog_open(struct inode *inodemastruct   7676   777       watchdtest_and_set_bistruct0, a href="+code=indydog_lock"  class="sref">indydog_alive;
  787       indydoEBUSY  7979a href="drivers/watchdog/indydog.c#L72" id8"L70" cl8ss="line" name="L70">  8080      nowayout,
  8181      __MODULE_param__MODUTHISE_STRIN
  828  8383      /* 30 secActivate\n&quopan>
  848       indydog_start(void)
href="drivers/watchdog/indydog.c#L63" id8"L75" cl8ss="line" name="L75">  858       indydog_ping(void)
href="drivers/watchdog/indydog.c#L63" id8"L66" cl8ss="line" name="L66">  868   878       pr_info("Stopped (defauog timer\n");
   888  898       indydoutnseekabaminodemastructf="+code=inode""drivers/watchfilf="dri  909
  919  929tatic void < href="+code=indydog_open" releasss="sref">indydog_aliveinode *inodemastruct   939
  9494      /* 30 secShu
  959span class="comment"> *             * Locken) pan>
  9696      nowayout,
   9797      indydog_stop(void)
);eeeeeeeeeflass="comment">/* 30 secTlse;censWDT/sfLian>
   989       watchdclear_bistruct0, a href="+code=indydog_lock"  class="sref">indydog_alive;
   999         100  101  102watchdssize_sa href="+code=mc_ctrg_aliveindydog_alive  103watchdsize_sa href="+code=mc_ctrlass="sref">indydolasa hrctf="+code=inode"lsfL_ss="sref">watchdlsfL_swatchdppos  104  105/* 30 secRefreshicensn&quonpan>
  106indydolasa hrref="drivers/watchdog/indydog.c#L68" id10"L17" cla0ss="line" name="L17">  107indydog_ping(void)
href="drivers/watchdog/indydog.c#L63" id10"L18" cla0ss="line" name="L18">  108indydolasa hrref="drivers/watchdog/indydog.c#L63" id10"L19" cla0ss="line" name="L19">  109  110  111boolwatchdcmd  112indydoarsa hrref="drivers/watchdog/indydog.c#L68" id1="L13" claass="line" name="L13">  113  114watchd) any sa hrctf="+code=inode" favass="sref">boolindydoEINVALa hrref="drivers/watchdog/indydog.c#L63" id1="L15" claass="line" name="L15">  115pr_infog/indyd clasa href="+code=mc_ctrgd* 30="sref">bool  116watchd) any sa hr  __MODUODIOF_KEEPALIVEPlas  117  118bool")"re Watchdog DeviceI IP22);
  119  120  121watchdcmd  122WATCHDODIOC_GETSUPPORs    :ef="drivers/watchdog/indydog.c#L44" id12"L13" claass="line" name="L23">  123watchdcopy_to_user) any2 pr_infog/indyd culaarivd1="L20" cl1ass="line" name="L20">  120  112watchdclear_bistrd clasa href="+code=mc_ctrgd, DEFIof>indydoutnseekabad clasa href="+code=mc_ctrgd)ef">indydog_alive;
  1127       indydoEINVALa hrref="drivers//watchdog1/indydog.c#L26" id="L26"1 clas12line" name="L16">  11L9">   999         122WATCHDODIOC_GETSUPPORs    :ef="drivers/watchdog/i/indydog.c#L28" id="L28"1 clas128ine" name="L12">  122WATCHDODIOC_GETSUPPORs    :ef="drivers/watchdog/i/indydog.c#L29" id="L29"1 clas12"line" name="L39">  318">  108f">pr_infog/indyd culaarivd1="L20" cl1ass=ef">indydog_ping(void)
href="drivers//watchdog1/indydog.c#L30" id="L30"1 clas130ine" name="L12">  122WATCHDODIOC_GETSUPPORs    :ef="drivers//watchdog1/indydog.c#L31" id="L31"1 clas13line" name="Lcmds="sref">watchdcmd  113indydoutnseekab  f">pr_infog/indyd culaarivd1="L20" cl1ass=ef">indydog_alive;
  1037       indydoEINVALa hrref="drivers//watchdog1/indydog.c#L34" id="L34"1 clas134ine" name="L12">  113w  122watchdcmd  11297      watchdcmd  11297      9         11 name="L19">  109  113w  122watchdcmd  3297      indydog_start(void)
href="drivers1/watchdog1/indydog.c#L40" id="L40"1 clas1="line" name="L40">  40   797      9         8 name="L19">  109  1118">  1089         109  122WATCHDODIOC_GETSUPPORs    :ef="drivers//watchdog1/indydog.c#L45" id="L45"1 clas145ine" name="L12">  117indydog_ping(void)
href="drivers//watchdog1/indydog.c#L46" id="L46"1 clas14line" name="L16">  11L9">   999         122WATCHDODIOC_GETSUPPORs    :ef="drivers//watchdog1/indydog.c#L48" id="L48"1 clas14"line" name="L68">  787 08f">pr_infog/indyd culaarivd1="L20" cl1ass=ef">indydog_ping(void)
href="drivers//watchdog1/indydog.c#L49" id="L49"1 clas1="line" name="topped >WATCHDODIOC_GETSUPPORs    :ef="drivers//watchdog1/indydog.c#L50" id="L50"1 clas15"line" name="L40">  487         109  109  63
  929tatic void <" clay_syeeeee.f="+code=ic void <" clay_sye="sref">bool  120  112 *indydoarsa hrref="drivers//watchdog1/indydog.c#L56" id="L56"1 clas15"line" name="L66">  7676   777     ca> *cpuctrl0 *indydoarsa hrref="drivers//watchdog1/indydog.c#L58" id="L58"1 clas15"line" name="L68">  7797        77stop(void)
);eeeeeeeeeflass="comment">/* 30 secTlse;censWDT/sfLian>
  7979a href="drivers1/watchdog1/indydog.c#L60" id="L60"1 clas1="line" name="87 089         51}
  828pr_infog/indy_stop" fopeeeee.f="+code=ic void bool  120  120  120  120  120  1209         71
pr_infog/indy_stop" " class+code=indydog_open" rel" classtrgd* 30="sref">bool  120watchdclear_bistruct0, afopeeeee.f="+code=ic void );
9         929tatic void <" clai ef="+code=mc_ctrc void <" clai etrgd* 30="sref">bool9         71
  929tati__" cleeee.f="+code=i__" clode""">  929tatig/indyd clacleeee.f="+code=ig/indyd clacls="sref">indydog_ping(void)
  113  1149         45
  46  reef="+code=__MODUrlue="s* 3  111watchdclear_bistruct0, a" clai ef="+code=mc_ctrc void <" clai etrgdef">indydog_ping(void)
href="drivers//watchdog1/indydog.c#L67" id8"L7" 1cla8s18"line" name="L7">   777     reef="+code=__MODUrlue="strcmds="sref">watchdcmd  7797      ®ists= " clas " clai e (ere=%d)topped (defauogss="sref">watchd) anf="+code=__MODUrlue="stf">indydog_ping(void)
href="drivers//watchdog1/indydog.c#L59" id8"L69"1 cl8s18"line" name="L39">  318">  1089         51}
  919  62  reef="+code=__MODUrlue="s* 3  111watchdclear_bistruct0, a" class+code=indydog_open" rel" classtrgdtf">indydog_ping(void)
href="drivers//watchdog1/indydog.c#L68" id9"L73"1 cl9s193line" name="L7">   777     reef="+code=__MODUrlue="strcmds="sref">watchdcmd  11797      ®ists= " classommeminoe=%d (ere=%d)topped (defauogsmds="sref">watchdcmd  112watchd) anf="+code=__MODUrlue="stf">indydog_ping(void)
href="drivers//watchdog1/indydog.c#L75" id9"L66"1 cl9s19line" name="L16">  11watchdclear_bistruct0, a" clai ef="+code=mc_ctrc void <" clai etrgdef">indydog_ping(void)
href="drivers//watchdog1/indydog.c#L68" id9"L7" 1cla9s1="line" name="L7">   918">  1089         51}
  7979a href="drivers2watchdog/2ndydog.c#L70" id10"L10" 2lasss20"line" name="L60">  60        pr_info(&quTommenot;)"re : 0.3topped (defauog timer\n");
  101   999         51}
  14
  67static__excleeee.f="+code=i__exclode""">  929tatig/indyd cexcleeee.f="+code=ig/indyd cexcls="sref">indydog_ping(void)
  7676  47    cl_deregists=+code=indydog_o" cl_deregists=s="sref">watchdclear_bistruct0, a" class+code=indydog_open" rel" classtrgdtf">indydog_ping(void)
href="drivers2watchdog/2ndydog.c#L63" id10"L18" 2la0ss20"line" name="L8">   989 k"regists=_" clas<" clai ef="+code=mc_ctrk"regists=_" clas<" clai es="sref">watchdclear_bistruct0, a" clai ef="+code=mc_ctrc void <" clai etrgdef">indydog_ping(void)
href="drivers2watchdog/2ndydog.c#L63" id10"L19" 2la0ss2"line" name="L19">  109  110  47   param  929tatig/indyd clacleeee.f="+code=ig/indyd clacls="sef">indydog_ping(void)
href="drivers2watchdog/2ndydog.c#L72" id1="L12" 2laass2"line"L47">  47   param  929tatig/indyd cexcleeee.f="+code=ig/indyd cexcls="sef">indydog_ping(void)
href="drivers2watchdog/2ndydog.c#L68" id1="L13" 2laass21"line" name="L63">  63
  929tatiRING" cAUTHORcode=WATCHDOG_TRING" cAUTHOR class="sref">pr_info(agx@sigxcpu.orgass=pped (defauog timer\n");
  929tatiRING" cs="sRIPTIONcode=WATCHDOG_TRING" cs="sRIPTION class="sref">pr_info(&quDss="fuot;)"re Watchdog Devi timer\n");
  929tatiRING" cLICENSref="+code=WATCHRING" cLICENSr class="sref">pr_info();
  RING" cALIAScMISCDEVcode=WATCHDOG_TRING" cALIAScMISCDEV class>  929tatiIMEOUT" cMINORcode=WATCHDOG_TIMEOUT" cMINORsref timer\n");



The original LXR softs="stbyass="mer\n&quohttp://sourceot;ge.net/projects/lxef>LXR d) )und* 3ity, it=" experi);eeal spaverstbyamer\n&quomailto:lxe@less..no">lxe@less..no3ity.
lxe.less..no kef=ly hoss="sbyamer\n&quohttp://www.redpill-lespro.no">Redpill Lespro AS3ity, provider of Lesux=15