OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [watchdog/] [synth/] [current/] [src/] [synth_watchdog.cxx] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      synth_watchdog.cxx
4
//
5
//      Watchdog driver for the synthetic target
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2002, 2009 Free Software Foundation, Inc.                        
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    bartv
43
// Contributors: bartv
44
// Date:         2002-09-04
45
//
46
//####DESCRIPTIONEND####
47
//==========================================================================
48
 
49
#include <pkgconf/system.h>
50
#include <pkgconf/devs_watchdog_synth.h>
51
 
52
#ifdef CYGIMP_WATCHDOG_HARDWARE
53
 
54
#include <cyg/hal/hal_arch.h>
55
#include <cyg/infra/cyg_type.h>
56
#include <cyg/infra/cyg_ass.h>
57
#include <cyg/infra/diag.h>
58
#include <cyg/hal/hal_io.h>
59
 
60
// FIXME: right now the generic watchdog header depends on the
61
// kernel. That should be fixed in the watchdog code, but will
62
// affect some device drivers as well
63
#include <pkgconf/kernel.h>
64
#include <cyg/io/watchdog.hxx>
65
 
66
// Protocol between host and target
67
#define SYNTH_WATCHDOG_START    0x01
68
#define SYNTH_WATCHDOG_RESET    0x02
69
 
70
// The synthetic target's watchdog implementation involves interaction
71
// with a watchdog.tcl script running in the I/O auxiliary. The device
72
// is instantiated during system initialization via the generic
73
// watchdog package's prioritized constructor. The main
74
// Cyg_Watchdog::start() and reset() functions involve passing a
75
// message to the host-side.
76
//
77
// There is an open issue re. resolution. Usually the hardware imposes
78
// limits on what resolutions are valid, in fact there may be only one.
79
// With the synthetic target it would be possible to configure the
80
// desired resolution either on the target-side using a CDL option, or
81
// on the host-side using the target definition file. The resolution
82
// would have to be fairly coarse, probably at least 0.1 seconds,
83
// to allow for communication overheads. It is not clear whether
84
// target-side or host-side configuration is more appropriate, so for
85
// now a fixed resolution of one second is used.
86
 
87
// Id for communicating with the watchdog instance in the auxiliary
88
static int aux_id   = -1;
89
 
90
// Hardware initialization.
91
void
92
Cyg_Watchdog::init_hw(void)
93
{
94
    // SIGPWR is disabled by default. It has to be reenabled.
95
    struct cyg_hal_sys_sigset_t blocked;
96
    CYG_HAL_SYS_SIGEMPTYSET(&blocked);
97
    CYG_HAL_SYS_SIGADDSET(&blocked, CYG_HAL_SYS_SIGPWR);
98
    cyg_hal_sys_sigprocmask(CYG_HAL_SYS_SIG_UNBLOCK, &blocked, (cyg_hal_sys_sigset_t*) 0);
99
 
100
    resolution = 1000000000LL;
101
    if (synth_auxiliary_running) {
102
        aux_id  = synth_auxiliary_instantiate("devs/watchdog/synth",
103
                                              SYNTH_MAKESTRING(CYGPKG_DEVS_WATCHDOG_SYNTH),
104
                                              "watchdog",
105
                                              (const char*) 0,
106
                                              (const char*) 0);
107
    }
108
}
109
 
110
void
111
Cyg_Watchdog::start(void)
112
{
113
    if (synth_auxiliary_running && (-1 != aux_id)) {
114
        synth_auxiliary_xchgmsg(aux_id, SYNTH_WATCHDOG_START, 0, 0,
115
                               (const unsigned char*)0, 0,
116
                               (int *) 0,
117
                               (unsigned char*) 0, (int*) 0, 0);
118
    }
119
}
120
 
121
void
122
Cyg_Watchdog::reset()
123
{
124
    if (synth_auxiliary_running && (-1 != aux_id)) {
125
        synth_auxiliary_xchgmsg(aux_id, SYNTH_WATCHDOG_RESET, 0, 0,
126
                               (const unsigned char*)0, 0,
127
                               (int *) 0,
128
                               (unsigned char*) 0, (int*) 0, 0);
129
    }
130
}
131
 
132
#endif // CYGIMP_WATCHDOG_HARDWARE

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.