[352c9b2] | 1 | /* |
---|
[9d9a3dd] | 2 | * COPYRIGHT (c) 1989-1999. |
---|
| 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
[352c9b2] | 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
[e49f9e6b] | 7 | * http://www.rtems.com/license/LICENSE. |
---|
[352c9b2] | 8 | * |
---|
| 9 | * $Id$ |
---|
| 10 | */ |
---|
| 11 | |
---|
[f42b726] | 12 | #if HAVE_CONFIG_H |
---|
| 13 | #include "config.h" |
---|
| 14 | #endif |
---|
| 15 | |
---|
[ebbe119e] | 16 | #include <rtems/itron.h> |
---|
[352c9b2] | 17 | |
---|
| 18 | #include <rtems/score/thread.h> |
---|
| 19 | #include <rtems/score/tod.h> |
---|
| 20 | |
---|
| 21 | #include <rtems/itron/time.h> |
---|
| 22 | |
---|
| 23 | /* |
---|
| 24 | * set_tim - Set System Clock |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | ER set_tim( |
---|
| 28 | SYSTIME *pk_tim |
---|
| 29 | ) |
---|
| 30 | { |
---|
[812da54] | 31 | #if 0 |
---|
| 32 | struct timespec time; |
---|
[7ded4e37] | 33 | |
---|
[352c9b2] | 34 | /* convert *pk_tim which is 48 bits integer in binary into an ordinary |
---|
| 35 | integer in milliseconds */ |
---|
[7ded4e37] | 36 | |
---|
[352c9b2] | 37 | /* XXX */ temp = 0; |
---|
| 38 | if(temp > 0) { |
---|
| 39 | _Thread_Disable_dispatch(); |
---|
[63f786e] | 40 | _TOD_Set(&time); |
---|
[352c9b2] | 41 | _Thread_Enable_dispatch(); |
---|
[812da54] | 42 | return E_OK; |
---|
[352c9b2] | 43 | } |
---|
[812da54] | 44 | #endif |
---|
[352c9b2] | 45 | return E_SYS; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | /* |
---|
| 49 | * get_tim - Get System Clock |
---|
| 50 | */ |
---|
| 51 | |
---|
| 52 | ER get_tim( |
---|
| 53 | SYSTIME *pk_tim |
---|
| 54 | ) |
---|
| 55 | { |
---|
| 56 | return E_OK; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | /* |
---|
| 60 | * dly_tsk - Delay Task |
---|
| 61 | */ |
---|
| 62 | |
---|
| 63 | ER dly_tsk( |
---|
| 64 | DLYTIME dlytim |
---|
| 65 | ) |
---|
| 66 | { |
---|
| 67 | Watchdog_Interval ticks; |
---|
| 68 | |
---|
| 69 | ticks = TOD_MILLISECONDS_TO_TICKS(dlytim); |
---|
| 70 | |
---|
| 71 | _Thread_Disable_dispatch(); |
---|
| 72 | if ( ticks == 0 ) { |
---|
| 73 | _Thread_Yield_processor(); |
---|
| 74 | } else { |
---|
| 75 | _Thread_Set_state( _Thread_Executing, STATES_DELAYING ); |
---|
| 76 | _Watchdog_Initialize( |
---|
| 77 | &_Thread_Executing->Timer, |
---|
| 78 | _Thread_Delay_ended, |
---|
| 79 | _Thread_Executing->Object.id, |
---|
| 80 | NULL |
---|
| 81 | ); |
---|
| 82 | _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks ); |
---|
| 83 | } |
---|
| 84 | _Thread_Enable_dispatch(); |
---|
| 85 | return E_OK; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | /* |
---|
| 89 | * def_cyc - Define Cyclic Handler |
---|
| 90 | */ |
---|
| 91 | |
---|
| 92 | ER def_cyc( |
---|
| 93 | HNO cycno, |
---|
| 94 | T_DCYC *pk_dcyc |
---|
| 95 | ) |
---|
| 96 | { |
---|
| 97 | Watchdog_Control *object; |
---|
| 98 | #if 0 |
---|
| 99 | Watchdog_Interval timeInterval; |
---|
| 100 | #endif |
---|
[7ded4e37] | 101 | |
---|
[352c9b2] | 102 | /* XXX */ object = 0; |
---|
| 103 | if ( pk_dcyc->cycatr != TA_HLNG) |
---|
| 104 | return E_RSATR; |
---|
| 105 | #if 0 |
---|
| 106 | timeInterval = pk_dcyc->cyctim / 1000; |
---|
| 107 | object->delta_interval = timeInterval; |
---|
| 108 | #endif |
---|
| 109 | _Watchdog_Initialize( |
---|
| 110 | object, |
---|
| 111 | pk_dcyc->cychdr, |
---|
| 112 | cycno, |
---|
| 113 | pk_dcyc->exinf); |
---|
| 114 | _Watchdog_Deactivate(object); |
---|
[7ded4e37] | 115 | |
---|
[352c9b2] | 116 | return E_OK; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | /* |
---|
| 120 | * act_cyc - Activate Cyclic Handler |
---|
| 121 | */ |
---|
| 122 | |
---|
| 123 | ER act_cyc( |
---|
| 124 | HNO cycno, |
---|
| 125 | UINT cycact |
---|
| 126 | ) |
---|
| 127 | { |
---|
| 128 | Watchdog_Control *object; |
---|
[7ded4e37] | 129 | |
---|
[352c9b2] | 130 | if(cycact != TCY_OFF || cycact != TCY_ON) |
---|
| 131 | return E_PAR; |
---|
| 132 | |
---|
| 133 | #if 0 |
---|
| 134 | if( object->Object_ID != cycno) |
---|
| 135 | return E_NOEXS; |
---|
| 136 | #endif |
---|
[7ded4e37] | 137 | |
---|
[352c9b2] | 138 | _Watchdog_Activate(object); |
---|
[7ded4e37] | 139 | |
---|
[352c9b2] | 140 | return E_OK; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | /* |
---|
| 144 | * ref_cyc - Reference Cyclic Handler Status |
---|
| 145 | */ |
---|
| 146 | |
---|
| 147 | ER ref_cyc( |
---|
| 148 | T_RCYC *pk_rcyc, |
---|
| 149 | HNO cycno |
---|
| 150 | ) |
---|
| 151 | { |
---|
| 152 | #if 0 |
---|
| 153 | int timeElapse_since_actCyclic; |
---|
| 154 | #endif |
---|
| 155 | T_DCYC *pk_dcyc; |
---|
| 156 | #if 0 |
---|
| 157 | Watchdog_Control *object; |
---|
| 158 | #endif |
---|
| 159 | |
---|
[7ded4e37] | 160 | /* XXX */ pk_dcyc = 0; |
---|
| 161 | |
---|
[352c9b2] | 162 | /* XXX will to use a "get" routine to map from id to object pointer */ |
---|
| 163 | /* XXX and the object pointer should be of type specific to this manager */ |
---|
| 164 | #if 0 |
---|
| 165 | if( object->Object_ID == cycno)) |
---|
| 166 | #else |
---|
| 167 | if ( 1 ) |
---|
| 168 | #endif |
---|
| 169 | { |
---|
| 170 | pk_rcyc->exinf = pk_dcyc->exinf; |
---|
| 171 | pk_rcyc->cycact = pk_dcyc->cycact; |
---|
| 172 | #if 0 |
---|
| 173 | pk_rcyc->lfttim = pk_dcyc->cyctim - timeElapse_since_actCyclic; |
---|
| 174 | #endif |
---|
[7ded4e37] | 175 | |
---|
[352c9b2] | 176 | return E_OK; |
---|
| 177 | } |
---|
| 178 | else |
---|
[7ded4e37] | 179 | return E_NOEXS; |
---|
[352c9b2] | 180 | } |
---|
| 181 | |
---|
| 182 | /* |
---|
| 183 | * def_alm - Define Alarm Handler |
---|
| 184 | */ |
---|
| 185 | |
---|
| 186 | ER def_alm( |
---|
| 187 | HNO almno, |
---|
| 188 | T_DALM *pk_dalm |
---|
| 189 | ) |
---|
[7ded4e37] | 190 | { |
---|
[352c9b2] | 191 | #if 0 |
---|
| 192 | Objects_Control *objectAlrm; |
---|
| 193 | Watchdog_Interval timeInterval; |
---|
[7ded4e37] | 194 | |
---|
[352c9b2] | 195 | timeInterval = pk_dalm->almtim / 1000; |
---|
| 196 | (void) _Watchdog_Remove(&objectAlrm); |
---|
| 197 | _Watchdog_Initialize( |
---|
| 198 | objectAlrm, |
---|
| 199 | pk_dalm->almhdr, |
---|
| 200 | almno, |
---|
| 201 | pk_dalm->exinf); |
---|
| 202 | _Watchdong_Insert_seconds(objectAlrm,timeInterval); |
---|
| 203 | _Thread_Enable_dispatch(); |
---|
| 204 | #endif |
---|
[7ded4e37] | 205 | |
---|
[352c9b2] | 206 | return E_OK; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | /* |
---|
| 210 | * ref_alm - Reference Alarm Handler Status |
---|
| 211 | */ |
---|
| 212 | |
---|
| 213 | ER ref_alm( |
---|
| 214 | T_RALM *pk_ralm, |
---|
| 215 | HNO almno |
---|
| 216 | ) |
---|
| 217 | { |
---|
[7ded4e37] | 218 | |
---|
[352c9b2] | 219 | return E_OK; |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | /* |
---|
| 223 | * ret_tmr - Return from Timer Handler |
---|
| 224 | */ |
---|
| 225 | |
---|
| 226 | void ret_tmr( void ) |
---|
| 227 | { |
---|
| 228 | } |
---|