OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [ecostest/] [common/] [ResetAttributes.h] - Blame information for rev 637

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####COPYRIGHTBEGIN####
2
//                                                                          
3
// ----------------------------------------------------------------------------
4
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5
//
6
// This program is part of the eCos host tools.
7
//
8
// This program is free software; you can redistribute it and/or modify it 
9
// under the terms of the GNU General Public License as published by the Free 
10
// Software Foundation; either version 2 of the License, or (at your option) 
11
// any later version.
12
// 
13
// This program is distributed in the hope that it will be useful, but WITHOUT 
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
16
// more details.
17
// 
18
// You should have received a copy of the GNU General Public License along with
19
// this program; if not, write to the Free Software Foundation, Inc., 
20
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
//
22
// ----------------------------------------------------------------------------
23
//                                                                          
24
//####COPYRIGHTEND####
25
//=================================================================
26
//#####DESCRIPTIONBEGIN####
27
//
28
// Author(s):     sdf
29
// Contributors:  sdf
30
// Date:          1999-04-01
31
// Description:   Holds information related to target reset.
32
// Usage:
33
//
34
//####DESCRIPTIONEND####
35
 
36
#ifndef _RESETATTRIBUTES_H
37
#define _RESETATTRIBUTES_H
38
 
39
#include "Collections.h"
40
#include "eCosStd.h"
41
#include "eCosSerial.h"
42
#include "eCosSocket.h"
43
#include "Properties.h"
44
 
45
//=================================================================
46
// This class deals with resetting a target.
47
// The ctor accepts the "reset string" this is something like
48
//    expect($T05,#) 3(off(ginga:5000,a1) delay(2000) on(,..com2,38400))
49
// and is parsed to generate the commands to reset the target.
50
// The syntax is:
51
//    resetstring :== [directive | <integer>(resetstring)] * 
52
//    directive   :== id(arg[,arg]*)
53
//    directive   :== port | action | delay | expect
54
//
55
// The <integer>(string) syntax repeats argument its until reset is achieved.
56
// Each directive is given by example below:
57
// expect: 
58
//   Expected string(s).            e.g. expect(str1,str2,...).
59
//   Arguments:
60
//     The string(s) expected to be output by a target after reset.
61
//     *all* supplied strings must be present *in order* in the reset string for a reset to be recognized as valid.
62
// port:
63
//   Provide port information to apply to all subsequent off|on|on_off|off_on actions until overwritten.
64
//   e.g. port(com1,38400,1000)
65
//   Arguments:
66
//     0. Port
67
//     1. Baud
68
//     2. Read timeout
69
//   These have the meanings described under off|on|on_off|off_on.
70
// off|on|on_off|off_on:
71
//   Request a reset host to perform a "power cycle" (or its logical equivalent - 
72
//   the meanings of "off" and "on" may depend on the reset host)
73
//   e.g. off_on(ginga:500,A4,com1,38400,10000,1000)
74
//   Arguments:
75
//     0. Reset host:port
76
//     1. Control string (meaning known to the reset host)
77
//     2. Port (from which to read startup output)
78
//     3. Baud for the above
79
//     4. Read timeout
80
//     5. Delay (between off and on or vice versa)
81
// delay:
82
//   Delay for a given time right now.      
83
//   e.g. delay(1000)
84
//   Arguments:
85
//     0. msec to delay
86
//=================================================================
87
 
88
class CResetAttributes {
89
public:
90
  CResetAttributes(LPCTSTR psz=_T(""));
91
 
92
        //bool IsValid();
93
 
94
  const LPCTSTR Image() const { return m_str; }
95
 
96
  bool IsNull() const { return m_str.empty(); }
97
  static const CResetAttributes NoReset;
98
 
99
  enum ResetResult {INVALID_STRING=-1,RESET_OK=0,NOT_RESET=1,
100
    RESET_ILLEGAL_DEVICE_CODE=30000,RESET_NO_REPLY, RESET_BAD_CHECKSUM, RESET_BAD_ACK, RESET_UNKNOWN_ERROR};
101
 
102
  // Perform the reset, sending the output to the log function supplied as parameter.
103
  ResetResult Reset (LogFunc *pfnLog=0, void *pfnLogparam=0,bool bCheckOnly=false);
104
 
105
  enum Action {OFF=0,ON=1,OFF_ON=2,ON_OFF=3};
106
 
107
protected:
108
 
109
  // This function determines whether the board startup has output all that is required
110
  // All the strings of m_arValidResetStrings [arguments of expect() in the reset string] must be present
111
  bool IsValidReset();
112
 
113
  Time m_tResetOccurred;
114
 
115
  // The log function.
116
  LogFunc *m_pfnReset;
117
  void *m_pfnResetparam;
118
  // Log some output to the reset log function.
119
  void ResetLog(LPCTSTR psz);
120
 
121
  CeCosSerial m_Serial;
122
  CeCosSocket m_Socket;
123
 
124
  const TCHAR *GetIdAndArg (LPCTSTR psz,String &strID,String &strArg);
125
  ResetResult Parse (LPCTSTR psz,bool bCheckOnly=false);
126
  bool Reset (Action action,bool bCheckOutput);
127
 
128
  void SuckThreadFunc ();
129
  static void CALLBACK SSuckThreadFunc (void *pParam) { ((CResetAttributes*)pParam)->SuckThreadFunc(); }
130
 
131
  String m_str;           // Here is the reset string.  Could be const, but avoid the assignment operator warnings
132
 
133
  // These members hold the information we extract by parsing the string:
134
 
135
        StringArray m_arValidResetStrings;
136
  String m_strHostPort;     // host we talk to
137
  String m_strControl;      // Control string
138
  int m_nDelay;             // Delay between power off and power on
139
  String m_strAuxPort;      // Auxiliary port (serial port to listen on if primary port is TCP/IP)
140
  int m_nReadTimeout;       // mSec to wait for board to say something
141
  int m_nBaud;              // Baud rate
142
 
143
  String m_strResetOutput;  // The output we get
144
};
145
 
146
#endif

powered by: WebSVN 2.1.0

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