Mercurial > flash_v2
annotate packages/devs/watchdog/current/include/watchdog.hxx @ 32:5af43b635655 ecos-sw-1999-08-18
Merge from eCos master repository on 1999-08-18-15:20:01-BST
| author | jlarmour |
|---|---|
| date | Wed, 18 Aug 1999 15:33:44 +0000 |
| parents | 443894e2e912 |
| children | c38311975d4f |
| rev | line source |
|---|---|
| 0 | 1 #ifndef CYGONCE_DEVS_WATCHDOG_HXX |
| 2 #define CYGONCE_DEVS_WATCHDOG_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 2 | 6 // watchdog.hxx |
| 0 | 7 // |
| 2 | 8 // Watchdog interface declaration |
| 0 | 9 // |
| 10 //========================================================================== | |
| 11 //####COPYRIGHTBEGIN#### | |
| 12 // | |
| 13 // ------------------------------------------- | |
| 14 // The contents of this file are subject to the Cygnus eCos Public License | |
| 15 // Version 1.0 (the "License"); you may not use this file except in | |
| 16 // compliance with the License. You may obtain a copy of the License at | |
| 17 // http://sourceware.cygnus.com/ecos | |
| 18 // | |
| 19 // Software distributed under the License is distributed on an "AS IS" | |
| 20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 21 // License for the specific language governing rights and limitations under | |
| 22 // the License. | |
| 23 // | |
| 24 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 25 // September 30, 1998. | |
| 26 // | |
| 27 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 2 | 28 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
| 0 | 29 // ------------------------------------------- |
| 30 // | |
| 31 //####COPYRIGHTEND#### | |
| 32 //========================================================================== | |
| 33 //#####DESCRIPTIONBEGIN#### | |
| 34 // | |
| 2 | 35 // Author(s): nickg |
| 36 // Contributors: nickg | |
| 37 // Date: 1998-07-14 | |
| 38 // Purpose: Watchdog declarations | |
| 39 // Description: This file defines the interface to the watchdog device | |
| 0 | 40 // that provides timer based recovery from software and |
| 41 // hardware faults. | |
| 42 // Usage: #include <cyg/devs/watchdog.hxx> | |
| 43 // | |
| 44 //####DESCRIPTIONEND#### | |
| 45 // | |
| 46 //========================================================================== | |
| 47 | |
| 48 #include <cyg/kernel/ktypes.h> | |
| 49 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 50 | |
| 51 class Cyg_Watchdog_Action; | |
| 52 | |
| 53 // ------------------------------------------------------------------------- | |
| 54 // Watchdog class | |
| 55 | |
| 56 class Cyg_Watchdog | |
| 57 { | |
| 58 | |
| 59 Cyg_Watchdog_Action *action_list; | |
| 60 | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
61 cyg_uint64 resolution; |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
62 |
| 0 | 63 public: |
| 64 | |
| 65 Cyg_Watchdog(); | |
| 66 | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
67 // Return time interval allowed between resets before watchdog |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
68 // triggers, in nanoseconds. |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
69 cyg_uint64 get_resolution(); |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
70 |
| 0 | 71 // Start the watchdog running. |
| 72 void start(); | |
| 73 | |
| 74 // Reset watchdog timer. This needs to be called regularly to prevent | |
| 75 // the watchdog firing. | |
| 76 void reset(); | |
| 77 | |
| 78 // Trigger the watchdog as if the timer had expired. | |
| 79 void trigger(); | |
| 80 | |
| 81 // Register an action routine that will be called when the timer | |
| 82 // triggers. | |
| 83 void install_action( Cyg_Watchdog_Action *wdaction ); | |
| 84 | |
| 85 // Deregister a previously registered action routine. | |
| 86 void uninstall_action( Cyg_Watchdog_Action *wdaction ); | |
| 87 | |
| 88 // A static instance of the single system defined watchdog device. | |
| 89 static Cyg_Watchdog watchdog; | |
| 90 | |
| 91 }; | |
| 92 | |
| 93 // ------------------------------------------------------------------------- | |
| 94 // Watchdog action class | |
| 95 | |
| 96 class Cyg_Watchdog_Action | |
| 97 { | |
| 98 friend class Cyg_Watchdog; | |
| 99 | |
| 100 Cyg_Watchdog_Action *next; // link in chain | |
| 101 | |
| 102 void (*action)( CYG_ADDRWORD data ); // action function | |
| 103 | |
| 104 CYG_ADDRWORD data; // data argument | |
| 105 | |
| 106 public: | |
| 107 | |
| 108 Cyg_Watchdog_Action( | |
| 109 void (*action)( CYG_ADDRWORD data ), | |
| 110 CYG_ADDRWORD data | |
| 111 ); | |
| 112 | |
| 113 ~Cyg_Watchdog_Action(); | |
| 114 | |
| 115 void install(); | |
| 116 | |
| 117 void uninstall(); | |
| 118 }; | |
| 119 | |
| 120 // ------------------------------------------------------------------------- | |
| 121 // Cyg_Watchdog_Action inlines | |
| 122 | |
| 123 inline Cyg_Watchdog_Action::Cyg_Watchdog_Action( | |
| 124 void (*action_arg)( CYG_ADDRWORD data ), | |
| 125 CYG_ADDRWORD data_arg | |
| 126 ) | |
| 127 { | |
| 128 next = NULL; | |
| 129 action = action_arg; | |
| 130 data = data_arg; | |
| 131 } | |
| 132 | |
| 133 inline Cyg_Watchdog_Action::~Cyg_Watchdog_Action() | |
| 134 { | |
| 135 Cyg_Watchdog::watchdog.uninstall_action( this ); | |
| 136 } | |
| 137 | |
| 138 inline void Cyg_Watchdog_Action::install() | |
| 139 { | |
| 140 Cyg_Watchdog::watchdog.install_action( this ); | |
| 141 } | |
| 142 | |
| 143 inline void Cyg_Watchdog_Action::uninstall() | |
| 144 { | |
| 145 Cyg_Watchdog::watchdog.uninstall_action( this ); | |
| 146 } | |
| 147 | |
| 148 // ------------------------------------------------------------------------- | |
| 149 #endif // ifndef CYGONCE_DEVS_WATCHDOG_HXX | |
| 150 // EOF watchdog.hxx |
